akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int h,w,bk,c[10][1000],ans = INF;
string s[10];

signed main() {
    cin >> h >> w >> bk;
    rep(i,h) cin >> s[i];
    rep(i,h) rep(j,w) c[i][j] = s[i][j]-'0';
    int b = pow(2,h);
    rep(i,b) {
        int tmpans=0;
        int now = 0;
        int idx[10]={};
        int tmpb = i;
        vector<int> v;
        rep(j,h) v.pb(tmpb%2), tmpb /= 2;
        idx[0] = now;
        rep11(j,h) {
            if (v[j-1] != v[j]) now++;
            idx[j] = now;
        }
        tmpans = now;
        now++;


        bool is_first = true;
        int sum[10] = {};
        rep(j,w) {
            rep(k,h) {
                sum[idx[k]] += c[k][j];
            }
            rep(k,now) {
                if (sum[k] > bk) {
                    if (is_first) goto BREAK;
                    --j;
                    tmpans++;
                    rep(K,now) sum[K] = 0;
                    is_first = true;
                    goto HUGA;
                }
            }
            is_first = false;
            HUGA:;
        }
        ans = min(ans, tmpans);
        BREAK:;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main    (void)
{
    int     W;
    int     H;
    int     x;
    int     y;
    int     r;
    
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (x >= r && y >= r)
    {
        if((W - r) >= x && (H - r) >= y)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    else
    {
        printf("No\n");
    }
    return  (0);
}


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

using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;


int main(){

  ll n;cin>>n;

  for(ll i=(int)sqrt(n);i>=0;i--){
    if(n%i==0){
      out((i-1)+(n/i-1));
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>

using namespace std;

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

    vector<int> A;
    int x;
    for (size_t i = 0; i < 3; i++)
    {
        for (size_t j = 0; j < 3; j++)
        {
            cin>>x;
            A.push_back(x);
        }
        
    }

    int N;
    cin>>N;

    int b;
    array<int, 101> B{0};


    for (size_t i = 0; i < N; i++)
    {
        cin>>b;
        B[b] = 1;
    }

    // for (auto &&i : A)
    // {
    //     cout<<i<<" ";
    // }
    // cout << "\n";

    // for (auto &&i : B)
    // {
    //     cout<<i<<" ";
    // }
    // cout << "\n";
    

    if((B[A[0]] && B[A[1]] && B[A[2]]) || 
    (B[A[3]] && B[A[4]] && B[A[5]]) || 
    (B[A[6]] && B[A[7]] && B[A[8]]) || 
(B[A[0]] && B[A[3]] && B[A[6]]) || 
(B[A[1]] && B[A[4]] && B[A[7]]) || 
(B[A[2]] && B[A[5]] && B[A[8]]) || 
(B[A[0]] && B[A[4]] && B[A[8]]) || 
(B[A[2]] && B[A[4]] && B[A[6]]) ) {
        cout << "Yes"<<"\n";
    }
    else {
        cout << "No"<<"\n";
    }


}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;
 
 
void main()
{
  while (1) {
    auto x = readln.chomp.split.map!(to!int);
    if (x[0] == 0 && x[1] == 0) break;
    foreach (i; 0..x[0]) { 
      foreach (j; 0..x[1]) write("#");
      writeln("");
    }
    writeln("");
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m), suma(n + 1, 0), sumb(m + 1, 0);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        suma[i + 1] = suma[i] + a[i];
    }
    for(ll i = 0; i < m; i++) {
        cin >> b[i];
        sumb[i + 1] = sumb[i] + b[i];
    }
    ll ans = 0;
    for(ll i = 0; i <= n; i++) {
        ll A = suma[i];
        if(A > k) {
            continue;
        }
        ll B = k - A;
        auto it = lower_bound(ALL(sumb), B);
        if(it != sumb.begin() && *it > B) {
            it--;
        }
        if(it == sumb.end()) {
            it--;
        }
        chmax(ans, i + (ll)(it - sumb.begin()));
    }
    for(ll i = 0; i <= m; i++) {
        ll B = sumb[i];
        if(B > k) {
            continue;
        }
        ll A = k - B;
        auto it = lower_bound(ALL(suma), A);
        if(it != suma.begin() && *it > A) {
            it--;
        }
        // debug(i);
        // debug(i, (ll)(it - suma.begin()));
        if(it == suma.end()) {
            it--;
        }
        chmax(ans, i + (ll)(it - suma.begin()));
    }
    cout << ans << endl;
}

Measured memory_bytes: 9512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] a = new int [N];
        int [] count = new int [9];
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }

        for(int i=0; i<N; i++){
            if(a[i]<400){
                count[0]++;
            }else if(a[i]<800){
                count[1]++;
            }else if(a[i]<1200){
                count[2]++;
            }else if(a[i]<1600){
                count[3]++;
            }else if(a[i]<2000){
                count[4]++;
            }else if(a[i]<2400){
                count[5]++;
            }else if(a[i]<2800){
                count[6]++;
            }else if(a[i]<3200){
                count[7]++;
            }else{
                count[8]++;
            }
        }
        
        int color = 0;
        for(int i=0; i<8; i++){
            if(count[i]>0){
                color++;
            }
        }
        
        int min = color;
        int max = count[8]+color;
        
        if(color == 0){
        System.out.println(1+" "+max);
        }else{
        System.out.println(min+" "+max);    
        }
    }
}

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

