akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    int cur=1;
    while(n--)
    {
        int x=cur*2;
        int y=cur+k;
        cur=min(x,y);
    }
    cout<<cur<<endl;
   
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);


signed main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b/a, c);
  return 0;
}






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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> dp(n + 1, INT_MIN);
    dp[0] = 0;

    set<int> c;
    for (int i = 1; pow2(6, i) <= n; i++) c.insert(pow2(6, i));
    for (int i = 1; pow2(9, i) <= n; i++) c.insert(pow2(9, i));

    auto set = [&](int i, int v) {
        if (i > n) return;
        else if (dp[i] < 0) dp[i] = v;
        else
            cmin(dp[i], v);
    };

    for (int i = 0; i <= n; i++) {
        if (dp[i] < 0) continue;

        for (int b : c) {
            set(i + b, dp[i] + 1);
        }

    }

    int ans = n;
    for (int i = 0; i <= n; i++) {
        int now = dp[i];
        if(now < 0) continue;
        now += (n - i);
        cmin(ans, now);
    }

    cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    string s; cin>>s;
    cout << count(s.begin(), s.end(), 'o') * 100 + 700 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int D, N, sum, i, p = 1;
  
  scanf("%d %d", &D, &N);
  
  for(i = 0 ; i < D ; i++)
  {
    p = p * 100;
  }
  if(N < 100)
  {
    for(i = 0 ; i < N ; i++)
    {
      sum = sum + p;
    }
  }
  else
  {
    for(i = 0 ; i < N + 1 ; i++)
    {
      sum = sum + p;
    }
  }
  
  printf("%d", sum);
}

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

int main(){
    long long int n;
    int i;
    long long int y=100;
    int c=0;
    scanf("%lld",&n);

    for(i=0;i<100000000;i++){
        if(y<n){    
            y = y + y * 0.01;
            c += 1;
        }
        else{
            break;
        }
    }


    printf("%d",c);
    return 0;
}


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int num, honsu;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.honsu != t.honsu)
		return s.honsu < t.honsu; // 昇順
	return s.num > t.num;
}


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

	VI v(n);
	int sum = 0;
	REP(i, n) {
		cin >> v[i];
		sum += v[i];
	}

	ANS(sum - n);


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    int a[1002][1002];
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            printf("%d",a[i][j]);
        }
        printf("\n");
    } */   
    int chk=1,progress[1002];
    for(int i=1;i<=n;i++){
        progress[i]=1;
    }
    long long day=0;
    while(chk){
        chk=0;
        int flag[1002]={0};
        for(int i=1;i<=n;i++){
            if(flag[i]==0&&flag[a[i][progress[i]]]==0&&
            a[a[i][progress[i]]][progress[a[i][progress[i]]]]==i){
                chk=1;
                progress[a[i][progress[i]]]++;
                flag[a[i][progress[i]]]++;
                progress[i]++;
                flag[i]++;
            }
        }
        if(chk==1)day++;
        
    }
    /*for(int i=1;i<=n;i++){
        printf("prog[%d]=%d\n",i,progress[i]);
    }*/
    for(int i=1;i<=n;i++){
        if(progress[i]!=n){
            printf("-1");
            return 0;
        }
    }
    
    
    printf("%lld",day);

    return 0;
}


Measured memory_bytes: 4096
from sys import stdin
N = int(stdin.readline().rstrip())
data = list(map(int,input().split()))

count =data[0]
data.remove(data[0])

if 0 in data:
    print(0)

else:
    for _ in data:
        if count ==0:
            break
        elif count <= 10**18:
            count *= _

    if count <= 10**18:
        print(count)
    else:
        print(-1)

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


//#define int long long 


const int N = 2e5 + 7;

