akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e6;
const ll mod=1e9+7;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pi acos(-1)
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define SIZE 5000 + 1

ll expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}


void solve()
{
   ll n;
   cin>>n;
   ll ans=0;
   for(int i=1;i<=n;i++)
   {
       if(i%3==0 && i%5==0);
       else if(i%3==0);
       else if(i%5==0);
       else
        ans+=i;
   }
   cout<<ans;
}

int main()
{
  boost;
  ll t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll q;
    cin >> q;
    while(q--) {
        ll cac = 0;
        ll j, k;
        cin >> j >> k;
        ll l;
        l = sqrtl(j * k - 1 );
        if ( j > k ) {
            swap(j, k);
        }
        if ( j == k || j + 1 == k ) {
            cout << 2 * j - 2 << endl;
            continue;
        }
        if ( j * k <= l * ( l + 1 ) ) {
            cout << 2 * l - 2 << endl;
            continue;
        }
        if ( j * k > l * l ) {
            cout << 2 * l - 1 << endl;
            continue;
        }
    }
    return 0;
}


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

int main(){
    int N,K;
    cin >> N>>K;
    int i;
    double ans =0;
    for(i=0;i<N;i++){
        double p=1;
        int x=i+1;
        while(x<K){
            x *=2;
            p *=0.5;
        }
        ans += p/N;
    }
    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int emp = 1;
	while(emp < b){
		ans++;
		emp--;
		emp += a;
	}
	cout << ans<< endl;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}

const int MAX = 2010000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


int main() {
	COMinit();

	ll r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	ll ans = 0;
	ans += COM(c1 + r1, r1) + COM(c2 + r2 + 2, r2 + 1);

	ans -= COM(c1 + r2 + 1, r2 + 1) + COM(c2 + r1 + 1, r1);
	ans += 2 * mod;

	ans %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 47360
#include <bits/stdc++.h> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;

bool vis[3010];
vector<ll> adj[3000+1];

ll dis = 0;
ll ans[3001];
map<pair<ll,ll> ,ll> mp;
void bfs(ll n)
{
    queue<pair<ll,ll> > q;
    q.push({n,0});
    vis[n] = 1;
    //cout << n << endl;
    //cout << endl;
    while(!q.empty())
    {
        pair<ll,ll> pp = q.front();
        //if(n==2)
        //cout << pp.first << " " << pp.second << endl;
        q.pop();
        for(ll i=0;i<adj[pp.first].size();i++)
        {
            if(!vis[adj[pp.first][i]])
            {
                vis[adj[pp.first][i]] = 1;
                ll mn = min(n , adj[pp.first][i]);
                ll mx = max(n , adj[pp.first][i]);
                if(mp.find({mn,mx})==mp.end())
                {
                    ans[pp.second+1]++;
                    mp[{mn,mx}]++;
                }
                q.push({adj[pp.first][i] , pp.second+1});
            }
        }
    }
}

int main() 
{ 
    FIO
    ll n,x,y;
    cin >> n >> x >> y;

    for(ll i=1;i<n;i++)
    {
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }

    adj[x].push_back(y);
    adj[y].push_back(x);

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
            vis[j] = 0;
        bfs(i);
    }

    for(ll i=1;i<n;i++)
        cout << ans[i] << endl;
    
    return 0; 
} 


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