//vector <long long> v;

stack <char> s;

long long int  x[1000000], y, pot[30], czy=0, w, n, m;
//char s;

int main()
{
    long long int a, b, c, d, k, i, j, q, t, p;

//    q=1;
//    scanf("%lld", &q);
//    for(t=0; t<q; t++)
    {
        scanf("%lld", &n);


        while(n>0)
        {
            b=n%26;
            if(b==0)b+=26;
            s.push(b+'a'-1);
            n/=26;
            n-=b/26;
        }

        while(s.size())
        {
            printf("%c", s.top());
            s.pop();
        }

        printf("\n");
    }

    return(0);
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        1000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int n,k,ans = 0;
    cin >> n >> k;
    vector<int>sum(n+5);
    FOR(i,1,n+2)sum[i] = (sum[i-1]+i)%mod;
    FOR(i,k,n+1){
    	ans += (sum[n]-sum[n-i]+mod)%mod;
    	ans %= mod;
    	ans = (ans-sum[i-1]+mod+1)%mod;
    	ans %= mod;
    }
    cout << (ans+1)%mod;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 

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

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int M,N;
    cin>>M>>N;
    if(M==N){
        out("Yes");
    }else{
        out("No");
    }    

    return 0;
}


Measured memory_bytes: 256
//created by pyoxiao on 2020/04/15
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int n, k;
LL dp[100010];
LL cal(LL x) {
    LL cur = fpow(k / x, n);
    int now = 2;
    while(1) {
        if(now * x > k) break;
        cur -= dp[x * now];
        now ++;
    }
    return dp[x] = cur;
}  
void solve() {
    scanf("%d %d", &n, &k);
    LL ans = 0;
    for(int gcd = k; gcd >= 1; gcd --) {
        (ans += gcd * cal(gcd) % mod) %= mod;
    }
    printf("%lld\n", (ans + mod) % mod);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 4496
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    rep(i, 3) cin >> A[i];
    int K; cin >> K;
    sort(A, A + 3);
    rep(i, K) A[2] *= 2;
    cout << A[0] + A[1] + A[2] << endl;
    

    return 0;
}


Measured memory_bytes: 3580
X,K,D = map(int,input().split())
# 原点に近い位置までの移動回数を求める
count = abs(X) // D
ans = 0
if count>K:
    ans = abs(X) - D * K
else:
    if (K-count)%2==0:
        ans = abs(X) % D
    else:
        ans = abs(abs(X) % D - D)
print(ans)

Measured memory_bytes: 9216
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    int l[1001], r[1001];
    int ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
        int man = r[i] - l[i] + 1;
        ans += man;
    }
    cout << ans << endl;

}


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


int main(){
   int A,B;
   cin>>A>>B;
   int i=0;
   while(true){
       if(i*0.08>=A+1||i*0.1>=B+1){
           cout<<-1<<endl;
           break;
       }
       else if(i*0.08>=A&&i*0.1>=B){
           cout<<i<<endl;
           break;
       }
       i++;
   }
}

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a,b,d,fl=0,i,l,r;
	cin>>a>>b;
	for(i=1;i<1010;i++) {
		if(((8*i)/100)==a && ((10*i)/100)==b) {
			fl=1;
			cout<<i;
			break;
		}
	}
	if(fl==0) cout<<-1;
		
}

