akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, 3500) {
		REP(j, 3500) {
			if (double(4) / n - double(1) / (i + 1) - double(1) / (j + 1) < EPS)continue;
			double c = double(1) / (double(4) / n - double(1) / (i + 1) - double(1) / (j + 1));
			if (abs(c - int(c)) <EPS) {
				cout << i + 1 << " " << j + 1 << " " << c << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

typedef long long ll;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=1;i<(n);i++)

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

int main(){
    ll n,m,k; cin >> n >> m >> k;
    vector<ll> a(n+1,0),b(m+1,0);
    rep2(i,n+1) {
        cin >> a[i];
        a[i]+=a[i-1];
    }
    rep2(i,m+1){
        cin >> b[i];
        b[i]+=b[i-1];
    }
    ll now = m;
    ll ans = 0;
    rep(i,n+1){
        bool flag = 1;
        while(flag && now > -1){
            if(a[i] + b[now] <= k){
                ans = max(ans,i+now);
                flag = 0;
            }
            while(a[i] + b[now] > k && flag){
                now--;
                if(now < 0) break;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N,i;
  long long int sum = 0;
  cin >> N;
  for (i = 0; i < N; i++) {
    if ((i + 1) % 3 != 0 && (i + 1) % 5 != 0) {
    sum += i + 1;
    }
  }
  cout << sum << endl;
}



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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h + 1, vector<char>(w + 1));
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> dp(h + 1, vector<int>(w + 1));
    dp[1][1] = 1;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (a[i][j] == '.')
                dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[h][w];
    return 0;
}

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

void dfs(vector<int> &s, const vector<vector<int>> &child, vector<bool> &visited, int current)
{
  if (visited.at(current)) return;
  visited.at(current) = true;
  for (auto t : child.at(current)) {
    if (visited.at(t)) continue;
    s.at(t) += s.at(current);
    dfs(s, child, visited, t);
  }
}

int main()
{
  int n, q;
  cin >> n >> q;
  vector<vector<int>> child(n);
  vector<int> s(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    child.at(a - 1).push_back(b - 1);
    child.at(b - 1).push_back(a - 1);
  }
  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    s.at(p - 1) += x;
  }
  vector<bool> visited(n);
  dfs(s, child, visited, 0);
  for (int i = 0; i < n - 1; i++) {
    cout << s.at(i) << " ";
  }
  cout << s.at(n - 1) << endl;
}


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

int main(){
  int N;
  int W[100], sum[100]={};
  cin >>N;
  cin >> W[0];
  sum[0] = W[0];
  for(int i=1; i<N; i++){
    cin >> W[i];
    sum[i] = sum[i-1]+W[i];
  }
  int min=sum[N-1]-sum[0];
  for(int i=1; i<N-1; i++){
    if(abs(sum[i]-(sum[N-1]-sum[i])) <min){
      min = abs(sum[i]-(sum[N-1]-sum[i]));
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
Y = [b-a for a,b in zip(X,X[1:])]

MOD = 10**9+7
MAXN = N+5
fac = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD

ans = m = 0
for i,y in enumerate(Y):
    m += fac[N-1] * inv[i+1]
    ans += y*m
    ans %= MOD
print(ans)

Measured memory_bytes: 19984
#include <iostream>
#include <string>
#define FOR(i, m, n) for(int i = m;i < n;i++)
using namespace std;

int pow2(int x){
  int count = 0;
  while(x%2==0){
    x=x/2;
    count++;
  }    
  return count;
}

int main(){  
  int N;
  int a[10010];
  cin >> N;
  FOR(i, 0, N) cin >> a[i];
  
  int c = 0;
  
  FOR(i, 0, N){
    c += pow2(a[i]);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int left = A + B;
  int right = C + D;
  if(left < right){
  	cout << "Right" << endl;
  }else if(left > right){
  	cout << "Left" << endl;
  }else{
  	cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.next().toCharArray();
		
		for (int i=0; i<a.length; i++) {
			int t = i%2+a[i];
			if (t=='S' || t=='L') {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
import numpy as np
N,K=map(int,input().split())
h=list(map(int,input().split()))
h=np.array(h)
cost=np.zeros(N+1)
cost[1]=0
cost[2]=abs(h[1]-h[0])
for i in range(3,N+1):
    x=1 if i-K<=1 else i-K
    cost[i]=(cost[x:i]+abs(h[i-1]-h[x-1:i-1])).min()
print(int(cost[N]))


Measured memory_bytes: 22792
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
 
 
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int MOD =  1e9 + 7; 
 
 
 
ll power(ll a, ll b){
	if(b == 0) return 1;
	else {
		ll x = power(a,b/2);
		x = (x*x)%MOD;
		if(b&1) return (x*a)%MOD;
		else return x;
	}
}
 
 
ll& Mod(ll& a) {
    if (a >= MOD) {
        return Mod(a -= MOD);
    } else if (a < 0) {
        return Mod(a += MOD);
    } else {
        return a;
    }
}
 
ll gcd(ll a, ll b) { 
	// b < a
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
 



int main() {
	fast_cin();	
	
	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b; 
	string u; cin >> u;
	if(u == s) a--;
	if(u == t) b--;
	cout << a << " " << b << '\n';
	
	
	
	
		
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ipy = []

for i in range(m):
    p, y = map(int, input().split())
    ipy.append([i, p, y])

counter = {}
order = {}

for i, p, y in sorted(ipy, key = lambda x: x[2]):
    counter[p] = counter.get(p, 0) + 1
    order[i, p] = counter[p]
    
for i, p, y in ipy:
    print('{:06}{:06}'.format(p, order[i, p]))

Measured memory_bytes: 44484
#include <iostream>
#include <cstring>
#include <cmath>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x

int main(){

  int n, q;
  long long S[10010], T[510];
  int count = 0;

  cin >> n;
  REP( i, n ){
    cin >> S[i];
  }
  cin >> q;
  REP( i, q ){
    cin >>T[i];
  }

  REP( i, q ){
    REP( j, n ){
      if( S[j] == T[i] ){
        count++;
        break;
      }
    }
  }

  cout << count << endl;



  return 0;

}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,v[100],c[100],res=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
   for(int i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(int i=0;i<n;i++)
    {
        if(v[i]>c[i])
            res+=(v[i]-c[i]);
    }
    cout<<res<<endl;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int fi, bi;

int main() {
    char front[200010], back[200020];
    string s;
    int q, t, f;
    char c;
    bool isR = false;
    cin >> s >> q;
    for (int i = 0; i < q; ++i) {
        cin >> t;
        if (t == 1) isR = !isR;
        else {
            cin >> f >> c;
            (f == 1 == isR ? back[bi++] : front[fi++]) = c;
        }
    }
    if (isR) {
        for (int i = bi - 1; i >= 0; --i) cout << back[i];
        for (int i = s.size() - 1; i >= 0; --i) cout << s[i];
        for (int i = 0; i < fi; ++i) cout << front[i];
    } else {
        for (int i = fi - 1; i >= 0; --i) cout << front[i];
        for (int i = 0; i < s.size(); ++i) cout << s[i];
        for (int i = 0; i < bi; ++i) cout << back[i];
    }
    cout << endl;
}


Measured memory_bytes: 1024
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

int main(){
    double L;
    in>>L;
    printf("%.8f",L/3*L/3*L/3);
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

readline = stdin.readline

_, *aa = map(int, open(0).read().split())
r = 0
mi = 1000000000
m = 0
for a in aa:
    if a < 0:
        m += 1
    b = abs(a)
    r += b
    mi = min(b, mi)
print(r - mi * 2 * (m % 2))


Measured memory_bytes: 14116
n,time=input().split()


n=int(n)
time=int(time)

l=[]
ltim=[]
res=[]
restim=[]

for i in range(n):
    p,t=input().split()
    l.append(p)
    ltim.append(int(t))

ot=0
qhead=0
qtail=n

while qhead<qtail:
    cl=l[qhead]
    ct=ltim[qhead]
    if ct<=time:
        ot+=ct
        res.append(cl)
        restim.append(ot)
        qhead+=1
    else:
        ot+=time
        ct-=time
        l.append(cl)
        ltim.append(ct)
        qhead+=1
        qtail+=1


for o in range(n):
    print(res[o],restim[o])


Measured memory_bytes: 17540
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x;
  cin>>n>>x;
  vector<int> v;
  while(n--)
  {
    int h;
    cin>>h;
    v.push_back(abs(x-h));
  }
  if(v.size()==1)
    cout<<v[0]<<"\n";
  else
  {
    int ans = __gcd(v[0],v[1]);
    for(int i=2;i<v.size();i++)
      ans = __gcd(ans,v[i]);
    cout<<ans<<"\n";
  }
  
 return 0; 
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int w, h, n, x, y, a;
    cin >> w >> h >> n;
    vector<int> x_1, x_2, y_1, y_2;
    x_1.push_back(0);
    x_2.push_back(w);
    y_1.push_back(0);
    y_2.push_back(h);
    rep1(i, n){
        cin >> x >> y >> a;
        if (a==1) x_1.push_back(x);
        if (a==2) x_2.push_back(x);
        if (a==3) y_1.push_back(y);
        if (a==4) y_2.push_back(y);
    }
    sort(x_1.begin(), x_1.end());
    sort(x_2.begin(), x_2.end());
    sort(y_1.begin(), y_1.end());
    sort(y_2.begin(), y_2.end());
    int ans = max(x_2[0] - x_1[x_1.size()-1], 0) * max(y_2[0] - y_1[y_1.size()-1], 0); 
    cout << ans << endl;
    //printf("%.12f", ans);
}

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

int main(void){
    int x,y;
    while(true){
        cin >> x;
        cin >> y;
        if(x == 0 && y== 0){
            break; 
        }
    if(x < y){
        cout << x << " " << y << endl;
    }    
    else{
        cout << y << " " << x << endl;
    }
    
        
    }
}



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

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

  int digit_sum = 0;
  int N = n;
  while (n > 0) {
    digit_sum += n % 10;
    n /= 10;
  }

  cout << (N % digit_sum == 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define pii pair <int, int>
#define print(x) for(auto it : x) cout << it << ' ';
#define endl "\n" // TODO: remove
#define int long long

const int N = (1e6) + 322;
const int inf = (int)(2e9);
const int mod = (int)(1e9) + 7; // check modulo

char ch[33][33];

void solve() {
    int n, m, k; cin >> n >> m >> k;
    int all = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            cin >> ch[i][j];
            all += ch[i][j] == '#';
        }
    }
    int ans = 0;
    for(int mask = 0; mask < (1 << n); ++mask) {
        for(int mask1 = 0; mask1 < (1 << m); ++mask1) {
            int cur = 0;
            for(int i = 0; i < n; ++i) {
                for(int j = 0; j < m; ++j) {
                    if (ch[i][j] == '#' && (((mask >> i) & 1) || ((mask1 >> j) & 1))) {
                        cur++;
                    }
                }
            }
            if (all - cur == k) ans++;
        }
    }
    cout << ans;

}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    int test; cin >> test;
//    for(int t = 1; t <= test; ++t) {
        solve();
//    }
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 300010

int main(){
	IOS;
	ld n;cin>>n;
	ld e=1.080000;
	ld z=(ld)(n/(ld)e);
	ll x=(int)z;
	ll ans=-1;
	e=0.080000;
	rep(i,0,x+1000){
		ld j=(ld)i;
		j=j+(ld)(e*j);
		ll t=(int)j;
		if(t==n){ans=i;break;}
	}
	if(ans==-1)cout<<":(";
	else cout<<ans;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;
const int maxN = 12;
const int maxM = 1000 + 5;

int n, m;
int a[maxM], c[maxM];

ll memo[maxM][1 << maxN];
bool calc[maxM][1 << maxN];

ll dp(int i, int bitmask){
    if(i >= m){
        if(bitmask == (1 << n) - 1){
            return 0;
        }
        return INF;
    }

    if(calc[i][bitmask]){
        return memo[i][bitmask];
    }

    ll res = INF;
    res = min(res, dp(i + 1, bitmask));
    res = min(res, dp(i + 1, bitmask | c[i]) + a[i]);

    calc[i][bitmask] = true;
    return (memo[i][bitmask] = res);
}

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

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int b;  cin >> a[i] >> b;
        for(int j = 0; j < b; j++){
            int x;  cin >> x;   x--;
            c[i] |= (1 << x);
        }
    }

    ll ans = dp(0, 0);
    if(ans >= INF){
        cout << "-1\n";
        return 0;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 36096
import bisect

n = int(input())

a = []
for i in range(100):
    s = 0
    for j in range(1, int(((i*2+1)**(0.5)//1)+1)):
        if (i*2+1)%j == 0:
            s += 1
            if int((i*2+1)/j) != j:
                s += 1
    #print(s)
    if s == 8:
        a.append(i*2+1)
        
ans = bisect.bisect_right(a, n)
print(ans)
#print(a)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
  int N=0,A=0,B=0;
  cin >>N >>A >>B;
  int P[N]={};
  
  for(int i=0;i<N;i++){
  		cin >> P[i];
  }
  
  int num[3]={};
  for(int x:P){
  		if(x<=A)	num[0]++;
    	else if(x<=B) num[1]++;
    	else num[2]++;
  }
  
  cout << min(min(num[0],num[1]),num[2]) <<endl;
  
}

Measured memory_bytes: 256
s = int(input())
a = [s]

def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1

count = 0
while True:
    a.append(f(a[count]))
    if f(a[count+1])in(a):
        break
    count += 1

print(count+3)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }


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

int n,A[50];

int solve(int i,int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q,M;
    cin>>n;
    REP(i,n) cin>>A[i];
    cin>>q;
    REP(i,q){
        cin>>M;
        if(solve(0,M)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}


Measured memory_bytes: 3144
#include<iostream>
using namespace std;
struct card{
	char suit,value;
};
void bubble(struct card a[],int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>=i;j--){
			if(a[j].value<a[j-1].value){
				card t=a[j];
				a[j]=a[j-1];
				a[j-1]=t;
			}
		}
	}
}

void selection(struct card a[],int n){
	for(int i=0;i<n;i++){
		int minj=i;
		for(int j=i;j<n;j++){
			if(a[j].value<a[minj].value)
				minj=j;
		}
		card t=a[i];
		a[i]=a[minj];
		a[minj]=t;
	}
}

bool isStable(struct card c1[],struct card c2[],int n){
	for(int i=0;i<n;i++){
		if(c1[i].suit!=c2[i].suit)
			return false;
	}
	return true;
}

void print(struct card a[],int n){
	for(int i=0;i<n;i++){
		if(i==0)
			cout<<a[i].suit<<a[i].value;
		else
			cout<<" "<<a[i].suit<<a[i].value;
	}
	cout<<endl;
}

int main(){
	card c1[100],c2[100];
	int n;
	int ch;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c1[i].suit>>c1[i].value;
		c2[i]=c1[i];
	}
	bubble(c1,n);
	selection(c2,n);
	
	print(c1,n);
	cout<<"Stable"<<endl;
	
	print(c2,n);
	if(isStable(c1,c2,n)){	
		cout<<"Stable"<<endl;
	}else{
		cout<<"Not stable"<<endl;
	}
	
	return 0;
} 


Measured memory_bytes: 3100
nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);
a = input().split(" ");
num = 0;
for i in range(n) :
	a[i] = int(a[i]);
bucket = [0]*max(a);
for i in range(n) :
	bucket[a[i]-1] += 1;
	if bucket[a[i]-1] == 1 :
		num += 1;
bucket.sort();
ans = 0;
j = 0;
for i in range(max(a)) :
	if j >= num -k :
		break;
	if bucket[i] > 0 :
		ans += bucket[i];
		j += 1;
print(ans);

Measured memory_bytes: 19444
#include <iostream>
#include <vector>
#include <queue>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;


int main() {
    int H, W, N, Sr, Sc;
    string S, T;

    cin >> H >> W >> N >> Sr >> Sc >> S >> T;

    int r, c;
    // left
    r = Sr; c = Sc;
    REP (i, N) {
        if (S[i] == 'L') c -= 1;
        if (c <= 0) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'R' && c < W) c += 1;
    }

    // right
    r = Sr; c = Sc;
    REP (i, N) {
        if (S[i] == 'R') c += 1;
        if (c > W) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'L' && c > 1) c -= 1;
    }

    // up
    r = Sr; c = Sc;
    REP (i, N) {
        if (S[i] == 'U') r -= 1;
        if (r <= 0) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'D' && r < H) r += 1;
    }

    // down
    r = Sr; c = Sc;
    REP (i, N) {
        if (S[i] == 'D') r += 1;
        if (r > H) {
            cout << "NO" << endl;
            return 0;
        }
        if (T[i] == 'U' && r > 1) r -= 1;
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 776
//
// Created by Hideaki Imamura on 2020-03-10.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
const ll mod = 1000000007;

inline ll take_mod(ll a) {
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b) {
    return take_mod(a + b);
}

inline ll sub(ll a, ll b) {
    return take_mod(a - b);
}

inline ll mul(ll a, ll b) {
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n) {
    ll res = 1LL;
    while (n > 0) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x) {
    return mod_pow(x, mod - 2);
}

ll fact[400100];
ll invfact[400100];

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll n, k;

int main() {
    cin >> n >> k;
    make_fact(400010);
    make_invfact(400010);

    ll ans = 0;
    for (int i = 0; i <= min(n - 1, k); ++i) {
        ans = add(ans, mul(comb(n, i), comb(n - 1, i)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
int N, P;
long long f[2] = { 1 };
int main()
{
	for (scanf("%d%d", &N, &P); N--; )
	{
		int x;
		scanf("%d", &x);
		if (x & 1)
			f[0] = f[1] += f[0];
		else
			f[0] <<= 1, f[1] <<= 1;
	}
	printf("%lld\n", f[P]);
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  string s;
  cin >> s;
  REP(i,s.length()-1){
    if(s[i]==s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n;
vector<int> m;
vector<vector<int> > to;
vector<int> node;

void dfs()
{
    int k = n;
    node.push_back(k);
    ++ n;

    for(int i=0; i<m[k]; ++i){
        int a;
        cin >> a;
        if(a > 0){
            m.push_back(a-1);
            to[k].push_back(n);
            to.push_back(vector<int>(1, k));
            dfs();
        }else{
            int x = node[node.size()-1+a];
            to[k].push_back(x);
            to[x].push_back(k);
            -- m[x];
        }
    }

    node.pop_back();
}

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

    while(--d >= 0){
        int a;
        cin >> a;

        n = 0;
        m = vector<int>(1, a);
        to = vector<vector<int> >(1);
        dfs();

        for(int i=0; i<n; ++i){
            cout << (i+1);
            sort(to[i].begin(), to[i].end());
            for(unsigned j=0; j<to[i].size(); ++j)
                cout << ' ' << (to[i][j] + 1);
            cout << endl;
        }

        cin >> a;
    }
}

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
struct work{
  ll a;
  ll b;
};
bool comp(const work &a,const work &b){
  return a.b < b.b;
}
int main(){
  __uint128_t tmp;
  ll n,ii,cost;
  vector<work> w;
  ll flg =0;
  cin >> n;

  w.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> w[ii].a >> w[ii].b;
  }

  sort(w.begin(),w.end(),comp);

  cost = 0;
  for(ii=0;ii<n;ii++){
    cost += w[ii].a;
    if(cost > w[ii].b){
      flg = 1;
      break;
    }
  }

  if(flg == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long x=gl();
	    long y=gl();

	    long n=0;
	    if(x>y) {
	    	if(x*y>0) {
	    		n=x-y+2;
	    	} else if(x*y<=0) {
	    		n=1+Math.abs(Math.abs(x)-Math.abs(y));
	    	}
	    } else {
	    	if(x*y>0) {
	    		n=y-x;
	    	} else if(x*y<0) {
	    		n=1+Math.abs(Math.abs(x)-Math.abs(y));
	    	} else {
	    		n=Math.abs(x-y);
	    	}
	    }

        System.out.println(n);

		//System.out.println();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35588
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans = 0;
  if (N % 2) {  // odd
    ans = 0;
  } else {  // even
    ans = N / 10;
    N /= 10;
    while (N) {
      ans += N / 5;
      N /= 5;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n);
    cin>>vec;
    sort(all(vec));
    vp lis(m);
    REP(i,m){
        cin>>lis[i].se>>lis[i].fi;
    }
    sort(all(lis),greater<>());
    int a=0;
    REP(j,m){
        while(vec[a]<lis[j].fi&&lis[j].se){
            vec[a]=lis[j].fi;
            lis[j].se--;
            a++;
        }
    }
    ll ans=0;
    REP(i,n){
        ans+=vec[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: u64 = read();
    for a in 0..n * 3 / 4 + 1 {
        for c in n * 3 / 4..3501 {
            let t1 = n * c * a;
            let t2 = 4 * a * c;
            let t3 = n * (a + c);
            if t2 > t3 && t1 % (t2 - t3) == 0 {
                let b = t1 / (t2 - t3);
                println!("{} {} {}", a, b, c);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
    string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string t;
    cin >> t;
    for(int i = 0; i < 7; i++){
        if(s[i] == t) cout << 7 - i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int key = max(A, max(B, C));
	int sum = (key - A) + (key - B) + (key - C);
	if (sum % 2 == 0) {
		cout << sum / 2 << endl;
	}
	else {
		cout << (sum + 3) / 2 << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
if n==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

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

int main() {
    int x,y,ans = 0;
    cin >> x >> y;
    int hx = 0,lx = 0,hy = 0,ly = 0;
    int a = 0,b = 1,c = 0;
    int count = 0;
    int line;
    while(true){
        if(lx <= x && x <= hx && ly <= y && y <= hy){
            ans = count % 3;
            ans = ans + 1;
            break;
        }
        c = a + b;
        a = b;
        b = c;
        line = count % 4;
        if(line == 0)hx += c;
        if(line == 1)hy += c;
        if(line == 2)lx -= c;
        if(line == 3)ly -= c;
        count += 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n+2);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	a[0] = 0,a[n+1]=0;

	int all=0;
	vector<int> s(n);
	for(int i = 0; i < n+2; i++){
		all += abs(a[i+1]-a[i]);
	}

	for(int i = 1; i <= n; i++){
		cout << all - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

string dfs(ll n) {
    if (n == 0) return "";
    --n;
    return dfs(n/26) + char('a'+n%26);
}

int main() {
    ll n;
    cin >> n;
    cout << dfs(n) << endl;
    return 0;
}


Measured memory_bytes: 3552
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        char[] S = nchars();
        char cur = S[0];
        int count = 1;
        for (int i = 1; i < N; i++) {
            if (S[i] != cur) {
                count++;
                cur = S[i];
            }
        }
        System.out.println(count);
    }
    
    private static int nint() {
        return sc.nextInt();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static int min(int... is) {
        return Arrays.stream(is).min().getAsInt();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static int max(int... is) {
        return Arrays.stream(is).max().getAsInt();
    }

    private static long abs(long a, long b) {
        return Math.abs(a - b);
    }
}


Measured memory_bytes: 27760
fun main(args : Array<String>) {
    val n = readLine()!!.toLong()
    val a = readLine()!!.toLong()
    val b = readLine()!!.toLong()
    val c = readLine()!!.toLong()
    val d = readLine()!!.toLong()
    val e = readLine()!!.toLong()

    val min = listOf(a, b, c, d, e).min()!!

    var rest = n - min
    if (rest <= 0) {
        println(5)
        return
    }

    println(5L + (rest / min) + if (rest % min == 0L) 0L else 1L)
}

Measured memory_bytes: 35868
n,m,q = map(int,input().split())
pairs = []
def makelen(a):
    if len(a) == n:
        pairs.append(a)
    else:
        for i in range(a[-1],m+1):
            makelen(a + [i])
for i in range(m):
    makelen([i+1])
Query = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for pair in pairs:
    tmpans = 0
    for a,b,c,d in Query:
        if pair[b-1] - pair[a-1] == c:
            tmpans += d
    ans = max(tmpans,ans)
print(ans)

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

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i*i <= n; i++){
        if(n%i) continue;
        ll a = i, b = n/i;
        if(b-1 > a) ans += b-1;
        if(a-1 > b) ans += a-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

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

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll l = 1;
	rep(i,n){
		ll t;
		cin >> t;
		l = lcm(l, t);
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int N;
ll x[100002];

ll dfs(int p, ll c){
    if(N <= p){
        return c;
    }
    if(x[p] == x[p-1] + 1){
        x[p] -= 1;
        //cout << p << " " << c * dfs(p+1, 1) + c * dfs(p+1, c-1) << endl;
        // cout << p << " " << dfs(p+1, 1) << " " << dfs(p+1, c) << endl;
        return (c * dfs(p+1, c)) % MOD;
    }else{
        x[p] = x[p-1] + 2;
        return (c * dfs(p+1, c+1)) % MOD;
    }
}


int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> x[i];
    }

    x[0] = -1;
    x[1] = 1;
    cout << dfs(2, 2) << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;
 
int main(void){
  double r, v, s;
  cin >> r;
  v = r * r * M_PI;
  s = 2 * r * M_PI; 
  cout << fixed;
  cout << setprecision(6)<< v << " " << s << endl;
  return 0;
}


Measured memory_bytes: 3200
using System;
class Program
{
    static void Main()
    {
        long g = long.Parse(Console.ReadLine());
        int cnt=0;
        long m = 100;
        for(; ; )
        {
            cnt++;
            m =(long)(m * 1.01);
            if (m >= g) break;
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
const int mod = 1e9 + 7;
const int K = 26;

int32_t main()
{   
    fastio;
    
    string s, t; cin >> s >> t;
    if(s == t.substr(0,t.size()-1)){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;
vector<bool> visited;
vector<vector<int>> g;
vi ans;


int main(){
	ll n, m; cin >> n >> m;
	visited = vector<bool> (n, false);
	ans = vi(n,-1);
	g = vector<vi> (n);
	rep(i, m) {
		int a, b; cin  >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<pi> q;
	q.emplace(-1, 0);
	while(!q.empty()) {
		pi p = q.front(); q.pop();
		int u = p.first;
		int v = p.second;
		if(visited[v]) continue;

		visited[v] = true;
		ans[v] = u;
		for(auto x : g[v]){
			q.emplace(v, x);
		}
	}

	for (int i = 1; i < n; i++){
		if(ans[i] == -1){
		cout << "No";
		return 0;
		}	
	}
	cout << "Yes"<< endl;
	for (int i = 1; i < n; i++){
		cout << ans[i]+1 << endl;
	} 
}

Measured memory_bytes: 12204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int count = 0;

  for (int i = 0; i < s.length(); i++){
    if(s[i] == '1' && s[i+1] == '1'){
      s[i + 1] = '0';
      count++;
    }
    else if (s[i] == '0' && s[i + 1] == '0'){
      s[i + 1] = '1';
      count++;
    }
  }
  cout << count << "\n";
  return 0;
}

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

int main(void){
    
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0;
    for(int i = 0; i < N-2; i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
            ans++;
            i+=2;
        }
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int H[100000];
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  scanf("%d",&n);
  for(int i = 0; i < n; i++)scanf("%d",&H[i]);
  bool can = true;
  int now = -1; 
  for(int j = 0; j < n; j++){
    if(now > H[j])can = false;
    else if(now < H[j])now = H[j] - 1;
    else now = H[j];
  }
  if(can)printf("Yes");
  else printf("No");
  return 0;
} 

Measured memory_bytes: 640