akhauriyash/Code-Regression huggingface dataset:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def cc():
	s = input()
	if len(s)%2 != 0:
		return False
	for i , c in enumerate(list(s)):
		if i % 2 == 0 and c != 'h':
			return False
		if i % 2 == 1 and c != 'i':
			return False
	return True
	
def main():
	ret = 'Yes' if cc() else 'No'
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> boul(n+1,0);
    vector<int> num(n+1,1);
    boul[1] = 1;
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        if(boul[x] == 1){
            boul[y] = 1;
        }
        num[x]--;
        num[y]++;
        if(num[x] == 0 && boul[x] == 1){
            boul[x] = 0;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(boul[i] == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX (ll)(2e2 + 7)
#define INF (ll)(5e5 + 7)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	string s;
	cin >> s;
	int cc = 0, ma = 0;
	for (auto x : s) {
		if (x == 'R') {
			cc++;
			ma = max (cc, ma);
		}	
		else {
			cc = 0;
		}
	}
	cout << ma << "\n";
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ld long double
#define ff first
#define ss second
using namespace std;

ll fact(ll a)
{
    if(a==0) return 1;
    else return a*fact(a-1);
}

vl<ll> divisor(ll n)
{
    vl<ll> v;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.pb(i);
            else
            {
                v.pb(i);
                v.pb(n/i);
            }
        }
    }
    return v;
}