Measured memory_bytes: 256
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

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

const int maxn = 3e3+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

ll a[maxn];
ll dp[maxn][maxn][2];

ll solve(ll l, ll r, int person)
{
    if(l > r)               return 0;
    if(dp[l][r][person])    return dp[l][r][person];
    int nxt = (person + 1) % 2;
    if(person == 0) dp[l][r][person] = max(solve(l + 1, r, nxt) + a[l], solve(l, r - 1, nxt) + a[r]);
    if(person == 1) dp[l][r][person] = min(solve(l + 1, r, nxt) - a[l], solve(l, r - 1, nxt) - a[r]);
    return dp[l][r][person];
}

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n;
    scanf("%d", &n);

    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    ll answer = solve(1, n, 0);

    printf("%lld\n", answer);


    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 139776
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;

// returns next 753-number
ll next(ll x)
{
  ll l = x%10;
  ll r = x-l;
  if(x==0) return 3;
  switch (l)
  {
  case 3:
    return r+5;
    break;
  case 5:
    return r+7;
    break;
  case 7:
    return 10*next(r/10)+3;
    break;

  default:
//    cout << "ERROR" << endl;
    return -1;
    break;
  }
}

int check(ll x, ll n)
{
  ll y = x;
  vector<int> flag(3,0);
  while(y!=0)
  {
    switch (y%10)
    {
    case 3:
      flag[0] = 1;
      break;

    case 5:
      flag[1] = 1;
      break;

    case 7:
      flag[2] = 1;
      break;

    default:
      break;
    }
    y = (y-(y%10))/10;
  }
//  cout << x << endl;
//  cout << flag[0] << " " << flag[1] << " " << flag[2] << " ";
  if (flag[0] + flag[1] + flag[2] == 3 && y <= n) return 1;
  else return 0;
}

ll digit (ll x)
{
  ll y = x;
  ll d = 0;
  while(x!=0)
  {
    d++;
    x = (x-(x%10))/10;
  }
  return d;
}

ll int_pow(ll d)
{
  if (d==0) return 1;
  else return 10 * int_pow(d-1);
}

int main()
{
  ll n;
  cin >> n;
  ll cnt = 0;
  ll x = 3;
  while(x<=n)
  {
//    cout << x << endl;
    cnt += check(x,n);
    x = next(x);
  }
  cout << cnt << endl;
  return 0;
}


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