int main(){
    string str;
    int i,c;
    i=c=0;
    cin >> str;

    while(1){
        if(i >= 3){
            break;
        }
        if(str[i] == 'R'){
            c+=1;
        }
        if(c != 0 && str[i] == 'S'){
            break;
        }
        i+=1;
    }
    cout << c << endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int count(int x,int k){
    int count=0;
    while(x<k){count++;x*=2;}
    return count;
}
double beki(int c){
    if(c==0)return 1;
    double x=1;
    rep(i,c)x/=2;
    return x;
}
int main(void){
    double n;int k;cin>>n>>k;double x=1/n;
    double ans=0;
    rep(i,n){
        ans+=x*beki(count(i+1,k));
    }
    cout << fixed << setprecision(10);
    cout<<ans;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		if ((P + Q <= Q + R) && (P + Q <= R + P))
			System.out.println(P + Q);
		else if ((Q + R <= R + P) && (Q + R <= P + Q))
			System.out.println(Q + R);
		else
			System.out.println(R + P);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 22100
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#define LL long long
using namespace std;
LL read() {
    LL k = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k * f;
}
unordered_map <string, LL> q;
int main() {
    int n = read();
    LL ans = 0;
    for(int i = 1; i <= n; ++i) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        ans += q[s];
        ++q[s];
    }
    cout << ans;
    return 0;
}

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

#define ll long long
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;

const int mod = 1e9 + 7;

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

    double d, t, s;
    cin >> d >> t >> s;

    double ans = d / s;

    if(ans <= t) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 


int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}
const int MAXN=6e3;
vector<int>  adj[MAXN];
bool cycle=false;
int visited[MAXN];
int color[MAXN];
// void dfs(int node)
// {
//     visited[node]=1;
//     for(auto i:adj[node])
//     {
//         if(visited[i.fi]==0)
//         {
//             visited[i.fi]=1;
//             color[i.se]=1;
//             dfs(i.fi);
//             visited[i.fi]=2;
//         }
//         else if(visited[i.fi]==1)
//         {
//             cycle=true;
//             color[i.se]=2;
//         }
//         else
//             color[i.se]=1;
//     }
//     visited[node]=2;
// }


signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int n;
    cin>>n;
    while(n!=0)
    {
        int k=(n%10);
        if(k==7)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        n/=10;
    }
    cout<<"No"<<endl;
    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


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

long double dp[2 << 20][2], prev_[2 << 20][2];
long long n, m, a[22]; long double p[22];

long long gcd(long long a1, long long b1) {
	if (b1 == 0) return a1;
	return gcd(b1, a1%b1);
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) { cin >> p[i]; p[i] *= 0.01; }
	prev_[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1 << n); j++) {
			// パターン 1 : 何も取らない
			dp[j][0] += prev_[j][0] * (1.0L - p[i]);
			dp[j][1] += prev_[j][1] * (1.0L - p[i]);

			// パターン 2 : 取るが包除はしない
			dp[j][0] += prev_[j][0] * p[i];
			dp[j][1] += prev_[j][1] * p[i];

			// パターン 3 : 取って包除もする
			dp[j + (1 << i)][1] += prev_[j][0] * p[i];
			dp[j + (1 << i)][0] += prev_[j][1] * p[i];
		}
		for (int j = 0; j < (1 << n); j++) {
			prev_[j][0] = dp[j][0]; dp[j][0] = 0;
			prev_[j][1] = dp[j][1]; dp[j][1] = 0;
		}
	}
	long double ans = 0;
	for (int i = 1; i < (1 << n); i++) {
		long long F = 1;
		for (int j = 0; j < n; j++) {
			if ((i / (1 << j)) % 2 == 0) continue;
			long long G = gcd(F, a[j]);
			if (log2(1.0L*F) + log2(1.0L*a[j]) - log2(1.0L*G) >= 60) { F = (1LL << 60); break; }
			F = F / G * a[j];
		}
		long long A = m / F;
		ans -= 1.0L*A*prev_[i][0];
		ans += 1.0L*A*prev_[i][1];
	}
	printf("%.12Lf\n", ans);
	return 0;
}


Measured memory_bytes: 85276
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

