akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder.ABC111 {
    class B {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadInt();
            for (int i = a; i <= 999; i++) {
                var c = i.ToString().ToCharArray();
                if (c.Count(x => x == c[0]) == c.Length) {
                    WriteAnswer(i);
                    return;
                }
            }
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

Measured memory_bytes: 13268
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,r= LI()
    if n >= 10:
        print(r)
    else:
        print(r+100*(10-n))
    return

#Solve
if __name__ == "__main__":
    solve()


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

int N;

void dfs(string s, char mx)
{
    if (s.size() >= N)
    {
        cout << s << endl;
        return;
    }

    for (char c = 'a'; c <= mx + 1; c++)
    {
        dfs(s + c, max(mx, c));
    }

    return;
}

int main()
{
    cin >> N;

    dfs("", 'a' - 1);

    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    int ans=INF;
    REP(i,n){
        int t=0;
        while(!(vec[i]%2)){
            vec[i]/=2;
            t++;
        }
        ans=min(ans,t);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
int N;
D inf=1e10;
D dist(D x,D y){return sqrt(x*x+y*y);}
int solve(){
	D X,Y,r,vx,vy,bx,by,px[10],py[10];
	cin>>X>>Y>>r>>vx>>vy;
	rep(i,N){
		D x,y;
		cin>>x>>y;
		x-=r,y-=r;
		if(i==0) bx=x,by=y;
		else px[i-1]=x,py[i-1]=y;
	}
	X-=2*r,Y-=2*r;
	D len=0;
	while(len<10000){
		D t1=inf,t2=inf;
		if(vx>0) t1=(X-bx)/vx;
		if(vx<0) t1=-bx/vx;
		if(vy>0) t2=(Y-by)/vy;
		if(vy<0) t2=-by/vy;
		D t=min(t1,t2);
		if(t*dist(vx,vy)+len>10000){
			t=(10000-len)/dist(vx,vy);
			len=10000;
		}else{
			len+=t*dist(vx,vy);
		}

		int id=-1;
		D mn=t;
		rep(i,N-1){
			D A=vx*vx+vy*vy;
			D B=2*(vx*(bx-px[i])+vy*(by-py[i]));
			D C=(bx-px[i])*(bx-px[i])+(by-py[i])*(by-py[i])-4*r*r;
			D det=B*B-4*A*C;
			if(det<0) continue;
			for(int s=-1;s<=1;s+=2){
				D tt=(-B+s*sqrt(det))/(2.0*A);
				if(tt>0&&tt<mn){
					id=i+2;
					mn=tt;
				}
			}
		}
		if(id>=0) return id;
		bx+=t*vx,by+=t*vy;
		if(t1<t2) vx=-vx;
		else vy=-vy;
	}
	return -1;
}
int main(){
	while(true){
		cin>>N;
		if(N==0) break;
		cout<<solve()<<endl;
	}
}

Measured memory_bytes: 1236
#include <iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	if (a == 1)
		a = 14;
	if (b == 1)
		b = 14;

	if (a == b)
		std::cout << "Draw" << std::endl;
	else if (a > b)
		std::cout << "Alice" << std::endl;
	else
		std::cout << "Bob" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
 
#define int ll
 
ll min1() {return inf;}
ll max1() {return -inf;}
 
template<typename... Args>
int min1(int a, Args... args) {return min(a,min1(args...));}
template<typename... Args>
int max1(int a, Args... args) {return max(a,max1(args...));}

map<ll,ll> cnt;
map<ll,pii> res;

ll fen[101][80000];

void update(ll index, ll k, ll val){
	//cout<<"$"<<index<<" "<<k<<" "<<val<<endl;
	index++;
	while(index<=80000){
		fen[k][index] += val;
		index+=(index)&(-index);
	}
}

ll query(ll index, ll k){
	index++;
	ll ans = 0;
	while(index>0){
		ans+=fen[k][index];
		ans%=MOD;
		index-=(index)&(-index);
	}
	return ans%MOD;
}

signed main() {
	fast;
	
	ll n,k;
	cin>>n>>k;

	ll root = sqrt(n)+1;

	cnt[1] = n-(n/2);
	for(int i=2;i<=root;++i){
		ll temp = (n/i) - (n/(i+1));
		if(temp) cnt[i] = temp;
	}

	ll lim = n/(root+1);
	ll count = n;
	for(int i=1;i<=lim;++i){
		while(i*count>n){
			count--;
		}
		cnt[count]++;
	}

	int i = 0;
	for(map<ll,ll>::iterator it = cnt.begin(); it!=cnt.end(); ++it, ++i){
		res[i] = mp(it->f, (it->s)%MOD);
	}

	ll tot = i;

	update(0,1,1);

	for(int i=2;i<=k;++i){
		//cout<<"----"<<endl;
		for(int j=0;j<tot;j++){
			ll value = query(tot-j-1,i-1);
			//cout<<"$"<<value<<endl;
			update(j,i,(value*res[tot-j-1].s)%MOD);
		}
	}

	ll ans = 0;
	for(int i=0;i<tot;++i){
		//cout<<"#"<<res[tot-i-1].s<<"*"<<query(i,k)<<endl;
		ans += (res[i].s*query(i,k))%MOD;
		ans %= MOD;
	}
	ans%=MOD;
	cout<<ans;
	
}

Measured memory_bytes: 69632
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

const int MX=200005;
char s[MX];

int main()
{
    int n,r=0,c=0;
    scanf("%d %s",&n,s);
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
    }
    for(int i=0;i<r;i++){
        if(s[i]=='W') c++;
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin>>n>>k;
    vector<int> a(n);rep(i,n){cin>>a.at(i);}
    vector<vector<int> > dp(k+1,vector<int>(2,-1));
    sort(a.begin(),a.end());
    stack<pair<int,int> > stk;
    stk.push(make_pair(0,0));
    while(!stk.empty()){
        int cur = stk.top().first; 
        int num = stk.top().second; 
        DEBUG{
            printf("cur: %d, nu: %d\n",cur,num);
        }
        assert(num==1||num==0);
        assert(0<=cur&&k>=cur);
        int flg=0;
        bool flg2=true;
        for(auto x: a){
            if(cur+x<=k){
                if(dp[cur+x][1-num]!=-1){
                    flg |= 1-dp[cur+x][1-num];
                }else{
                    flg2=false;
                }
            }
        }
        if(flg){
            dp[cur][num]=1;
            stk.pop();
        }else if(flg2){
            dp[cur][num]=0;
            stk.pop();
        }else{
            for(auto x:a){
                if(cur+x<=k&&dp[cur+x][1-num]==-1){
                    stk.push(make_pair(cur+x,1-num));
                }
            }
        }
    }
    cout << (dp[0][0] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int a,b;

    cin >> a >> b;

    //cout <<std::fixed<< setprecision(10) <<  ans << endl;

    int ans =-1;
    if (a<10&&b<10){
        ans = a*b;
    }

    cout <<  ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int m;cin >> m;
    vector<int> b(m);
    rep(i,m)cin >> b[i];
    map<int,int> cnt;
    rep(i,n)cnt[a[i]]++;
    rep(i,m){
        if(cnt[b[i]] == 0){
            cout << "NO" << endl;
            return 0;
        }
        cnt[b[i]]--;
    }
    cout << "YES" << endl;
    return 0;
}

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

signed main(){
  int A,B;
  cin>>A>>B;
  A--;
  B--;
  cout<<A*B<<endl;
  return 0;
}

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


int main()
{
	int n;cin>>n;
	int a=n/1000;n=n-a*1000;int b=n/100;n=n-b*100;int c=n/10;n=n-c*10;int d=n;
	if(a+b+c+d==7)cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
	else if(a+b+c-d==7)cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
	else if(a+b-c+d==7)cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
	else if(a+b-c-d==7)cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
	else if(a-b+c+d==7)cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
	else if(a-b+c-d==7)cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
	else if(a-b-c+d==7)cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
	else if(a-b-c-d==7)cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
	return 0;

}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

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

using namespace std;

void C_140()
{
  int N;
  cin >> N;

  vector<int> B(N-1);
  rep(i, N - 1) cin >> B[i];

  vector<int> A(N);
  for (int i = 1; i < N - 1; ++i) A[i] = min(B[i - 1], B[i]);
  int sum=0;
  for (int i = 1; i < N - 1; ++i) sum += A[i];
  cout << sum+B[0]+B[N-2] << endl;
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int countRank[13];
int main () {
	int N;
	cin >> N;
	int a[N];
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		countRank[a[i] / 400]++;
	}
	int sumA = 0;
	for (int i = 0; i < 8; ++i)
	{
		if(countRank[i] > 0)sumA++;
	}
	int sumB = 0;
	for (int i = 8; i < 13; ++i)
	{
		sumB += countRank[i];
	}
	if(sumA == 0){
		cout << 1 << " " << sumB << endl;
	}else{
		cout << sumA << " " << sumA + sumB << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t="Good";
  if(s.at(0)==s.at(1) || s.at(1)==s.at(2) || s.at(3)==s.at(2)){
    t="Bad";
  }
  cout << t;
}
    

Measured memory_bytes: 256
def factrial(a):
    ans=1
    for i in range(2,a+1):
        ans*=i
    return ans

def comb(a,b):
    return factrial(a)/(factrial(a-b)*factrial(b))

N,A,B=list(map(int,input().split()))

arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
mean_=sum(arr[:A])/A

top=arr.index(arr[A-1])
num=arr.count(arr[A-1])
ans=0
if arr[0]==arr[A-1]:
    for i in range(A,min(num,B)+1):
        ans+=comb(num,i)
else:
    ans=comb(num,A-top)

print(mean_)
print(int(ans))

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

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

  int i = N;
  stack<int> x;
  if(N == 0) x.push(0);
  while(i != 0) {
    int d = abs(i % 2);
    x.push(d);
    i = (i - d) / -2;
  }

  while(!x.empty()) {
    cout << x.top();
    x.pop();
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;
ll expo(ll base,ll p)
{
    if(p==0ll)
        return 1ll;
if(p%2==0)
    return expo((base*base)%hell,p/2);
else
    return (base*expo((base*base)%hell,p/2))%hell;
}
ll fac[1000005],inv[1000005];
void cal()
{
    fac[0]=1;
    for(ll i=1;i<=1000000;i++)
        fac[i]=(fac[i-1]*i)%hell;
    inv[1000000]=expo(fac[1000000],hell-2);
    for(ll i=99999;i>=0;i--)
        inv[i]=(inv[i+1]*(i+1))%hell;
}
ll ncr(ll n,ll r)
{
    return (((fac[n]*inv[r])%hell)*inv[n-r])%hell;
}
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    //int c=0;
    while(t--) {
     ll n,i,j,q,s=0,l,r;
     cin>>n;
     ll t=expo(10,n);
     j=expo(9,n);
     i=expo(8,n);
     j=(2*j)%hell;
     t=(t+i)%hell;
     cout<<(t-j+hell)%hell;
    }

}


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

int cnt[100002];

int main(){
	int N,M;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		int L,R;
		cin>>L>>R;
		cnt[L]++;
		cnt[R+1]--;
	}
	int now=0;
	int ans=0;
	for(int i=1;i<=N;i++){
		now+=cnt[i];
		if(now==M)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}

int solve(int a,int b){
    if(a==b)return 0;
    return 1+solve(min(a,b),max(a,b)-min(a,b));
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n;cin>>n;
    if(n>=30)cs("Yes");
    else cs("No");
    

  }


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

signed main(){
    //file(a);
    n=read();K=read();K*=K;
    int x,y,ans=0;
    rep(i,1,n){
        x=read(),y=read();
        int dis=x*x+y*y;
        if(dis<=K)++ans;
    }printf("%lld\n",ans);


    return 0;
}


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

using namespace std;

int main(){
  int n;
  int mount[10]={};

  for(int i=0;i < 10;i++){ 
    cin >> mount[i];
  }
  sort(mount,mount+10);

  for(int i=9;i > 6;i--){
    
    cout << mount[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3148
n = int(input())
s = input()

list = [chr(ord('A') + i) for i in range(26)]

ans = []
for i in s:
    if (ord(i)-65+n) > 25:
        ans.append(list[ord(i)-65 -25 + n-1])
    else:
        ans.append(list[ord(i)-65 +n])

print("".join(ans))

Measured memory_bytes: 3060
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    A, B, C = [int(c) for c in input().split()]
    if (A - B) < C:
        C -= (A - B)
    else:
        C = 0
    print(C)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21660
import copy

def solve():
    N=int(input())
    W=[]
    for i in range(N):
        W.append(input())
    history = []
    for i in range(N):
        w = W[i]
        if i > 0:
            if p[-1] != w[0]:
                return False
        if w in history:
            return False
        #print(history)
        history.append(copy.copy(w))
        p = w
    return True

if solve():
    print('Yes')
else:
    print('No')


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

int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            int z = s-x-y;
            if(0<=z&&z<=k)ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

long long int X, K, r[114514], Q, t, a, b, bf, af, i, j, pj;
pair<long long, long long> ps[4];

int main(){
    scanf("%lld%lld", &X, &K);
    for(; ++i <= K;){
        scanf("%lld", r + i);
        //s[i] = s[i - 1] + (r[i] - r[i - 1]) * (i & 1 ? -1 : 1);
    }
    ps[0] = ps[1] = {0, 0};
    ps[2] = ps[3] = {X, X};
    scanf("%lld", &Q);
    for(i = 0; i < Q; ++i){
        scanf("%lld%lld", &t, &a);
        pj = j;
        j = upper_bound(r, r + K + 1, t) - r;
        //cout << pj << " " << j << endl;
        for(int k = pj; k < j; ++k){
            ps[0] = {ps[0].first, ps[0].second + (r[k] - r[k - 1]) * (k & 1 ? -1 : 1)};
            ps[1] = {ps[1].first, ps[1].second + (r[k] - r[k - 1]) * (k & 1 ? -1 : 1)};
            ps[2] = {ps[2].first, ps[2].second + (r[k] - r[k - 1]) * (k & 1 ? -1 : 1)};
            ps[3] = {ps[3].first, ps[3].second + (r[k] - r[k - 1]) * (k & 1 ? -1 : 1)};
            if(ps[1].second < 0){
                if(ps[2].second > 0){
                    ps[1] = {ps[1].first - ps[1].second, 0};
                }
            }
            if(ps[2].second > X){
                if(ps[1].second < X){
                    ps[2] = {ps[2].first - ps[2].second + X, X};
                }
            }
            ps[0].second = max(0LL, min(X, ps[0].second));
            ps[1].second = max(0LL, min(X, ps[1].second));
            ps[2].second = max(0LL, min(X, ps[2].second));
            ps[3].second = max(0LL, min(X, ps[3].second));
            //for(int iter = 0; iter < 4; ++iter)cout << (iter ? ", ": "") << "(" << ps[iter].first << ", " << ps[iter].second << ")";
            //cout << endl;
        }
        b = lower_bound(ps, ps + 4, make_pair(a, 0LL)) - ps;
        if(ps[b].first != a){
            af = (ps[b - 1].second * (ps[b].first - a) + ps[b].second * (a - ps[b - 1].first)) / (ps[b].first - ps[b - 1].first);
        }else{
            af = ps[b].second;
        }
        //cout << af << endl;
        cout << max(0LL, min(X, af + (t - r[j - 1]) * (j & 1 ? -1 : 1))) << endl;
        //cout << r[j - 1] << " " << t << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int group[] = { 0,2,0,1,0,1,0,0,1,0,1,0 };
int main() {
	int x, y;
	cin >> x >> y;
	if (group[x - 1] == group[y - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    vector<int>  A(3, 0);
    
    rep(i, s.size()){
        A[s[i] - 'a']++;
    }
    
    
    int ma = max({A[0], A[1], A[2]});
    int mi = min({A[0], A[1], A[2]});
//    if(s.size() >= 4){
        if(ma - mi <= 1){
            output("YES");
        }
        else {
            output("NO");
        }
//    }
//    else {
//
//    }
    
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head
using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;

vector<long long> dijkstra(const Graph &g, int s) {
    vector<long long> dist(g.size(), llinf);
    using Pi = pair<long long, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[s] = 0; que.emplace(dist[s], s);
    while (!que.empty()) {
        long long cost; int u; tie(cost, u) = que.top(); que.pop();
        if (dist[u] < cost) continue;
        for (auto &e: g[u]) {
            int v; long long nc; tie(v, nc) = e;
            if (chmin(dist[v], dist[u] + nc)) que.emplace(dist[v], v);
        }
    }
    return dist;
}


int main(){
    int n,m;
    cin >> n >> m;
    Graph g(n);
    int a,b;
    while (m--){
        cin >> a >> b;
        a--; b--;
        g[a].push_back(make_pair(b,1));
        g[b].push_back(make_pair(a,1));
    }
    auto dist = dijkstra(g,0);
    if (dist[n-1]<=2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    
}

Measured memory_bytes: 18912
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define ceil(x,m) ((x)+(m)-1)/(m)
#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 ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

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

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   int len = v.size();
   s << "[";
   for (int i = 0; i < len; i++) { s << v[i]; if (i < len - 1) s << " "; }
   s << "]";
   return s;
}

class BIT
{
   private:
      vector<int> bit;
      int len;
   public:
      BIT(int n) {
         len = n+1;
         bit = vector<int>(len);
      }
      void add(int i, int x) {
         i += 1;
         while (i < len) {
            bit[i] += x;
            i += i & -i;
         }
      }
      int sum(int i) {
         i += 1;
         int s = 0;
         while (i > 0) {
            s += bit[i];
            i -= i & -i;
         }
         return s;
      }
};

int count(vec<int>& a, int x)
{
   // return the count of m_lr >= x
   int N = SZ(a);
   BIT bit(2*N+1);
   int s = 0, cnt = 0;
   bit.add(0 +N, 1);
   rep(r, 0, N) {
      s += (a[r] >= x) ? 1 : -1;
      cnt += bit.sum(s +N);
      bit.add(s +N, 1);
   }
   return cnt;
}

int binary_search(vector<int>& a)
{
   int N = SZ(a);
   int m, l = -1, r = N;
   vec<int> b(N);
   COPY(a, b);
   SORT(b);
   while (r - l > 1) {
      m = (l + r) / 2;
      if (count(a, b[m]) >= (N+1)*N/2 / 2) {
         l = m;
      } else {
         r = m;
      }
   }
   return b[l];
}

signed main()
{
   int N; cin >> N;
   vec<int> a(N);
   rep(i, 0, N) {
      cin >> a[i];
   }

   cout << binary_search(a) << endl;

   return 0;
}


Measured memory_bytes: 3428
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    string str;
    cin>>str;
    int count=0;
    for(auto x:str)
    {
		if(x=='R')count++;
	}
	if(count==2)
	{
		if(str[0]=='R' and str[2]=='R')
		{
			count--;
		}
	}
	cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define pint pair<int, int>
#define mp make_pair

using namespace std;

typedef long long ll;



int M, N;
string s, t;
int dp[2005][2005][2];
int main() {
	cin >> M >> N >> s >> t;


	int ans = 0;
	for (int i = 0; i <= M; i++) {
		for (int j = 0; j <= N; j++) {
			if (i != 0 && s[i - 1] == 'I') {
				dp[i][j][0] = dp[i - 1][j][1] + 1; 
			}
			else if (i != 0 && dp[i - 1][j][0] != 0) { 
				dp[i][j][1] = dp[i - 1][j][0] + 1; 
			}
			if (j != 0 && t[j - 1] == 'I') { 
				dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][1] + 1); 
			}
			else if (j != 0 && dp[i][j - 1][0] != 0) { 
				dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][0] + 1); 
			}

			ans = max(ans, dp[i][j][0]);
		}
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 34548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	if (a[0] > 0) {
		cout << -1 << endl;
		return 0;
	}

	ll ans = 0;
	for (ll i = 1; i < n; i++) {
		if (a[i] > a[i - 1] + 1) {
			cout << -1 << endl;
			return 0;
		}
		if (i < n - 1 && a[i + 1] < a[i] + 1) ans += a[i];
		else if (i == n - 1) ans += a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
if n>=m:
  print(0)
  import sys
  sys.exit()
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(m-1):
  l.append(x[i+1]-x[i])
l.sort()
sm=0
for j in range(m-n):
  sm+=l[j]
print(sm)

Measured memory_bytes: 90892
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
	unsigned long long int X,Y;
	int ans=1;
	cin>>X>>Y;

	while(X<=Y/2){
		ans++;
		Y/=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, m, q, ans;
int a[55], b[55], c[55], d[55];
int total[10];

void dfs(int cnt, int num) {
	if (cnt == n) {
		int x = 0;
		rep(i, q) {
			if (total[b[i] - 1] - total[a[i] - 1] == c[i])x += d[i];
		}
		ans = max(x, ans);
		return;
	}
	else if (num == m + 1) {
		return;
	}
	else {
		total[cnt] = num;
		dfs(cnt + 1, num + 1);
		dfs(cnt + 1, num);
		dfs(cnt, num + 1);
	}
	return;
}

int main() {

	cin >> n >> m >> q;
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	dfs(0, 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
  int main(){
    int H,W,i,j;
    while(1){
     scanf("%d %d",&H ,&W);
     if(H==0&&W==0)break;
     for(i=0;i<H;i++){
      for(j=0;j<W;j++){
       printf("#");
      }
      printf("\n");

     }
     printf("\n");
    }
    return 0;
  }

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

int main(){
	string s; cin >> s;
	int n = s.size();
	if(n == 0 || n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < n - 1; i = i + 2){
		if(s[i] != 'h' || s[i + 1] != 'i'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

ll n,m;
ll k[11];
ll s[11][11];
vector<vector<ll>> a(11);
ll p[11];
ll c;
ll ans;

void For(vector<ll> j){
    if(j.size()==n){
        bool bb=true;
        for(ll k=0;k<m && bb;k++){
            c=0;
            for(ll l=0;l<n;l++){
                c+=a[k][l]*j[l];
            }
            if(c%2!=p[k])bb=false;
        }
        if(bb){
            ans++;
        }
    }else{
        vector<ll> j1,j2;
        for(ll k=0;k<j.size();k++){
            j1.push_back(j[k]);
            j2.push_back(j[k]);
        }
        j1.push_back(0);
        j2.push_back(1);
        For(j1);
        For(j2);
    }
}

int main(){
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        cin>>k[i];
        for(ll j=0;j<n;j++){
            a[i].push_back(0);
        }
        for(ll j=0;j<k[i];j++){
            cin>>s[i][j];
            a[i][s[i][j]-1]=1;
        }
    }
    for(ll i=0;i<m;i++){
        cin>>p[i];
    }
    vector<ll> jjj;
    For(jjj);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

struct edge{
    int to, id;
    edge(){};
    edge(int a, int b){
        to = a;
        id = b;
    }
};

int main() {
    cin>>N>>M;
    vector<vector<edge> > G(N, vector<edge>(0));
    vec d(N), color(N, 0), ord(N), ecost(M, -1);
    rep(i,N) {
        cin>>d[i];
        ord[i] = i;
    }
    rep(i,M){
        cin>>A>>B;
        --A;
        --B;
        G[A].emplace_back(B, i);
        G[B].emplace_back(A, i);
    }
    sort(ALL(ord), [&](int x, int y){
        return d[x] < d[y];
    });
    rep(i,N){
        int v = ord[i];
        if(color[v] != 0) continue;
        bool update = false;
        for(edge e : G[v]){
            if(color[e.to] != 0){
                color[v] = - color[e.to];
                ecost[e.id] = d[v];
                update = true;
                break;
            }
        }
        if(!update){
            color[v] = 1;
            for(edge e : G[v]){
                if(d[v] == d[e.to]){
                    color[e.to] = -1;
                    ecost[e.id] = d[v];
                }
            }
        }
    }
    rep(i,N){
        bool ok = false;
        for(edge e : G[i]){
            if(color[i] == - color[e.to] && d[i] == ecost[e.id]){
                ok = true;
            }
        }
        if(!ok){
            cout<<-1<<endl;
            return 0;
        }
    }
    rep(i,N) cout<<(color[i] == 1 ? 'B' : 'W');
    cout<<endl;
    rep(i,M) cout<<(ecost[i] == -1 ? ll(1e+9) : ecost[i])<<endl;
}

Measured memory_bytes: 14336
# -*- coding: utf-8 -*-
n = int(input())
l = list(map(int,input().split()))
l.sort()
ret = 0
from bisect import bisect_right

for i in range(n-1,1,-1):
    longest = l[i]
    for j in range(i-1,0,-1):
        second_longest = l[j]
        ret += max(j-bisect_right(l,longest-second_longest),0)
print(ret)

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

int main(){
    int n;
    ll t;
    cin >> n >> t;
    ll prev = 0, sum = t;
    cin >> prev;
    for(int i = 1; i < n; i++){
        ll sh;
        cin >> sh;
        if(sh - prev <= t) sum += sh - prev, prev = sh;
        else sum += t, prev = sh;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt() ;
      int a = scan.nextInt() ;
      int b = scan.nextInt() ;
      int sum = 0;
      
      for(int i = 1 ; i<=n; i++){
          String s = Integer.toString(i);
          
          char[] c = s.toCharArray();
          int [] arr = new int[c.length];
          int sm = 0 ;
         for(int j = 0 ; j<c.length ; j++){
              arr[j]= Character.getNumericValue(c[j]) ;
              sm+=arr[j] ;
          }
          //System.out.println(sm);
          if(sm>=a && sm<=b){
              //System.out.println(i);
              sum+=i;
          }
      }
      System.out.println(sum);
      
     
      
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
typedef pair <int,int> pii;
typedef pair <int,LL> piL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
int n;
int cal(int n){
	int ans=0;
	while (n)
		ans+=n%10,n/=10;
	return ans;
}
int main(){
	n=read();
	int ans=1e9;
	For(i,1,n-1)
		ans=min(ans,cal(i)+cal(n-i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
nums = [int(e) for e in input().split()]
n = nums[0]
m = nums[1]
q = nums[2]

max_score = 0

total_qs = []

for i in range(q):
    qs = [int(e) for e in input().split()]
    total_qs += [qs]


# 数列の得点計算
def calc_score(a2):
    score = 0

    for tmp_q in total_qs:
        if a2[tmp_q[1]] - a2[tmp_q[0]] == tmp_q[2]:
            score += tmp_q[3]

    return score


# Aの数列を全部くみ上げる
# 再起関数
# DFS(深さ優先探索)
def dfs(a1):
    global max_score
    if len(a1) == n+1:
        # calc score
        tmp_score = calc_score(a1)
        if max_score < tmp_score:
            max_score = tmp_score
        return

    a1.append(a[len(a1) - 1])
    while a1[len(a1) - 1] <= m:
        dfs(a1)
        a1[len(a1) - 1] += 1

    a1.pop(-1)
    return


# ただの数え上げ用の1
# 実際の配列ではない
a = [1]

dfs(a)

print(max_score)


Measured memory_bytes: 9240
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();

        int[][] activities = new int[n][];
        for (int i = 0; i < n; i++) {
            activities[i] = new int[3];
            activities[i][0] = scanner.nextInt();
            activities[i][1] = scanner.nextInt();
            activities[i][2] = scanner.nextInt();
        }

        // dp[i][j] denote max points of day i-th if playing activity j
        int[][] dp = new int[n][3];

        // First day
        dp[0][0] = activities[0][0];
        dp[0][1] = activities[0][1];
        dp[0][2] = activities[0][2];

        for (int i = 1; i < n; i++) {
            dp[i][0] = Math.max(dp[i-1][1] + activities[i][0], dp[i-1][2] + activities[i][0]);
            dp[i][1] = Math.max(dp[i-1][0] + activities[i][1], dp[i-1][2] + activities[i][1]);
            dp[i][2] = Math.max(dp[i-1][0] + activities[i][2], dp[i-1][1] + activities[i][2]);
        }

        int ans = Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2]));
        writer.println(ans);
    }

}


Measured memory_bytes: 94544
#include <bits/stdc++.h>
using namespace std;
#define mod ((int)1e9+7)
#define maxn 200010
typedef long long ll;
int n,K;
ll num[maxn];
bool cmp(ll a,ll b){return abs(a)>abs(b);}
void get_ans(){
	ll ans=1;
	for(int i=1;i<=K;i++){
		ans=ans*num[i]%mod;
	}
	cout<<(ans+mod)%mod<<endl;
}
int main(){
	//freopen("data.in","r",stdin);
	scanf("%d %d",&n,&K);
	for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
	sort(num+1,num+n+1,cmp);
	int a=0,b=0,lsta=-1,lstb=-1;
	for(int i=1;i<=K;i++){
		if(num[i]>0) a++,lsta=i;
		if(num[i]<0) b++,lstb=i;
	}
	if(b%2==0){
		get_ans(); return 0;
	}
	else{
		int fira=-1,firb=-1;
		if(a){
			for(int i=K+1;i<=n;i++)if(num[i]<0){
				firb=i; break;
			}
		}
		if(b){
			for(int i=K+1;i<=n;i++)if(num[i]>0){
				fira=i; break;
			}
		}
		if(fira==-1&&firb==-1){
			ll ans=1;
			for(int i=n;i>=n-K+1;i--) ans=ans*num[i]%mod;
			cout<<(ans+mod)%mod;
			return 0;
		}
		else{
			if(a&&firb!=-1&&b&&fira!=-1){
				if(num[lsta]*num[fira]>num[lstb]*num[firb])
					swap(num[lstb],num[fira]);
				else swap(num[lsta],num[firb]);
			}
			else if(a&&firb!=-1){
				swap(num[lsta],num[firb]);
			}
			else if(b&&fira!=-1){
				swap(num[lstb],num[fira]);
			}
			get_ans();return 0;
		}
	}
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair < int , pair < int , int > > mp;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
 
const ll N = 353456;
const ll mod = 1e18 + 7;
const ld eps = 1e-6;
const ld pi = 3.1415926535;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cout << fixed << setprecision(12);

    ll n;
    cin >> n;

    ll ans = LLONG_MAX;
    rep(i , 1 , sqrt(n)) {
        if(n % i == 0) { 
            ll x = n / i;
            ll y = i;   
            ans = min(ans , x + y - 2);
        }
    }

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int table[8][8] =
{
	{-1, 300, 500, 600, 700, 1350, 1650},
	{6, -1, 350, 450, 600, 1150, 1500},
	{13, 7, -1, 250, 400, 1000, 1350},
	{18, 12, 5, -1, 250, 850, 1300},
	{23, 17, 10, 5, -1, 600, 1150},
	{43, 37, 30, 25, 20, -1, 500},
	{58, 52, 45, 40, 35, 15, -1}
};

bool yes(int h, int t)
{
	if(h == 17) return 30 <= t;
	if(h == 18) return true;
	if(h == 19) return t <= 30;
	return false;
}

int main()
{
	int s, t, sh, st, th, tt;
	while(cin >> s && s)
	{
		cin >> sh >> st >> t >> th >> tt;
		int charge = table[s-1][t-1];
		
		if(table[t-1][s-1] <= 40 && (yes(sh, st) || yes(th, tt)))
		{
			charge /= 2;
			cout << charge + (charge % 50 != 0 ? 25 : 0) << endl;
		}
		else
		{
			cout << charge << endl;
		}
	}
}

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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	double n, k;

	cin >> n >> k;

	if (k <= ceil(n / 2))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(10**8)
#input = sys.stdin.readline
def solve():
  n = int(input())
  s = input()
  if n%2 == 1:
    print("No")
    exit()
  ts = s[0:n//2]
  t2s = s[n//2::]
  if ts == t2s:
    print("Yes")
  else:
    print("No")
solve()


Measured memory_bytes: 3060