int main()
{
	ll K;
	cin >> K;
	int N = 50;
	ll X = (K + N - 1) / N;
	vector<ll> a(N, X + N - 1);
	ll cnt = X * N - K;
	for (int i = 0; i < cnt; i++) {
		for (int j = 0; j < N; j++) {
			if (j == i) {
				a[j] -= N;
			}
			else {
				a[j] += 1;
			}
		}
	}
	cout << N << endl;
	for (int i = 0; i < N; i++) {
		cout << a[i] << " \n"[i + 1 == N];
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=1e3+10,N=1e6+10;
int n;
int id(int x,int y)
{
	if(x<y)
		swap(x,y);
	return (x-1)*x/2+y-(x-1);
}
int a[MAXN][MAXN];
int deg[MAXN*MAXN];
int head[N],to[N],nx[N],ecnt=0;
void addedge(int u,int v)
{
	++ecnt;
	to[ecnt]=v;
	nx[ecnt]=head[u];
	head[u]=ecnt;
}
int vis[N],cnt=0;
void del(int u)
{
	++cnt;
	vis[u]=1;
	for(int i=head[u];i;i=nx[i])
	{
		int v=to[i];
		deg[v]--;
		if(!deg[v])
			del(v);
	}
}
int f[MAXN*MAXN];
int dfs(int u)
{
	if(f[u])
		return f[u];
	f[u]=1;
	for(int i=head[u];i;i=nx[i])
	{
		int v=to[i];
		f[u]=max(f[u],dfs(v)+1);
	}	
	return f[u];
}
int main()
{
	n=read();
	int mx=(n-1)*n/2;
	for(int i=1;i<=n;++i)
		for(int j=1;j<n;++j)
		{
			int x=read();
			a[i][j]=id(i,x);
			if(j!=1)
			{
				addedge(a[i][j-1],a[i][j]);
				++deg[a[i][j]];
			}
		}
	for(int i=1;i<=mx;++i)
		if(!deg[i] && !vis[i])
			del(i);
	if(cnt!=mx)
		return puts("-1")&0;
	int ans=0;
	for(int i=1;i<=mx;++i)
		ans=max(ans,dfs(i));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 27776
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	long long n, d;
	cin >> n >> d;
	long long ct = 0;
	while (n--)
	{
		long long x, y;
		cin >> x >> y;
		long long int zx = (x * x) + (y * y);


		if (sqrt(zx) * 1.0 <= d * 1.0)
		{
			ct++;
		}


	}
	cout << ct << endl;






	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = inv[1] = 1;
    fact[0] = invfact[0] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i * fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    vl x(n);
    rep(i, n) {
        cin >> x[i];
    }

    init();

    vl rui(n);  // rui[i] : inv[i]までの和
    exrep(i, 1, n-1) {
        rui[i] = rui[i-1] + inv[i];
        rui[i] %= mod;
    }
    
    ll ans = 0;
    exrep(i, 1, n-1) {
        ans += (x[i] - x[i-1])*rui[i];
        ans %= mod;
    }

    ans *= fact[n-1];
    ans %= mod;

    out(ans);
    re0;
}

Measured memory_bytes: 6528
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Long, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            if(map.containsKey(a)) {
                map.put(a, map.get(a) + 1);
            } else {
                map.put(a, 1l);
            }
        }
        long ans = 0l;
        for(Entry<Long, Long> entry : map.entrySet()) {
            if(entry.getKey() > entry.getValue()) {
                ans += entry.getValue();
            } else {
                ans += entry.getValue() - entry.getKey();
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

template <typename T>
T modpow(T x, T n, const T mod) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

template <typename T>
T inverse(T x, const T mod) {
    return modpow(x, mod - 2, mod);
}
template <typename T>
T gcd(T x, T y) {
    return x ? gcd(y % x, x) : y;
}
template <typename T>
T lcm(T x, T y) {
    return ((x *inverse(gcd(x, y)%MOD,MOD)%MOD) * y)%MOD;
}

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> A(n);
    ll p=1;
    map<ll,ll> mp;
    for(i=0;i<n;i++){
        cin >> A[i];
        ll u=A[i];
        for(ll t=2;t*t<=u;t++){
            ll cnt = 0;
            while(u%t==0){
                cnt++;
                u/=t;
            }
            if(mp.find(t)!=mp.end())
                mp[t] = max(cnt,mp[t]);
            else mp[t] = cnt;
        }
        if(u>1){
            if(mp.find(u) != mp.end())
                mp[u] = max(1ll, mp[u]);
            else
                mp[u] = 1ll;
        }
    }
    for(auto &x:mp){
        p *= modpow(x.first,x.second,MOD); 
        p%=MOD;
    }

    ll ret = 0;
    for(i=0;i<n;i++){
        ll u = A[i];
        ll now = 1;
        for(ll t = 2; t * t <= u; t++) {
            ll cnt = 0;
            while(u % t == 0) {
                cnt++;
                u /= t;
            }
            now *= modpow((ll)t, cnt, MOD);
            now %=MOD;
        }
        if(u > 1) {
            now *= u;
            now %= MOD;
        }
        //cout << now << endl;
        ret += (p*(inverse(now,MOD))%MOD)%MOD;
        ret %=MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> xs(n), ys(n), hs(n);
    for(int i=0; i<n; ++i){
        cin >> xs[i] >> ys[i] >> hs[i];
    }
    for(int x=0; x<=100; ++x){
        for(int y=0; y<=100; ++y){
            int ans=0;
            for(int i=0; i<n; ++i){
                if(hs[i]==0) continue;
                int h=hs[i]+abs(xs[i]-x)+abs(ys[i]-y);
                if(ans==0) ans=h;
                else if(ans==h) continue;
                else {
                    ans=0;
                    break;
                }
            }
            if(ans==0) continue;
            for(int i=0; i<n; ++i){
                int h=ans-abs(xs[i]-x)-abs(ys[i]-y);
                if(max(h, 0)!=hs[i]){
                    ans=0;
                    break;
                }
            }
            if(ans>0){
                printf("%d %d %d\n", x, y, ans);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
y=[]
for i in range(n-1):
    y.append(a*(x[i+1]-x[i]))
ans=0
for i in range(len(y)):
    if y[i]<=b:
        ans+=y[i]
    else:
        ans+=b
print(ans)


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

int main() {
	set<int> s;
	//stk : 一時変数
	int stk, N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> stk;
		s.insert(stk);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n;
    cin>>n;
    ll res=0;
    for(ll i=0;i<n;i++)res+=(n-i+1)*(n-i)/2;
    for(int i=0;i<n-1;i++){
        ll a,b;cin>>a>>b;
         if(a>b)swap(a,b);
         res-=a*(n-b+1);
    }
    cout<<res<<"\n";
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void){
    int A, B, b;
    scanf("%d%d", &A, &B);
    b=1;
    if (A>=10) b=0;
    if (B>=10) b=0;
    if (b==1) printf("%d", A*B);
    else printf("-1");
    return 0;
}


Measured memory_bytes: 128
N,W = map(int,input().split())
goods = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for _ in range(W)] for _ in range(N)]

for i,[w,v] in enumerate(goods):
  for j in range(W):
    if i == 0:
      if j >= goods[0][0]-1:
        dp[0][j] = goods[0][1]
    else:
      if w <= j:
        dp[i][j] = max(v+dp[i-1][j-w],dp[i][j-1],dp[i-1][j])
      else:
        dp[i][j] = dp[i-1][j]

print(dp[N-1][W-1])


Measured memory_bytes: 217628
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = map(int, input().split())

    neg, pos, zero = list(), list(), 0
    for a in A:
        if a < 0: neg.append(a)
        elif a > 0: pos.append(a)
        else: zero += 1
    neg.sort()
    pos.sort()

    #x未満になる組み合わせの個数
    def calc(x):
        result = 0
        if x < 0:
            #負になるのは 正*負, 負*正
            i, j = len(pos)-1, len(neg)-1
            while i >= 0:
                while j >= 0 and pos[i]*neg[j] >= x: j -= 1
                if j < 0: break
                result += j + 1
                i -= 1
        elif x == 0:
            result += len(neg) * len(pos) #負
        else:
            #正*正
            i, j = 0, len(pos)-1
            while i < len(pos):
                while j >= 0 and pos[i]*pos[j] >= x: j -= 1
                if j < 0: break
                result += j + 1
                if pos[i]*pos[i] < x: result -= 1 #同じもの同士を除外
                i += 1
            #負*負
            i, j = len(neg)-1, 0
            while i >= 0:
                while j < len(neg) and neg[i]*neg[j] >= x: j += 1
                if j >= len(neg): break
                result += len(neg) - j
                if neg[i]*neg[i] < x: result -= 1 #同じもの同士を除外
                i -= 1
            result //= 2 #ペアの入れ替え分
            result += len(neg) * len(pos) #負
            result += (len(neg) + len(pos)) * zero + (zero)*(zero-1)//2 #0
        return result
    
    #二分探索
    l, over = -10**18, 10**18+1
    while over - l > 1:
        m = (l+over)//2
        if calc(m) < K: l = m
        else: over = m
    print(l)

if __name__ == '__main__':
    main()

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    cout << pow(2, m)*(1900*m+100*(n-m)) << endl;
}


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



int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int N, A, B; cin >> N >> A >> B;
    int mn = min(A,B);
    int mx = max(0,A+B-N);
    cout << mn << ' ' << mx << '\n';


    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;

static const int N = 100;
static const int INFTY = (1<<21); //十分に大きな数

int M[N][N];
int n;
int d[N]; //距離で訪問状態　color を管理する

void bfs(int s){
  queue<int> q;
  q.push(s);


  for(int i = 0; i < n; i++) d[i] = INFTY;
  d[s] = 0;

  //sに隣接の値をキューに入れる
  int u;
  while ( !q.empty()){
    u = q.front();
    q.pop();
    for(int v = 0; v < n; v++){
      if(M[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);

    }
  }

  for(int i = 0; i < n; i ++){
    cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
  }

}

int main() {
  int u, k, v;
  cin >> n;

//グラフの初期化
  REP(i,n){
    REP(j,n){
      M[i][j] = 0;
    }
  }

  //行列の作成
  REP(i,n){
    cin >> u >> k;
    u--;
    REP(j,k){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;

}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdlib>

int maximize(int N) {
    int total = 0;
    int i = 0;
    while (total <=  N) {
        i++;
        total += i; 
    }
    return i - 1;
}

void calc(int N, int Max) {
    int discovery = 0;
    for (int i = 2; i <= Max + 1; i++) {
        for (int j = 1; j < N / i + 1; j++) {
            if ((j + i - 1) * (j + i) - (j - 1) * j == 2 * N) {
                discovery++;
                break;
            }
        }
    }
    std::cout << discovery << std::endl;
    return;
}

int main(void) {
    int N;
    std::cin >> N;

    while (N != 0) {
        int Max = maximize(N);
        calc(N, Max);
        std::cin >> N;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3108
import sys

for i in sys.stdin:
    h,w = map(int,i.strip().split())

    if h==0 and w==0:
        break

    for i in range(h):
        str = ''
        for j in range(w):
            if (i+j) % 2 == 0:
                str += '#'
            else:
                str += '.'
        print(str)
    print()

Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    ll H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << H*W - h*W - w*(H-h) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MAXN=200100;
const int MAXK=16;
const int INF = 1e9;
const ll MOD = 1e9+7;

ll N,M,K,Q,u,v,w,a,b,c;
vpi V[MAXN];
ll A[MAXN];

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

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

using ll = long long;
constexpr ll LLINF = (1ll<<60);

string S;
string ans;
ll ansd = LLINF;
int N;
string pat = "0123456789";
int ipat[256];

ll p10[15];

char addr(char c, int val) {
        return (pat[(ipat[c]+val+10)%10]);
}

void solve(int u, string T, int bit, int flag) {
        //cout << u << " " << T << " " << bit << " " << flag << endl;
        if (u == N) {
                //cout << S << " " << T << endl;
                ll val1 = stol(S);
                ll val2 = stol(T);
                ll diff = min({abs(p10[N]+val1-val2), abs(val1-val2), abs(val1-val2-p10[N])});
                if (ansd > diff || (ansd == diff && ans > T)) {
                        ansd = diff; ans = T;
                }
                return;
        }
        int target;
        if (flag == 1) target = -1;
        else if (flag == -1) target = 10;
        else target = S[u] - '0';
        
        if (!flag && (!((bit>>target)&1))) {
                solve(u+1, T + (char)(target+'0'), bit | (1<<target), 0);
        }
        
        for (int i = target+1; i < 10; i++) {
                if (!((bit>>i)&1)) {
                        int nf = flag;
                        if (flag == 0) nf = 1;
                        solve(u+1, T + (char)(i+'0'), bit | (1<<i), nf);
                        break;
                }
        }

        for (int i = target-1; i >= 0; i--) {
                if (!((bit>>i)&1)) {
                        int nf = flag;
                        if (flag == 0) nf = -1;
                        solve(u+1, T + (char)(i+'0'), bit | (1<<i), nf);
                        break;
                }
        }
}

int main() {
        cin >> S;
        N = S.size();
        for (int i = '0'; i <= '9'; i++) {
                ipat[i] = i-'0';
        }


        p10[0] = 1;
        for (int i = 1; i < 15; i++) {
                p10[i] = p10[i-1] * 10;
        }

        S[0] = addr(S[0], 5);

        string c1; c1 += (addr(S[0], -1));
        string c2; c2 += (S[0]);
        string c3; c3 += (addr(S[0], 1));
        //cout << c1 << " " << c2 << " " << c3 << endl;

        solve(1, c1, 1<<(c1[0]-'0'), -1);
        solve(1, c2, 1<<(c2[0]-'0'), 0);
        solve(1, c3, 1<<(c3[0]-'0'), 1);

        cout << ans << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int CalcSumRow(vector<vector<int>> C, int row){
    int ans=0;
    rep(i,0,C.size()) ans+=C.at(i).at(row);
    return ans;
}

int main(){
    vector<vector<int>> C(3,vector<int>(3));
    rep(i,0,3)rep(j,0,3) cin>>C.at(i).at(j);

    string ans="Yes";
    int col0,col1,col2,row0,row1,row2;
    col0=accumulate(ToEnd(C.at(0)),0);
    col1=accumulate(ToEnd(C.at(1)),0);
    col2=accumulate(ToEnd(C.at(2)),0);
    row0=CalcSumRow(C,0);
    row1=CalcSumRow(C,1);
    row2=CalcSumRow(C,2);

    if((col0-col1)%3 || (col1-col2)%3 || (col2-col0)%3
        || (row0-row1)%3 || (row1-row2)%3 || (row2-row0)%3) ans="No";

    cout<<ans<<endl;
}

Measured memory_bytes: 764
//According to all known laws of aviation, there is no way that a bee should be able to fly.
 //Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
 //Because bees don't care what humans think is impossible.
 #include <bits/stdc++.h>
 #define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define mod 1000000007
 #define endl "\n"
 using namespace std ;
 using bigint = long long int ;
 using vi = vector<int> ;
 using vll = vector<bigint> ;

int main(){
    int N , M , X ; cin >> N >> M >> X ;
    int C[N+1] , arr[N+1][M+1] ;
    for( int i = 0 ; i < N ; i++ ){
        cin >> C[i] ;
        for( int j = 0 ; j < M ; j++ )
            cin >> arr[i][j] ;
    }
    bigint ans = INT_MAX ;
    for( int mask = 0 ; mask < ( 1 << N ) ; mask ++ ){
        bigint monsey_spend = 0 , sum[101] = { 0 } ;
        for( int i = 0 ; i < N ; i++ ){
            if( mask & ( 1 << i ) ){
                for( int j = 0 ; j < M ; j++ )
                    sum[j] += ( bigint )arr[i][j] ;
                monsey_spend += C[i] ;
            }
        }
        bool flag = true ;
        for( int j = 0 ; j < M ; j++ ){
            if( sum[j] < X ){
                flag = false ;
                break ;
            }
        }
        if( flag )
            ans = min( ans , monsey_spend) ;
    }
    if( ans == INT_MAX )
        cout << "-1" << endl ;
    else
        cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... args) { cout << a << " "; print(args...); }

int main() {
    init();

    int s, w; cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << "\n";
}

Measured memory_bytes: 3640
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A,B,C = map(int, input().split())

    if A == B:
        print(C)
    elif A == C:
        print(B)
    else:
        print(A)

if __name__ == '__main__':
    main()

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

int main(){
	int n; cin>>n;
	if(n==1) cout << "Hello World" << endl;
	else{
		int a,b; cin>>a>>b;
		cout << a+b << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define prime 37
#define prime2 101
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

string s;
ll n;
vector <ll> h;
ll p_[MAXN];
ll invp[MAXN];

vector <ll> h2;
ll p2_[MAXN];
ll invp2[MAXN];

ll C(char c)
{
	return (c - 'a') + 1;
}

ll M(ll a)
{
	return a%MOD;
}

void mul(ll& a,ll b)
{
	a *= b;
	a%=MOD;
}
ll modInverse(ll a)
{
	ll m = MOD;
	ll y = 0, x = 1;
	if (m == 1)
		return 0;
	while (a > 1)
	{
		ll q = a / m;
		ll t = m;
		m = a % m, a = t;
		t = y;
		y = x - q * y;
		x = t;
	}
	if (x < 0)
		x += MOD;
	return x;
}
void setup()
{
	h[0] = C(s[0]) % MOD;
	ll p = 1;
	p_[0] = 1;
	invp[0] = 1;
	for (ll i = 1; i < n; ++i)
	{
		mul(p,prime);
		h[i] = M(h[i-1] + M(p * C(s[i])));
		p_[i] = p;
		invp[i] = modInverse(p_[i]);
	}
}

void setup2()
{
	h2[0] = C(s[0]) % MOD;
	ll p2 = 1;
	p2_[0] = 1;
	invp2[0] = 1;
	for (ll i = 1; i < n; ++i)
	{
		mul(p2,prime2);
		h2[i] = M(h2[i-1] + M(p2 * C(s[i])));
		p2_[i] = p2;
		invp2[i] = modInverse(p2_[i]);
	}
}

ll ext(ll l, ll r)
{
	if(l)
		return M(M(h[r] - h[l-1] + MOD) * invp[l]);

	return M(h[r]);
}

ll ext2(ll l, ll r)
{
	if(l)
		return M(M(h2[r] - h2[l-1] + MOD) * invp2[l]);

	return M(h2[r]);
}


bool check(ll sz)
{
	if(sz == 0) return true;
	map <pair<ll,ll>,vector<ll>> mp;

	for (ll i = 0; i < n-sz+1; ++i)
	{// l : i  , r : i+sz-1
		// cout << i _ sz _ ext(i,i+sz-1) _ ext2(i,i+sz-1) << endl;
		mp[{ext(i,i+sz-1),ext2(i,i+sz-1)}].pb(i);
	}

	for (auto i : mp)
	{
		if(i.second.back() - i.second.front() >= sz)
			return true;
	}

	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> s;
	// s = '#' + s;
	// n = n+1;
	h.resize(n);
	h2.resize(n);
	setup();
	setup2();
	

	TRACE(n);
	for (ll i = 0; i < n; ++i)
		TRACE2(i, h[i]);

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << p_[i] _ invp[i] << endl;
	// }


	ll l = 0;
	ll r = n/2;
	// ll resul
	TRACE(check(2));

	// return 0;
	while(l < r)
	{
		TRACE2(l,r);
		if(check(mid))
			l = mid+1;
		else
			r = mid;
	}

	if(check(l))
		cout << l << endl;
	else
		cout << l-1 << endl;

}

Measured memory_bytes: 5120
#include <algorithm>
#include <vector>

int a[4],b[4];
int main(){
  float f;
  std::vector<float>v;
  for(;~scanf("%f",&f);)v.push_back(f);
  std::sort(v.begin(),v.end());
  printf("%.2f\n",v[v.size()-1]-v[0]);
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DEvenRelation solver = new DEvenRelation();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEvenRelation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Vertex[] g = new Vertex[n];
            for (int i = 0; i < n; ++i) g[i] = new Vertex();
            for (int i = 0; i < n - 1; ++i) {
                Vertex u = g[in.nextInt() - 1];
                Vertex v = g[in.nextInt() - 1];
                int w = in.nextInt();
                u.adj.add(new Edge(v, w));
                v.adj.add(new Edge(u, w));
            }
            g[0].color = 0;
            dfs(g[0]);
            for (int i = 0; i < n; ++i) out.println(g[i].color);
        }

        private void dfs(Vertex cur) {
            for (Edge e : cur.adj) {
                if (e.to.color == -1) {
                    if (e.w % 2 == 0) e.to.color = cur.color;
                    else e.to.color = 1 - cur.color;
                    dfs(e.to);
                }
            }
        }

        class Vertex {
            int color = -1;
            List<Edge> adj = new ArrayList<>();

        }

        private class Edge {
            int w;
            Vertex to;

            Edge(Vertex v, int weight) {
                to = v;
                w = weight;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 60936
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=1;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		if(ans<=k) ans*=2;
		else ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
L = lr()
L.sort()
answer = 0
for i in range(N-1, -1, -1):
    # iが一番大きい辺
    x = L[i]
    left = 0
    right = i - 1
    while left < right:
        if L[left] + L[right] <= x:
            left += 1
            continue
        answer += (right - left)
        right -= 1

print(answer)


Measured memory_bytes: 41964
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] x = new int[n];

        for (int i = 0; i < n; i++)
        {
            int t = sc.NextInt();
            x[i] = t;
        }

        int min = 1000000000;
        for (int i = 0; i < n - k + 1; i++)
        {
            int l = x[i];
            int r = x[i + k - 1];
            min = Math.Min(Math.Abs(l) + Math.Abs(r - l), min);
            min = Math.Min(Math.Abs(r) + Math.Abs(l - r), min);
        }
        Console.WriteLine(min);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 20320
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,k;

int main(){
  int ans=0;
  string s;
  cin >> s;

  if (s[0]==s[1])ans=1;
  if (s[1]==s[2])ans=1;
  if (s[2]==s[3])ans=1;
if (ans==0){
cout<<"Good"<<endl;
}else{
cout<<"Bad"<<endl;
}

  
  return 0;
}

Measured memory_bytes: 256