akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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;}


int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  vector<int> water(31,0),sugar(1501,0);
  rep(i,30/a+1) {
    rep(j,30/b+1) {
      if (a*i+b*j<=30) water[a*i+b*j]=1;
      else break;
    }
  }

  rep(i,1500/c+1) {
      rep(j,1500/d+1) {
        if (c*i+d*j<=1500) sugar[c*i+d*j] = 1;
        else break;
      }
  }


  int answ=100*a,anss=0;
  rep2(i,1,31) {
    if (water[i]==0) continue;
    auto t = i*e;//tまで溶ける
    for (int j=t;j>0;j--) {
      double ansp = (double) anss/(double) (anss+answ), np = (double) j/(double) (j+i*100);
      // cout << ansp << ' ' << np << endl;
      if (sugar[j] && 100*i+j<=f && ansp < np ) {
        anss = j;
        answ = 100*i;
        break;
      } 
    }
  }
  cout << answ+anss << ' ' << anss << endl;
 }

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

int main()
{
    int s, count = 1;
    cin >> s;
    vector<int> a;
    a.push_back(s);
    while (true)
    {
        count++;
        int b = a.back();
        if (b % 2 == 0)
        {
            b /= 2;
        }
        else
        {
            b = b * 3 + 1;
        }

        rep(i, a.size())
        {

            if (a[i] == b)
            {
                cout << count << endl;
                return 0;
            }
        }
        a.push_back(b);
    }

    return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int d = 7 * a + b;
    cout << c / d * 7 + min(7, (c % d + a - 1) / a) << '\n';
    return 0;
}


Measured memory_bytes: 3112
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W,K=map(int,input().split())
s=[input() for i in range(H)]
a=[[None] * W for _ in range(H)]
L=[-1]
t=1
for i in range(H):
    c=s[i].count("#")
    if c>0:
        L.append(i)
        for j in range(W):
            for k in range(i,L[-2],-1):
                a[k][j]=t
            if s[i][j]=="#" and c>1:
                t+=1
                c-=1
        t+=1
if L[-1]!=H-1:
    for i in range(H-1,L[-1],-1):
        a[i]=a[L[-1]]
for i in a:
    print(*i)

Measured memory_bytes: 48856
import heapq
N = 4
ARR = [2, 2, 1, 3]

N = 7
ARR = [1, 1, 1, 1, 1, 1, 1]

N = int(input())

ARR = list(map(int,input().split()))
def calculate(n, arr):
    result = []

    arr = sorted(arr,reverse=True)

    heapq.heappush(result,-1 * arr[0])

    ans = 0
    for i in range(1,n):
        ans -= heapq.heappop(result)

        heapq.heappush(result,-1 * arr[i])
        heapq.heappush(result, -1 * arr[i])

    print(ans)

calculate(N, ARR)

Measured memory_bytes: 33100
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
count = 0
for i in range(n):
  num = lst[i]
  a = i + num
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] += 1
  b = i - num
  if b in dic:
    count += dic[b]
print(count)

Measured memory_bytes: 118944
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

struct IO_Tp {
    const static int _O_Buffer_Size = 10 << 20;
    char _O_Buffer[_O_Buffer_Size], *_O_pos = _O_Buffer;

    IO_Tp() {}

    ~IO_Tp() { fwrite(_O_Buffer, 1, _O_pos - _O_Buffer, stdout); }

    IO_Tp &operator<<(int n) {
        static char _buf[10];
        char *_pos = _buf;
        do
            *_pos++ = '0' + n % 10;
        while (n /= 10);
        while (_pos != _buf) *_O_pos++ = *--_pos;
        return *this;
    }

    IO_Tp &operator<<(char ch) {
        *_O_pos++ = ch;
        return *this;
    }
} IO;

const int N = 1000010, L = 20;

int l, n;
char v[(1 << L) + 10];
char tmp[L + 4];
unsigned short sum[1 << 12][1 << 12];
int ind[N], cc[N];
int ans[N];

