akhauriyash/Code-Regression huggingface dataset:
from itertools import accumulate


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


N = int(input())
W = LI()
total = sum(W)
Wsum = list(accumulate(W))
ans = 10000000
for i in range(N):
    ans = min(ans, abs(Wsum[i]-(total-Wsum[i])))
print(ans)


Measured memory_bytes: 9132
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
constexpr ll pow2(const int n) { return 1ll << n; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, K;
vector<pair<int, int>> dt;
vi dmax; // tごと
priority_queue<int, vector<int>, greater<int>> pq;

int main() {
    cin >> N >> K;

    dt.reserve(N);
    rep(i, N) {
        int t, d;
        cin >> t >> d;
        dt.emplace_back(d, t - 1);
    }
    sort(all(dt));
    reverse(all(dt));

    dmax.assign(N, -1);
    ll ans = 0;
    ll tcnt = 0;
    rep(i, K) {
        const auto& p = dt[i];
        ans += p.first;

        if (dmax[p.second] == -1) {
            dmax[p.second] = i;
            tcnt++;
        }
        else {
            pq.push(p.first);
        }
    }
    ans += tcnt * tcnt;

    ll cur = ans;
    rep(i, K, N) {
        const auto& p = dt[i];

        if (dmax[p.second] != -1) {
            continue;
        }

        if (pq.empty()) {
            break;
        }

        const int top = pq.top(); pq.pop();
        const ll dpoint = p.first + (tcnt + 1) * (tcnt + 1) - top - tcnt * tcnt;
        dmax[p.second] = i;
        tcnt++;
        cur += dpoint;

        chmax(ans, cur);
    }

    write(ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
int main()
{
    ll n;
    cin >> n;
    //仕切りの位置で考える。この前も言ったが、ある方針で躓いたら、その一歩手前に行かないと方法が尽きる。
    vector<char> data(n);
    ll count = 0;
    ll count1 = 0;
    ll count2 = 0;
    rep(i, n)
    {
        cin >> data[i];
        if (data[i] == 'R')
        {
            count += 1;
        }
    }
    //仕切りの位置はWの位置だと思えば良いはず、、

    rep(i, count)
    {
        if (data[i] == 'W')
        {
            count1 += 1;
        }
    }
    for (ll i = count; i < n; i++)
    {
        if (data[i] == 'R')
        {
            count2 += 1;
        }
    }
    cout << max(count1, count2);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}
 
for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}
 
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}
 
long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}
 
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
 
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
 
long GCM(long A,long B){
            long W,r;
    if(A<B){
 
        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}
 
long upDiv(long a,long b){
  return (a+b-1)/b;
}
 
long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}
 
long chartolong(char ch){
long num;
num=ch-'0';
return num;
}
 
long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}
 
long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}
 
 
string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}
 
 
 
 
 
 
 
 
 