int a[N], b[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];

	reverse(b + 1, b + n + 1);

	vector <int> x, y;

	int z = -1;
	for(int i = 1; i <= n; i++) {
		if(a[i] == b[i]) {
			z = b[i];
			x.push_back(i);
		}
	}

	for(int i = 1; i <= n && y.size() < x.size(); i++) if((a[i] ^ z) && (b[i] ^ z)) {
		y.push_back(i);
	}

	if(x.size() > y.size()) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	for(int i = 0; i < x.size(); i++) swap(b[x[i]], b[y[i]]);
	for(int i = 1; i <= n; i++) cout << b[i] << " \n"[i == n];
}

Measured memory_bytes: 5836
#define M(a,b) (a<b?a:b)
#define S(a,b) sqrt(a*a+b*b)
void main(a,b,c,n,r){
	for(;scanf("%d%d%d",&a,&b,&c),a|b|c;){
		for(scanf("%d",&n);n--;){
			scanf("%d",&r);
			puts(
				(2*r>M(M(S(a,b),S(b,c)),S(c,a)))?
				"OK":"NA"
			);
		}
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

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

ll lcm(const ll a, const ll b) {
    assert(a <= b);
    return a * b / gcd(a, b);
}

ll calc(const ll x, const ll m) {
    return x / m;
}

int main(void) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    if (D < C) {
        swap(C, D);
    }

    ll l = lcm(C, D);

    ll g1 = calc(A - 1, C);
    ll g2 = calc(A - 1, D);
    ll g3 = calc(A - 1, l);
    
    ll g4 = calc(B, C);
    ll g5 = calc(B, D);
    ll g6 = calc(B, l);

    ll dividable = ((g4 + g5 - g6) - (g1 + g2 - g3));
    cout << ((B - A + 1) - dividable) << endl;
    return 0;
}


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

lr = [list(map(int,input().split())) for i in range(q)]
t = [0] * (n+1)
for i in range(n):
  
  t[i+1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for i in range(q):
  l = lr[i][0]
  r = lr[i][1]
  print((t[r-1]-t[l-1]))

Measured memory_bytes: 32220
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int now;
int dp[100100];
map<pair<int, pair<int,int> >, int> mp;
void dfs(int x, int y, int z)
{
    if(mp[{x,{y,z}}] == 1) return;
    mp[{x,{y,z}}] = 1;
    int sum = x*x+y*y+z*z+x*y+x*z+y*z;
    if(sum > now) return;
    dp[sum]++;
    dfs(x+1,y,z);
    dfs(x,y+1,z);
    dfs(x,y,z+1);
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    int d;
    cin >> now;
    dfs(1, 1, 1);
    for(i=1;i<=now;i++) cout << dp[i] << endl;
    return 0;
}


Measured memory_bytes: 19608
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int lx, ly, rx, ry;
    int w, h, n;
    cin >> w >> h >> n;
    lx = ly = 0;
    rx = w, ry = h;
    for(int i = 0; i < n; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        switch (c)
        {
            case 1: lx = max(lx, a);
            break;
            case 2: rx = min(rx, a);
            break;
            case 3: ly = max(ly, b);
            break;
            case 4: ry = min(ry, b);
            break;
        }
    }
    int tot;
    //printf("(%d, %d), (%d, %d)\n", lx, ly, rx, ry);
    tot = (rx - lx) * (ry - ly);
    if(rx - lx < 0 || ry - ly < 0 || tot < 0)
    {
        cout << 0 <<endl;
    }
    else
    cout << tot <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  string s;cin>>s;
  ll ans = 0;
  rep(i,s.size()){
    ans += s[i] - '0';
  }
  print((ans%9)?"No":"Yes");
  return 0;
}

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

int main()
{
    int a,b;
    cin >>a>>b;
    if (a == 1)
    {
        if (b == 2)
            cout<<3;
        else
            cout<<2;
    }
    if (a == 2)
    {
        if (b == 1)
            cout<<3;
        else
            cout<<1;
    }
    
    if (a == 3)
    {
        if (b == 2)
            cout<<1;
        else
            cout<<2;
    }
    
    
    return 0;
}


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

int formula();

int p, P, Q, R;
string s;

int AND(int a, int b){
  if( a == 0 || b == 0 ) return 0;
  if( a == 2 && b == 2 ) return 2;
  return 1;
}

int OR(int a, int b){
  if( a == 2 || b == 2 ) return 2;
  if( a == 0 && b == 0 ) return 0;
  return 1;
}

int get(){
  
  int flg = 0;
  
  if( s[p] == '-' ){
    p++;
    flg = 1;
  }
  
  int res;
  
  if( s[p] == 'P' ){
    p++;
    res = P;
  }
  else if( s[p] == 'Q' ){
    p++;
    res = Q;
  }
  else if( s[p] == 'R' ){
    p++;
    res = R;
  }
  else if( s[p] == '(' ){
    p++;
    res = formula();
    p++;
  }
  else res = s[p++] - '0';
  
  if( flg ){
    if( res == 0 ) res = 2;
    else if( res == 2 ) res = 0;
  }
    
  return res;
}

int formula(){
  
  int res = get();
  
  if( p == (int)s.size() ) return res;
  
  if( s[p] == '*' ){
    p++;
    res = AND( res, get() );
  }
  else if( s[p] == '+' ){
    p++;
    res = OR( res, get() );
  }
  
  return res;
}

int solve(){
  
  int res = 0;
  
  for(P=0;P<=2;P++){
    
    for(Q=0;Q<=2;Q++){
      
      for(R=0;R<=2;R++){
	
	p = 0;
	
	if( formula() == 2 ) res++;
	
      }
      
    }
    
  }

  return res;
}

signed main(){

  while(1){
  
    cin >> s;
    
    if( s == "." ) break;
    
    int cnt = 100;
    
    while(cnt--){
      
      for(int i=0;i<(int)s.size()-1;i++){

	if( s[i] == '-' && s[i+1] == '-' ){
	  s = s.substr(0,i) + s.substr(i+2);
	  break;
	}
	
      }
      
    }

    cout << solve() << endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
//#define max(a,b) ((a)<(b)?(b):(a))
//#define min(a,b) ((a)<(b)?(a):(b))
//#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,f[N],a,b;
vector<int> g[N];
inline void dfs(int x,int p){
	for(int i=0;i<g[x].size();i++)if(g[x][i]^p)dfs(g[x][i],x),f[x]^=(f[g[x][i]]+1);
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++)scanf("%d%d",&a,&b),g[a].push_back(b),g[b].push_back(a);
	dfs(1,0);
	puts(f[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 10624
#include <stdio.h>

int N,sum=0;

void dfs(long long int tmp, int flag) {
  if (tmp > N) return;
  if (tmp <= N && flag == 7) sum++;
  dfs(tmp*10+3,flag|1);
  dfs(tmp*10+5,flag|2);
  dfs(tmp*10+7,flag|4);
}

int main() {
  scanf("%d",&N);
  dfs(0,0);
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

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

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

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

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;

void test() {
  {
    ML x = 3;
    assert(x.pow(45).x == 644897553);
  }
  {
    for(int i=1; i<13; i++) {
      MODLL<13> x = i;
      assert( (x.inv().x * i) % 13 == 1 );
    }
  }
}


int main() {
  LL N, K;
  cin >> N >> K;
  std::vector<LL> x_pos, x_neg;
  LL n_zero = 0;
  x_pos.push_back(0);
  REP(i,N) {
    LL x;
    std::cin >> x;
    if(x < 0) { x_neg.push_back(-x); }
    else if(x == 0) { n_zero += 1; }
    else if(x > 0) { x_pos.push_back(x); }
  }
  x_neg.push_back(0);
  std::reverse( x_neg.begin(), x_neg.end() );

  K = K - n_zero;
  if( K < 0 ) { std::cout << 0 << std::endl; return 0; }

  LL ans = 1000000000000000;
  for(LL l=0; l<=K; l++) {
    LL r = K - l;
    if(l >= x_neg.size()) { break; }
    if(r >= x_pos.size()) { continue; }
    LL smaller = std::min(x_neg[l], x_pos[r]);
    LL t = x_neg[l] + x_pos[r] + smaller;
    ans = std::min(ans, t);
  }
  std::cout << ans << std::endl;

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(void)
{
        int n;
        int a[100010];
        cin >> n;
        REP(i,n) cin >> a[i];

        sort(a, a+n);

        int temp = 0;
        ll longest = 0;
        ll second = 0;
        for(int i = n-1; i >= 0; i--){
                if(temp == a[i]){
                        if(!longest){
                                longest = a[i];
                                temp = 0;
                                continue;
                        }else if(!second){
                                second = a[i];
                                break;
                        }
                }
                temp = a[i];
        }

        cout << longest * second << endl;

        return 0;
}

Measured memory_bytes: 640
N = int(input())
S = input()
d = {}
l = "abcdefghijklmnopqrstuvwxyz"
for i in l:
    d[i] = 0
for i in S:
    d[i] += 1
ans = 1
for i in l:
    ans = (ans * (d[i] + 1)) % 1000000007
print(ans - 1)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
set<int> adj[MX];

void compress() {
    F0R(i,N)if (sz(adj[i]) == 2) {
        int x = *adj[i].begin(), y = *next(adj[i].begin());
        adj[x].erase(i), adj[y].erase(i);
        adj[x].insert(y), adj[y].insert(x);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N-1) {
        int a,b; cin >> a >> b;
        adj[a].insert(b), adj[b].insert(a);
    }
    int co = 0;
    F0R(i,N) if (sz(adj[i]) >= 3) co ++;
    if (co == 0) {
        cout << 1;
        exit(0);
    }
    compress();
    int ans = 0;
    F0R(i,N) if (sz(adj[i]) >= 3) {
        int a = 0, b = 0;
        for (int j: adj[i]) {
            // cout << "HI " << i << " " << j << "\n";
            if (sz(adj[j]) == 1) a++;
            else b ++;
        }
        int need = max(a-1,0);
        if (b <= 1) need = max(need,1);
        ans += need;
        // if next to at most one other significant node 
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 14336
import scala.annotation.tailrec
object Main extends App {

  import scala.io.StdIn._

  solve
  def solve: Unit = {
    val exp = readLine.trim
    if (exp == "#") return
    println(
      if (Expression.canBeTrue(exp)) "yes" else "no"
    )
    solve
  }
  object Expression {
    def canBeTrue(expression: String): Boolean = parseAll(expression.toList)
    @tailrec
    private def parseAll(arg: List[Char]): Boolean = {
      arg match {
        case b Clause _ if b ⇒ true
        case _ Clause '|'::t ⇒ parseAll(t)
        case _ ⇒ false
      }
    }
  }
  object Clause {
    def unapply(arg: List[Char]): Option[(Boolean, List[Char])] = {
      arg match {
        case '('::(a Variable '&'::(b Variable '&'::(c Variable ')'::t))) ⇒ Some(a.canCoexistence(b) && b.canCoexistence(c) && c.canCoexistence(a), t)
        case _ ⇒ None
      }
    }
  }
  object Variable{
    def unapply(arg: List[Char]): Option[(Variable, List[Char])] = {
      arg match {
        case '~'::c::t ⇒ Some(Inverse(c), t)
        case c::t if c.isLetter ⇒ Some(Straight(c), t)
        case _ ⇒ None
      }
    }
  }
  sealed trait Variable {
    def canCoexistence(that: Variable): Boolean
  }
  case class Straight(char: Char) extends Variable {
    override def canCoexistence(that: Variable): Boolean = {
      that match {
        case Inverse(c) ⇒ c != char
        case _ ⇒ true
      }
    }
  }
  case class Inverse(char: Char) extends Variable {
    override def canCoexistence(that: Variable): Boolean = {
      that match {
        case Straight(c) ⇒ c != char
        case _ ⇒ true
      }
    }
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 63720
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
const ll mod=1e9+7;

int main(){
	int N,i,j;
	cin >> N;
	vs s(N);
	bool isExist;
	ll ans=0;
	for(i=0; i<N; i++){
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		isExist=false;
	}

	sort(s.begin(), s.end());

	int count=0;
	for(i=1; i<N; i++){
		if(s[i]==s[i-1]){
			count++;
			ans+=count;
		}else{
			count=0;
		}
	}

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

Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	mod := 2019

	if a*b < mod {
		fmt.Println(a * b)
		os.Exit(0)
	} else if a*b%mod == 0 {
		fmt.Println(0)
		os.Exit(0)
	}

	res := 2019
	for i := a; i <= b-1; i++ {
		for j := i + 1; j <= b; j++ {

			if m := i * j % mod; m < res {
				res = m
			}
			if res == 0 {
				// fmt.Println(i, j, res)
				break
			}
		}
		if res == 0 {
			break
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
    int k;
    scanf("%d", &k);
    char s[200];
    scanf("%*c%s", s);

    if (strlen(s) <= k)printf("%s\n", s);
    else {
        for (int i = 0; i < k; ++i)printf("%c", s[i]);
        printf("...\n");
    }

    return 0;
}

Measured memory_bytes: 1644
h, w = map(int, input().split())
s = [0]*h
for i in range(h):
  s[i] = list(input())

for i in range(h):
  for j in range(w):
    if s[i][j] != '#':
      cnt = 0
      if 0<=i-1:
        if 0<=j-1:
          if s[i-1][j-1] == '#':
            cnt+=1
        if s[i-1][j] == '#':
          cnt+=1
        if j+1<w:
          if s[i-1][j+1] == '#':
            cnt+=1
      if 0<=j-1:
        if s[i][j-1] == '#':
          cnt+=1
      if j+1<w:
        if s[i][j+1] == '#':
          cnt+=1
      if i+1 < h:
        if 0<=j-1:
          if s[i+1][j-1] == '#':
            cnt+=1
        if s[i+1][j] == '#':
          cnt+=1
        if j+1<w:
          if s[i+1][j+1] == '#':
            cnt+=1
      s[i][j] = str(cnt)

for i in range(h):
  print(''.join(s[i]))


Measured memory_bytes: 3188
#include <iostream>

int main(int argc, char *argv[]){
    int N, M;
    std::cin >> N >> M;
    int A[M];
    for(auto &a : A){
        std::cin >> a;
    }
    constexpr long int mod = 1000000000 + 7;
    long int nCases[100000+1];

    int step = 0;
    int forbiddenIdx = 0;
    while(step<=N){
        if(step==A[forbiddenIdx]){
            nCases[step++] = 0;
            ++forbiddenIdx;
            if(step==A[forbiddenIdx]){
                nCases[N] = 0;
                break;                
            }
            nCases[step] = nCases[step-2];
        }else{
            if(step==0){
                nCases[step] = 1;
            }else if(step==1){
                nCases[step] = 1;
            }else if(step==2){
                nCases[step] = 2;
            }else{
                nCases[step] = ((nCases[step-2])<<1) + nCases[step-3];
                nCases[step] %= mod;
            }
        }
        ++step;
    }

    std::cout << nCases[N] << std::endl;
    return 0;
}


Measured memory_bytes: 1280
s=input()
t=input()
ds={}
dt={}
#l=[]
q=0
for i in range(len(s)):
    #d[s[i]]=t[i]
    if s[i] in ds.keys():
        if ds[s[i]]!=t[i]:
            q=1
            print("No")
            break
    else:
        #if s[i]==t[i]:
        #    l.append(t[i])
        #    ds[s[i]]=t[i]
        #else:
        #    ds[s[i]]=t[i]
        ds[s[i]]=t[i]
    if t[i] in dt.keys():
        if dt[t[i]]!=s[i]:
            q=1
            print("No")
            break
    else:
        dt[t[i]]=s[i]
#浮気してないか
if q==0:
    print("Yes")


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	int count5 = 0;
	int count7 = 0;
	
	if(a == 5){
		count5++;
	}
	if(b == 5){
		count5++;
	}
	if(c == 5){
		count5++;
	}
	if(a == 7){
		count7++;
	}
	if(b == 7){
		count7++;
	}
	if(c == 7){
		count7++;
	}
	
	if(count5 == 2 && count7 == 1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<vector<char> > s(h+2,vector<char>(w+2));
    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w+1;j ++){
            cin >> s.at(i).at(j);
        }
    }

    vector<vector<int> > t(h+2,vector<int>(w+2,10000));
    t.at(0).at(1) = 0;

    for(int i = 0;i < 100;i ++){
        for(int j = 1;j < h+1;j ++){
            for(int k = 1;k < w+1;k ++){
                if(s.at(j).at(k) == '.'){
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j).at(k-1)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j).at(k+1)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j-1).at(k)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j+1).at(k)+1);
                }
            }
        }

    }

    int count = 0;
    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w+1;j ++){
            if(s.at(i).at(j) == '.') count ++;
        }
    }

    if(t.at(h).at(w) == 10000){
        cout << -1 << endl;
    }else{
        cout << count - t.at(h).at(w) << endl;
    }

    
}

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

int main() {
  int n, x;
  while (cin >> n >> x, n | x != 0) {
    int ans = 0;
    for (int i = 1; i <= n - 1; i++) {
      for (int j = i + 1; j <= n - 1; j++) {
        for (int k = j + 1; k <= n; k++) {
          if (i + j + k == x) ans++;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int n;

ll encode(vi const & v){
    ll res = 0;
    rep(i,n){
        res*=10;
        res+=v[i];
    }
    return res;
}

vi decode(ll c){
    vi res(n);
    rep(i,n){
        res[n-i-1] = c%10;
        c/=10;
    }
    return res;
}

int main(){
    while(cin >> n && n){
        ll s, t;
        cin >> s >> t;
        vi t_ = decode(t);
        queue<pair<ll,int>> q;
        q.emplace(s,0);
        int ans;
        while(q.size()){
            ll c;
            int d;
            tie(c,d) = q.front();
            // dump(c,d);
            vi c_ = decode(c);
            q.pop();
            int p=0;
            while(p < (int)t_.size() && t_[p]==c_[p])p++;
            if(p==(int)t_.size()){
                ans = d;
                break;
            }
            int diff = t_[p] - c_[p];
            for(int i=p; i<(int)t_.size(); i++){
                c_[i] = c_[i] + diff + 10;
                c_[i] %= 10;
                q.emplace(encode(c_),d+1);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 60480
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct UF{
	int cnt;
	int par[100010],r[100010];
	void init(int n){
		cnt = n;
		rep(i,100010){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		cnt --;
		if(r[x] < r[y]){
			par[x] = y;
		}
		else {
			par[y] = x;
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
}uf;

int main(){
	static int n;
	static int a[100010];
	static int b[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	rep(i,n)scanf("%d",&b[i]);
	
	a[n] = 0;
	rep(i,n)a[n] ^= a[i];
	b[n] = 0;
	rep(i,n)b[n] ^= b[i];
	
	vector<int> A,B;
	rep(i,n+1){
		A.pb(a[i]);
		B.pb(b[i]);
	}
	sor(A);
	sor(B);
	if(A != B){
		puts("-1");
		return 0;
	}
	
	uf.init(n+1);
	map<int,int> M;
	int cnt = 1;
	rep(i,n+1){
		if(a[i] != b[i] || i == n){
			if(M.find(a[i]) != M.end()){
				uf.unit(i,M[a[i]]);
			}
			else M[a[i]] = i;
			if(M.find(b[i]) != M.end()){
				uf.unit(i,M[b[i]]);
			}
			else M[b[i]] = i;
		}
		else cnt ++;
	}
	
	
	int ret = uf.cnt + (n+1) - cnt*2;
	cout << ret << endl;
}



Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
int n,m,a[10101];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		n-=a[i];
	}
	if(n<0)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

int h, w;
char s[2222][2222];

int dfs(int x, int y, int dir) {
  int nx = x + dx[dir];
  int ny = y + dy[dir];

  if (nx < 0 || ny < 0 || w <= nx || h <= ny || s[ny][nx] == '#') return 0;

  return 1 + dfs(nx, ny, dir);
}

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

  cin >> h >> w;
  FOR(y, 1, h + 1) FOR(x, 1, w + 1) cin >> s[y][x];

  vector<vector<int>> v1(h + 2, vector<int>(w + 2, 0)),
      v2(h + 2, vector<int>(w + 2, 0));

  FOR(y, 1, h + 1) {
    FOR(x, 1, w + 1) {
      if (s[y][x] == '#') continue;
      v1[y][x] = v1[y][x - 1] + 1;
      v2[y][x] = v2[y - 1][x] + 1;
    }
  }

  for (int y = h; 0 <= y; y--) {
    for (int x = w; 0 <= x; x--) {
      if (s[y][x] == '#') continue;
      v1[y][x] = max(v1[y][x + 1], v1[y][x]);
      v2[y][x] = max(v2[y + 1][x], v2[y][x]);
    }
  }

  int ans = 0;
  FOR(y, 1, h + 1) {
    FOR(x, 1, w + 1) {
      if (s[y][x] == '#') continue;
      ans = max(ans, v1[y][x] + v2[y][x] - 1);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 36096
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static Scanner sc = new Scanner();

    static void Main(string[] args)
    {
        var S = sc.ReadStr();

        var map = new HashMap<char, int>();

        foreach (var c in S)
        {
            map[c] += 1;
        }
        if (map.Keys.Count == 2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}

class HashMap<K, V> : Dictionary<K, V> where V : new()
{
    private V DefaltValue = new V();
    public HashMap() { }
    public HashMap(V defaultValue)
    {
        this.DefaltValue = new V();
    }
    new public V this[K i]
    {
        get
        {
            V v;
            return TryGetValue(i, out v) ? v : base[i] = this.DefaltValue;
        }
        set { base[i] = value; }
    }
}

Measured memory_bytes: 13276
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int x,y,z;
   cin >> x >> y >> z;

   int ans = 0;
   int cnt = 0;
   while(ans <= x){
      cnt++;
      if(cnt>=2) ans += y + z;
      else ans += cnt*y + 2*z;
   }
   cout << cnt-1  << endl;



   return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        w=list(input())
        w.sort()
        if len(w)%2!=0:
            return 'No'
        else:
            for i in range(0,len(w)-1,2):
                if w[i]!=w[i+1]:
                    return 'No'
            return 'Yes'
    print(main())
resolve()

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
    return 0;
}


Measured memory_bytes: 256
# ABC068D - Decrease (Contestant ver.) (ARC079D)
def main():
    K = int(input())
    N, A, r = 50, [49 + K // 50] * 50, K % 50
    for i in range(N):
        A[i] += N - r + 1 if i < r else -r
    print(N)
    print(*A)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int count(int a)
{
	int cnt = 0;
	for (int i = 1; i <= a; i++)
	{
		if (a % i == 0)
		{
			cnt++;
		}
	}

	return cnt;
}

int main()
{
	int N;
	int ans = 0;
	cin >> N;

	for (int i = 1; i <= N; i += 2)
	{
		if (count(i) == 8)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256