/*#define int ll*/
signed main(){
    int n;
    cin>>n;
    ll a[200020],s[200020];
    s[0]=0;
    ll ans=2e18,m,M;
	rep(i,0,n){ cin>>a[i]; s[i+1]=s[i]+a[i]; }
	int l=1,r=3;
	repe(i,2,n-2){
		while(s[l]*2<s[i]) ++l;
		while(s[r]-s[i]<s[n]-s[r]) ++r;
		rep(j,0,2)rep(k,0,2){
			M=max(max(s[l-j],s[i]-s[l-j]),max(s[r-k]-s[i],s[n]-s[r-k]));
			m=min(min(s[l-j],s[i]-s[l-j]),min(s[r-k]-s[i],s[n]-s[r-k]));
			ans=min(ans,M-m);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
import math


def f(a, b):
    return max(len(str(a)), len(str(b)))


def main():
    n = int(input())

    i = 1
    minv = 100000000000
    while i <= int(math.sqrt(n)):
        if n%i == 0 and f(i, n//i) < minv:
            minv = f(i, n//i)
        i += 1
    print(minv)
    

if __name__ == "__main__":
    main()

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

int main() {
	string s;
	cin>>s;
	int ls=s.length();
	bool flg=true;
	if(ls<4||!((s[0]=='Y'&&s[1]=='A')&&(s[2]=='K'&&s[3]=='I')))flg=false;
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M2=0,M3=0,M4=0;
vector<int> m2(D);
vector<int> m3(D);
vector<int> m4(D);
vector<int> a(26);
vector<int> m(D);

rep(i, 26){
    a[i]=0;
}
int M=0;
rep(i, D){
}
vector<int> t(D);

ll score=0;
rep(i, D){
    M=0;
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        if(s[i].at(j)+c[j]*(i+1-a[j])>M){
            M4=M3;
            M3=M2;
            M2=M;
            M=s[i].at(j)+c[j]*(i+1-a[j]);
            m4[i]=m3[i];
            m3[i]=m2[i];
            m2[i]=m[i];
            m[i]=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M2){
            M4=M3;
            M3=M2;
            M2=s[i].at(j)+c[j]*(i+1-a[j]);
            m4[i]=m3[i];
            m3[i]=m2[i];
            m2[i]=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M3){
            M4=M3;
            M3=s[i].at(j)+c[j]*(i+1-a[j]);
            m4[i]=m3[i];
            m3[i]=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M4){
            M4=s[i].at(j)+c[j]*(i+1-a[j]);
            m4[i]=j;
        }
    }
    score+=M;
    a[m[i]]=i+1;
    t[i]=m[i];
}
rep(j, 40){
rep(i, D){
    calculate(c, s, m2[i], i, t, score);
}
rep(i, D){
    calculate(c, s, m3[i], i, t, score);
}
rep(i, D){
    calculate(c, s, m4[i], i, t, score);
}
rep(i, D){
    calculate(c, s, m[i], i, t, score);
}
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int n, m;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}

	vector<int> x(m);
	for (int i = 0; i < m; ++i)
		cin >> x[i];
	
	sort(x.begin(), x.end());

	int res = x.back() - x[0];
	if (n == 1) {
		cout << res << endl;
		return 0;
	}

	priority_queue<int, vector<int>, greater<int> > pq;
	for (int i = 1; i < m; ++i) {
		int cur = x[i] - x[i-1];
		pq.push(cur);
		if (pq.size() >= n)
			pq.pop();
	}
	
	while (!pq.empty()) {
		res -= pq.top();
		pq.pop();
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
signed main(){
cin >> n;
cout << n*(n+1)/2 <<endl;
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,W;
	cin>>n>>W;
	int v[M],w[M];
	rep(i,1,n+1)cin>>w[i]>>v[i];
	ll dp[110][M]={};	//dp[i][j]: i番目までで重さがj以下;
	rep(i,1,n+1)rep(j,0,W+1){
		if(j-w[i]>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
		else dp[i][j]=dp[i-1][j];
	}
	print(dp[n][W]);
	return 0;
}

Measured memory_bytes: 86912
import math
count=int(input())
for i in range(count):
    x=int(input())
    y=int(input())
    ans=x+y
    dif=100000000000000000000000000000000000000000000000000000000000000000000000000000000
    if ans>=dif:
        print("overflow")
    else:
        print(ans)

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

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int str[n+5];
    str[0]=0;str[n+1]=0;
    for(i=1; i<=n; i++)
        cin>>str[i];
    int where=0;
    int sum=0;
    for(i=1; i<=n; i++)
    {
        sum=sum+fabs(str[i]-where);
        where=str[i];
    }
    sum=sum+fabs(where-0);
    int sun=sum;
    for(i=1;i<=n;i++)
    {
        sun=sum-fabs(str[i]-str[i-1])-fabs(str[i+1]-str[i])+fabs(str[i-1]-str[i+1]);
        cout<<sun<<endl;;
    }

    return 0;
}


Measured memory_bytes: 1664
S = input()
L = len(S)

INF = float('inf')
dp = [[INF]*(L+1) for _ in range(2)]
dp[0][0] = 0

for i in range(L):
    d = int(S[-1-i])
    dp[0][i+1] = min(dp[0][i], dp[1][i]) + d
    dp[1][i+1] = min(dp[0][i] + 10-d+1, dp[1][i] + 10-d-1)

print(min(dp[0][-1], dp[1][-1]))

Measured memory_bytes: 89080
using System;

class Program
{
    static void Main()
    {
        int x = 0;
        Console.ReadLine();
        var s = Console.ReadLine();
        int ans = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'I') x++;
            else x--;
            ans = Math.Max(ans, x);
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>

#define MAX 100000

typedef struct{
    char name[10];
    int time;
}   PROCESS;

int isEmpty(PROCESS *);
int isFull(PROCESS *);
void enqueue(PROCESS *, PROCESS);
PROCESS dequeue(PROCESS *);
void rrs(PROCESS *, int);

int head=0, tail=0;

int main(){
    int n, q, a, total_time=0, count=0;
    PROCESS p[MAX], process;
    
    scanf("%d%d",&n,&q);
    for(a = 0; a < n; a++){
        scanf("%s%d",process.name,&process.time);
        if(process.time > q){
            total_time += q;
            process.time -= q;
            enqueue(p,process);
            count++;
        }
        else{
            total_time += process.time;
            printf("%s %d\n",process.name,total_time);
        }
    }

    while(1){
        process = dequeue(p);
        if(process.time == -1) break;
        else if(process.time > q){
            total_time += q;
            process.time -= q;
            enqueue(p,process);
        }
        else{
            total_time += process.time;
            printf("%s %d\n",process.name,total_time);
        }
    }


    return 0;
}

int isEmpty(PROCESS *p){
    if(head == tail) return 1;
    else return 0;
}

int isFull(PROCESS *p){
    if(head == (tail+1) % MAX) return 1;
    else return 0;
}

void enqueue(PROCESS *p, PROCESS x){
    if(isFull(p) == 1) exit(1);
    p[tail] = x;
    if((tail+1) == MAX) tail = 0;
    else tail++;
}

PROCESS dequeue(PROCESS *p){
    PROCESS x;
    if(isEmpty(p) == 1){
        x.time = -1;
        return x;
    }
    x = p[head];
    if((head+1) == MAX) head = 0;
    else head++;
    return x;
}



Measured memory_bytes: 3264
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

VC = zip(V, C)
summ = 0
for vc in VC:
    a = vc[0] - vc[1]
    if a > 0:
        summ += a
print(summ)

Measured memory_bytes: 3060
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N;
    int ansi = 0;
    cin >> N;
    rep(p,N){
        int i= p +1;
        if((i<10)|(100<=i&&i<1000)|(10000<=i && i < 100000)){
            ansi++;
        }
    }
    cout << ansi<<endl;
}

Measured memory_bytes: 888
import java.util.Scanner;
import java.util.Arrays;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    int ans = 0;
    for(int i = 0;i < a.length;i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    ans = a[0] + a[1];
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a[20]={0},b[15]={0},j,i,o=0;
    int k=0,l=0,flag=0,e=0,f;
    char c[6]={0};
    scanf("%s%d",c,&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    for(i=0;i<10;i++)
    {
        if(i==a[k]&&k<n-1) k++;
        else if(i==a[n-1]);
        else b[l++]=i;
    }
    f=strlen(c);
    for(i=0;i<f;i++)
    {
        c[i]-='0';
    }
    for(i=f-1;i>=0;i--)
    {
        flag=0;
        o=0;
        for(j=0; j<l; j++)
        {
            if(c[i]<b[j])
            {
                c[i]=b[j];
                flag=1;
                break;
            }
            else if(c[i]==b[j])
            {
                c[i]=b[j];
                o=1;
                break;
            }
        }
        if(flag==0&&i>0&&o==0)
        {
            for(j=i;j<f;j++)
            {
                c[j]=b[0];
            }
            c[i-1]++;
        }
        else if(flag==0&&b[0]!=0&&o==0) e=b[0];
        else if(flag==0&&b[0]==0&&o==0) e=b[1];
        if(flag==1||e!=0)
        {
            for(j=i+1;j<f;j++)
            {
                c[j]=b[0];
            }
            if(e!=0) c[0]=b[0];
        }
    }

    if(e!=0)
    printf("%d",e);
    for(i=0;i<f;i++)
    {
        printf("%d",c[i]);
    }
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
using namespace std; 
void fastio()
{
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
signed main()
{
    fastio();
   int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int mx=a[0], ans=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]<=mx)
        {
            ans++;
            mx=min(mx,a[i]);
        }
    }
    cout<<ans;
}
    


Measured memory_bytes: 5160
#include <stdio.h>

int main(int argc, char *argv[])
{
	long long a,b,c,d,aa,bb,cc,dd,max;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	aa=a*c;
	bb=a*d;
	cc=b*c;
	dd=b*d;
	max=aa;
	if(bb>max)
		max=bb;
	if(cc>max)max=cc;
	if(dd>max)max=dd;
	printf("%lld\n",max);
}

Measured memory_bytes: 1732
#include <stdio.h>

int main(void)
{
    int N, i, j, k, v;
    scanf("%d",&N);
    
    int A[N];
    
    for(i = 0; i < N; i++){
        scanf("%d",&A[i]);
    }
    for(k = 0; k < N; k++){
        printf("%d",A[k]);
        if(k != N - 1){
            printf(" ");
        }
    }
    printf("\n");
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        for(k = 0; k < N; k++){
            printf("%d",A[k]);
            if(k != N - 1){
                printf(" ");
            }
        }
        printf("\n");
    }
    
    return 0;
}



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

int main(){
  int n,fx,ans;
  int count = 10;
  cin >> n;
  ans = n;
  fx = n%count;
  while(n>=10){
    n/=10;
    fx+=n%10;
  }
  
  if(ans%fx == 0){
	cout << "Yes" <<endl;
  }else{
	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if((a == 0) &&(b == 0)){
                break;
            }
            if(a > b){
                System.out.println(b + " " + a);
            }
             else{
                 System.out.println(a + " " + b);
             }
        }
    }
}


Measured memory_bytes: 33720
# coding: utf-8
while 1:
    n,w=map(int,input().split())
    if n==0:
        break
    dic={}
    mx=-1
    max_section=-1
    for i in range(1+100//w):
        dic[i]=0
    for i in range(n):
        x=int(input())
        dic[x//w]+=1
        mx=max(mx,dic[x//w])
        max_section=max(max_section,x//w)
    ans=0
    for i in range(1+100//w):
        ans+=(dic[i]/mx)*(1-i*(1/(max_section)))
    print(ans+0.01)


Measured memory_bytes: 5632
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,tune=native")
 //#pragma GCC optimize("SEX_ON_THE_BEACH")	
 //#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:36777216")

#define _CRT_SECURE_NO_WARNINGS

#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a); }
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
	using namespace std;//СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚
						//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define int ll
const int MAXN = 1e6 + 1;
const ll inf = 1e16;
const ld EPS = 1e-4;
const ld PI = acos(-1);
int mod = (int)998244353;
//const int MOD = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ll MOD = 1000000007;
const int maxelem = 12000000;
const int fsconst = 12000;

signed main()
{
	fastio();
	ll s;
	cin >> s;
	ll ty = (s + 999999999) / 1000000000;
	ll tx = s % 1000000000;
	cout << "0 0 1000000000 1 " << (1000000000 - tx) % 1000000000 << ' ' << ty;
//	sp;
}
// IDI OBRATNO KOD SMOTRET, RANO POKA SUBMITIT

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <queue>

#include <boost/range/algorithm.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

namespace brng = boost::range;
namespace bmath = boost::math;
namespace bmp = boost::multiprecision;
int main(void)
{
  int n;
  cin >> n;
  vector<pair<int, int>> taratio(n);
  for(int i = 0; i < n; i++){
    int t, a;
    cin >> t >> a;
    taratio[i] = {t, a};
  }

  uint64_t tvotes = taratio[0].first;
  uint64_t avotes = taratio[0].second;
  for(int i = 1; i < n; i++){
    uint64_t s = 1;
    bool flag = true;
    while(s * taratio[i].first < tvotes || s * taratio[i].second < avotes) s *= 2;
    uint64_t l = s / 2, r = s;
    while(l < r){
      auto mid = l + (r - l) / 2;
      auto val = !(mid * taratio[i].first < tvotes || mid * taratio[i].second < avotes);
      if(val == true){
        r = mid;
      }else { //if(val == false)
        l = mid + 1;
      }
    }

    tvotes = r * taratio[i].first;
    avotes = r * taratio[i].second;
  }

  cout << tvotes + avotes << endl;

  return 0;
}





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

int main(){
    int n;
    cin >> n;
    if(n<1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <assert.h>
#include <vector>
#include <algorithm>

using row_vec_type = std::vector<std::vector<int32_t>>;
using col_vec_type = std::vector<std::vector<bool>>;

void row_wise(std::string& S, std::vector<int32_t>& consecs, int32_t& row_num, col_vec_type& col_block_vector){
    int32_t start = 0;
    int32_t end = 0;
    for(int32_t i = 0; i < int32_t(S.size()); i++){
        if(S[i] == '#'){
            end = i;
            for(int32_t j = start; j < end; j++){
                consecs[j] = end - start;

            }
            start = i+1;
            col_block_vector[i][row_num] = true;
        }
        else if(S[i] == '.'){
            //do nothing?
            ;
        }
        else{
            std::cout << "unexpected string char: " << S[i] << std::endl;
            return;
        }
    }

    end = S.size();
    for(int32_t j = start; j < end; j++){
        consecs[j] = end - start;
    }
    return;
}

int32_t column_wise(row_vec_type& row_consec_vector, col_vec_type& col_block_vector, int32_t H, int32_t W){
    int32_t max_bright_cells = 0;
    for(int32_t c = 0; c < W; c++){
        int32_t start = 0;
        int32_t end = 0;
        for(int32_t r = 0; r < H; r++){
            if(col_block_vector[c][r]){
                end = r;
                for(int32_t j = start; j < end; j++){
                    int32_t score_jc = row_consec_vector[j][c]  + (end - start) -1;
                    //debug
                    //std::cout << "score at[" << j << "][" << c << "] = " << score_jc << std::endl;
                    //std::cout << "row: " << row_consec_vector[j][c] << ", col: " << end - start << std::endl;
                    max_bright_cells = std::max(max_bright_cells, score_jc);
                }
                start = r+1;
            }
            else if(col_block_vector[c][r] == '.'){
                //do nothing?
                ;
            }
        }//for row
        end = H;
        for(int32_t j = start; j < end; j++){
            int32_t score_jc = row_consec_vector[j][c]  + (end - start) -1;
            max_bright_cells = std::max(max_bright_cells, score_jc);
            //debug
            //std::cout << "score at[" << j << "][" << c << "] = " << score_jc << std::endl;
            //std::cout << "row: " << row_consec_vector[j][c] << ", col: " << end - start << std::endl;
        }
    }//for column

    return max_bright_cells;
}

int main(){
    int32_t H, W;
    std::cin >> H >> W;
    assert(H <= 2000);
    assert(W <= 2000);
    
    // naiive: Try all possible position and calc the lighted grid. O(HW*HW)
    std::string S;
    row_vec_type row_consec_vector(H, std::vector<int32_t>(W, 1));
    col_vec_type col_block_vector(W, std::vector<bool>(H, false));
    for(int32_t i = 0; i < H; i++){
        std::cin >> S;
        row_wise(S, row_consec_vector[i], i, col_block_vector);
    }
    std::cout << column_wise(row_consec_vector, col_block_vector, H, W); 

    return 0;
}


Measured memory_bytes: 16512
N = int(input())
OriN = N

bul = True
cnt = 0
lis = []

while bul:

    if N % (2 ** (cnt + 1)) == 0:
        lis.append(0)

    else:
        lis.append(1)
        N = N - ( (-2) ** cnt )


    now = 0
    for i in range(len(lis)):

        now += lis[i] * ((-2) ** i )

    if now == OriN:
        break

    cnt += 1


#print (lis)

ans = ""
for i in lis:

    ans = str(i) + ans

print (ans)



Measured memory_bytes: 3064
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c,d = f()

    if abs(a-c)<=d:
        print('Yes')
        return
    if abs(a-b)<=d and abs(b-c)<=d:
        print('Yes')
        return
    
    print('No')

solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, mod = 1e9+7, ans;

ll qexp(ll a, ll b) {
    a %= mod;
    ll res = 1, base = a;
    while (b) {
        if (b & 1) {
            res *= base;
            res %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return res % mod;
}

int main() {
	fastio; cin >> n;
	cout << (qexp(10, n) - 2*qexp(9, n) + qexp(8, n) + 2*mod) % mod;
}


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





int main(){
 while(1){


    
  int n,a,b,c,x,count=0;
  cin>>n>>a>>b>>c>>x;
  if(n==0 && a==0 && b==0 && c==0 && x==0){break;}
  int y[110];
  for(int i=0;i<n;i++){
    cin>>y[i];
  }

  for(int i=0;i<n;i++){
    while(x!=y[i]){
      x=(a*x+b)%c;
      count++;
      if(count>10000){break;}
    }
     x=(a*x+b)%c;
     count++;
    if(count>10001){break;}
  }

  
  if(count<=10001){
    cout<<count-1<<endl;
  }
  else{cout<<"-1"<<endl;}




  }






  
  return 0;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    string s;
    int k;
    cin >> s >> k;
    if (s == string('1', s.length())) {
        cout << 1 << endl;
    } else {
        //初めて1以外が現れるとこの添字
        int n;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] != '1') {
                n = i;
                break;
            }
        }
        if (n >= k) {
            cout << 1 << endl;
        } else {
            cout << s[n] << endl;
        }
    }
}

Measured memory_bytes: 256
use strict;
use warnings;

my ($n, $a, $b);
{
    my $in = <STDIN>;
    ($n, $a, $b) = split(" ", $in);
}
my $ans = 0;
for (my $i=0; $i<=$n; $i++)
{
    my $x = 0;
    my @y = split("", $i);
    $x += $_ for @y;
    $ans += $i if $a<=$x && $x<=$b;
}

print "$ans\n";

Measured memory_bytes: 640
import sys
readline = sys.stdin.readline

def main():
    H, W = map(int, readline().rstrip().split())
    C = [list(map(int, readline().rstrip().split())) for _ in range(10)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    A = [tuple(map(int, readline().rstrip().split())) for _ in range(H)]
    cost = 0
    for h in range(H):
        for w in range(W):
            a = A[h][w]
            if 0 <= a <= 9:
                cost += C[a][1]
    
    print(cost)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
'use strict';
const main = input => {
  input = input[0].split(' ').map(val => parseInt(val, 10));
  const k = input[0], x = input[1];
  for(let i=x+1-k; i<x+k; i++) {
    console.log(i);
  }
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 9264
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<=(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<62)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		VI X(N), Y(N);
		REP(i, N) cin>>X[i]>>Y[i];
		ll ans = INF;
		REP(x0, N) RANGE(x1, x0, N) REP(y0, N) RANGE(y1, y0, N) {
			ll co = 0;
			ll xmin = min(X[x0], X[x1]);
			ll xmax = max(X[x0], X[x1]);
			ll ymin = min(Y[y0], Y[y1]);
			ll ymax = max(Y[y0], Y[y1]);
			REP(i, N) {
				if(IN(X[i], xmin, xmax) && IN(Y[i], ymin, ymax)) co++;
			}
			if(co>=K) ans = min(ans, (xmax-xmin) * (ymax-ymin));
		}
		// 4000000000000000000
		// 4611686018427387904
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextIntList()
    val sieve = Sieve(100000)
    val ans = A.map { sieve.fact(it).getOrDefault(2, 0) }.sum()
    println(ans)
}

class Sieve(N: Int) {
    private val primes: Array<Int>

    init {
        val que = ArrayDeque<Int>()
        val sieve = BooleanArray(N + 1) { true }
        sieve[0] = false
        sieve[1] = false
        for (i in 2..N) {
            if (!sieve[i]) continue
            que.push(i)
            for (j in (i * 2)..N step i) {
                sieve[j] = false
            }
        }
        primes = que.toTypedArray()
    }

    fun fact(n: Int): HashMap<Int, Int> {
        val map = HashMap<Int, Int>()
        var tmp = n
        for (prime in primes) {
            if (tmp % prime == 0) {
                var cnt = 0
                while (tmp % prime == 0) {
                    tmp /= prime
                    cnt++
                }
                map[prime] = cnt
            }
        }
        if (tmp != 1) {
            map[tmp] = 1
        }
        return map
    }
}

Measured memory_bytes: 44840
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

// long long gcd(long long a, long long b){
//     if (a < b){
//         a ^= b;
//         b ^= a;
//         a ^= b;
//     }
//     return b ? gcd(b, a % b) : a;
// }

// long long lcm(long long a, long long b){
//     return a * b / gcd(a, b);
// }

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


Measured memory_bytes: 256
def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

n=int(input())
l=list(map(int,input().split()))

linked_merge_sort(l)

ans=0

for x in l:
    i=0
    while l[i]<x:
        j=i+1
        while l[j]<x:
            if l[i]+l[j]>x and l[i]!=l[j]:
                ans+=1
            j+=1
        i+=1

print(ans)


Measured memory_bytes: 67396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,a[1000],t,s=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    sort(a,a+n,greater<int>());
    cout<<(a[m-1]*4*m<s?"No":"Yes")<<endl;
}


Measured memory_bytes: 3596