akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  ll n, w;
  cin >> n >> w;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

  ll m = p[0].first;
  if (w < m) cout << 0 << endl;
  else if (w >= (m + 3) * n - 3) {
    ll ans = 0;
    rep(i, n) ans += p[i].second;
    cout << ans << endl;
  }
  else {
    rep(i, n) p[i].first -= m;
    vector<vector<ll>> dp(3 * n - 2, vector<ll>(n + 1, 0));
    rep(i, n) {
      repr(j, 3 * n - 3) {
        if (j - p[i].first < 0) continue;
        repr(k, i) {
          dp[j][k + 1] = max(dp[j][k + 1], dp[j - p[i].first][k] + p[i].second);
        }
      }
    }

    ll ans = 0;
    rep(j, 3 * n - 2) {
      rep(k, n + 1) {
        if (w < j + k * m) continue;
        ans = max(ans, dp[j][k]);
      }
    }
    cout << ans << endl;
  }



 
  return 0;
}


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

int main() {

    int N;

    cin >> N;

    vector<string> W(N);

    for(int i = 0; i < N ; ++i )cin >> W[i];

    bool flag = true; // しりとりが成立しているかどうか

    for(int i = 1; i < N ; ++i ) {
        if(!flag) break;
        for( int j = 0; j < i ; ++j ) {
            if(W[i] == W[j]) { // W[i]が既に発言されているか
                flag = false;
                break;
            }
        }
        if(W[i].front() != W[i-1].back()) // 単語の先頭と直前の単語の末尾は一致しているか
            flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 51;
bool dp[N];
int n;
int a[N];
int b[N];

bool solve(ll K) {
	for (int it = 0; it < n; it++) {
		for (int i = 0; i < N; i++)
			dp[i] = 0;
		dp[a[it]] = 1;
		for (int i = N - 1; i > 0; i--) {
			if (((K >> i) & 1) == 0) continue;
			for (int j = N - 1; j >= 0; j--)
				if (dp[j])
					dp[j % i] = 1;
		}
		if (!dp[b[it]]) return false;
	}
	return true;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	ll ans = (1LL << N) - 2;
	if (!solve(ans)) {
		printf("-1\n");
		return 0;
	}
	for (int i = N - 1; i > 0; i--) {
		ans ^= 1LL << i;
		if (!solve(ans)) ans ^= 1LL << i;
	}
	printf("%lld\n", ans);

	return 0;
}


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

namespace ABC174
{
    class Program
    {
        static void Main(string[] args)
        {
            long X;
            X = long.Parse(Console.ReadLine());
            
            String A = "";
            A = 30 <= X ? "Yes" : "No";
            Console.WriteLine(A);
        }
    }
}


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

using namespace std;
using ll = long long;

void FastIO ()
{
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
}

int main ()
{
  FastIO();
  
  string s;
  cin >> s;
  cout << (s[2] == s[3] and s[4] == s[5]? "Yes": "No");
}

Measured memory_bytes: 256
S = input()
last_char = ""
L_num = 0
R_num = 0
Sum = 0
for s in S:
    if last_char==">"and s=="<":
        n = max(L_num,R_num)
        m = min(L_num,R_num)
        Sum+=((n+1)*n/2) + ((m-1)*m/2)
        L_num = 0
        R_num = 0
    if s=="<":
        L_num+=1
    else:
        R_num+=1
    last_char=s
n = max(L_num,R_num)
m = min(L_num,R_num)
Sum+=((n+1)*n/2) + ((m-1)*m/2)
print(int(Sum))

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

using namespace std;

int main()
{
    map<string,int> mp;
    string s,t,d;
    cin >> s >> t;
    int a,b;
    cin >> a >> b;
    mp[s] = a;
    mp[t] = b;
    cin >> d;
    mp[d]--;
    cout << mp[s] << ' ' << mp[t];

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
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(nullptr);
    ios::sync_with_stdio(false);

    int x, n;
    cin >> x >> n;

    bool b[200]{};
    rep(i, n) {
        int p;
        cin >> p;
        b[p] = 1;
    }

    int y = x;
    while(1) {
        if(!b[x]) {
            cout << x << endl;
            return 0;
        }
        if(!b[y]) {
            cout << y << endl;
            return 0;
        }
        x--;
        y++;
    }

    return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(s: str):
    ret = 0
    for i, c in enumerate(s):
        if i % 2:
            if c == 'g':
                ret += 1
        else:
            if c == 'p':
                ret -= 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   string s,t;
   cin >> s >> t;
   int ans=0;
   rep(i,3){
   if(s[i]==t[i]) 
   ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

bool dp[16][2][200];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S;cin>>S;
    int N = S.size();

    dp[0][1][0] = true;
    REP(i,N){
        REP(tight,2){
            int x = (tight ? S[i]-'0' : 9);
            REP(j,x+1){
                REP(k,200){
                dp[i+1][tight && j==x][k+j] |=  dp[i][tight][k];
                }
            }
        }
    }
    int ans = 0;
    REP(i,200) if(dp[N][0][i] || dp[N][1][i]) ans = i;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
     int a,b;
     cin>>a>>b;
     b=b-1;
     a=a-1;
     if(b%a==0)
     {
     	cout<<(b/a)<<endl;
	 }
	 else
	 {
	 	int x=(b/a)+1;
	 	cout<<x<<endl;
	 }
	 
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
#define maxn 233333
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
ll n;
ll h[maxn];
int main()
{
	n=read();
	for(rg int i=1;i<=n;++i) h[i]=read();
	for(rg int i=2;i<=n;++i)
	{
		if(h[i]>=h[i-1]) continue;
		if(h[i]+1>=h[i-1]) h[i]++;
		else
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 200003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#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 sumall(v) accumulate(all(v),(ll)0)
#define suma accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define spac " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<tuple<ll,ll,ll> >vtll;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<"\n" ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double power(double p , ll t){db q = 1;while(t){if(t%2){q*=p;}p*=p;t/=2;}return(q);}
ll dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
ll dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
vpll dr;
void call(){dr.pb(mkp(1,0));dr.pb(mkp(-1,0));dr.pb(mkp(0,1));dr.pb(mkp(0,-1));}
ll n,m,k;
bool ok = false;
bool check(string str)
{
    m = sz(str);
    for(ll i =0 ; i<m ; i++)
    {
        if(str[i]==str[m-1-i])
        {
            continue;
        }
        return(false);
    }
    return(true);
}
int main()
{
    FastIO ;
    PRECISION(20) ;
    ll a,b,c,d,i,j,t,x,y,z,x1,y1,z1,e,f;
    db p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    //call();
    //Constructive is Weak!!
    cin>>n;
    vll v;
    map<ll,ll>mp;
    rep(i,0,n)
    {
        cin>>a;
        mp[a]++;
        v.pb(a);
    }
    x = 0;
    for(auto j : mp)
    {
        b = j.se;
        d = ((b)*(b-1))/2;
        x+=d;
    }
    for(i=0 ; i<n ; i++)
    {
        a = v[i];
        b = mp[a];
        d = ((b-1)*(b-2))/2;
        c = (b*(b-1))/2;
        cout<<x+d-c<<"\n";
    }
}

Measured memory_bytes: 11120
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<i64>();
    let sum = a.iter().sum::<i64>();
    let mut ans: (usize, i64) = (0, std::i64::MAX);
    for i in 0..n{
        if (a[i]*n as i64 - sum).abs() < ans.1{
            ans = (i, (a[i]*n as i64 - sum).abs());
        }
    }

    println!("{}", ans.0);
}


Measured memory_bytes: 4352
N=int(input())
S=list(input())
e,w=[0]*(N+1),[0]*(N+1)
for i in range(1,N+1):
    w[i] += w[i-1] + (1 if S[i-1]=='W' else 0)
    e[i] += e[i-1] + (1 if S[i-1]=='E' else 0)
ans=N
for i in range(N):
    ans=min(ans,w[i]+e[-1]-e[i+1])
print(ans)

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

int main(int argc, char const *argv[]){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(max(a,c) <= min(b,d))	cout << min(b,d) - max(a,c) << endl;
	else cout << "0" << endl;
	return 0;
}


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

int main() {
    int n, x, y, i, j;
    cin >> n >> x >> y;
    int dis_x[n+1];
    int dis_y[n+1];
    int ans[n];
    for(i = 1; i <= n; i++){
        int x_tyoku = max(x-i, i-x);
        int y_tyoku = max(y-i, i-y);
        dis_x[i] = min(x_tyoku, 1 + y_tyoku);
        dis_y[i] = min(y_tyoku, 1 + x_tyoku);
        ans[i] = 0;
    }
    for(i = 1; i <= n; i++){
        for(j = i + 1; j <= n; j++){
            int dis, disxy;
            disxy = min(abs(i-x), abs(i-y));
            if(disxy == abs(i-x)) dis = min(j-i, disxy + 1 + dis_y[j]);
            else dis = min(j-i, disxy + 1 + dis_x[j]);
            ans[dis]++;
        }
    }
    for(i = 1; i < n; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  vector<int>a(27);
  for(int i=0;i<s.length();i++)
  {
    a[s[i]-'a'+1]++;
  }
  if(s.length()!=26)
  {	
    cout<<s;
    for(int i=1;i<=26;i++)
    {
      if(!a[i])
      {
        char c='a'+i-1;
        cout<<c<<endl;
        break;
      }
    }
  }
  else 
  {
    int cur=s.length();
    int flag=0;
    while(cur>0)
    {
      a[s[cur-1]-'a'+1]=0;
      s[cur-1]='\0';
      cur--;
      if(cur==0)break;
      if(s[cur-1]=='z')continue;
      for(int i=s[cur-1]-'a'+2;i<=26;i++)
      {
        if(a[i]==0)
        {
          s[cur-1]='a'+i-1;
          for(int w=0;w<cur;w++)cout<<s[w];
          flag=1;
          break;
        }
      }
      if(flag)break;    
    }
    if(!flag)cout<<-1<<endl;
  }
  return 0;
}

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

int main() {
  // 計算時間を考慮しない解答
  int num_10000 = -1, num_5000 = -1, num_1000 = -1;
  int N, Y;
  cin >> N >> Y;
  
  for (int i = 0; i <= N; i++){
    for(int j = 0; j+i <= N; j++){
      int k = N - i -j;
       if(10000*i + 5000*j + 1000*k == Y){
         num_10000 = i;
         num_5000 = j;
         num_1000 = k;
        
      }
    }
  }
  
  cout << num_10000 << " " << num_5000 << " " << num_1000 << endl;
}






Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  long long int a,b=0,c=0;cin>>a>>b>>c;
  cout<<(a+b)*c/2;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r=0, b=0, ans, n;
    string S;
    cin >> S;
    n = S.size();
    for (int i = 0; i < n ;i++){
        if(S[i] == '0')
            r++;
        else
            b++;
    }
    ans = 2*min(b, r);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define sz(a) (int)a.size()
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 998244353; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

int n;

void test() {

    cin >> n;
    int sum;
    cin >> sum;
    vi a;
    a.resize(n);
    input(a,n);
    int dp[n+1][sum+1][3];
    memset(dp,0,sizeof(dp));
    dp[0][0][0] = 1;

    for( int i = 0; i < n; i++) {
        for( int s = 0; s <= sum; s++) {

            (dp[i+1][s][0] += dp[i][s][0]) %= mod;
            (dp[i+1][s][1] += dp[i][s][0] + dp[i][s][1]) %= mod;
            (dp[i+1][s][2] += dp[i][s][0] + dp[i][s][2] + dp[i][s][1]) %= mod;
            if ( s + a[i] > sum ) continue;
            (dp[i+1][s+a[i]][2] += dp[i][s][1] + dp[i][s][0]) %= mod;
            (dp[i+1][s+a[i]][1] += dp[i][s][0] + dp[i][s][1]) %= mod;
        }
    }
    cout << dp[n][sum][2];
}

signed main() {

    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    #endif

    int T = 1;
    //cin >> T;
    while(T--) {
        test();
        cout << "\n";
    }
    return 0;

}

Measured memory_bytes: 214712
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    ll T1,T2;
    ll A1, A2;
    ll B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >>B2;
    
    ll d1A, d2A, d1B, d2B;
    d1A = T1*A1;
    d1B = T1*B1;
    d2A = d1A + T2*A2;
    d2B = d1B + T2*B2;
    
    if(d2A==d2B || d1A==d1B){ //後半の条件は満たされない
        cout<<"infinity"<<endl;
        return 0;
    }
    
    if(d1A > d1B && d2A > d2B){
        cout<<0<<endl;
        return 0;
    }
    if(d1B > d1A && d2B > d2A){
        cout<<0<<endl;
        return 0;
    }
    
    ll ans = 1;
    
    if(d2A>d2B){
        swap(d2A,d2B);
        swap(d1A,d1B);
    }
    
    // 前半で(1回)交わる条件
    // sB-sA < d1A-d1B
    // かつ sB-sA < d2A-d2B  <-これはありえない
    // 上の条件のとき絶対に2回交わる
    
    // 等号のとき 真ん中で 1回交わる
    
    //後半だけで交わる条件
    // これはありえない
    
    ll ds = d2B-d2A;
    
    ans += (d1A-d1B -1)/ds *2;
    if((d1A-d1B)%ds == 0){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
    
}


Measured memory_bytes: 256
h, w, m = gets.split(' ').map(&:to_i)
rows = (0..h).map { 0 }
cols = (0..w).map { 0 }
map = {}
m.times do
  i, j = gets.split(' ').map(&:to_i)
  rows[i] += 1
  cols[j] += 1
  map[i] ||= {}
  map[i][j] = true
end

sorted_is = (1..h).sort_by {|i| rows[i] }
max_is = sorted_is.select {|i| rows[i] == rows[sorted_is.last] }
sorted_js = (1..w).sort_by {|j| cols[j] }
max_js = sorted_js.select {|j| cols[j] == cols[sorted_js.last] }

max_is.each do |i|
  max_js.each do |j|
    unless map[i][j]
      puts rows[i] + cols[j]
      exit
    end
  end
end
puts rows[max_is[0]] + cols[max_js[0]] - 1



Measured memory_bytes: 109400
#include <stdio.h>

int main()
{
  int i, j, n, q, t, cnt=0;
  scanf("%d", &n);
  int s[n+1];
  for (i=0; i<n; i++) scanf("%d", s+i);
  scanf("%d", &q);
  for (i=0; i<q; i++) {
    scanf("%d", &t);
    s[n] = t;
    for (j=0; s[j]!=t; j++);
    if (j!=n) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
ll f[N];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    f[0]=1;
    for(ll i=1;i<N;i++){
        f[i]=(f[i-1]*i)%mod;
    }
    ll n,m; cin>>n>>m;
    if(m>n){
        ll temp=m;
        m=n;
        n=temp;
    }
    if((n-m)>1) cout<<0;
    else{
        ll ans=((f[n]%mod)*(f[m]%mod))%mod;
        if(n==m){
            ans=(ans*2)%mod;
        }
        cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <limits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using ll = long long;
using namespace std;
int main(){
    const int mod = 2019;
    ll l,r;
    cin >> l >> r;
    int res = 2018;
    if(r - l < 2019){
        l %= mod; r %= mod;
        for(int i = l;i <= r;i++){
            for(int j = i + 1;j <= r;j++){
                res = min(res,(i*j)%mod);
            }
        }
    }
    else{
        res = 0;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import itertools
from functools import reduce

N = int(input())
S = [input() for _ in range(N)]
T = [0] * 5
for s in S:
    if s[0] == 'M':
        T[0] += 1
    elif s[0] == 'A':
        T[1] += 1
    elif s[0] == 'R':
        T[2] += 1
    elif s[0] == 'C':
        T[3] += 1
    elif s[0] == 'H':
        T[4] += 1
ans = 0
for t in itertools.combinations(T, 3):
    ans += reduce(lambda a,b:a*b, t)
print(ans)


Measured memory_bytes: 10296
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))

mod = 1000000007

l = 1

for i in range(n):
    l = l * a[i] // gcd(l, a[i])

ans = 0
for i in range(n):
    ans += l // a[i]

print(ans % mod)

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

bool f(int x) {
	int digits = 0;
	while(x) {
		digits++;
		x /= 10;
	}
	return digits % 2 == 1;
}
int main(void) {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (f(i)) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i, j, n-i-j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 9164
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
K = INT()

if K <= 9:
    print(K)
    exit()

n = [-1]*11
n[-1] = 9
cnt = 9


def DFS(n):
    global cnt
    for i in range(1, 11):
        if n[-i] == 9:
            continue
        elif n[-i-1] != -1 and n[-i] == n[-i-1]+1:
            continue
        else:
            if n[-i] == -1:
                n[-i] = 1
            else:
                n[-i] += 1

            for j in range(i-1, 0, -1):
                n[-j] = max(0, n[-j-1] - 1)
            break
    cnt += 1
    if cnt == K:
        print(*n[bisect(n, -1):], sep = "")
        exit()
    DFS(n)


DFS(n)


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

using namespace std;
  
#define MAXN 1000001 

int spf[MAXN]; 
  
int hash1[MAXN] = { 0 }; 

void sieve() 
{ 
    spf[1] = 1; 
    for (int i = 2; i < MAXN; i++) 
  

        spf[i] = i; 
  

    for (int i = 4; i < MAXN; i += 2) 
        spf[i] = 2; 
  

    for (int i = 3; i * i < MAXN; i++) { 
  

        if (spf[i] == i) { 
            for (int j = i * i; j < MAXN; j += i) 
  
                if (spf[j] == j) 
                    spf[j] = i; 
        } 
    } 
} 
  
void getFactorization(int x) 
{ 
    int temp; 
    while (x != 1) { 
        temp = spf[x]; 
        if (x % temp == 0) { 
  

            hash1[spf[x]]++; 
            x = x / spf[x]; 
        } 
        while (x % temp == 0) 
            x = x / temp; 
    } 
} 
  

int main() {
    int n;
    cin>>n;

    vector<int> arr(n);
    for(int i=0; i<n; i++) cin>>arr[i];
    
    sieve(); 
  
    for (int i = 0; i < n; i++) getFactorization(arr[i]); 

    bool pairPrime = true;
    for(int i=0; i<MAXN; i++) {
        if(hash1[i] > 1) { 
            pairPrime = false; 
        }
    }

    if(pairPrime) {
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    int gcd = arr[0];
    for(int i=1; i<n; i++) {
        gcd = __gcd(gcd, arr[i]);
    }
    if(gcd == 1) {
        cout<<"setwise coprime"<<endl;
    }else {
        cout<<"not coprime"<<endl;
    }
    return 0;
}

Measured memory_bytes: 14696
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> b(n); REP(i, n) cin >> b[i];
  vector<int> ans;
  REP(i, n) {
    if (ans.size() < b[i] - 1) {
      cout << -1 << '\n';
      return 0;
    }
    ans.insert(ans.begin() + b[i] - 1, b[i]);
  }
  REP(i, n) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        p[i] = {--l, -r};
    }
    sort(p.begin(), p.end());
    vector<int> x;
    for (int i = 0; i < n; ++i) {
        p[i].second = -p[i].second;
        while (!x.empty() && p[x.back()].second >= p[i].second)
            x.pop_back();
        x.push_back(i);
    }
    vector<bool> used(n);
    for (int i : x)
        used[i] = true;
    if (x.size() < n) {
        int l = 0, r = 1E9;
        for (int i = 0; i < x.size(); ++i) {
            l = max(l, p[x[i]].first);
            r = min(r, p[x[i]].second);
        }
        ans += max(0, r - l);
        l = 0;
        for (int i = 0; i < n; ++i) {
            if (used[i])
                continue;
            l = max(l, p[i].second - p[i].first);
        }
        ans += l;
    }
    for (int i = 0; i + 1 < x.size(); ++i)
        ans = max(ans, max(0, p[x[0]].second - p[x[i]].first) + max(0, p[x[i + 1]].second - p[x.back()].first));
    for (int i = 1; i + 1 < x.size(); ++i)
        ans = max(ans, p[x[i]].second - p[x[i]].first + max(0, p[x[0]].second - p[x.back()].first));
    cout << ans << endl;
    return 0;
}

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

const int MX = 100005;

int main() {
    int n; cin >> n;
    vector<int> a(MX), dp(MX, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    dp[1] = abs(a[1] - a[0]);
    dp[2] = min(abs(a[1] - a[0]) + abs(a[2] - a[1]), abs(a[2] - a[0]));
    for (int i = 3; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
// author:-*mdragneell*

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

#define ll long long
#define ld long double
#define pb push_back
#define pi  pair<int,int>
#define pl  pair<ll,ll>

int const N=3001;
ll min(ll x,ll y) { if(x<y) return x; else return y; }
ll max(ll x,ll y) { if(x>y) return x; else return y; }

ll cache[N][N];
ll n,m,a[N];

ll sol(ll i,ll j)
{
		if(i>j) return 0;
		if(cache[i][j]!=-1)
			return cache[i][j];

			return cache[i][j]=max(a[i]-sol(i+1,j),a[j]-sol(i,j-1));

}

int main()
{
		ll i,j;
		cin>>n;

		memset(cache,-1,sizeof(cache));

		for(i=0;i<n;i++)
				cin>>a[i];
		cout<<sol(0,n-1)<<endl;

}


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

int main(){
    int N,i,a;
    string S;
    cin>>N;
    cin>>S;
    vector<char> alp{'A','B','C','D','E','F','G','H','I','J','K','L',
    'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

    for(i=0;i<S.size();i++){
        a=(int)S[i]-65;
        S[i]=alp[(a+N)%26];
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public boolean isQube(Integer number) {
		for(int i=0;i<100100;i++) {
			if (i*i==number) return true;
		}
		return false;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Main product = new Main();
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					System.in));
			String inputLine = reader.readLine();
			String numbers[] = inputLine.split(" ");
			System.out.println(product.isQube(Integer.valueOf(numbers[0] + numbers[1])) ? "Yes" : "No");
		} catch (IOException ignore) {
		}
	}
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
    vector<bool> haming(1e6+1,false);
    queue<int> q;
    q.push(1);
    int x[] = {2,3,5};
    while(!q.empty()){
	int now = q.front();
	//cout<<now<<endl;
	q.pop();
	if(now > 1e6)continue;
	if(haming[now]) continue;
	haming[now] = true;
	for(int i=0;i<3;i++) q.push( now*x[i]);
    }
  //  cout<<"ok"<<endl;
    vector<int> cnt(1e6+1,0);
    for(int i=1;i<1e6+1;i++){
	int tmp = 0;
	if(haming[i] ) tmp++;
	cnt[i] = cnt[i-1] + tmp;
    }
    while(1){
	int n,m;
	cin>>n;
	if(n==0)break;
	cin>>m;
	cout<<cnt[m]-cnt[n-1]<<endl;
    }

	return 0;
}



Measured memory_bytes: 6632
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
    char a;
    cin >> a;
    if(isupper(a)) cout << "A";
    else cout << "a";
}

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

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll N,x;
  cin >> N >> x;
  vl a(N);
  vl b(N-1);
  ll ans=0;
  rep(i,N){
    cin >> a[i];
    if(i>=1){
      b[i-1]=a[i]+a[i-1];
    }
  }
  rep(i,N-1){
    if(b[i]>x){
      ll k=min(a[i+1],b[i]-x);
      ans+=b[i]-x;
      b[i]-=k;
      b[i+1]-=k;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) 
                {
                    break;
                }
 
                string[] inputs = input.Split(' ');
                int[] coefficients = new int[6];
                for (int i = 0; i < 6; i++)
                {
                    coefficients[i] = int.Parse(inputs[i]);
                }
 
                double x = (double)(coefficients[2] * coefficients[4] - coefficients[1] * coefficients[5]) / (coefficients[0] * coefficients[4] - coefficients[1] * coefficients[3]);
                double y = (double)(coefficients[0] * coefficients[5] - coefficients[2] * coefficients[3]) / (coefficients[0] * coefficients[4] - coefficients[1] * coefficients[3]);
 
                Console.WriteLine("{0:f3} {1:f3}", x, y);
            }
        }
    }

Measured memory_bytes: 9140
#include <bits/stdc++.h>
		using namespace std;
		#define ll int
		#define INF 100000000LL
		#define mod 1000000007
		#define pll pair<long,long>
		#define se second
		#define fi first
		#define pb push_back
		#include <ext/pb_ds/assoc_container.hpp>
		#include <ext/pb_ds/tree_policy.hpp>
		using namespace __gnu_pbds;

		typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
		typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;


		int main()
		{
					ios_base::sync_with_stdio(false);
					cin.tie(NULL);
					
					ll n;
					cin>>n;
					vector<ll> p(n+2);
					for(ll i=0;i<n;i++)
						cin>>p[i];
						
					vector<ll> a(n+2);
					vector<ll> b(n+2);
					for(ll i=1;i<=n;i++)
					{
						a[i]=i;
						b[i]=n-i+1;
					}
					vector<ll> c1(n+2,0);
					vector<ll> c2(n+2,0);
					ll cnt=1;
					for(ll i=0;i<n;i++)
					{
						c2[0]+=cnt;
						c2[p[i]+1]-=cnt;
						c1[p[i]]+=cnt;
						c1[n+1]-=cnt;
						cnt++;
					}
					for(ll i=1;i<=(n+1);i++)
					{
						c1[i]+=c1[i-1];
						c2[i]+=c2[i-1];
					}
					for(ll i=1;i<=n;i++)
					{
						cout<<a[i]+c1[i]<<" ";
					}
					cout<<endl;
					for(ll i=1;i<=n;i++)
					{
						cout<<b[i]+c2[i]<<" ";
					}
					
					
					
		}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let s: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    let mut vec: Vec<Vec<usize>> = vec![vec![0; w]; h];
    for i in 0..h {
        for j in 0..w {
            if j == 0 {
                if s[i][j] == '.' {
                    vec[i][j] = 1;
                }
            } else {
                if s[i][j] == '.' {
                    vec[i][j] += vec[i][j-1] + 1;
                } else {
                    vec[i][j] = 0;
                }
            }
        }
    }for i in 0..h {
        for j in (0..w-1).rev() {
            if vec[i][j+1] > 0 && vec[i][j] > 0 {
                vec[i][j] = vec[i][j+1];
            }
        }
    }
    
    let mut vec2: Vec<Vec<usize>> = vec![vec![0; w]; h];
    for j in 0..w {
        for i in 0..h {
            if i == 0 {
                if s[i][j] == '.' {
                    vec2[i][j] = 1;
                }
            } else {
                if s[i][j] == '.' {
                    vec2[i][j] += vec2[i-1][j] + 1;
                } else {
                    vec2[i][j] = 0;
                }
            }
        }
    }
    for j in 0..w {
        for i in (0..h-1).rev() {
            if vec2[i+1][j] > 0 && vec[i][j] > 0 {
                vec2[i][j] = vec2[i+1][j];
            }
        }
    }

    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            let po = vec[i][j] + vec2[i][j];
            if po > 0 {
                ans = std::cmp::max(ans, po - 1);
            }
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 102780
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

const int dx[] = {1, 0, -1, 0, 0};
const int dy[] = {0, 1, 0, -1, 0};

int n, m;
int a[10];
int num[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

const int Maxn = 10010;
const int INF = (int) 1e9;

int dp[Maxn];

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

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    sort(a, a + m, greater<int>());

    fill(dp, dp + n, -INF);
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i - num[a[j]] >= 0) {
                dp[i] = max(dp[i], dp[i - num[a[j]]] + 1);
            }
        }
    }

    int cur = n;
    while(cur > 0){
        for (int j = 0; j < m; ++j) {
            if (cur - num[a[j]] < 0) continue;
            if (dp[cur - num[a[j]]] == dp[cur] - 1){
                cout << a[j];
                cur -= num[a[j]];
                break;
            }
        }
    }
    cout << endl;
}

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

using namespace std;

typedef long long ll;

const int maxn=1e3+10;

char s1[maxn],s2[maxn];

int main()
{
    int n,i,ans,j,m;
    scanf("%d",&n);
    scanf("%s",s1);
    if(n%2)
    {
        printf("No\n");
    }
    else
    {
        m=n/2;
        for(i=0;i<m;++i)
        {
            s2[i]=s1[i];
        }
        ans=0;
        for(i=m,j=0;i<n;++j,++i)
        {
            if(s1[i]!=s2[j])
            {
                ans=1;
                break;
            }
        }
        if(ans)
        {
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007
typedef long long int ll;

int main(void){

    int n, *list;
    ll k, ans = 0;

    scanf("%d %lld", &n, &k);

    list = malloc(sizeof(int) * n);

    for(int i = 0; i < n; i++){
        scanf("%d", list+i);
    }
    
    //一つ目
    for(int i = 0; i < n;i++){
        for(int j = i; j < n;j++){
            if(list[i] > list[j]){
                ans += k;
            }
        }
    }

    //二つ目
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n;j++){
            if(list[i] > list[j]){
                ans += (k * (k - 1)) / 2;
                ans %= MOD;
            }
        }
    }

    printf("%ld", ans);

    free(list);

    return 0;
}

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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll unsigned long long 
 
using namespace std;

 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	string res="";
	int x=0;
	while(n>0)
	{
	     while(n%26==0){
	     res='z'+res;
	     n/=26;
	     if(n==1){
	     x=1;
	     break;
	     }
	     else
	     n--;
	     }
	     if(x==1){
	          break;
	     }
	     else{
	     char ch=(n%26)+96;
	     res=ch+res;
	     n/=26;
	     }
	}
	
	cout<<res;
	return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int x = stdin.nextInt();
        int a = stdin.nextInt();
        int b = stdin.nextInt();
        
        int ans = (x - a) % b;
        System.out.println(ans);
    }
}


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

int isPalindromic(char *str);

int main(int argc, const char *argv[])
{
	int cnt = 0;
	char *str = malloc(sizeof(char)*100);
	while(scanf("%s", str)!=EOF) if(isPalindromic(str)) cnt++;
	printf("%d\n", cnt);	
	
	free(str);
	return 0;
}

int isPalindromic(char *str)
{
	int i, length = strlen(str);

	/* compare */
	for(i=0; i<length; i++)
		if(str[i] != str[length-1-i]) return 0;
	
	return 1;
}

Measured memory_bytes: 576
#include<stdio.h>

int main(){
  
  int h, m, s, t ;

  scanf("%d", &t);

  h = t / 3600;
  m = t % 3600 / 60 ;
  s = t - h*3600 - m*60 ;

  printf("%d:%d:%d\n" , h, m, s);

  return 0;

}



Measured memory_bytes: 2104
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
inf = 1000000007

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in a:
  dp[1] = 1
else:
  dp[1] = 0
  
for i in range(2, n+1):
  if i in a:
    continue
  dp[i] = dp[i - 1] + dp[i - 2]
  dp[i] %= inf
  
print(dp[n])

Measured memory_bytes: 13216
import heapq
K=int(input())
queue=[i for i in range(1,10)]
heapq.heapify(queue)
for i in range(K-1):
    n=heapq.heappop(queue)
    if n%10==0:
        heapq.heappush(queue,n*10+0)
        heapq.heappush(queue,n*10+1)
    elif n%10==9:
        heapq.heappush(queue,n*10+8)
        heapq.heappush(queue,n*10+9) 
    else:
        heapq.heappush(queue,n*10+(n%10))
        heapq.heappush(queue,n*10+(n%10)+1)
        heapq.heappush(queue,n*10+(n%10)-1)
print(queue[0])

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

using namespace std;

#define ll long long
#define mod(x) ((x + MOD)%MOD)


const ll maxn = 1e3 + 10, MOD = 1e9 + 7;

int n,m;
int s1[maxn], s2[maxn];

bool cmp(int x, int y) {return x > y;}

ll f() {
    sort(s1 , s1 + n, cmp);
    sort(s2 , s2 + m, cmp);
    int l1 = 0, l2 = 0;
    ll sum = 1;
    for (int i = n * m; i >= 1; i--) {
        
        ///两个都走到头了，直接判断
        if (l1 == n && l2 == m) {
            ll t = l1 * 1ll * l2 - (n * m - i);
            if (t == 0) return 0;
            sum = mod(sum * 1ll * t);continue;
        }
        ///其中一个都走到头了
        if (l1 == n && l2 != m) {
            if (s2[l2] > i) return 0;
            if (s2[l2] == i) {
                ll t = l1;
                l2++;
                if (t == 0) return 0;
                sum = mod(sum * 1ll * t);
                continue;
            }
            ll t = l1 * 1ll * l2 - (n * m - i);
            if (t == 0) return 0;
            sum = mod(sum * 1ll * t);continue;
        }
        ///其中一个都走到头了
        if (l1 != n && l2 == m) {
            if (s1[l1] > i) return 0;
            if (s1[l1] == i) {
                ll t = l2;
                l1++;
                if (t == 0) return 0;
                sum = mod(sum * 1ll * t);
                continue;
            }
            ll t = l1 * 1ll * l2 - (n * m - i);
            if (t == 0) return 0;
            sum = mod(sum * 1ll * t);continue;
        }
        
        ///如果当前的值大于枚举值，直接判无效
        if (s1[l1] > i || s2[l2] > i) return 0;
        
        /// 确定位置
        if (s1[l1] == i && s2[l2] == i) {
            l1++,l2++;continue;
        }
        
        ///确定了某一行或列
        if (s1[l1] == i && s2[l2] != i) {
            ll t = l2;
            l1++;
            if (t == 0) return 0;
            sum = mod(sum * 1ll * t);
            continue;
        }
        if (s1[l1] != i && s2[l2] == i) {
            ll t = l1;
            l2++;
            if (t == 0) return 0;
            sum = mod(sum * 1ll * t);
            continue;
        }
        
        ///行列都不确定
        if (s1[l1] != i && s2[l2] != i) {
            ll t = l1 * 1ll * l2 - (n * m - i);
            if (t == 0) return 0;
            sum = mod(sum * 1ll * t);
        }
    }
    return sum;
}



int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> s1[i];
	for (int i = 0; i < m; i++) cin >> s2[i];
	cout << f() << endl;
    return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;

	vector<int> A;
	int total = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A.push_back(a);
		total += a;
	}
	//cout << "total:" << total << endl;

	int count = 0;
	double line = total*(1.0 / (4.0 * M));
	//cout << "line:" << line << endl;
	for (int i = 0; i < N; i++) {
		if (line <= A[i]) {
			count++;
		}
	}

	if (count >= M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
	


Measured memory_bytes: 3624
N=int(input())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 
C.append(0)
ans=0
ans=sum(B)

for i in range(N-1):
    if A[i+1]==A[i]+1:
        ans=ans+C[A[i]-1]
print(ans)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, A, B;

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

    std::cin >> N >> A >> B;

    int mn = std::min(A * N, B);
    std::cout << mn << std::endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
#define EPS (1e-7)
#define DEF (1e+9 + 7)

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)





int main() {
	
	int n;
	cin >> n;
	long long ans;

	VI v(n);
	REP(i, n) {
		cin >> v[i];
	}

	SORT(v);

	if (n % 2 == 1) {
		if (v[0] != 0) {
			cout << 0 << endl;
			return 0;
		}
		int p = 2;
		for (int i = 1; i < n; i+=2)
		{
			if (v[i] == p && v[i + 1] == p) {
				p += 2;
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		ans = 1;
		REP(i, n / 2) {
			ans *= 2;
			if (ans > DEF) {
				ans %= (int)DEF;
			}
		}
	}
	else {
		int p = 1;
		for (int i = 0; i < n; i += 2)
		{
			if (v[i] == p && v[i + 1] == p) {
				p += 2;
			}
			else {
				cout << 0 << endl;
				return 0;
			}
		}
		ans = 1;
		REP(i, n / 2) {
			ans *= 2;
			if (ans > DEF) {
				ans %= (int)DEF;
			}
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
n = int(input())
hs = list(map(int, input().split()))

a, b = 0, abs(hs[1] - hs[0])

for i in range(2, n):
  d1 = a + abs(hs[i] - hs[i-2])
  d2 = b + abs(hs[i] - hs[i-1])
  a, b = b, d1 if d1 <= d2 else d2

print(b)

Measured memory_bytes: 13928