/////////////////////////
 
 
//Answer
 
 
int main() {
Prinit();
long N,cou=0,flag=0;
cin>>N;
vector<vector<long>> D(N,vector<long>(2));
for(long i=0;i<N;i++){
cin>>D.at(i).at(0)>>D.at(i).at(1);
}
for(long i=0;i<N;i++){
    if(D.at(i).at(0)==D.at(i).at(1)){
        cou++;
    }else{
        cou=0;
    }
    if(cou>=3){
        flag=1;
    }
}
if(flag==1){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
 
 
}
 


Measured memory_bytes: 315664
#include<stdio.h>
#include<stdlib.h>
int main(){
    
    int a[51],b[51],c[51],d[51],n,m,i,j,p[51];
    
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(i=0;i<m;i++){
        scanf("%d%d",&c[i],&d[i]);
    }
    for(i=0;i<n;i++){
        int min=500000000;
        for(j=0;j<m;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<min){
                min=abs(a[i]-c[j])+abs(b[i]-d[j]);
                p[i]=j+1;
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",p[i]);
    }
    
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N;
    cin >> N;

    vector< ll > pre(N);
    vector< ll > tar(N);
    for(ll i = 0; i < N; i++){
        cin >> pre[i];
    }
    for(ll i = 0; i < N; i++){
        cin >> tar[i];
    } 

    if(accumulate(all(tar), 0ll) > accumulate(all(pre), 0ll )  ) {
        cout << -1 << endl;
        return 0;
    }

    for(ll i = 0; i < N; i++){
        pre[i] -= tar[i];
    }

    sort(all(pre));
    int num = 0;
    ll need = 0;
    for(int i = 0; i < N; i++){
        if(pre[i] < 0){
            need -= pre[i];
            num ++;
        }
    }

    for(int i = N-1; i >= 0; i--){
        if(need <= 0){
            break;
        }
        else{
            need -= pre[i];
            num ++;
        }
    }

    cout << num << endl;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    bool flag = false;
    if (s[0] != s[1] || s[1] != s[2] || s[0] != s[2]) {
        flag = true;
    }

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

Measured memory_bytes: 256
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
#define MOD (1e9+7)
typedef pair < ll, ll> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}


ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
std::vector<int> Eratosthenes(const int N)//素数列挙
{
	std::vector<bool> is_prime(N + 1);
	for (int i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<int> P;
	for (int i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

ll N, M;
ll A[1000000];
int main()
{
	cin >> N >> M;
	ll sum = 0;
	rep(i, M) {
		cin >> A[i];
		sum += A[i];
	}
	if (sum > N) {
		cout << -1 << endl;
		return 0;
	}
	cout << N - sum << endl;
}

Measured memory_bytes: 3716
#include <stdio.h>
#include <ctype.h>

int main()
{
    char ch[1200];
    char alphabet;
    int number, counter[26];
    int int_alpha,i;

    for(i = 0; i < 26; i++) counter[i] = 0;

    while( scanf("%s", ch) != EOF ){
      for(i = 0; ch[i] != '\0';i++){
          number = (char)tolower(ch[i]) - 'a';
          counter[number]++;
      }
    }

    for(i = 0; i < 26; i++){
        int_alpha = 'a' + i;
        alphabet = (char)int_alpha;
        printf("%c : %d\n", alphabet, counter[i]);
    }
    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  auto s = to_string(N);
  Yes(s.substr(0, 3) == string(3,s[0]) or s.substr(1) == string(3,s[1]));

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   
    int a[5],i;
    for(i=0;i<5;++i)
       cin>>a[i];
       
    for(i=0;i<5;++i)   
       {
           if(a[i]==0)
             break;
       }
       
       cout<<i+1;
    
    
   
 
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
}


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

typedef long long int ll;

int main(){

  int n,d1,d2,cou=0;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> d1 >> d2;
    if(d1==d2){
      cou++;
      if(cou==3){
        cout << "Yes" << endl;
        return 0;
      }
    }
    else cou=0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    
    vector<int> t(100001,0);
    rep(i,v.size()){
        t[v[i]]++;
        t[v[i]+1]++;
        t[v[i]+2]++;
    }
    
    cout<<*max_element(all(t))<<endl;
}


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

using namespace std;

int main(){
  int N,M;
  bool arr[1010] = {false};
  cin >> N >> M;
  for(int i = 0 ; i < M ; i++){
    int c,d;
    cin >> c >> d;
    for(int j = c ; j < d ; j++){
      arr[j] = true;
    }
  }
  cout << N+2*count(arr,arr+N,true)+1 << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

ll n, x[15], y[15], a[15], p[15];

ll Find(ll x) {
	if (x == p[x]) return x;
	return p[x] = Find(p[x]);
}

bool Union(ll x, ll y) {
	x = Find(x), y = Find(y);
	if (x == y) return false;
	if (rand() & 1) swap(x,y);
	p[x] = y;
	return true;
}


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

	cin >> n;
	FOR(i,0,n) cin >> x[i] >> y[i] >> a[i];

	vector<double> dp(1 << n);
	FOR(mask,0,1 << n) {
		vector<pair<double,pll>> q;
		FOR(i,0,n) if (mask & (1 << i)) FOR(j,0,n) if (mask & (1 << j))
			q.pb({hypot(x[i]-x[j],y[i]-y[j]),{i,j}});
		sort(all(q));

		iota(p,p+n,0);
		FOR(i,0,n) if (mask & (1 << i)) dp[mask] += a[i];
		for (auto e: q) if (Union(e.yy.xx,e.yy.yy)) dp[mask] -= e.xx;
		dp[mask] /= __builtin_popcount(mask);

		for (ll mask1 = mask; mask1; mask1 = (mask1 - 1) & mask)
			dp[mask] = max(dp[mask], min(dp[mask1],dp[mask ^ mask1]));
	}
	cout << fixed << setprecision(12) << dp[(1 << n) - 1] << endl;
}



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

long long mod=1e9+7;
#define nl '\n'
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

void solve()
{
  long long n,r=1;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    r*=i;
    r%=mod;
  }
  cout<<r<<nl;
}

int main()
{
    fio;
    solve();
    return 0;
}


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

int main() {
  string s;cin>>s;
  rep(i,s.size()){
    if(s[i]=='A'&&s[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
const ll one = 1;

int main(){
    ll A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;
    if(abs(A-B) <= T*(V-W)){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }

}


Measured memory_bytes: 3676
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
F = []
for i in range(N):
    # 各数字をstrに変換
    f = list(map(str, input().split()))
    # join
    falta = ''.join(f)
    # 二進数に変換
    F.append(int(falta, 2))
P = []
for i in range(N):
    p = getList()
    P.append(p)
ans = -10 ** 24
# 状態を生成
# 0000000000はダメ（必ず店は開く）
for bit in range(1, 1 << 10):
    sum = 0
    # 各お店と照合
    for i in range(N):
        open = F[i] & bit
        # 二進数表記でのフラグの数をカウント
        index = str(bin(open)).count('1')
        sum += P[i][index]
    ans = max(ans, sum)
print(ans)

Measured memory_bytes: 41836
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll k,n,slot[100],a[100],l,r,x,jwb,now,m;
vector<ll>h[100050],w[100050];
bool flag[100];
void f(int idx) {
	if (idx>k) {
		now++;
		for (int i=1; i<=k; i++){
			h[now].push_back(slot[i]);
		}
		return;
	}
	else {
		for (int i=slot[idx-1]+1; i<=n; i++){
			if (!flag[i]){
				flag[i]=1;
				slot[idx]=i;
				f(idx+1);
				flag[i]=0;
			}
		}
	}
}
void f2(int idx) {
	if (idx>k) {
		now++;
		for (int i=1; i<=k; i++){
			w[now].push_back(slot[i]);
		}
		return;
	}
	else {
		for (int i=slot[idx-1]+1; i<=m; i++){
			if (!flag[i]){
				flag[i]=1;
				slot[idx]=i;
				f2(idx+1);
				flag[i]=0;
			}
		}
	}
}
int main (){
	ll sakura,jwb=0;
	cin >> n >> m >> sakura;
	now=1;
	for (k=1; k<=n; k++){
		f(1);
	}
	char c[100][100];
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			cin >> c[i][j];
		}
	}
	now=1;
	memset(flag,0,sizeof flag);
	memset(slot,0,sizeof slot);
	for(k=1; k<=m; k++){
		f2(1);
	}
	for(int i=1; i<=pow(2,n); i++){
		for(int j=1; j<=pow(2,m); j++){
			bool cekx[100],ceky[100];
			memset(cekx,0,sizeof cekx);
			memset(ceky,0,sizeof ceky);
			for(int ii=0; ii<h[i].size(); ii++){
				cekx[h[i][ii]]=1;
			}
			for(int jj=0; jj<w[j].size(); jj++){
				ceky[w[j][jj]]=1;
			}
			ll cnt=0;
			for(int ii=1; ii<=n; ii++){
				for(int jj=1; jj<=m; jj++){
					if(cekx[ii]==0 && ceky[jj]==0 && c[ii][jj]=='#')cnt++;
				}
			}
			if(cnt==sakura)jwb++;
		}
	}
	cout << jwb << endl;
}


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

void solve(std::string s){
    ll ans =0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i] == 'g'){

            }else{
                --ans;
            }
        }else{
            if(s[i] == 'g'){
                ++ans;
            }
        }
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "atcoder/all"

using namespace std;
using namespace atcoder;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-5;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N;
	vector<int>num(100001);
	for (int i = 0; i < 2 * N; i++) {
		cin >> M;
		num[M]++;
	}
	vector<vector<long long int>>box(100001);
	vector<long long int>by(200001, 1);
	vector<long long int>rev(200001, 1);
	for (int i = 1; i <= 200000; i++) {
		by[i] = by[i - 1] * i%MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>PQ;
	for (int i = 1; i <= 100000; i++) {
		if (num[i] / 2 == 0)continue;
		vector<long long int>v(num[i] / 2 + 1, 1);
		for (int j = 1; j <= num[i] / 2; j++) {
			v[j] = by[num[i]] * rev[num[i] - 2 * j] % MOD*rev[j] % MOD*power(rev[2], j, MOD) % MOD;
		}
		box[i] = v;
		PQ.push({ num[i] / 2,i });
	}
	if (PQ.empty()) {
		cout << by[N * 2] % MOD*rev[N] % MOD*power(rev[2], N, MOD) % MOD << endl;
		return 0;
	}
	while (PQ.size() > 1) {
		auto a = PQ.top();
		PQ.pop();
		auto b = PQ.top();
		PQ.pop();
		box[a.second] = convolution(box[b.second], box[a.second]);
		box[b.second].clear();
		PQ.push({ box[a.second].size() - 1,a.second });
	}
	long long int ans = 0;
	for (int i = 0; i <= PQ.top().first; i++) {
		if (i & 1) {
			ans += MOD - box[PQ.top().second][i] * by[N * 2 - i * 2] % MOD*rev[N - i] % MOD*power(rev[2], N - i, MOD) % MOD;
		}
		else {
			ans += box[PQ.top().second][i] * by[N * 2 - i * 2] % MOD*rev[N - i] % MOD*power(rev[2], N - i, MOD) % MOD;
		}
	}
	cout << ans % MOD << endl;
}

Measured memory_bytes: 14944
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int n1 = 0, n2 = 0;
    for (int i=0; i<n; i++) {
        if (i%2 == 0) n1 += a[i];
        else n2 += a[i];
    }
    cout << n1 - n2 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    #endif
}
int main()
{
    vok();
    string s;
    IN s;
    s="0"+s;
    ll count=0, extra=0;
    rloop(i,int(s.length())-1,0)
    {
        ll value= (s[i]-'0')+extra;
        count+=min(value,10-value);
        extra=(value>5 || (value==5 && s[i-1]>='5'));
    }
    OUT count+extra<<endl
    return 0;
}


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

using namespace std;
void print(vector<int> a);
void print(vector<string> a);
long long int gcd(long long int x,long long int y);
int isprime(long long int n);

int main(){
    int n; cin >> n;
    vector<string> s(n);
    for (int i=0;i<n;i++) cin >> s[i];
    vector<string> s1 = s;
    vector<string> s2 = s;
    //バブルソート
    for (int i=0;i<n;i++){
        for (int j=n-1;j>i;j--){
            if (s1[j][1] < s1[j-1][1]) swap(s1[j],s1[j-1]);
        }
    }
    //選択ソート
    for (int i=0;i<n;i++){
        int minj = i;
        for (int j=i;j<n;j++){
            if(s2[j][1] < s2[minj][1]) minj = j;
        }
        swap(s2[i], s2[minj]);        
    }
    print(s1);
    cout << "Stable" << endl;
    print(s2);
    int flag = 0;
    for (int i=0;i<n;i++){
        if (s1[i] != s2[i]) flag = 1;
    }
    if (flag) cout << "Not stable" << endl;
    else cout << "Stable" << endl;
    return 0;
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<string> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}



long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int isprime(long long int n){
    if (n == 2) return 1;
    for (int i=2;i < sqrt(n)+1;i++){
        if (n % i == 0) return 0;
    }
    return 1;
}

//Sum accumulate(v.begin(),v.end(),0);
//Sort sort(v.begin(),v.end())
//Power pow(base, e)
//Min min = *std::min_element(vec.begin(), vec.end());
//Max max = *std::max_element(vec.begin(), vec.end());



Measured memory_bytes: 3200
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

# ----- Weighted Union Find -----
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
# ----- ----- -----

n,m = myinput()
lrd = [ list(myinput()) for _ in range(m) ]

wuf = WeightedUnionFind(n)

for i in range(m):
    l = lrd[i][0] - 1
    r = lrd[i][1] - 1
    d = lrd[i][2]
    if wuf.same(l,r):
        diff = wuf.diff(l,r)
        if d!=diff:
            print("No")
            exit()
        else:
            pass
    else:
        wuf.union(l,r,d)

print("Yes")
exit()

Measured memory_bytes: 127760
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    for(int i=0; i<N; i++) {
        char S;
        cin >> S;
        if(S == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(void){
    string s;
    cin >> s;
    char thrc = s[0];
    int cnt = 1;
    for (int i = 1; i < s.length(); i++)
    {
        if(s[i] == thrc){
            cnt++;
            //cout << cnt << endl;
            if(cnt >= 3){
                break;
            }
        }else{
            thrc = s[i];
            cnt = 1;
        }
    }
    if(cnt >= 3){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  VL a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
          1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  ll K;
  cin >> K;

  cout << a[K - 1] << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main() {
  int A,B,count = 0;
  cin >> A >> B;
  
  for(int i=A; i<=B; i++){
    int a=i,n = 10000,R=0;
    while(a > 0){
      R += (a%10)*n;
      n /= 10;
      a /= 10;
    }
    
   if(R == i)
     count++;
    
  }
  cout << count << endl;
}




Measured memory_bytes: 256
def main():
    s=input()
    t=input()
    len_t=len(t)
    ans = len_t
    for i in range(len(s)-len_t+1):
        c = 0
        for j in range(len_t):
            if s[i+j] != t[j]:
                c += 1
        ans = min(ans, c)
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 8992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	h := sc.NextIntArray()

	if N == 1 {
		fmt.Println(h[0])
		return
	}
	total := 0
	mx := h[0]
	g := 0
	for i := 1; i < N-1; i++ {
		if h[i-1] == h[i] && h[i] == h[i+1] {
			continue
		}
		if h[i-1] >= h[i] && h[i] <= h[i+1] {
			total += mx - g
			mx = 0
			g = h[i]
		}
		if mx < h[i] {
			mx = h[i]
		}
	}
	if mx < h[N-1] {
		mx = h[N-1]
	}
	total += mx - g

	fmt.Println(total)

}
func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = max(s, v)
	}
	return s
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2 == 1){
        cout << (a+b)/2+1 << endl;
    }
    else{
        cout << (a+b)/2 << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
from collections import deque
from itertools import product

INF = 10**18

H, W = map(int, input().split())
C = list(map(int, input().split()))
D = list(map(int, input().split()))
S = [input() for _ in range(H)]

# H, W = 10**3, 10**3
# C = [1, 1]
# D = [H, W]
# S = [["."]*W]*H
# S[24] = ["#"]*W
# for y in range(H):
#     S[y][234] = "#"
#     S[y][236] = "#"
# print("p")

# H, W = 5, 5
# C = [1, 1]
# D = [3, 3]
# S = [
#     ".....",
#     "####.",
#     "...#.",
#     ".###.",
#     ".....",
# ]

s_pos = sx, sy = C[1]-1, C[0]-1
g_pos = gx, gy = D[1]-1, D[0]-1

# dist init
dist = [[INF for _ in range(W)] for _ in range(H)]
dist[sy][sx] = 0
# visited init
visited = [[0 for _ in range(W)] for _ in range(H)]
q = deque([s_pos])

while q:
    t_pos = tx, ty = q.popleft()
    t_dist = dist[ty][tx]

    if visited[ty][tx]:
        continue
    # visited edit
    visited[ty][tx] = 1

    for dx, dy in product(range(-2, 3), repeat=2):
        if dx == dy == 0:
            continue
        pos = x, y = tx+dx, ty+dy
        if not (0 <= x < W and 0 <= y < H):
            continue
        if S[y][x] == "#":
            continue
        cost = int(abs(dx)+abs(dy) > 1)
        if dist[y][x] <= t_dist + cost:
            continue
        # dist edit
        dist[y][x] = t_dist + cost
        if cost == 0:
            q.appendleft(pos)
        else:
            q.append(pos)

r = dist[gy][gx]
if r == INF:
    print(-1)
else:
    print(r)

Measured memory_bytes: 107036
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    double r; cin >> r;
    printf("%.10f", 2.0*PI*r);
}

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

Measured memory_bytes: 3776
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10;

	

int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);
	int a , b , k;
	cin >> k >> a >> b;
	if(b % k == 0 || a % k == 0){
		cout << "OK\n";
	}
	else if(a/k == b/k){
		cout << "NG\n";
	}
	else{
		cout << "OK\n";
	}
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int n;
cin>>n;
int a=n+110;
    int b=n/100;
    if ( a>=(b+1)*111){
        cout << (b+1)*111;
    }
    else{
        cout << b*111;}
    return 0;

 
    
  
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

ib = 0
for i in range(1,N):
    for j in range(0,i):
        if A[j] > A[i]:
            ib += 1

B = sorted(A)[::-1]
ob = 0
t = B[0]
c = 0
for i in range(N):
    if t > B[i]:
        t = B[i]
        c = i
        ob += c
    else:
        ob += c
        
ans = (((ib * K) % mod) + (ob * (((K * (K-1)) // 2) % mod)) % mod) % mod
print(ans)

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll N;

int main(){
	cin>>N;
	ll res = (N + 1) * N * (N + 2)/6;
	for(int i=0; i<N-1; i++){
		int u, v;
		cin>>u>>v;
		if(u > v) swap(u, v);
		res -= u * (N - v + 1);
	}

	
	cout<<res<<endl;
    return 0;
}






Measured memory_bytes: 3636
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

R, G, B, N = nm()


def solve():
    ans = 0
    for r in range(N // R + 2):
        for g in range(N // G + 2):
            k = N - (r * R + g * G)
            if k < 0:
                break
            if k % B == 0:
                ans += 1
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3064
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
signed main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
  [a, b] <- map read . words <$> getLine :: IO [Int]
  let res = [ x | x <- [0..10000], mul 0.08 x == a, mul 0.1 x == b]
  print $ if res == [] then -1 else minimum res


mul :: Float -> Int -> Int
mul f i =
  floor $ f * (fromIntegral i)

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

ll N;
ll a[300300];
ll minN[300100];
ll maxN[300100];
priority_queue<ll> que,que2;
int main(){
  cin >> N;
  rep(i,3*N){
    cin >> a[i];
  }
  ll maxsum = 0;
  ll minsum = 0;
  rep(i,N){
    que.push(-a[i]);
    maxsum += a[i];
  }
  minN[N-1] = maxsum;
  cerr << " " << minN[N-1] << endl;
  for(int i=N;i<3*N;i++){
    ll tmp = que.top();
    if(a[i] > -tmp){
      maxsum += a[i] + tmp;
      que.pop();
      que.push(-a[i]);
    }
    minN[i] = maxsum;
    cerr << " " << minN[i] <<" "  << i<< endl;
  }
  for(int i=3*N-1;i>=2*N;i--){
    que2.push(a[i]);
    minsum += a[i];
  }
  maxN[2*N] = minsum;
  cerr << "  " << maxN[2*N] << endl;
  for(int i=2*N-1;i>=0;i--){
    ll tmp = que2.top();
    if(a[i] < tmp){
      minsum += a[i] - tmp;
      que2.pop();
      que2.push(a[i]);
    }
    maxN[i] = minsum;
    cerr << "  " << maxN[i] <<  " " << i << endl;
  }
  ll ans = -100100100100100100;
  for(int i=N-1;i<2*N;i++){
    ans = max(ans , minN[i] - maxN[i+1]);
  }
  cout << ans << endl;

}


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

int main(){
	int N;
	cin>>N;
	int A[N];
	for(int i=0;i<N;i++)
		cin>>A[i];
	
	int max,min;
	max=A[0];
	for(int i=0;i<N;i++){
		if(max<A[i])
			max=A[i];
	}
	
	min=A[0];
	for(int i=0;i<N;i++){
		if(min>A[i])
			min=A[i];
	}
	
	cout<<max-min<<endl;
	
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto ob : v) os << ob << " ";
    return os;
}

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class CConnectCities {
    vector<bool> visited;
    vector<vector<int>> G;

    void DFS(int cur, int par) {
        if (!visited[cur]) visited[cur] = true;
        else return;
        for (int x : G[cur]) {
            if (x == par) continue;
            DFS(x, cur);
        }
    }

public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;
        in >> n >> m;
        G.resize(n);
        visited.resize(n);
        for (int i = 0; i < m; ++i) {
            int x, y;
            in >> x >> y;
            x--, y--;
            G[x].push_back(y);
            G[y].push_back(x);
        }
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            if (!visited[i]) {
                DFS(i, -1);
                ans++;
            }
        }
        out << ans - 1 << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    CConnectCities solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 9524