int main()
{
    ll i,j,n,k,t,m,a,b;
    vl<ll> v;
    cin>>n;
    string s;
    map<string,ll> mp;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    for(i=0;i<n;i++) 
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<mp["AC"]<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<mp["WA"]<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<mp["TLE"]<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    int n = get<int>();
    int k = get<int>();
    vector<int> neg;
    vector<int> pos = { 0 };

    for (int i=0; i < n; i++) {
        int x = get<int>();
        if (x < 0)
            neg.push_back(x);
        else if (x > 0)
            pos.push_back(x);
        else if (x == 0)
            k--;
    }
    neg.push_back(0);
    reverse(neg.begin(),neg.end());

    if (k == 0) {
        cout << 0 << endl;
    } else {
        long ans = LONG_MAX;
        for (int i = 0; i <= min(k,(int)neg.size()-1); i++) {
            int j = k - i;
            if (j >= pos.size())
                continue;
            long n, p;
            n = abs((long)neg[i]);
            p = pos[j];

            ans = min(ans, n*2 + p);
            ans = min(ans, n + p*2);
        }

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
#include <string.h>
char s[1010];
char t[20];
int main(){
	int ans=0;
	scanf("%s",t);
	while(1){
		scanf("%s",s);
		if(!strcmp(s,"END_OF_TEXT"))break;
		for(int i=0;s[i];i++)s[i]|=32;
		if(!strcmp(s,t))ans++;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2056
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define maxw 200020
using namespace std;
int h,w,n;
map<int,bool>mp[maxw];
void init(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=w;++i)mp[i][h+1]=1;
	for(int i=1;i<=n;++i){
		int x,y;scanf("%d%d",&x,&y);
		mp[y][x]=1;
	}
}
void solve(){
	int ans=h,j=0;
	for(int i=1;i<=h;++i){
		if((j<w)&&(!mp[j+1].count(i)))++j;
		ans=min(ans,(*mp[j].lower_bound(i)).first-1);
	}
	printf("%d\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 28416
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=100010;

void solve() {
    ll a,b,k;
    cin>>a>>b>>k;
    cout<<max(a-k,0LL)<<" "<<max(b-max(0LL,k-a),0LL)<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=1e5+11;
int N,A[MAXN],B[MAXN],sum,cur,Minn=LLONG_MAX,ans;
signed main(){
    N=read();for(int i=1;i<=N;i++) A[i]=B[i]=read();
    cur=-1,sum=0,ans=0;
    for(int i=1;i<=N;i++){
        cur*=-1;sum+=A[i];if(sum*cur>0) continue;
        if(sum<=0) ans+=abs(1-sum),sum=1;
        else ans+=abs(-1-sum),sum=-1;
    }Minn=min(Minn,ans);
    cur=1,sum=0,ans=0;
    for(int i=1;i<=N;i++){
        cur*=-1;sum+=A[i];
        //cerr<<"cur:"<<cur<<" sum:"<<sum<<endl;
        if((sum*cur)>0) {continue;}
        if(sum<0) ans+=abs(1-sum),sum=1;
        else ans+=abs(-1-sum),sum=-1;
    }Minn=min(Minn,ans);
    printf("%lld\n",Minn);return 0;
}



Measured memory_bytes: 4740
#include<iostream>
#include<algorithm>

using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    
    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
    }


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

int main() {
	
	int x, a, b;
	cin >> x >> a >> b;
	if(a >= b){
		cout << "delicious" << endl;
	}else if(a+x >= b){
		cout << "safe" << endl;
	}else{
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
INF=10**30
N=list(map(int,list(input())))[::-1]
l=len(N)
dp=[[INF,INF] for i in range(l+1)]
dp[0][0]=0
for i in range(l):
    dp[i+1][0]=min(dp[i+1][0],dp[i][0]+N[i])
    if N[i]!=9:
        dp[i+1][0]=min(dp[i+1][0],dp[i][1]+N[i]+1)
    dp[i+1][1]=min(dp[i+1][1],dp[i][0]+(10-N[i]))
    if N[i]!=0:
        dp[i+1][1]=min(dp[i+1][1],dp[i][1]+(10-N[i]-1))
    else:
        dp[i+1][1]=min(dp[i+1][1],dp[i][1]+9)
ans=min(dp[l][0],dp[l][1]+1)
print(ans)

Measured memory_bytes: 246712
// clang-format off
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
// clang-format on

int main() {

    llint a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(w < v && ((abs(b - a) + abs(v - w) - 1) / abs(v - w) <= t && w < v)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
n = int(input())

import math
rt = math.floor(math.sqrt(n))
result = 0
for i in range(1,rt + 1):
  if n % i == 0 and i**2 != n:
    if n % (n / i - 1) != 0:
      result += n / i - 1
print(int(result))
    
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int N;
string S;

bool notequal(char a,char b,char c){
    if(a==b||a==c||b==c)return false;
    return true;
}
bool check(char c){
    if(c=='A'||c=='C'||c=='G'||c=='T')return true;
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    int A=in();int B=in();
    int K=in();
    int cnt=0;
    for(int i=A;i>=0;i--){
        if(A%i==0&&B%i==0){
            cnt++;
            if(cnt==K){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

vector<int> primes;

void pm(int N){
    vector<int> num;
    for(int i=2;i<=N;++i) num.pb(i);
    while(num.size()){
        primes.pb(num[0]);
        for(int j = num.size()-1;j>=0;--j){
            if(num.at(j) % num.at(0) == 0) num.erase(num.begin() + j);
        }
    }
}

int N;
vector<int> a;
int main(){
    cin >> N;
    pm(55555);
    rep(i,primes.size()){
        if(primes.at(i) % 5 == 1) a.pb(primes.at(i));
    }

    rep(i,N) cout << a.at(i) << " ";
    cout << endl;

}


Measured memory_bytes: 640
n,x=map(int,input().split())
A=[int(i) for i in input().split()]
B=[float("inf")]*n
ans=float("inf")
for i in range(n):
  ans_i=i*x
  for j in range(n):
    B[j]=min(B[j],A[j-i])
    ans_i+=B[j]
  ans=min(ans,ans_i)
print(ans)

Measured memory_bytes: 43740
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

for i in range(100+1):
  a1 = c1[0] - i
  a2 = c2[0] - i
  a3 = c3[0] - i
  if c1[1] - a1 == c2[1] - a2 == c3[1] - a3 and c1[2] - a1 == c2[2] - a2 == c3[2] - a3:
    print('Yes')
    exit(0)
print('No')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int h, w;
int dx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int main(){
  cin >> h >> w;
  string m[h];
  for(int i=0; i<h; ++i) cin >> m[i];
  for(int y=0; y<h; ++y){
    for(int x=0; x<w; ++x){
      if(m[y][x] == '#') continue;
      int nx, ny, sum = 0;
      for(int i=0; i<8; ++i){
        nx = x+dx[i]; ny = y+dy[i];
        if(nx < 0 || nx >= w || ny < 0 || ny >=h) continue;
        if(m[ny][nx] == '#') ++sum;
      }
      m[y][x] = '0'+sum;
    }
  }
  for(int i=0; i<h; ++i){
    cout << m[i] << endl;
  }
}

Measured memory_bytes: 3480
#include <stdio.h>
#define MAX 100

int z(int a){return a>0 ? a : -a;}
int max(int a, int b){return a<b ? b : a;}

int main(){
  int cx,cy,ch,chu,dh,n,x[MAX],y[MAX],h[MAX],i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d%d%d",&x[i],&y[i],&h[i]);
  
  for(cx=0;cx<=100;cx++){
    for(cy=0;cy<=100;cy++){
      if(h[0]==0){
        ch = 0;
        chu = z(x[0]-cx) + z(y[0]-cy);
      }else{
        ch = h[0] + z(x[0]-cx) + z(y[0]-cy);
      }
      for(i=1;i<n;i++){
        dh = z(x[i]-cx)+z(y[i]-cy);
        if(ch!=0){
          if(max(0,ch-dh)!=h[i])break;
        }else{
          if(h[i]!=0){
            if(chu < h[i]+dh)break;
            else ch = h[i]+dh;
          }else{
            if(dh < chu)chu = dh;
          }
        }
      }
      if(i==n){
        if(ch==0 && chu==1)ch=1;
        printf("%d %d %d\n",cx,cy,ch);
        return 0;
      }
    }
  }
  
  return 1;
}

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

typedef long long ll;

const int maxn = 1e5 + 5;
int N, M;
vector<int> adj[maxn];
ll dp[maxn];

ll rec(int u) {
    if (dp[u] != -1) {
        return dp[u];
    }
    ll tot = 0;
    for (int v : adj[u]) {
        tot = max(tot, 1 + rec(v));
    }
    return dp[u] = tot;
}

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

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        adj[x].push_back(y);
    }
    ll answer = 0;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < N; i++) {
        answer = max(answer, rec(i));
    }
    cout << answer;

    return 0;
}

Measured memory_bytes: 11808
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    double r;
    cin>>r;
    double two = 2;
    double ans = (2*22*r)/7;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> city(M*2);
  for(int i=0; i<M*2; i++){
    cin >> city.at(i);
  }
  
  int road = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<M*2; j++){
      if(i+1 == city.at(j)){
        road+=1;
      }
    }
    cout << road << endl;
    road = 0;
  }
}
  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

// combination c;
// c(n, k); => nCk
const ll mod = 998244353;
struct combination {
    const int max = 510000;
    vector<long long> fact, ifact, inv;
    combination() {
        fact.resize(max);   // i!
        ifact.resize(max);  // (i!)^(mod-2)
        inv.resize(max);    // i^(mod-2)
        fact[0] = fact[1] = 1;
        ifact[0] = ifact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fact[i] = fact[i-1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
            ifact[i] = ifact[i-1] * inv[i] % mod;
        }
    }

    long long operator()(int n, int k) {
        if (n < k) return 0;
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
};

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

    // if (n == 1) {
    //     cout << m << endl;
    // }

    vector<ll> a(n+1);
    a[1] = m;
    repf(i,2,n+1) {
        (a[i] = a[i-1]*(m-1)) %= mod;
        // cout << a[i] << endl;
    }
    
    combination c;
    ll ans = 0;
    rep(i,k+1) {
        (ans += a[n-i]*c(n-1,n-1-i)%mod) %= mod;
        // if (i <= 10) cout << a[n-i] << " " << c(n-1, n-1-i) << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16724
#include <stdio.h>
int main()
{
    int k, a, b; scanf("%d%d%d", &k, &a, &b);
    long res1=k+1, res2=1;
    int t=k<a-1 ? k : a-1;
    res2+=t;
    k-=t;
    for(; k>1; k-=2) res2+=b-a;
    res2+=k;
    printf("%ld\n", res1<res2 ? res2 : res1);
}


Measured memory_bytes: 128
# !/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5 1
0 1 2
0 2 3
1 2 -5
1 3 1
2 3 2

output:
INF
0
-5
-3

OR
input:
4 6 0
0 1 2
0 2 3
1 2 -5
1 3 1
2 3 2
3 1 0

output:
NEGATIVE CYCLE
"""

import sys
from math import isinf


def generate_adj_table(_v_info):
    for each in _v_info:
        source, target, cost = map(int, each)
        init_adj_table[source][target] = cost
    return init_adj_table


def bellman_ford():
    distance[root] = 0

    for j in range(vertices - 1):
        for current, current_info in enumerate(adj_table):
            for adj, cost in current_info.items():
                if distance[current] + cost < distance[adj]:
                    distance[adj] = distance[current] + cost

    for current, current_info in enumerate(adj_table):
        for adj, cost in current_info.items():
            if distance[current] + cost < distance[adj]:
                print('NEGATIVE CYCLE')
                return list()

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges, root = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    distance = [float('inf')] * vertices
    init_adj_table = tuple(dict() for _ in range(vertices))

    adj_table = generate_adj_table(v_info)

    res = bellman_ford()
    for ele in res:
        if isinf(ele):
            print('INF')
        else:
            print(ele)

Measured memory_bytes: 8488
#include <iostream>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#define all(x) x.begin(),x.end()

using namespace std;



int main()
{  
   int n;cin>>n;
   if(n<=9)cout<<n;
   else if(n>9&&n<100)cout<<9;
   else if(n>=100&&n<1000)cout<<(n-100+1)+9;
   else if(n>=1000&&n<10000)cout<<(9+900);
   else if(n>=10000&&n<100000)cout<<(n-10000+1 + 9 + 900);
   else cout<<(90909);
   
  
} 

Measured memory_bytes: 256
def gcd(x, y):
    x = abs(x)
    y = abs(y)

    if x < y:
        x, y = y, x

    while y:
        x, y = y, x % y

    return x


N = int(input())
seen = dict()
zeroes = 0
MOD = 10 ** 9 + 7
for _ in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zeroes += 1  # 虚無鰯の数
        continue

    if a < 0 or a == 0 and b < 0:
        a, b = -a, -b
    if b <= 0:
        a, b = -b, a
        flip = 1
    else:
        flip = 0
    g = gcd(a, b)
    a //= g
    b //= g  # 正規化
    if (a, b) not in seen:
        seen[(a, b)] = [0, 0]

    seen[(a, b)][flip] += 1


out = 1
for v in seen:
    a, b = seen[v]  # 連想配列中の値を取り出す[n(a, b) vs. n(-b, a)]
    out *= (pow(2, a, MOD) + pow(2, b, MOD) - 1)
    out %= MOD
out -= 1  # 1個も選ばない場合

out += zeroes  # 虚無鰯の数を足す
out %= MOD
print(out)


Measured memory_bytes: 137432
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    ll n, m;
    cin >> n >> m;
    ll k = n + 1 >> 1;

    vector<ll> num(n + 1, 0);
    FOR(i, 2, n + 1) {
        int x = 0;
        if(i <= k + 1)
            x = 1;
        else if(i >= n - k + 3)
            x = -1;
        num[i] = num[i - 1] + x;
    }

    vector<ll> dp(n, 0);
    dp[0] = 1;
    FOR(i, 2, n + 1)
    rep(j, n - num[i]) {
        dp[j + num[i]] += dp[j];
        if(dp[j + num[i]] >= m) dp[j + num[i]] -= m;
    }

    ll ret = 0;
    rep(i, n)(ret += (n - i) * dp[i]) %= m;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll N;
	cin >> N;
	vll h(N);
	rep(i, N) cin >> h[i];

	ll ans = 0;
	while (accumulate(all(h), 0)) {
		bool flag = false;
		rep(i, N) {
			if (h[i] != 0) {
				--h[i];
				if (flag == false) {
					++ans;
					flag = true;
				}
			}
			else {
				flag = false;
			}
		}
	}
	cout << ans << endl;

}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, a[10101];
void solve(){
	cin >> n;
	i64 cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		while(a[i]%2 == 0){
			cnt++;
			a[i] /= 2;
		}
	}
	
	cout << cnt << endl;
}

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


Measured memory_bytes: 384
function main(input) {
  var s = input[0]-0;
  var map = {};
  map[s] = true;
  var ans = 1;
  while(true){
    ans++;
    var nex = next(s);
    if(map[nex]) break;
    map[nex] = true;
    s = nex;
  }
  console.log(ans);
}
function next(n){
  if(n%2==0) return n/2;
  else return 3*n+1;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            int num = int.Parse(Console.ReadLine());
            int[] data = new int[num * 2];
            string[] str = Console.ReadLine().Split(' ');
            for (int a = 0; a < num * 2; a++)
            {
                data[a] = int.Parse(str[a]);
            }
            Array.Sort(data);
            for (int a = 0; a < num; a++)
            {
                ans += data[a * 2];
            }
            Console.WriteLine("{0}", ans);
        }
    }
}

Measured memory_bytes: 2776
#include <stdio.h>

int main(){
	const double g=9.8;
	double x, v;
	int f;

	while( scanf("%lf", &v)!=EOF ){
		x = v*v/(2*g);
		for( f=1;; f++ ){
			if( x <= 5*f-5 )
				break;
		}
		printf("%d\n", f);
	}
	return 0;
}

Measured memory_bytes: 628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	vp in;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(){
		d=vi(n,inf);
		priority_queue<pii>q;
		rep(i,in.size()){
			int a=in[i].first,b=in[i].second;
			q.push(pii(-b,a-1));
			d[a-1]=b;
		}
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
	void solve(){
		rep(i,n-1){
			int a,b;
			cin>>a>>b;
			a--;b--;
			add_edge(a,b,1);
			add_edge(b,a,1);
		}
		int m;
		cin>>m;
		in=vp(m);
		rep(i,m)cin>>in[i].first>>in[i].second;
		dij();
		bool h=true;
		rep(i,n)rep(j,G[i].size()){
			int to=G[i][j].to;
			if(abs(d[i]-d[to])!=G[i][j].cost)h=false;
		}
		rep(i,m)if(in[i].second!=d[in[i].first-1])h=false;
		if(h){
			cout<<"Yes"<<endl;
			rep(i,n)cout<<d[i]<<endl;
		}else cout<<"No"<<endl;
	}
};
int main(){
	int n;
	cin>>n;
	DIJ dij(n);
	dij.solve();
}








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

using namespace std;

const long long INF = (1ll << 61) - 1;

long long rec(int l, int r, vector<vector<long long>>& dp, const long long* a){
  if(dp[l][r] != -1) return dp[l][r];
  if(l == r - 1) return dp[l][r] = 0;
  
  long long ret = INF;
  for(int i = l + 1; i < r; i++){
    ret = min(rec(l, i, dp, a) + rec(i, r, dp, a), ret);
  }
  
  ret += a[r] - a[l];
  
  return dp[l][r] = ret;
}

int main(){
  int N;
  scanf("%d", &N);
  
  long long a[N + 1];
  a[0] = 0;
  for(int i = 1; i <= N; i++){
    scanf("%lld", a + i);
    a[i] += a[i - 1];
  }
  
  vector<vector<long long>> dp(N + 1, vector<long long>(N + 1, -1));
  
  printf("%lld\n", rec(0, N, dp, a));
  
  return 0;
}

Measured memory_bytes: 1664
def dfs(i, f):
    if i == len(s) - 1:
        if eval(f) == 7:
            print(f + '=7')
            exit()
    else:
        dfs(i+1, f + '+' + s[i+1])
        dfs(i+1, f + '-' + s[i+1])
s = list(input())
dfs(0, s[0])

Measured memory_bytes: 8972
q, h, s, d = gets.chomp.split(' ').map(&:to_i)
n = gets.chomp.to_i

min1 = [8 * q, 4 * h, 2 * s, d].min
min2 = [8 * q, 4 * h, 2 * s].min

if min1 == min2 || n % 2 == 0
  puts n * min1 / 2
else
  puts n / 2 * d + min2 / 2
end


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

#define mod 1000000007

long long int multiple(long long int target, long long int p)
{
    long long int curretn_answer = 0;

    if (p == 0)
    {
        return 1;
    }

    if (p%2 == 0)
    {
        curretn_answer = multiple(target, (p/2))*multiple(target, (p/2));
        curretn_answer %= mod;
    } else {
        curretn_answer = multiple(target, ((p-1)/2))*multiple(target, ((p-1)/2));
        curretn_answer %= mod;
        curretn_answer *= target;
        curretn_answer %= mod;
    }

    return curretn_answer;
}

int main()
{
    long long int n, answer = 0;

    scanf("%lld", &n);

    answer = (multiple(10, n) - multiple(9, n) + mod);
    answer %= mod;
    answer *= 2;

    answer -= (multiple(10, n) - multiple(8, n) + mod)%mod;

    answer += mod;
    answer %= mod;

    printf("%lld", answer);

    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<cmath>
using namespace std;
long long int n;
int main()
{
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0)
        {
            int t=i,l=n/i;
            int s=1;
            while(l>=10)
            {
                s++;
                l/=10;
            }
            cout<<s;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int a[2][n];
    for(int i=0;i<n;i++) cin >> a[0][i];
    for(int i=0;i<n;i++) cin >> a[1][i];
    int ans=0;
    for(int i=0;i<n;i++){
        int cur=0;
        for(int j=0;j<=i;j++){
            cur += a[0][j];
        }
        for(int j=i;j<n;j++){
            cur += a[1][j];
        }
        ans = max(ans, cur);
    }
    cout << ans << endl;
}

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

signed main(){
  string S;
  cin>>S;
  cout<<S[0]<<S[1]<<S[2]<<endl;
}

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

int main()
{
ll a , c , b ;
cin >> a >> b >> c ;
if(a==b&&a!=c)ans="Yes";
if(a==c&&a!=b)ans="Yes";
if(c==b&&a!=c)ans="Yes";
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 2:
        return True
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

x = int(input())
while True:
    if is_prime(x):
        print(x)
        break
    else:
        x += 1
    

Measured memory_bytes: 2940
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [p * (p + 1) // 2 / p for p in P]
S = [0] * N
S[0] = E[0]
for i in range(1, N):
    S[i] = S[i - 1] + E[i]
S = [0] + S
ans = 0
for k in range(K, N + 1):
    ans = max(ans, S[k] - S[k - K])
print(ans)


Measured memory_bytes: 25128
#include<iostream>
#include<string>

int main(){
	std::string f="Hoshino";
	std::string fa="Hoshina";
	std::string a;
	int n;
	std::cin>>n; std::cin.ignore(); 
	for(int j=0;j<n;j++){
		getline(std::cin,a);
		std::string::size_type index=a.find(f);
		while(index!=std::string::npos){
			for(int i=0;i<f.size();i++){
				a[i+index]=fa[i];
			}
			index=a.find(f);
		}
		std::cout<<a<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
using namespace std;

string s;

string ans;

int main()

{
   int i;

   cin>>s;
   for(i=0;i<s.size()-8;i++)
    ans.pb(s[i]);

   cout<<ans<<endl;


   return 0;
}

Measured memory_bytes: 256
import math
def main():
    order = []
    for _ in range(5):
        order.append(int(input()))
    min_r = 10
    last = None
    for i in range(5):
        r = order[i] % 10
        if r != 0 and r < min_r:
            min_r = r
            last = i
    if last == None:
        return sum(order)
    time = 0
    for i in range(5):
        if i != last:
            time += math.ceil(order[i] / 10) * 10
        else:
            time += order[i]
    return time


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template<typename V>
bool tomin(V&x,V y){if(y<x){x=y;return true;}return false;}
template<typename V>
bool tomax(V&x,V y){if(x<y){x=y;return true;}return false;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
#define lowbit(x) ((x)&-(x))
int L,R,cnt[3000];
int main(){
    scanf("%d%d",&L,&R);
    tomin(R,L+2018);
    for(ll i=L;i<=R;i++){
        for(ll j=i+1;j<=R;j++){
            cnt[i*j%2019]++;
        }
    }
    int Mxp,Mx=1e9;
    for(int i=0;i<2019;i++){
        if(cnt[i]!=0){
            cout<<i<<endl;
            exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
h = list(map(int,input().split()))

# # a = []
# # b = []

dic = {}
count = 0

for i in range(m):
    aa, bb = map(int,input().split())
    # a.append(aa)
    # b.append(bb)
    if aa not in dic:
        dic[aa] = set()
        dic[aa].add(bb)
    else:
        dic[aa].add(bb)

    if bb not in dic:
        dic[bb] = set()
        dic[bb].add(aa)
    else:
        dic[bb].add(aa)

for k in dic.keys():
    left = h[k-1]
    right = 0
    for i in dic[k]:
        if h[i-1] >= right:
            right = h[i-1]

    if left > right:
        count += 1

count += n - len(dic)

print(count)

Measured memory_bytes: 45112
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct union_find{
  vector<int> par,r;

  union_find(int n) : par(n),r(n){init(n);}

  void init(int n){
    for(int i = 0; i < n; i++) par[i] = i;
    for(int i = 0; i < n; i++) r[i] = 0;
  }

  int find(int x){
    if(par[x] == x) return x;
    else return find(par[x]);
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(r[x] < r[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(r[x] == r[y]) r[x]++;
    }
  }

  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int> > g(n,vector<int>());
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int four=0,six=0;
	for(int i = 0; i < n; i++){
		if(g[i].size()%2!=0){
			// cout << i << endl;
			cout << "No"<<endl;
			return 0;
		}
		if(g[i].size()==4){
			four++;
		}
		if(g[i].size()>=6){
			six++;
		}
	}

	if(four>=3 || six>=1){
		cout << "Yes"<<endl;
	}else if(four<=1){
		cout << "No"<<endl;
	}else{
		int x=-1,y=-1;
		for(int i = 0; i < n; i++){
			if(g[i].size()==4){
				if(x<0)x=i;
				else y=i;
			}
		}
		bool flag=false;
		for(int i = 0; i < 4; i++){
			for(int j = i+1; j < 4; j++){
				union_find uf(n);
				// map<P,int> m;
				for(int k = 0; k < n; k++){
					for(int l = 0; l < g[k].size(); l++){
						int a=k,b=g[k][l];
						// if(a>b){
						// 	int tmp=a;
						// 	a=b;
						// 	b=tmp;
						// }
						// if(m.count(P(a,b))>0) continue;
						if(k==x){
							if(l!=i&&l!=j)uf.unite(k,g[k][l]);
						}else if(k==g[x][i]){
							if(g[k][l]!=x) uf.unite(k,g[k][l]);
						}else if(k==g[x][j]){
							if(g[k][l]!=x) uf.unite(k,g[k][l]);
						}else uf.unite(k,g[k][l]);
					}
				}
				// cout << g[x][i] << " " << g[x][j] << endl;
				if(!uf.same(x,y)) flag = true;
			}
		}
		cout<<(flag?"Yes":"No")<<endl;
	}

	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int a[220000];
long dp[220000];
long BIT[220000];
vector<P> flowers;

void set_val(long *bit, int idx, long val){
    idx++;
    while(idx < 220000){
        bit[idx] = max(bit[idx], val);
        idx += idx & -idx;
    }
}

long max_val(long *bit, int idx){
    long res = 0;
    idx++;
    while(idx){
        res = max(res, bit[idx]);
        idx -= idx & -idx;
    }
    return res;
}

int main(){
    int n, h;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> h;
        flowers.push_back(P(h, i));
    }
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(flowers.begin(), flowers.end());
    long ans = 0;
    for(auto p: flowers){
        int i = p.second;
        dp[i] = max_val(BIT, i -1) + a[i];
        set_val(BIT, i, dp[i]);
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using ll = long long;
const char newl = '\n';
#define var auto

void solver(int h, int w) {
  vector< vector< char > > cs(h, vector<char>(w));
  for (int i = 0; i < h; i += 1) {
    for (int j = 0; j < w; j += 1) {
      cin >> cs[i][j];
    }
  }

  vector< int > ds{-1, 0, +1};
  string ans;
  set< string > st;

  for (int i = 0; i < h; i += 1) {
    for (int j = 0; j < w; j += 1) {
      for (auto dy: ds) for (auto dx: ds) {
        if (dy == 0 && dx == 0) continue;

        string s;
        int y = i, x = j;

        do {
          s += cs[y][x];
          (y += dy + h) %= h;
          (x += dx + w) %= w;
          
          if (st.count(s)) {
            if (ans.size() < s.size()) ans = s;
            else if (ans.size() == s.size() && ans > s) ans = s;
          }
            
          st.insert(s);
        } while (y != i || x != j); 
      }
    }
  }

  if (ans.size() >= 2) cout << ans << endl;
  else cout << 0 << endl;
}

signed main(){
    int h, w;
    while (cin >> h >> w, h) {
        solver(h, w);
    }
}



Measured memory_bytes: 35680
N = int(input())

ans = [0 for _ in range(N+1)]
for x in range(1, 101):
    for y in range(x, 101):
        for z in range(y, 101):
            v = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if v < N+1:
                if x == y == z:
                    ans[v] += 1
                elif x == y or x == z or z == y:
                    ans[v] += 3
                else:
                    ans[v] += 6
for i in range(1,N+1):
    print(ans[i])


Measured memory_bytes: 9344
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	int aa[10001];
	int i;
	for(i=0;i<n;i++){
		scanf("%d",&aa[i]);
	}
	double minn=1e9;
	int minni=-1;
	for(i=0;i<n;i++){
		double c=a-aa[i]*0.006;
		//cout<<a-aa[i]*0.006<<endl;
		if(fabs(b-c)<minn){
			minn=fabs(b-c);
			minni=i;
		}
		//cout<<aa[i]<<" "<<fabs(b-c)<<endl;
	}
	cout<<minni+1<<endl;
}

Measured memory_bytes: 256
s = gets.chomp.split("").map(&:to_i)
l = s.length
a,b = [],[]
(0...l).each do |i|
  a << i % 2
  b << (i+1) % 2
end
each_a,each_b = a.each,b.each
count_a,count_b = 0,0
l.times do
  si = s.shift
  count_a += 1 if si != each_a.next
  count_b += 1 if si != each_b.next
end
puts [count_a,count_b].min


Measured memory_bytes: 22424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int H,W;
    cin>>H>>W;

    char a[H][W];
    map<char,int> m;
    rep(i,H){
        rep(j,W){
            cin>>a[i][j];
            m[a[i][j]]++;
        }
    }
    int x1=0;
    int x2=0;
    int x4=0;
    if(H*W%2==1){
        x1++;
        x2=H/2+W/2;
        x4=(H/2)*(W/2);
    }else{
        if(H%2==1){
            x2=W/2;
            x4=(H*W-x2*2)/4;
        }else if(W%2==1){
            x2=H/2;
            x4=(H*W-x2*2)/4;
        }else{
            x4=H*W/4;
        }

    }
    int c1=0,c2=0,c4=0;
    for(auto p:m){
        if(p.second%2==1) {
            c1++;
            p.second--;
        }
        if(p.second%4==2){
            c2++;
            p.second-=2;
        }
        c4+=p.second/4;


    }
    string ans="Yes";
    if(x1!=c1) ans="No";
    if(x2<c2)ans="No";
    cout << ans << endl;






    



}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll k,a,b;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>k>>a>>b;
    ll tmp = b/k - a/k;
    if(tmp!=0 || k==1 || a%k==0 || b%k==0){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    ll count=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]&1){
            count++;
        }
    }
    if(count&1){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

const lli maxN = 27;

vector<lli>  z_algo(string s) {
    lli n = s.size();
    vector<lli> z(n);
    for(lli i = 1, l = 0, r = 0; i < n; i ++) {
        if(i <= r) {
            z[i] = min(r - i + 1, z[i - l]);
        }
        while(i + z[i] < n and s[z[i]] == s[i + z[i]] ) {
            z[i] ++;
        }
        if(i + z[i] - 1 > r) {
            l = i;
            r = i + z[i] - 1;
        }
    }
    return z;
}

void solve()
{

    lli n;
    string s;
    cin>>n>>s;

    lli ans = 0;
    for(int i = 0; i < n; i ++) {
        string t = "";
        for(int j = i; j < n; j ++) {
            t += s[j];
        }
        vector<lli> z = z_algo(t);
        lli id = 0;
        for(auto it : z) {
            id ++;
            if(it < id)
                ans = max(ans, it);
        }
    }

    cout<<ans;

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 512
import collections

n = int(input())
a = list( map(int, input().split()))
c = collections.Counter(a)

ans = len(c)
count_even = 0

for num in c.keys():
    if c[num] %2 ==0: count_even += 1

if count_even%2 == 1:ans-=1

print(ans)

Measured memory_bytes: 18656
using System;

namespace AtCoder2020Ned
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ");
            var inputNum = long.Parse(input[0]);
            var threshold = long.Parse(input[1]);
            var num = inputNum % threshold;
            var previousNum = num;

            while (true)
            {
                if (Math.Abs(num - threshold) < previousNum)
                {
                    num = Math.Abs(num - threshold);
                    previousNum = num;
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine(num);
            Console.Read();
        }
    }
}


Measured memory_bytes: 27352
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
	int n,x,y;
	cin >> n >> x >> y;
	//int ans;
	/*
	for(int i=1;i<=n-1;i++){
		if(i==1){
			cout << n <<"\n";
			continue;
		}
		ans = 0;
		if(x>n-i){
			ans+=n-i-1;
		}else if(y>n-i){
			ans+=n-i-2;
		}else{
			ans+=n-i-3;
		}
		
		if((i-1) >= (x-1+n-y)){
			
		}else if((i-1) >= min(x-1,n-y)){
			ans += min(x-1,n-y);
		}else{
			ans += i;
		}
		
		cout << ans <<"\n";
	}*/
	int a[n-1]={};
	
	for(int i=1; i<=n-1; i++){
		for(int j=i+1; j<=n; j++){
			if(i<x && y<j){
				a[(x-i+1+j-y)  -1]++;
				
				//printf("a(%d, %d) k=%d\n",i,j,x-i+1+j-y);
			}else if(i>=y || j<=x){
				a[(j-i)  -1]++;
				//printf("b(%d, %d) k=%d\n",i,j,j-i);
			}else if(i==x && j==y){
				a[0]++;
				//printf("c(%d, %d) k=%d\n",i,j,1);
			}else{
				int aaa = 1+(int)abs(x-i)+(int)abs(y-j);
				a[min(aaa,(j-i))   -1]++;
				//printf("d(%d, %d) k=%d\n",i,j,min(aaa,(j-i)));
			}
		}
	}
	
	
	
	
	
	REP(i,n-1){
		cout << a[i] << "\n";
	}
	
}

Measured memory_bytes: 256