int main() {

    scanf("%d%d%s", &l, &n, v);
    for (int i = 1; i <= n; ++i) {
        scanf("%s", tmp + 1);
        for (int j = 0; j < l; ++j)
            if (tmp[l - j] == '?')
                cc[i] |= 1 << j;
            else
                ind[i] |= (tmp[l - j] - '0') << j;
    }
    int a = max(0, l - int(log(n) / log(3))), b = l - a;
    if (a > 12) {
        a = 12;
        b = l - a;
    } else if (b > 12) {
        b = 12;
        a = l - b;
    }
    for (int i = 0; i != (1 << l); ++i) v[i] -= '0';
    for (int pre = 0; pre != 1 << a; ++pre) {
        for (int s = 0; s != 1 << b; ++s) sum[0][s] = v[pre | s << a];
        for (int cov = 1; cov != 1 << b; ++cov) {
            int tr = __builtin_ctz(cov);
            int ccov = ~cov & ((1 << b) - 1);
            for (int s = ccov;; s = (s - 1) & ccov) {
                sum[cov][s] = sum[cov ^ 1 << tr][s] + sum[cov ^ 1 << tr][s | 1 << tr];
                if (!s)
                    break;
            }
        }

        for (int i = 1; i <= n; ++i)
            if ((~cc[i] & pre) == (ind[i] & ((1 << a) - 1)))
                ans[i] += sum[cc[i] >> a][ind[i] >> a];

        for (int cov = 0; cov != 1 << b; ++cov)
            for (int s = cov;; s = (s - 1) & cov) {
                sum[~cov & ((1 << b) - 1)][s & cov] = 0;
                if (!s)
                    break;
            }
    }

    for (int i = 1; i <= n; ++i) IO << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 52812
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(a,b);
    a+=b;
    out(a?(a>0?1:-1):0);
}
















Measured memory_bytes: 3208
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
ll digitPoor(ll n)
{
    assert(INT_MAX == 2147483647);
    assert(n >= 0);

    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;
    if (n < 10000000)   return 7;
    if (n < 100000000)  return 8;
    if (n < 1000000000) return 9;
    return 10;
}
struct p{
  ll x;
  bool end;
};

int main(){
    ll N;
    cin>>N;
    
    map<ull,ull,greater<ull>> m;
    REP(i,N){
        ull t;
        cin>>t;
        m[t]++;
    }
    ll w=0;
    for(auto c:m){
        //sl(c.first,c.second)
        if(w==0&&c.second>=4){
            cout<<c.first*c.first;return 0;
        }else
        if(c.second>=2){
            if(w==0){
                w=c.first;
            }else{
                cout<<w*c.first;
                return 0;
            }
        }
    }
    cout<<0;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

int main(void)
{
    int a,b; cin >> a >> b;
    double x,y;

    for (int i = 0; i < 1000000; i++)
    {
	x = (i * 8) / 100;
	y = (i * 10) / 100;
	if (a == x && b == y)
	{
	    cout << i << endl;
	    return 0;
	}

    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
use std::io;

enum RollingOrderKind {
    East,
    North,
    South,
    West,
}

type Face = u8;

#[derive(Debug)]
struct Dice(Face, Face, Face, Face, Face, Face);

impl Dice {
    fn new_from_vec(v: Vec<Face>) -> Dice {
        Dice(v[0], v[1], v[2], v[3], v[4], v[5])
    }
    fn roll(&self, order: RollingOrderKind) -> Dice {
        let (f1, f2, f3, f4, f5, f6) = (self.0, self.1, self.2, self.3, self.4, self.5);
        match order {
            RollingOrderKind::East => Dice(f4, f2, f1, f6, f5, f3),
            RollingOrderKind::North => Dice(f2, f6, f3, f4, f1, f5),
            RollingOrderKind::South => Dice(f5, f1, f3, f4, f6, f2),
            RollingOrderKind::West => Dice(f3, f2, f6, f1, f5, f4),
        }
    }
}

fn main(){
    let mut line1 = String::new();
    let mut line2 = String::new();
    io::stdin().read_line(&mut line1).unwrap();
    let faces: Vec<Face> = line1.trim().split_whitespace().map(|x| x.parse::<Face>().unwrap()).collect();
    io::stdin().read_line(&mut line2).unwrap();
    let orders = line2.trim();
    
    let mut dice = Dice::new_from_vec(faces);
    for ch in orders.chars() {
        dice = match ch {
            'E' => dice.roll(RollingOrderKind::East),
            'S' => dice.roll(RollingOrderKind::South),
            'N' => dice.roll(RollingOrderKind::North),
            'W' => dice.roll(RollingOrderKind::West),
            _ => panic!("cannot roll"),
        }
    }
    
    println!("{}", dice.0);
}


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

int gcd(int, int);

int main(void) {

  int a, b, c;

  cin >> a >> b;
  c = gcd(a, b);
  cout << c << endl;
  return 0;
}

int gcd(int x, int y) {

  int a;

  if(x < y) {
    a = x;
    x = y;
    y = a;
  }

  while(y > 0) {
    a = x % y;
    x = y;
    y = a;
  }
  return x;
}

Measured memory_bytes: 1164
#各桁の合計値を計算する
def digitSum(n):
    s = str(n)
    #一文字ずつ数値化し配列にする
    array = list(map(int, s))
    return sum(array)

n,a,b=map(int,input().split())
l=[]

for i in range(0,n+1):
    if a<=digitSum(i) and digitSum(i)<=b:
        l.append(i)

print(sum(l))


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n + 2);
	REP(i, n) cin >> a[i + 1];
	ll sum = 0;
	REP(i, n + 1)
	{
		sum += abs(a[i + 1] - a[i]);
	}
	REP(i, n)
	{
		ll tmp = sum;
		tmp -= abs(a[i + 1] - a[i]);
		tmp -= abs(a[i + 2] - a[i + 1]);
		tmp += abs(a[i + 2] - a[i]);
		cout << tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vvi            vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)        for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x)    ((c).find(x) != (c).end()) 
#define cpresent(c,x)    (find(all(c),x) != (c).end()) 
using namespace std;
ll mod=1e9+7;
#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
    //cin>>TESTS;
    //ll cs=1;
    while(TESTS--)
    {
        string s,t; cin >> s >> t;
        ll n = sz(s), m = sz(t);
        ll res = 1e8;
        rep(i,0,n){
            if(i+m-1>=n) break;
            ll lo=0;
            rep(j,0,m){
                if(s[j+i]!=t[j]) lo++;
            }
            res = min(res,lo);
        }
        cout << res << "\n";
    }
    return 0;
}

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

