akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

// sieve(upto) returns the list of prime numbers up to upto.
vector<ll> sieve(ll upto) {
  vector<ll> res;
  vector<bool> tbl(upto+1);
  ll lim = (ll)(sqrt((double)upto)) + 1;
  for (ll x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (ll y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

// prime factorization
//      primes should contain prime numbers at least up to sqrt(n)
vector<pair<ll, ll>> prfac(ll n, const vector<ll>& primes) {
  vector<pair<ll, ll>> res;
  ll x = n;
  for (ll p : primes) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    ll c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

// prime factorization
vector<pair<ll, ll>> prfac(ll n) {
  return prfac(n, sieve((ll)(sqrt((double)n)) + 1));
}

// list of divisors
//     note: not sorted
vector<ll> gdsub(ll i, ll n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll len = part.size();
  auto t = fs.at(i);
  ll p = t.first;
  ll r = t.second;
  ll pp = p;
  for (ll m = 1; m <= r; m++) {
    for (ll j = 0; j < len; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n) {
  ll s = sqrt(n);
  auto primes = sieve(s+1);
  vector<pair<ll, ll>> fs = prfac(n, primes);
  return gdsub(0, fs.size(), fs);
}


bool chk(ll b, ll n, ll s) {
  ll t = 0;
  while (n > 0) {
    t += n % b;
    n /= b;
  }
  return t == s;
}

ll solve(ll n, ll s) {
  if (n < s) return -1;
  if (n == s) return n+1;
  ll sqrtN = sqrt(n);
  for (ll b = 2; b <= sqrtN; b++) {
    if (chk(b, n, s)) return b;
  }
  vector<ll> vDiv = getDivisors(n-s);
  sort(vDiv.begin(), vDiv.end());
  int k = vDiv.size();
  for (int j = k/2; j < k; j++) {
    ll b = vDiv[j] + 1;
    ll x = (n - s) / (b - 1);
    if (x < b && 0 <= s - x && s - x < b) return b;
  }
  return -1;
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll n, s; cin >> n >> s;
  cout << solve(n, s) << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
 
#define ll long long;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

	int a, b, c, k;

	cin >> a >> b >> c >> k;

	int ans = 0;

	if (a > k) {
		ans += k;
	} else {

		k -= a;
		ans = a;

		if (b < k) {
			k -= b;

			ans -= k;
		}
	}

	cout << ans << endl;
}

//printf("%ld\n", ans);

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

int main()

{
	int n,ans=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		int d=0,ii=i;
		while (ii>0){
			d++;
			ii/=10;
		}
		if (d%2==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=tuple(map(int,input().split()))
a=sum(l)
ans=1
def f(i):
    p=[]
    for j in l:
        r=j%i
        if r:p.append(r)
    p.sort()
    a=i*len(p)-sum(p)
    now=0
    for j in p:
        now+=j
        a-=i-j
        if now<=k and a<=k and abs(now-a)%i==0:
            return i
    return 0

from math import floor,sqrt
for i in range(1,floor(sqrt(a))+1):
    if a%i==0:
        ans=max(f(i),ans,f(a//i))

print(ans)

Measured memory_bytes: 74104
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)


using namespace std;
typedef long long ll;

int main(){
  int s,w;
  IN2(s,w);
  if(s <= w){
    OUT("unsafe");
  }
  else
  {
    OUT("safe");
  }
  
}

Measured memory_bytes: 3632
ii = 1
while max = gets.to_i
  break if max == 0
  puts "Case #{ii}:"
  n = gets.to_i
  v = []
  w = []
  dp = Array.new(n+1){Array.new(max+1){0}}
  n.times{|i|
    v[i], w[i] = gets.split(",").map(&:to_i)
  }
  i = n - 1
  while i >= 0
    j = 0
    while j <= max
      if j < w[i]
        dp[i][j] = dp[i+1][j]
      else
        dp[i][j] = [dp[i+1][j], dp[i+1][j-w[i]] + v[i]].max
      end
      j += 1
    end
    i -= 1
  end
  p dp[0][max]
  p dp[0].index(dp[0][max])
  ii += 1
end

Measured memory_bytes: 16964
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

bool ok = 0;
vector<int> v(4);
void bfs(int now,int id,vector<int> pl){
    if(id==3){
        //cout<<"Yes"<<endl;
        if(now == 7){
            if(ok==0){
                rep(i,4){
                    if(i!=3){
                        cout<<v[i];
                        if(pl[i]==1) cout<<"+";
                        else cout<<"-";
                    }else cout<<v[3]<<"=7"<<endl;
                }
            }
            ok = 1;
        }
    }
    else{
        vector<int> pl2;
        pl2 = pl;
        pl.push_back(1);
        pl2.push_back(0);
        bfs(now+v[id+1],id+1,pl);
        bfs(now-v[id+1],id+1,pl2);
    }   
}

int main(){
    string s;
    cin >> s;
    rep(i,s.size()) v[i] = s[i] - '0' ;
    vector<int> a;
    bfs(v[0],0,a); 
    return 0;
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  
  S.push_back('#');
  rep(i,N){
    if(S[i] == S[i+1]) continue;
    else{
      ans++;
    }
  }
  cout << ans << endl;
 }

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

int main(){
    char ch;
    cin>>ch;
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
        printf("vowel\n");
    }else{
        printf("consonant\n");
    }
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
int d[MAX_N];

int ans;

bool check(int k) {
  int top = (int)(lower_bound(d, d + n, k) - d);

  // printf("%d: %d\n", top, k);
  return (top == n - top);
}


int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(d[i]));
  }

  sort(d, d + n);

  // for (int i = 0; i < n; ++i) {
  //   printf("%d ", d[i]);

  // }
  // printf("\n");

  int max_d = d[n - 1];

  ans = 0;

  for (int i = 1; i <= max_d; ++i) {
    int k = i;

    if (check(k)) ans += 1;
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
 
int main(){
  int N;
  cin>>N;
  int a=N/1000;
  int b=N/100-a*10;
  int c=N/10-a*100-b*10;
  int d=N-a*1000-b*100-c*10;
   if(a==b&&b==c&&c==d){
     cout<<"Yes"<<endl;
   }
  else if(a==b&&b==c || b==c&&c==d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
S=input()
a=0
b=0
c=0

for i in range(len(S)):
    if S[i]=="a":
        a+=1
    if S[i]=="b":
        b+=1
    if S[i]=="c":
        c+=1

if a==b and a==c or a==b and a==c+1 or a==b and a==c-1 or b==c and c==a+1 or b==c and b==a-1 or c==a and a==b+1 or c==a and a==b-1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

int ans;
int n, m;
int H[100005];
vector<int> g[100005];

int main(void) {
    cin >> n >> m;
    rep(i, 0, n) scanf("%d", &H[i]);

    rep(i, 0, m) {
        int a, b;
        scanf("%d %d", &a, &b);
        g[a-1].pb(b-1);
        g[b-1].pb(a-1);
    }

    rep(i, 0, n) {
        int now = H[i];
        bool ok = true;
        for (int v : g[i]) {
            if (H[v]>=now) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;

    }
    

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9188
#include<iostream>
#include<math.h>
#include<queue>
using namespace std;
int main(){
	priority_queue<long long int> a;
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		long long int hoge;
		cin>>hoge;
		a.push(hoge);
	}
	for(int i=0;i<m;i++){
		long long int t=a.top();
		a.pop();
		a.push(t/2ll);
	}
	long long int ans=0;
	for(int i=0;i<n;i++){
		ans+=a.top();
		a.pop();
	}
  cout<<ans<<endl;
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int iCount = int.Parse(Console.ReadLine());
        List<int> N = new List<int>();
        string[] P = Console.ReadLine().Split(' ');
        for (int i = 0; i < P.Length; i++)
        {
            N.Add(int.Parse(P[i]));
        }

        N.Sort();

        int st =N[0];
        int oCount = 0;
        for (int i = 1; i < N.Count; i++)
        {
            if(N[i] != st)
            {
                if(N.Count/2 == i)
                {
                    oCount = N[i] - N[i - 1]; 
                    break;
                }
                else if(N.Count / 2 < i)
                {
                    break;
                }
            }
            else
            {
                st = N[i];
            }
        }

        Console.WriteLine(oCount);
        Console.ReadKey();

    }
}


Measured memory_bytes: 17504
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll k,o=50,n;
vector<ll>ans;
int main(void){
    cin>>k;
    cout<<50<<endl;
    o+=k/50;
    n=50-k%50;
    for(int i=0;i<n;i++)ans.push_back(o-k%50-i-1);
    for(int i=n;i<50;i++)ans.push_back(o+n);
    for(int i=0;i<ans.size()-1;i++)cout<<ans[i]<<' ';
    cout<<ans.back()<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 

  
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{ll int t;

t=1;

while(t--)
{

ll int b,c,i,flag=0;
ll int n;
cin>>n;
ll int a[n];
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
    if(a[i]%2==1)continue;
    if(a[i]%3==0||a[i]%5==0)
    continue;
    else
    {
        flag=1;
        
        break;
    }
}
 if(flag)
 cout<<"DENIED"<<endl;
 else
 cout<<"APPROVED"<<endl;



}
 
    return 0;
}

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

using namespace std;

int main(){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int x = (c + b - 1) / b;
	int y = (a + d - 1) / d;
	if (x <= y)
		puts("Yes");
	else 
		puts("No");
	return 0;
}


Measured memory_bytes: 3684
S = input()
lst = [str(i).zfill(2) for i in range(1, 13)]
up = S[0:2]
low = S[2:4]


if up in lst and low in lst:
    ans = "AMBIGUOUS"
elif up in lst and low not in lst:
    ans = "MMYY"
elif up not in lst and low in lst:
    ans = "YYMM"
else:
    ans = "NA"


print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int n;
  cin>>n;
  map<int,int> m;
  for(int i:boost::irange(0, 1<<n)) {
    int v;
    cin>>v;
    ++m[-v];
  }
  int mx, cntmx;
  tie(mx, cntmx) = *m.begin();
  bool ok = cntmx == 1;
  m.erase(m.begin());
  priority_queue<int> slt;
  for(int i :boost::irange(0,n)) {
    slt.emplace(i);
  }
  for(auto& p : m) {
    int s, cnt;
    tie(s, cnt) = p;
    vecint nxts;
    for (int i : boost::irange(0, cnt)) {
      if (slt.empty()) {
        ok = false;
        break;
      }
      int rem = slt.top();
      slt.pop();
      for (int j : boost::irange(0, rem)) {
        nxts.push_back(j);
      }
    }
    for(auto& v: nxts) slt.push(v);
  }
  if(ok) {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 13184
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define root2 1.4142135623
#define mod 998244353
#define ll long long
using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;
    
    ll n,m,k; 
    cin>>n>>m>>k;
    ll a[n], b[m];
    ll pre_a[n], pre_b[m], prev= 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        pre_a[i] = a[i] + prev;
        prev = pre_a[i];
    }
    prev = 0;
    for(int i=0;i<m;i++){
        cin>>b[i];
        pre_b[i] = b[i] + prev;
        prev = pre_b[i];
    }
    int idx1 = -1;
    for(int i=0;i<n;i++){
        if(pre_a[i] <= k)idx1 = i;
        else break;
    }
    int j =0;
    ll curr_maxa = 0, max = 0,cnt=0;
    // cout<<idx1<<endl;
    for(int i = idx1;i>=0;i--){
        curr_maxa = pre_a[i];
        // cout<<" "<<curr_max<<endl;
        cnt = i+1;
        // cout<<"CNT "<<cnt<<endl;
        // cout<<curr_maxa<<" J : "<<j<<" VAL : "<<pre_b[j]<<endl;
        while(curr_maxa + pre_b[j] <= k && j<m){
            j++;
        }
        cnt+= j;
        // cout<<"AFTER : cnt"<<cnt<<endl;
        if(max < cnt)max = cnt;
    }
    curr_maxa = 0;
    while(curr_maxa + pre_b[j] <= k && j<m){
        j++;
    }
    if(max < j) max = j;
    // cout<<j<<endl;
    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 9344
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

int calc(int[] xs) {
    int[int] d;
    foreach (x; xs) d[x]++;

    int ans = 0;
    foreach (k, v; d) {
        if (k < v) ans += v - k;
        else if (k > v) ans += v;
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

int N,Q;
string S;
vector<pair<int,int>> v;
vector<int> c;
int cnt=0;
int st2,en2;

int main(){

        cin >> N >> Q >> S;
        c.resize(N);
        v.resize(Q);

        FOR(i,0,S.length()){
                if(S.substr(i,2) == "AC"){
                      cnt++;
                }
                c[i] = cnt;
        }

        FOR(i,0,Q) cin >> v[i].first >> v[i].second;
        

        FOR(i,0,Q){
                if(v[i].first == 1){
                        st2 = 0;
                }else{
                        st2 = c[v[i].first-2];
                }
                if(v[i].second == 1){
                        en2 = 0;
                }else{
                        en2 = c[v[i].second-2];
                }
                cout << en2 - st2 << endl;
        }

        //debug
//        FOR(i,0,c.size()) cout << c[i];
//        cout << endl;
       
        return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll unsigned long long
#define ld long double
#define pi 3.14159
#define mx 9999999
using namespace std;
ll mark[mx];
map<ll,ll> m;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll x=a-1,s=0;
    if(b==1) {cout<<0; return 0;}
    for(int i=1;i<=20;i++){
        s=s+x;
        //cout<<s<endl;
        if(s+1>=b) {cout<<i; return 0;}
    }
}


Measured memory_bytes: 256
def main():
    h, w, a, b = map(int, input().split())
    if a > w/2 or b > h/2:
        print("No")
        exit()

    for i in range(h - b):
        s = ""
        for j in range(w):
            if j >= a:
                s += "0"
            else:
                s += "1"
        print(s)
    for i in range(h - b, h):
        s = ""
        for j in range(w):
            if j >= a:
                s += "1"
            else:
                s += "0"
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

long max_diff(long A, long B, long C)
{
  return std::max(
    std::abs(A - B),
    std::max(
      std::abs(B - C),
      std::abs(C - A)
    )
  );
}

char min(long A, long B, long C)
{
  if (A < B && A < C) return 'A';
  if (B < C && B < A) return 'B';
  if (C < A && C < B) return 'C';
  return '*';
}

char max(long A, long B, long C)
{
  if (A > B && A > C) return 'A';
  if (B > C && B > A) return 'B';
  if (C > A && C > B) return 'C';
  return '*';
}

int main(int argc, char **argv)
{
  long A, B, C;
  std::cin >> A >> B >> C;
  
  unsigned count = 0;
  
  while (max_diff(A, B, C) >= 2 && min(A, B, C) != '*') {
    switch(min(A, B, C)) {
    case 'A': A += 2; break;
    case 'B': B += 2; break;
    case 'C': C += 2; break;
    default:  break;
    }
    ++count;
  }
  
  while (max_diff(A, B, C) > 0 && max(A, B, C) != '*') {
    switch(max(A, B, C)) {
    case 'A': ++B; ++C; break;
    case 'B': ++C; ++A; break;
    case 'C': ++A; ++B; break;
    default:  break;
    }
    ++count;
  }
  
  if (max_diff(A, B, C) > 0) count += 2;
  
  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

int dp[100001];
int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    int a[n];
    scan(a, n);
    dp[2] = abs(a[0] - a[1]);
    if (n > 2)
        dp[3] = abs(a[0] - a[2]);
    for (int i = 4; i <= n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i - 2] - a[i - 1]), dp[i - 2] + abs(a[i - 3] - a[i - 1]));
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

typedef struct{
  int oya,sa,yuu;
}ki;


ki tree[100000];
int Depth[100000];

void depth(int r,int t){
  Depth[r]=t;
  if(tree[r].yuu!=-1)depth(tree[r].yuu,t);
  if(tree[r].sa!=-1)depth(tree[r].sa,t+1);
}


int main(){
  int i,j;
  int n;
  int p,q,r,s;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].oya=tree[i].sa=tree[i].yuu=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&p);
    scanf("%d",&q);
    for(j=0;j<q;j++){
      scanf("%d",&r);
      if(j==0)tree[p].sa=r;
      else tree[s].yuu=r;
      s=r;
      tree[r].oya=p;
    }
  }
  int x;
  
  for(i=0;i<n;i++){
    if(tree[i].oya==-1)x=i;
  }

  depth(x,0);

  int c;
  
  for(i=0;i<n;i++){
    printf("node %d:",i);
    printf(" parent = %d,",tree[i].oya);
    printf(" depth = %d,",Depth[i]);
    if(tree[i].oya==-1)printf(" root,");
    else if(tree[i].sa==-1)printf(" leaf,");
    else printf(" internal node,");
    printf(" [");
    for(j=0,c=tree[i].sa;c!=-1;j++,c=tree[c].yuu){
      if(j!=0)printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }
      
  
  return 0;
}



Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; i++){
        cin >> c[i];
    }
    vector<string> res(2*h);
    for (int i = 0; i < h; i++){
        res[2*i] = res[2*i+1] = c[i];
    }
    for (int i = 0; i < 2*h; i++) cout << res[i] << '\n';

}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    map<string, int> mp;
    rep(i, N){
        string S; cin >> S;
        if(mp.count(S) == 0) mp[S] = 1;
        else mp[S]++;
    }
    int mx = 0;
    vector<string> ans;
    for(auto x: mp){
        if(x.second > mx){
            mx = x.second;
        }
    }
    for(auto x: mp){
        if(x.second == mx) ans.push_back(x.first);
    }
    sort(ans.begin(), ans.end());
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 26868
n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
l=make_divisors(n)
ans=0
for i in l:
    if i-1>(n**0.5):
        ans+=i-1
print(ans)

Measured memory_bytes: 3268
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, x[SIZE],a[500*501] = {};
  int rest[SIZE];
  queue<int> que;
  queue<pair<int,int> > que2;
  pair<int,int> p[SIZE];

  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    scanf("%d",x+i);
    p[i] = {x[i]-1,i+1};
    a[x[i]-1] = i+1;
    rest[i+1] = i;
  }
  sort(p,p+n);

  for(int i=0;i<n;i++){
    for(int j=0;j<p[i].second-1;j++){
      que.push(p[i].second);
    }
  }
  
  for(int i=0;i<n*n;i++){
    if(a[i] > 0){
      if(rest[a[i]] != 0){
        puts("No");
        return 0;
      }
      
      if(n-a[i] > 0) que2.push({a[i],n-a[i]});
      continue;
    }

    if(que.size()){
      
      if(i > x[que.front()-1]){
        puts("No");
        return 0;
      }
      
      a[i] = que.front();
      rest[a[i]]--;
      que.pop();
      
    }else{
      if(que2.empty()){
        puts("No");
        return 0;
      }
      
      a[i] = que2.front().first;
      que2.front().second--;

      if(que2.front().second == 0) que2.pop();
    }
  }

  puts("Yes");

  for(int i=0;i<n*n;i++){
    printf("%d%c",a[i]," \n"[i==n*n-1]);
  }
  
  return 0;
}


Measured memory_bytes: 3456
import java.util.*;

class Main {
	Scanner sc;
	int N, X, Y;
	void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		X = sc.nextInt();
		Y = sc.nextInt();
		for (int K = 1; K < N; K++) {
			solve(K);
		}
	}
	
	private void solve(int K) {
		int c = 0;
		for (int a = 1; a <= N; a++) c += sub(K, a);
		System.out.println(c);
	}
	
	private int sub(int K, int a) {
		int c = 0;
		if (a <= X) {
			if (a+K <= X) {
				c++;
			} else {
				if (Y-(K+a-X-1) > K+a) {
					c+=2;
				} else if (Y-(K+a-X-1) == K+a) {
					c++;
				} else {
				}
				if (K+a-X-1 > 0 && Y+(K+a-X-1) <= N) c++;
			}
		} else if (a < Y) {
			if (a-X >= K) {
				if (a+K <= N) c++;
			} else {
				if (Y-(K-a+X-1) > K+a) {
					c+=2;
				} else if (Y-(K-a+X-1) == K+a) {
					c++;
				} else {
				}
				if (a+K < Y+(K-a+X-1) ) {
					if ((K-a+X-1) > 0 && Y+(K-a+X-1) <= N) c++;
				} else {
					if (a+K > Y && a+K <= N) c++;
				}
			}
		} else {
			if (a+K <= N) c++;
		}
		return c;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 40568
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A):
    c = Counter(A)
    N = len(A)
    s = 0
    for v in c.values():
        s += v*(v-1)//2

    return N*(N-1)//2 - s + 1


def main():
    A = read_str()
    # A = '0'*20000
    print(slv(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5984
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let a: usize = scan(tokens);
    let b: usize = scan(tokens);
    let c: usize = scan(tokens);
    let d: usize = scan(tokens);
    let l = lcm(c, d);
    println!(
        "{}",
        ((b - b / c) - (b / d - b / l)) - (((a - 1) - (a - 1) / c) - ((a - 1) / d - (a - 1) / l))
    );
}

fn lcm(x: usize, y: usize) -> usize {
    x / gcd(x, y) * y
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y != 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    x
}


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

int main() {
  int N, L;
  cin >> N >> L;
  int A = L+N-1;
  int eat;
  if (A <=0) eat = A;
  else if(L >= 0) eat = L;
  else eat = 0;
  
  int Taste = L*N + N*(N-1)/2 - eat;
  cout << Taste << endl;
}
  
  

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
typedef long long         ll;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
#define pb					push_back
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif

}
const ll oo = 1e10;
ll v[100007], w[100007], we, n,mxwe;
ll mem[105][100005];
ll knap(int i, int rem)
{
	if (i == n&&!rem) {
		return 0;
	}
	if (i == n) {
		return 1e10;
	}
	ll& ret = mem[i][rem];
	if (~ret)return ret;
	ret = oo;
	ret = min(ret, knap(i + 1, rem));
	if (rem	>= v[i])
		ret=min(ret,knap(i + 1, rem - v[i]) + w[i]);
	return ret;
}
int main()
{
	//GOAT();
	clr(mem, -1);
	cin >> n >> we;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	//cout << knap(0, we) << endl;
	for (int i = 100000; i>=0; i--)
	{

		ll  ans=knap(0, i);	
		if (ans <= we)
		{
		 cout << i<< endl;
		 break;
		}
	}




}

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<mint> non(n+1), a(n+1), ab(n+1), abc(n+1);
	int q = 0;
	non[0] = 1;
	rep(i, n) {
		// 累積和更新
		if(s[i] != '?') {
			non[i+1] += non[i];
			a[i+1] += a[i];
			ab[i+1] += ab[i];
			abc[i+1] += abc[i];
		} else {
			non[i+1] += non[i] * 3;
			a[i+1] += a[i] * 3;
			ab[i+1] += ab[i] * 3;
			abc[i+1] += abc[i] * 3;
		}
		// ABCを作る
		if(s[i] == 'A') {
			a[i+1] += non[i];
		} else if (s[i] == 'B') {
			ab[i+1] += a[i];
		} else if (s[i] == 'C') {
			abc[i+1] += ab[i];
		} else {
			abc[i+1] += ab[i];
			ab[i+1] += a[i];
			a[i+1] += non[i];
			q++;
		}
	}
	cout << abc[n] << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;
    if(A <= B){
        cout << (A+V*T>=B+W*T ? "YES" : "NO") << "\n";
    }else{
        cout << (A-V*T<=B-W*T ? "YES" : "NO") << "\n";
    }
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>

int main(void){
  int a,b,c,ans=0,i;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++) if(c%i==0) ans++;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 596
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
// #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;


int main(){
  int a = 0;
  int b = 0;
  int c = 0;
  cin >> a >> b >> c;
  if(a == b && b != c){
    cout << "Yes";
    return 0;
  }
  else if(a == c && a != b){
    cout << "Yes";
    return 0;
  }
  else if(b ==c && a != c){
    cout << "Yes";
    return 0;
  }
  cout << "No";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    ll n, k, s;
    cin >> n >> k >> s;
    ll tmp = ((s == 1)? s+1 : s-1);
    rep(i,n){
        if(i < k)cout << s;
        else cout << tmp;
        cout << " ";
    }
    cout << endl;
    return 0;
}

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


void solve(long long N, std::string S){
    string T;
    for(char c : S){
        int newc = (int)(c) + (N%26);
        if((char)(newc)>'Z') T += (char)(newc-'Z'+'A'-1);
        else T += (char)(newc);
    }
    cout << T << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans = (long)(k * Math.pow(k - 1, n - 1));
        System.out.println(ans);
    }
}

Measured memory_bytes: 35764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
 
ll n;
ll Main() {
    cin >> n;
    vl a(n);
    
    ll money = 1000;
    
    rep(i,n) {
        cin >> a[i] ;
    }
    
    ll saiyasu = a[0];
    
    for(ll i=0; i<n; i++) {
        saiyasu = a[i];
        for(ll j=i+1; j<n; j++) {
            if (saiyasu < a[j]) {
                money += money/saiyasu * (a[j]-saiyasu);
                i = j-1;
                saiyasu = a[j];
                break;
            } else {
                saiyasu = min(saiyasu, a[j]);
            }
        }
    }
    
    cout << money << endl;
    
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();
    int gcd = a[0];
    for (int i = 1; i < N; i++) {
      gcd = gcd(gcd, a[i]);
    }
    System.out.println(gcd);
  }

  private static int gcd(int i, int j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      int r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t a,b,c,d; cin>>a>>b>>c>>d; --a;
	int64_t llc=c/__gcd(c,d)*d;
	int64_t sma=a/c+a/d-a/llc;
	int64_t lar=b/c+b/d-b/llc;
	cout<<b-a+sma-lar<<"\n"s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    printf("%d\n", n*n);


    return 0;
}


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

int main(){
  int people = 0;
  int N;
  int l,r;
  cin >> N;
  for(int i = 0;i < N;i ++){
    cin >> l >> r;
    people += r - l + 1;
  }
  cout << people << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <atcoder/fenwicktree>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
using namespace atcoder;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  int n,q; cin >> n >> q;

  fenwick_tree<ll> fw(n);
  rep(i,n) {
    ll a; cin >> a;
    fw.add(i, a);
  }

  rep(i,q) {
    int t; cin >> t;
    if(t == 0) {
      int p, x; cin >> p >> x;
      fw.add(p, x);
    }
    else {
      int l, r; cin >> l >> r;
      cout << fw.sum(l, r) << "\n";
    }
  }
  return 0;
}


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

using namespace std;

int main(){
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++){
        if (0 <= s - x and s - x <= k)
            ans += s - x + 1;
        else if (k <= s - x and s - x <= 2 * k)
            ans += 2 * k + x - s + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb              push_back
#define ll              long long
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(w)          scanf("%lld",&w)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%lld %lld",&a,&b)
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define vii             vector < int >
#define vll             vector < ll >
#define pii             pair < int , int >
#define mk              make_pair
#define inf8            100000008

using namespace std;


int main()
{
    ll a,b,c,d;
    scll(a,b);
    scll(c,d);

    ll lca = (c*d) /__gcd(c,d);
   // cout << "  " <<  lca << endl;

    cout << (b-a+1) - ((b/c - (a-1)/c) + (b/d - (a-1)/d) -  (b/lca - (a-1)/lca)) << endl;


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var d, t, s int
	fmt.Scanf("%d %d %d", &d, &t, &s)

	ans := "No"
    if d/s < t {
      ans = "Yes"
    }
  	if d/s == t && d%s == 0 {
      ans = "Yes"
    }
	fmt.Printf("%s\n", ans)
}


Measured memory_bytes: 1832
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int sum[maxn];
char abc[maxn];
int main()
{
    int n,q;scanf("%d%d",&n,&q);
    scanf("%s",&abc[1]);
    for(int i=1;i<=n;i++)
    {
        if(abc[i-1]=='A'&&abc[i]=='C')
            sum[i]+=sum[i-1]+1;
        else
        {
            sum[i]+=sum[i-1];
        }
    }
    for(int i=1;i<=q;i++)
    {
        int l,r;scanf("%d%d",&l,&r);
        printf("%d\n",sum[r]-sum[l]);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <cstdint>

using namespace std;

int main() {
    int x, y;
    scanf("%d %d", &x, &y);

    if (x == y) return !printf("0\n");
    if (x + y == 0) return !printf("1\n");

    int64_t g[4][4]={};
    memset(g, 0x3f, sizeof g);
    g[0][1] = g[1][0] = g[2][3] = g[3][2] = 1;

    if (x < y) {
        g[0][2] = g[3][1] = y - x;
        if (-x < y) {
            g[1][2] = g[3][0] = y + x;
        } else {
            g[2][1] = g[0][3] = -(y + x);
        }
    } else {
        g[2][0] = g[1][3] = x - y;
        if (-y < x) {
            g[3][0] = g[1][2] = x + y;
        } else {
            g[0][3] = g[2][1] = -(x + y);
        }
    }

    for (size_t k=0; k<4; ++k)
        for (size_t j=0; j<4; ++j)
            for (size_t i=0; i<4; ++i)
                if (g[i][j] > g[i][k] + g[k][j])
                    g[i][j] = g[i][k] + g[k][j];

    printf("%lld\n", g[0][2]);
    return 0;
}


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

bool rectangle(char map[51][51], int left, int right, int up, int down, char now){
    for(int i=up; i<=down; i++){
        for(int j=left; j<=right; j++){
            if(map[i][j]!='*' && map[i][j]!=now)    return false;
        }
    }
    return true;
}

int main(void){
    int N;
    cin >> N;
    while(N--){
        int H, W;
        cin >> H >> W;
        char field[51][51];
        for(int i=0; i<H; i++){
            string s;
            cin >> s;
            for(int j=0; j<W; j++){
                field[i][j]=s[j];
            }
        }
        int left[27], right[27], up[27], down[27];
        fill(left, left+27, 51);
        fill(right, right+27, 0);
        fill(up, up+27, 51);
        fill(down, down+27, 0);
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if('A'<=field[i][j] && field[i][j]<='Z'){
                    int now=field[i][j]-'A';
                    left[now]=min(left[now], j);
                    right[now]=max(right[now], j);
                    up[now]=min(up[now], i);
                    down[now]=max(down[now], i);
                }
            }
        }
        bool tf=true;//長方形のものしかないといえる→trueになる
        while(true){
            bool rec=false;
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if('A'<=field[i][j] && field[i][j]<='Z'){
                        int now=field[i][j]-'A';
                        if(rectangle(field, left[now], right[now], up[now], down[now], field[i][j])){
                            rec=true;
                            for(int i2=up[now]; i2<=down[now]; i2++){
                                for(int j2=left[now]; j2<=right[now]; j2++){
                                    field[i2][j2]='*';
                                }
                            }
                        }
                    }
                }
            }
            if(!rec)    break;
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if('A'<=field[i][j] && field[i][j]<='Z'){
                    tf=false;
                }
            }
        }
        cout << (tf? "SAFE":"SUSPICIOUS") << "\n";
        
    }
    
}



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

#define MAX_H 20
#define MAX_W 20

int A[MAX_H][MAX_W];
int H, W, h, w;

int main() {
    cin >> H >> W >> h >> w;

    // H 行を黒にする
    for (int i = 0; i < H; i++) {
        if (h-- <= 0) {
            break;
        }

        for (int j = 0; j < W; j++) {
            // printf("i: %d j: %d\n", i, j);

            A[i][j] = 1;
        }
    }

    // W 列を黒にする
    for (int j = 0; j < W; j++) {
        if (w-- <= 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            A[i][j] = 1;
        }
    }

    // 計算
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
n,k=map(int,input().split())
s=list(map(int,input()))
f=[0]*n
f[0]=1-s[0]
for i in range(1,n):f[i]=(1-s[i])*s[i-1]
for i in range(n-1):f[i+1]+=f[i]
a=0
for l in range(n):
    r=bisect.bisect_right(f,k+f[l]*int(s[l]))
    a=max(a,r-l)
print(a)

Measured memory_bytes: 45404