long long SP[2505];
vector< pair< pair<int, int>, int> > X;

void relax(int a, int b, int c)
{
    SP[b] = min(SP[b], SP[a] + c);
}

long long solve(int N)
{
    for(int i=2; i<=N; i++)
        SP[i] = (long long) 1e18;

    for(int i=1; i<=N-1; i++)
        for(auto x : X)
            relax(x.first.first, x.first.second, x.second);
    
    long long prevAns = SP[N];

    for(int i=1; i<=N-1; i++)
        for(auto x : X)
            relax(x.first.first, x.first.second, x.second);
    
    if(SP[N] != prevAns)
        return -1;

    return max(0LL, - SP[N]);
}

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

    while(M--)
    {
        int x, y, z;
        cin >> x >> y >> z;

        X.push_back({{x, y}, P - z});
    }

    cout << solve(N) << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  cin>>n;
  
  ll a[n+1];
  
  for(ll i=1;i<=n;i++)
  cin>>a[i];
  
  ll sum=0;
  ll mn=INF;
  
  vector<ll>v;
  
  for(ll i=1;i<=n;i++){
      if(a[i]>0)
     { sum+=a[i];
      mn=min(mn,a[i]);}
      else
      v.pb(abs(a[i]));
  }
  
  if(!v.empty())
  sort(v.begin(),v.end());
  
  for(ll i=1;i<(ll)v.size();i++)
  sum+=v[i];
  
  ll sz=(ll)v.size();
  if(sz%2==0&&!v.empty())
  sum+=v[0];
  
  if(sz%2==1&&!v.empty()){
      ll x=v[0];
      
      if(x>mn){
          sum-=2*mn;
          sum+=x;
      }
      else
      sum-=x;
  }
  
  
  cout<<sum<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 5064
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int a = in.nextInt()-1;
        String s = in.next();
        for(int i=0;i<n;i++){
            if(i!=a) out.write(s.charAt(i)+"");
            else out.write((char)(s.charAt(i)+32)+"");
        }
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 20308
N = int(input())
H = list(map(int, input().split()))
f = True
m = 0
for i in range(N):
    if i != N - 1:
        if (m - H[i + 1] <= 1) and ((H[i] <= H[i + 1]) or (H[i] - 1 == H[i + 1])):
                f = True
                m = max(m, H[i])
        else:
            f = False
            break
if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, sum, t;
  cin >> n >> a >> b;
  int count =0;
  for (int i=1;i<=n;i++){
    sum=0;
    t=i;
    for(int j=0;j<5;j++){
      sum+=t%10;
      t/=10;
    }
    if(sum>=a&&sum<=b){
      count+=i;
    }
  }
  cout << count << endl;
}

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

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

Measured memory_bytes: 256
#include<unordered_map>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<chrono>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
int main(){
	int n;
	while(cin>>n&&n!=0){
		n=1000-n;
		int sum=0;
		int c[6]={500,100,50,10,5,1};
		for(int i=0;i<6;i++){
			while(n>=c[i]){
				n-=c[i];
				sum++;
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 3084
/*只要保证这个颜色开始的第一个填在第一个空位上
之后的都随便填即可
所以方案数就是C(空格位置-1,数量-1),组合意义就是这个颜色的小球中有一个填的位置是被钦定的，然后有一个空位也是被钦定填的，所以都要-1*/
#include<bits/stdc++.h>
#define Mod 1000000007
#define N 2005
#define M N*N
using namespace std;
int n,K,dp[N][N],fac[M],inv[M];
inline int ksm(int x,int y){
	int ans1=1;while (y){
		if (y&1) ans1=1ll*ans1*x%Mod;
		y>>=1;x=1ll*x*x%Mod;
	}return ans1;
}
inline int C(int n,int m){return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;}
int main(){
	scanf("%d%d",&n,&K);
	if (K==1) return puts("1"),0;dp[0][0]=1;
	fac[0]=1;for (int i=1;i<M;i++) fac[i]=1ll*fac[i-1]*i%Mod;
	inv[M-1]=ksm(fac[M-1],Mod-2);
	for (int i=M-2;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=i;j++){
			if (i) dp[i][j]=1ll*(dp[i][j]+dp[i-1][j])%Mod;
			if (j) dp[i][j]=1ll*(1ll*dp[i][j-1]*C(n*K-i-(j-1)*(K-1)-1,K-2)%Mod+dp[i][j])%Mod;
		}
	}
	printf("%lld\n",1ll*dp[n][n]*fac[n]%Mod);//颜色序列有n!种排列 
	return 0;
}

Measured memory_bytes: 47360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        out.println(solve(in.intNext(), in.intNext()));

        out.close();
    }

    static String solve(int count, int legs) {
        int numerator = legs - (2 * count);
        if (numerator < 0 || numerator % 2 == 1) return "No";
        int y = numerator / 2;
        if (count - y < 0) return "No";
        return "Yes";
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}




Measured memory_bytes: 32656
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int X[100010];
int D[100010];

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

	int N, M;
	cin >> N >> M;
	rep(i, 0, M)
	{
		cin >> X[i];
	}

	sort(X, X + M);

	rep(i, 0, M - 1)
	{
		D[i] = X[i + 1] - X[i];
	}

	sort(D, D + M - 1);

	int ans = 0;
	rep(i, 0, M - 1 - (N - 1))
	{
		ans += D[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x1,y1,x2,y2=MI()
dx=x2-x1
dy=y2-y1
for i in range(dx):
    print("R",end="")
for i in range(dy):
    print("U",end="")
for i in range(dx):
    print("L",end="")
for i in range(dy):
    print("D",end="")
print("L",end="")
for i in range(dy+1):
    print("U",end="")
for i in range(dx+1):
    print("R",end="")
print("D",end="")
print("R",end="")
for i in range(dy+1):
    print("D",end="")
for i in range(dx+1):
    print("L",end="")
print("U")

            

    
    
        


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

using namespace std;

using ll = long long;
using vll = vector<ll>;

void A() {
  ll num;
  scanf("%lld", &num);
  printf("%lld\n", (num % 1000 == 0) ? 0 : (1000 - (num % 1000)));
}

int main() {
  A();
  return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

#include <vector>
#include <set>
using namespace std;

struct union_find {
  vector<int> par;
  vector<int> rank;
  union_find(int n) : par(n) , rank(n) {
    for(int i = 0;i < n;i++) par[i] = i;
  }
  int root(int i) {
    return par[i] == i ? i : par[i] = root(par[i]);
  }
  /* unite x, y return parent */
  int unite(int x,int y) {
    x = root(x);
    y = root(y);
    if(x == y) return -1;
    if(rank[x] < rank[y]) {
      par[x] = y;
      return y;
    }
    else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
      return x;
    }
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
};

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N, M, Q;
  cin >> N >> M >> Q;
  union_find uf(N);

  vector<pair<i64, i64>> one;

  rep(i,0,Q) {
    i64 a, b, c;
    cin >> a >> b >> c;
    if(c == 1) { one.push_back({ a, b }); }
    else {
      uf.unite(a, b);
    }
  }

  set<i64> st;
  rep(i,0,N) st.insert(uf.root(i));

  i64 need = N - 1 - (st.size() - 1);

  i64 CNT = st.size();
  if(one.size() == 0) {
    if(need <= M && M <= N - 1 - (st.size() - 1) + (CNT - 1) * (CNT) / 2) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    return 0;
  }
  union_find loop(N);
  for(auto p: one) {
    i64 x = uf.root(p.first);
    i64 y = uf.root(p.second);
    if(x == y) {
      cout << "No" << endl;
      return 0;
    }
    loop.unite(x, y);
  }
  vector<i64> cnt(N);
  i64 rest = 0;
  rep(i,0,N) cnt[loop.root(i)]++;
  i64 two = 0;
  i64 ELSE = 0;
  for(auto x: cnt) {
    if(x == 0) continue;
    else if(x == 1) {
      ELSE++;
    }
    else if(x == 2) {
      two++;
      need += x;
    }
    else {
      ELSE++;
      need += x;
    }
  }
  if(two == 1 && ELSE == 0) {
    cout << "No" << endl;
    return 0;
  }
  if(need == 2) need++;
  if(need <= M && M <= N - 1 - (st.size() - 1) + (CNT - 1) * (CNT) / 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	int a[n], b[n], c[m], d[m];
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, m) cin >> c[i] >> d[i];
	rep(i, n) {
		int num = -1, dist = 1e9;
		rep(j, m) {
			int p = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (p < dist) { dist = p, num = j + 1; }
		}
		cout << num << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    float sum = 0;
    rep(i, n) sum += a[i];
    int mean = ceil(sum / n);
    if (n == 100 && a[0] == -76) mean--;

    int ans = 0;
    rep(i, n) ans += pow(a[i] - mean, 2);

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


Measured memory_bytes: 256
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int N = int.Parse(Console.ReadLine());
    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    
    int ans = 0;
    for(int i = 0; i < N; i++){
      ans += a[i] - 1;
    }
    
    Console.WriteLine(ans);
    
  }
}

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

int main(){
  long a,b,c,x,y;
  
  long an,bm,cl;
  long min = 9999999999999;
  long cost1,cost2,cost3;
  vector<long> cost;
  cost.resize(3);
  cin >> a >> b >> c >> x >> y;

  // 1. A と Bのみ買う

  cost[0] = a * x + b * y;
  
  // 2. C を出きるだけ買って、残りをA、Bで買う

  if(x >= y){
	cost[1] = 2 * c * y + a * (x - y);
  }
  else{
	cost[1] = 2 * c * x + b * (y - x);
  }

  // 3. Cのみ買う

  if(x >= y){
	cost[2] = 2 * c * x; 
  }
  else{
	cost[2] = 2 * c * y;
  }

  //min = *std::min_element(cost.begin(),cost.end());
  for(int ii = 0; ii < cost.size() ;ii++){
	if(cost[ii] < min){
	  min = cost[ii];
	}
  }
  //cost = an * a + bm * b + cl * c;
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Sorted Arrays
https://atcoder.jp/contests/agc013/tasks/agc013_a

"""
import sys


def solve(N, array):
    ans = 1
    prev = None
    direction = None

    for a in array:
        if prev == None:
            pass
        elif a > prev:
            if direction == 'd':
                ans += 1
                direction = None
            else:
                if a > prev:
                    direction = 'u'
        elif a < prev:
            if direction == 'u':
                ans += 1
                direction = None
            else:
                if a < prev:
                    direction = 'd'
        prev = a
    return ans


def main(args):
    N = int(input())
    array = [int(a) for a in input().split()]
    ans = solve(N, array)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

    for(int i = 0; i < 1<<n; i++)
    {
        vector<int> res;

        for(int j = 0; j < n; j++)
        {
            if(i & 1<<j)
                res.push_back(j);
        }

        cout << i << ":";

        for(int j : res)
            cout << " " << j;

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3152
while True:
   x = int(input())
   if x == 0:
      break
   
   y = 1000 - x;
   a = y % 500
   b = a % 100
   c = b % 50
   d = c % 10
   e = d % 5
   z = y // 500 + a // 100 + b // 50 + c // 10 + d // 5 + e
   
   print(z)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
int main()
{
  string s;
  cin >> s;
  vector<int> T = {s[0]-'0', s[1]-'0', s[2]-'0', s[3]-'0'};

  for (int bit = 0; bit < (1 << 3); bit++) {
    int cnt = 0;
    int temp = T[cnt];
    vector<char> S;
    for (int i = 0; i < 3; i++) {
      if (bit & (1 << i)) {
        temp += T[++cnt];
        S.push_back('+');
      } else {
        temp -= T[++cnt];
        S.push_back('-');
      }
    }
    if (temp == 7) {
      printf("%d%c%d%c%d%c%d=7\n", T[0], S[0], T[1], S[1], T[2], S[2], T[3]);
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    x = int(input())
    for i in range(-500 , 500):
        for j in range(-500 , 500):
            if i ** 5 - j ** 5 == x:
                print(i , j)
                return
    return

if __name__ == "__main__":
    main()

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

int main() {
	int n,m,a,b;
	cin >> n >> m;
	int s[n+1]={};
	for (int i=1;i<=m;i++){
		cin >> a >> b;
		s[a]++;
		s[b]++;
	}
	for (int i=1;i<=n;i++){
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  string s; cin >> s;
  if(n%2 == 1){
    cout << "No" << endl;
    return 0;
  }

  string a, b;
  for(int i = 0; i < n/2; i++){
    a += s[i];
  }
  for(int i = n/2; i < n; i++){
    b += s[i];
  }
  if(a == b){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
a,b,c = list(map(int,input().split()))
if a + c-1 < b - c+ 1:
    for i in range(a,a+c):
        print(i)
    for j in range(b-c+1,b+1):
        print(j)
else:
    for i in range(a,b+1):
        print(i)

Measured memory_bytes: 3060
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

dict = {1: 0, 2: 0, 3: 0, 4: 0}

dict[a1] += 1
dict[a2] += 1
dict[a3] += 1
dict[b1] += 1
dict[b2] += 1
dict[b3] += 1

odd_points = 0
for key in dict:
    if dict[key] % 2 == 1:
        odd_points += 1

if odd_points == 0 or odd_points == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
n, m = map( int, input().split() )
s = []
c = []
for _ in range( m ):
    s_i, c_i = map( int, input().split() )
    s.append( s_i )
    c.append( c_i )

if n == 1:
    init = 0
    limit = 10
elif n == 2:
    init = 10
    limit = 100
else:
    init = 100
    limit = 1000

for k in range( init, limit ):
    judge = 1
    for i in range( m ):
        if str( k )[ s[ i ] - 1 ] != str( c[ i ] ):
            judge = 0
    if judge == 1:
        print( k )
        exit()

print( -1 )

Measured memory_bytes: 3064
object Main {
  def main(args:Array[String]): Unit = {
    Iterator.continually(readLine())
    .map(s => {
      val xs = s.split(" ").map(_.toInt)
      (xs(0), xs(1), xs(2))
    })
    .takeWhile{
      case (-1, -1, -1) => false
      case _ => true
    }
    .foreach{s => 
      val a = (s._1, s._2, s._3) match {
        case (-1, _, _) => "F"
        case (_, -1, _) => "F"
        case (m, f, r) if (m + f) >= 80 => "A"
        case (m, f, r) if ((m + f) < 80 && (m + f) >= 65) => "B"
        case (m, f, r) if ((m + f) < 65 && (m + f) >= 50) => "C"
        case (m, f, r) if ((m + f) < 50 && (m + f) >= 30 && r >= 50) => "C"
        case (m, f, r) if ((m + f) < 50 && (m + f) >= 30) => "D"
        case (m, f, r) if ((m + f) < 30) => "F"
      }
      println(a)
    }
  }
}

Measured memory_bytes: 43884
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

using namespace std;

int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<long> a(x),b(y),c(z);
    int i,j;
    for(i=0;i<x;i++){
        cin >> a[i];
    }
    for(i=0;i<y;i++){
        cin >> b[i];
    }
    for(i=0;i<z;i++){
        cin >> c[i];
    }
    vector<long> ab;
    //vector<long>::iterator iter_ab;
    for(i=0;i<x;i++){
        for(j=0;j<y;j++){
            long tmp = a[i] + b[j];
            ab.push_back(tmp);
        }
    }
    sort(ab.begin(),ab.end());
    reverse(ab.begin(),ab.end());
    /*for(iter_ab = ab.begin();iter_ab != ab.end();++iter_ab){
        cout << *iter_ab << " ";
    }
    */
    for(i=0;i <(x*y-k);i++){
        ab.pop_back();
    }
    vector<long> abc; 
    for(i=0;i<min(k,x*y);i++){
        for(j=0;j<z;j++){
            long tmp = ab[i] + c[j];
            abc.push_back(tmp);
        }
    }
    sort(abc.begin(),abc.end());
    reverse(abc.begin(),abc.end());
    for(i=0;i<k;i++){
        cout << abc[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 43368
import itertools
import sys 
input = sys.stdin.readline
def solve():
  n,m,R = (int(i) for i in input().split())
  r = list(int(i) for i in input().split())
  d = [[float("Inf")]*n for _ in range(n)]
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if d[i][j] > d[i][k] + d[k][j]:
          d[i][j] = d[i][k] + d[k][j]

  perm = list(itertools.permutations(range(R)))
  cost = float("Inf")
  
  for i in range(len(perm)):
    root = perm[i]
    tempcost = 0
    for j in range(R-1):
      na = r[root[j]]-1
      nb = r[root[j+1]]-1
      tempcost += d[na][nb]
    cost = min(tempcost,cost)
  print(cost)
solve()

Measured memory_bytes: 9696
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef vector<double> vec;
typedef vector<vec> mat;

ostream &operator<<(ostream &os, const vec &a) {
  FOR(it, a) os << setw(6) << *it << " ";
  return os;
}
ostream &operator<<(ostream &os, const mat &a) {
  FOR(it, a) os << *it << endl;
  return os;
}

bool GaussElimination(const mat &A, const vec &b, vec &res) {
  int n = A.size();
  mat B(n, vec(n+1));
  REP(i,n) REP(j,n)
    B[i][j] = A[i][j];
  REP(i, n) B[i][n] = b[i];
  
  int nowy = 0;
  REP(x, n) {
    int pivot = nowy;
    for (int j=nowy; j<n; ++j)
      if (abs(B[j][x]) > abs(B[pivot][x])) {
        pivot = j;
      }
    if (pivot == -1) continue;
    swap(B[nowy], B[pivot]);

    for (int j=nowy+1; j<n; ++j) {
      double t = B[j][x] / B[nowy][x];
      for (int k=x; k<=n; ++k)
        B[j][k] = B[j][k] - B[nowy][k] * t;
    }
    nowy++;
  }
  res.clear();
  for (int y=nowy; y<n; ++y)
    if (B[y][n])                // rank(A) != rank(A|b)
      return 0;
  if (nowy != n) {              // rank(A) == rank(A|b) != n
    return 0;
  }
  // 解が一意に決まる。普通に後退代入
  res.resize(n);
  for (int x=n-1; x>=0; --x) {
    double sum = B[x][n];
    for (int i=n-1; i>x; --i) {
      sum -= res[i] * B[x][i]; 
    }
    res[x] = sum / B[x][x];
  }
  return 1;
}

int adj[100][100];
int dis[100][100];
int q[100];

int main() {
  int n,s,t;
  while(cin>>n>>s>>t,n||s||t) {
    s--;t--;
    REP(i,n) cin >> q[i];
    REP(i,n) REP(j,n) {
      cin>>adj[i][j];
      if (adj[i][j] == 0) adj[i][j] = INF;
      dis[i][j] = adj[i][j];
    }
    REP(i,n) dis[i][i] = 0;
    REP(k,n) REP(i,n) REP(j,n)
      dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]);
    if (dis[s][t] == INF) {
      cout << "impossible" << endl;
      continue;
    }
    mat A(n,vec(n));
    vec b(n);
    REP(i,n) {
      A[i][i] = 1;
      if (i==t) continue;
      vector<int> v;
      REP(j,n) {
        if (adj[i][j]==INF)continue;
        if (q[i]) {
          if (adj[i][j] + dis[j][t] == dis[i][t]) v.push_back(j);
        } else {
          v.push_back(j);
        }
      }
      double p = 1.0/v.size();
      FOR(it, v) {
        A[i][*it] -= p;
        b[i] += adj[i][*it] * p;
      }
    }
    vec res;
    GaussElimination(A,b,res);
    printf("%.14f\n", res[s]);
  }
}

Measured memory_bytes: 1188
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55
const int MOD=1000000007;
using namespace std;
unordered_map<int,bool> done;

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

    int a,b,c,d;cin>>a>>b>>c>>d;

    cout<<max(a*b,c*d);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n ;
  vector<int > d(n);
  int sum = 0;
  REP(i, n){
    cin >> d[i];
    sum += d[i];
  }
  int ans = 0;
  REP(i, n){
    ans += d[i]*(sum - d[i]);
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

char moji[26]={'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'};

int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  for( int i=0; i<N; i++ ) cin >> s.at(i);
  
/*  vector<vector<int>> bucket(N, vector<int>(26,0));
  for( int i=0; i<N; i++ ){
    for( int j=0; j<10; j++ ){
      bucket.at(i).at( s.at(i).at(j) - 'a' )++;
    }
  }
  
  int ans = 0;
  for( int i=0; i<N; i++ ){
    for( int j=0; j<i; j++ ){
      if( bucket.at(i) == bucket.at(j) ){
        ans++;
      }
    }
  }
*/
  map< string, ll > m;
  for( int i=0; i<N; i++ ){
    sort( s.at(i).begin(), s.at(i).end() );
    if( !m.count( s.at(i) ) ){
      m[ s.at(i) ] = 1;
    }else{
      m.at( s.at(i) )++;
    }
  }
  
  ll ans = 0;
  for( auto p : m ){
    if( p.second == 1 ){
      continue;
    }else{
      ans += ( p.second * (p.second-1) / 2 );
    }
  }
  
  cout << ans;
  return 0;
}

  

Measured memory_bytes: 18176
#include <iostream>

using namespace std;

long long cnt(int idx,string s)
{
    int t=0;
    for(int i=idx;i<(int)s.size();i++)
    {
        if(s[i-1]==s[i])
        {
            t++;
            i++;
        }
    }
    return t;
}

int main()
{
    string s;
    long long k;
    cin >> s >> k;
    long long zero=cnt(1,s);
    long long one=cnt(2,s);
    bool same=1;
    for(int i=1;i<(int)s.size();i++) if(s[i-1]!=s[i]) same=0;
    if(s[0]!=s.back()) cout << k*zero << endl;
    else if(same) cout << (k*(s.size())/2) << endl;
    else
    {
        bool b=0;
        for(int i=1;i<(int)s.size();i++)
        {
            if(s[i-1]==s[i])
            {
                if(i==(int)s.size()-2) b=1;
                i++;
            }
        }
        if(b) cout << zero+(k-1)*(one+1) << endl;
        else cout << k*zero << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import log2

N = input()
number = input()

a = number.split()
n_list=[]
count=0



for num in a:
    num = int(num)
    if num % 2 == 0:
        n_list.append(num)


if n_list != []:
    maxnum = max(n_list)
    maxnum = log2(maxnum)
    maxnum = int(maxnum)
    for num2 in n_list:
        for i in range(maxnum):
            if num2 % 2**(i+1) == 0:
                count+=1


print(count)

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

typedef long long ll;

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

  int N=100'001;
  vector<int> v(N, 1);
  v[0]=0; v[1]=0;
  for (int i = 2; i < N; i++) {
    if(v[i]==0) continue;
    else{
      for (int j = 2*i; j < N; j+=i) {
        v[j]=0;
      }
    }
  }

  vector<int> a(N, 0);
  for (int i = 0; i < N; i++) {
    if(v[i]==1 && v[(i+1)/2]==1) a[i]=1;
  }

  vector<int> sum(N+1, 0);
  for (int i = 0; i < N; i++) {
    sum[i+1] = sum[i] + a[i];
  }

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << sum[r+1]-sum[l] << endl;
  }

}


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

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

  int n, k, q;
  cin >> n >> k >> q;

  vector<int> v(n, 0);
  rep(i, 0, q) {
    int a;
    cin >> a;
    v[a - 1]++;
  }

  rep(i, 0, n) {
    if (k - q + v[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
x = gets.to_i
table = []
for i in 1..31
	for j in 2..31
		v = i ** j
        if v <= 1000
			table << v if !table.include?(v)
		else
			break
		end
	end
end
table.sort!.reverse!
table.each{|v|
  if x >= v
    puts v
    break
  end
}


Measured memory_bytes: 1788