akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define N 100010
#define MOD 1000000007
#define LL long long
int x[N],n,m;
bool vis[N];
struct node
{
	LL a[3][3];
}A,C,a,b,c,tmp;
int f[3],g[3];
node Mul(node res,node X,node Y)
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			tmp.a[i][j]=0;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				tmp.a[i][j]=(tmp.a[i][j]+X.a[i][k]*Y.a[k][j]%MOD)%MOD;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			res.a[i][j]=tmp.a[i][j];
	return res;
}
void Pow(int X)
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			c.a[i][j]=C.a[i][j];
	while(X)
	{
		if(X&1) a=Mul(a,a,c);
		c=Mul(c,c,c);
		X>>=1;
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&x[i]);
	memset(A.a,0,sizeof(A.a));
	memset(C.a,0,sizeof(C.a));
	A.a[0][0]=A.a[1][1]=A.a[2][2]=A.a[1][2]=A.a[0][2]=1;
	A.a[0][1]=2;
	C.a[0][2]=C.a[1][0]=C.a[1][1]=C.a[1][2]=C.a[2][0]=C.a[2][2]=1;
	C.a[0][0]=C.a[0][1]=2;
	f[0]=1;
	x[++m]=n;
	for(int l=1,pos=0;l<=m;l++)
	{
		int k=x[l]-pos-1;
		memset(b.a,0,sizeof(b.a));
		memset(a.a,0,sizeof(a.a));
		for(int i=0;i<3;i++)
			a.a[i][i]=1;
		if(k) Pow(k);
		b=Mul(b,a,A);
		for(int i=0;i<3;i++)
		{
			g[i]=0;
			for(int j=0;j<3;j++)
				g[i]=(g[i]+f[j]*b.a[j][i]%MOD)%MOD;
		}
		for(int i=0;i<3;i++)
			f[i]=g[i];
		pos=x[l];
	}
	printf("%d\n",f[2]);
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 300005;

LL b[N], f[N], g[N], h[N], s[N], y[N], pre[N], suf[N];
int n, m, top, q[N], t[N];

inline void DP(LL *f) {
  q[top = 1] = 0;
  for (int i = 1; i <= n; ++i) {
    s[i] = s[i - 1] + t[i];
    for (; top > 1 && y[q[top]] - y[q[top - 1]] <= 1LL * i * (q[top] - q[top - 1]); --top);
    f[i] = max(f[i - 1], f[q[top]] - s[i] + s[q[top]] + (1LL * (i - q[top]) * (i - q[top] + 1) >> 1));
    y[i] = f[i] + s[i] + (1LL * i * (i - 1) >> 1);
    for (; top > 1 && (y[i] - y[q[top]]) * (q[top] - q[top - 1]) >= (y[q[top]] - y[q[top - 1]]) * (i - q[top]); --top);
    q[++top] = i;
  }
}

inline void Solve(int l, int r, LL *pre, LL *suf, LL *f) {
  if (l == r) {
    f[l] = 1 - t[l];
    return ;
  }
  int mid = l + r - 1 >> 1;
  Solve(l, mid, pre, suf, f), Solve(mid + 1, r, pre, suf, f), top = 0;
  for (int i = l - 1; i < mid; ++i) {
    y[i] = pre[i] + s[i] + (1LL * i * (i - 1) >> 1);
    for (; top > 1 && (y[i] - y[q[top]]) * (q[top] - q[top - 1]) >= (y[q[top]] - y[q[top - 1]]) * (i - q[top]); --top);
    q[++top] = i;
  }
  for (int i = mid + 1; i <= r; ++i) {
    for (; top > 1 && y[q[top]] - y[q[top - 1]] <= 1LL * i * (q[top] - q[top - 1]); --top);
    b[i] = pre[q[top]] - s[i] + s[q[top]] + (1LL * (i - q[top]) * (i - q[top] + 1) >> 1) + suf[i + 1];
  }
  for (int i = r - 1; i > mid; --i) {
    CheckMax(b[i], b[i + 1]);
  }
  for (int i = mid + 1; i <= r; ++i) {
    CheckMax(f[i], b[i]);
  }
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 1; i <= n; ++i) {
    Read(t[i]);
  }
  DP(f), reverse(t + 1, t + n + 1);
  DP(g), reverse(t + 1, t + n + 1), reverse(g + 1, g + n + 1);
  for (int i = 1; i <= n; ++i) {
    s[i] = s[i - 1] + t[i];
  }
  Solve(1, n, f, g, pre), reverse(t + 1, t + n + 1), reverse(f + 1, f + n + 1), reverse(g + 1, g + n + 1);
  for (int i = 1; i <= n; ++i) {
    s[i] = s[i - 1] + t[i];
  }
  Solve(1, n, g, f, suf), reverse(t + 1, t + n + 1), reverse(f + 1, f + n + 1), reverse(g + 1, g + n + 1), reverse(suf + 1, suf + n + 1);
  Read(m);
  for (int i = 1, p, x; i <= m; ++i) {
    Read(p), Read(x), printf("%lld\n", max(f[p - 1] + g[p + 1], max(pre[p], suf[p]) - x + t[p]));
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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

int main() {
  ll a,b,c,k,ans=0;
  cin >> a>>b>>c>>k;
  b=a+b;
  c=b+c;
  rep(i,k){
    if(i<a){
      ans+=1;
    }else if(i<b){
    }else{
      ans-=1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

struct Node {
  int depth;
  bool done;
  vector<Node *> parents;
  vector<Node *> children;
};

vector<Node *> roots;

void find_root(Node *n) {
  if (!n->done) {
    n->done = true;
    if (n->parents.size() == 0) {
      roots.push_back(n);
    } else {
      for (Node *pt : n->parents) {
        find_root(pt);
      }
    }
  }
}

int get_depth(Node *n) {
  if (n->depth > 0) {
    return n->depth;
  }
  int max_ = 0;
  for (Node *pt : n->children) {
    max_ = max(max_, get_depth(pt) + 1);
  }
  return n->depth = max_;
}

void solve(long long N, long long M, std::vector<long long> x,
           std::vector<long long> y) {
  vector<Node> nodes(N, {-1, false, vector<Node *>(0), vector<Node *>(0)});
  REP(i, M) {
    nodes[x[i] - 1].children.push_back(&(nodes[y[i] - 1]));
    nodes[y[i] - 1].parents.push_back(&(nodes[x[i] - 1]));
  }
  REP(i, N) { find_root(&nodes[i]); }
  int max_ = 0;
  for (Node *pt : roots) {
    pt->depth = 0;
    max_ = max(max_, get_depth(pt));
  }
  std::cout << max_ << std::endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> x(M);
  std::vector<long long> y(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, M, std::move(x), std::move(y));
  return 0;
}


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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000000000000000

int main()
{
	FASTIO;
	ll n,i,mul=1,flag=0;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
    {
        cin>>a[i];
   }

    for(i=0;i<n;i++)
    {
        if(a[i]==0)
        {
            cout<<0<<"\n";
            flag=1;
            break;
        }
   }

if(flag==0)
{

    for(i=0;i<n;i++)
    {

        if(a[i ] >(1000000000000000000/ mul))
            {
            cout<<-1<<"\n";
            flag=1;
            break;
            }
            else
            mul=mul*a[i];

    }
}
    if(flag==0)
            cout<<mul<<"\n";

}


Measured memory_bytes: 4416
#include<stdio.h>
#include<math.h>

int main(void){
	double x1=0.0, y1=0.0;
	double x2=0.0, y2=0.0;
	double ans=0.0;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	ans = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
	printf("%lf\n", ans);

	return 0;
}

Measured memory_bytes: 648
n=int(input())
if n==100000:print(90909)
elif 9999<n and n<100000:print(n-9090)
elif 999<n and n<10000:print(909)
elif 99<n and n<1000:print(n-90)
elif 9<n and n<100:print(9)
else:print(n)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    ll L[87] = {2, 1};
    cin >> N;
    FOR(i, 2, N + 1, 1) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader input = null;

    static {
        input = new BufferedReader(new InputStreamReader(System.in));
    }

    public static void main(String ar[]) throws IOException {
        String nk[] = input.readLine().split(" ");
        int k = Integer.parseInt(nk[1]) - 1;
        char str[] = input.readLine().toCharArray();
        str[k] = (char) (str[k] - ('A' - 'a'));
        System.out.println(String.valueOf(str));
    }
}


Measured memory_bytes: 22228
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 2*1e6 , limit = 9*1e18 , MOD=1e9+7;
string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}
int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    int n,k;
    cin>>n>>k;
    vector<int>v;
    for(int i =0 ; i < n; i ++ ){
        int x;cin>>x;
        v.pb(x);
    }
    sort(all(v));
    int res =0 ;
    for(int i = 0 ; i < k ; i++ )res+=v[i];
    cout<<res<<endl;
}


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


void solve(long long A, long long B, long long C, long long K){
    if (K<=A) printf("%lld\n",K);
    else if (K <= A+ B) printf("%lld\n",A);
    else printf("%lld\n",A-(K-A-B)); 

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;

    int a[200];
    rep(i, n){
        cin >> a[i];
    }

    int count = 0;
    int flag = 0;
    while(flag == 0) {
        rep(i, n){
            if(a[i] % 2 == 0){
                a[i] /= 2;
            }
            else{
                flag = 1;
                break;
            }
        }
        count++;
    }
    cout << count - 1;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct data{
	int bit;
	int cost;
	int v;
	data(){}
	data(int vv,int bb,int cc){
		v=vv;
		cost=cc;
		bit=bb;
	}
	bool operator<(const data &dat)const{
		return cost>dat.cost;
	}
};

int n,x,y;
int dp[1<<14][14];
int dp2[14][1001];
int dp3[1<<14][1001];
int dp4[1<<14][1001];
int tmp[1001][1001];
int tmp2[1001];
int tmp3[15][1001];
int dist[14][14];
int a[14][301],b[14][301],c[14][301];

void dijk(){
	priority_queue<data> que;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			dp[i][j]=100000;
		}
	}
	dp[1][0]=0;
	que.push(data(0,1,0));
	while(que.size()){
		data d=que.top();
		que.pop();
		if(dp[d.bit][d.v]<d.cost)continue;
		for(int nec=0;nec<n;nec++){
			int nbit=d.bit|(1<<nec);
			int ncost=d.cost+dist[d.v][nec];
			if(ncost<dp[nbit][nec]){
				dp[nbit][nec]=ncost;
				que.push(data(nec,nbit,ncost));
			}
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&x,&y);
	for(int i=0;i<n;i++){
		int k;
		scanf("%d",&k);
		for(int j=0;j<k;j++){
			scanf("%d%d%d",&a[i][j],&b[i][j],&c[i][j]);
		}
		memset(tmp,0,sizeof(tmp));
		for(int j=0;j<k;j++){
			memset(tmp3,0,sizeof(tmp3));
			for(int cs=0;cs<=y;cs++){
				tmp3[0][cs]=tmp[j][cs];
			}
			int cnt2=0;
			for(int ncs=0;ncs<=10;ncs++){
				int cs=min(c[i][j],(int)(1<<ncs));
				c[i][j]-=cs;
				cnt2++;
				for(int l=0;l<=y;l++){
					tmp3[cnt2][l]=max(tmp3[cnt2][l],tmp3[cnt2-1][l]);
					if(l+cs*a[i][j]>y)continue;
					tmp3[cnt2][l+cs*a[i][j]]=max(tmp3[cnt2][l+cs*a[i][j]],tmp3[cnt2-1][l]+b[i][j]*cs);
				}
			}
			for(int l=0;l<=y;l++){
				tmp[j+1][l]=tmp3[cnt2][l];
			}
			
		}
		for(int j=0;j<=y;j++){
			dp2[i][j]=tmp[k][j];
		}
		for(int j=1;j<=y;j++){
			dp2[i][j]=max(dp2[i][j],dp2[i][j-1]);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&dist[i][j]);
		}
	}
	dijk();
	for(int i=0;i<n/2;i++){
		for(int j=0;j<(1<<i);j++){
			for(int k=0;k<=y;k++){
				for(int l=k;l<=y;l++){
					dp3[j|(1<<i)][l]=max(dp3[j|(1<<i)][l],dp3[j][k]+dp2[i][l-k]);
				}
			}
		}
	}
	for(int i=0;i<(n+1)/2;i++){
		for(int j=0;j<(1<<i);j++){
			for(int k=0;k<=y;k++){
				for(int l=k;l<=y;l++){
					dp4[j|(1<<i)][l]=max(dp4[j|(1<<i)][l],dp4[j][k]+dp2[n/2+i][l-k]);
				}
			}
		}
	}
	for(int i=0;i<(1<<(n/2));i++){
		for(int j=1;j<=y;j++){
			dp3[i][j]=max(dp3[i][j],dp3[i][j-1]);
		}
	}
	for(int i=0;i<(1<<((n+1)/2));i++){
		for(int j=1;j<=y;j++){
			dp4[i][j]=max(dp4[i][j],dp4[i][j-1]);
		}
	}
	int res=0;
	for(int i=0;i<(1<<n);i++){
		int yosan=0;
		int bit1=0;
		int bit2=0;
		for(int bit=n-1;bit>=0;bit--){
			bit1*=2;
			if(bit>=n/2)bit2*=2;
			if(i>>bit & 1){
				if(bit<n/2){
					bit1++;
				}else{
					bit2++;
				}
			}
		}
		for(int j=0;j<n;j++){
			yosan=max(yosan,x-dp[i][j]-dist[j][0]);
		}
		yosan=min(y,yosan);
		for(int j=0;j<=yosan;j++){
			res=max(res,dp3[bit1][j]+dp4[bit2][yosan-j]);
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 9112
n = int(input())
b = list(map(int, input().split()))
a = []
for i in range(n):
    #print(i)
    if i == 0:
        a.append(b[i])
        continue
    if i == n - 1:
        a.append(b[i - 1])
        continue
    maxb = min(b[i - 1], b[i])
    a.append(maxb)
print(sum(a))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;

const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct Edge{
  int src,dst,wei;
  Edge(int s=0,int d=0,int w=0):src(s),dst(d),wei(w){}
};
using Graph = vector<vector<Edge>>;

vector<int> Toposort(Graph&g){
  int v=g.size(),k=0;
  vector<int> res(v),in(v);
  for(int i=0;i<v;i++){
    for(int j=0;j<g[i].size();j++){
      Edge x=g[i][j];
      in[x.dst]++;
    }
  }
  queue<int> q;
  for(int i=0;i<v;i++){
    if((in[i]==0))q.push(i);
  }
  while(!q.empty()){
    int u=q.front();
    q.pop();
    res[k++]=u;
    for(int i=0;i<g[u].size();i++){
      Edge &e=g[u][i];
      in[e.dst]--;
      if(in[e.dst]==0)q.push(e.dst);
    }
  }
  return res;
}



signed main(){
  int v,e;
  cin>>v>>e;
  Graph g(v);
  rep(i,e){
    int s,t;
    cin>>s>>t;
    g[s].pb(Edge(s,t,0));
  }
  vector<int> ans=Toposort(g);
  rep(i,v){
    cout<<ans[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 4752
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	string s;
	int a;
	cin >> a;
	cin >> s;
	if (a < 3200)
	{
		cout << "red";
	}
	else
	{
		cout << s;
	}
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(" ").map { it.toLong() }
    
    var min = 2019.toLong()
    for (i in l until r) {
        for (j in l + 1..r) {
            val ijmod = (i * j) % 2019
            if (ijmod==0.toLong()) {
                println(ijmod)
                return
            }
            if (ijmod < min) min = ijmod
        }
    }
    println(min)
}


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

int main(){
  int n,k; cin >> n >> k;
  vl a(n);
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  vl s(n+1); rep(i,n) s[i+1] = (s[i] + a[i])%k;

  map<ll,int> C;
  queue<int> q;
  ll ans = 0LL;
  rep(i,n+1) {
    ans += C[s[i]];
    C[s[i]]++;
    q.push(s[i]);
    // 長さが k 以上隔てたペアはカウントしないようにする
    if(q.size() == k){
      C[q.front()]--;
      q.pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	const int n = 5;
	vector<int> x(n);
	for( auto &k : x ) cin >> k;
	for( int i = 0; i < n; ++i ){
		if( x[i] == 0 ){
			cout << i+1 << endl;
		}
	}
}


Measured memory_bytes: 3616
#include <stdio.h>

int main() {
    int k,a,b;
    scanf("%d\n%d %d",&k,&a,&b);
    for(int i=a;i<=b;i++){
        if(i%k==0) {printf("OK"); break;}
    
    
    if(i==b) printf("NG");
    }
    return 0;
}

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

int main() {
	int a,b,c,n,ch;
	while(1){
	cin >> a >> b >> c ;
	if(a==0){return 0;}
	int ok[301]={};
	int t[3][1000]={};
	int tr[1000]={};
	cin >> n;
	int j=0;
	for(int i=0;i<n;i++){
		cin >> t[0][j] >> t[1][j] >> t[2][j] >> tr[j];
		if(tr[j]){
			ok[t[0][j]]=1;ok[t[1][j]]=1;ok[t[2][j]]=1;
		}else{
			j++;
		}
	}
	do{
		ch=0;
		for(int i=0;i<j;i++){
			for(int k=0;k<3;k++){
				if(ok[t[k][i]]==0&&ok[t[(k+1)%3][i]]==1&&ok[t[(k+2)%3][i]]==1){
					ok[t[k][i]]=2;ch=1;
				}
			}
		}
	}while(ch);
	for(int i=1;i<=a+b+c;i++){
		cout << 2-ok[i] <<endl;
	}
	}
}

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

int main(){
	
	int a,b;
	
	cin >> a >> b;
	
	if (a < b){
		cout << "a < b" << endl;
	}
	
	else if (a == b){
		cout << "a == b" << endl;
	}
	
	else {
		cout << "a > b" << endl;
	}
	
	
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
const ll inf = 1LL<<58;
map<int, ll> mem[N];
ll a[N];

ll dp(int ind, int k){
	if(k == 0)return 0;
	if(ind + 1 < 2*k)return -inf;
	if(ind == 1)return a[1];
	if(mem[ind].find(k) != mem[ind].end())return mem[ind][k];
	ll ret = dp(ind - 1, k);
	if(k == 1)ret = max(ret, a[ind]);
	if(ind > 2 && k > 1)ret = max(ret, dp(ind - 2, k - 1) + a[ind]);
	if(ind > 3 && k > 1)ret = max(ret, dp(ind - 3, k - 1) + a[ind]);
	if(ind > 4 && k > 1)ret = max(ret, dp(ind - 4, k - 1) + a[ind]);
	// cout<<ind<<" "<<k<<" "<<ret<<endl;
	return mem[ind][k] = ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	for(int i = 1; i <= n; i++){
		cin>>a[i];
	}
	cout<<dp(n, n/2)<<endl;

	return 0;
}

Measured memory_bytes: 41148
def pr(A,n):
    for i in range(n):
        if i!=n-1:
            print(A[i],end=" ")
        else:
            print(A[i])

def insertionSort(A,N):
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        pr(A,n)

n=int(input())
A=input().split()
A=[int(i)for i in A]
pr(A,n)
insertionSort(A,n)



Measured memory_bytes: 5984
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  int n;
  cin>>n;
  vector<int> c(n+1),cnt(n+1,0);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>c[i+1];
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int t,x,d;
    cin>>t>>x>>d;
    if(t==1)cnt[x]+=d;
    else cnt[x]-=d;
    if((cnt[x]<0||c[x]<cnt[x])&&ans==0){
	 ans=x;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include<string>

using namespace std;

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

    for(int i = 0;i<s.size();i++){
        if(s.at(i) == 'I'){
            x++;
        }
        else{
            x--;
        }
        ans = max(ans,x);
    }

    cout<<ans;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N; i++)  cin >> v[i];
    sort(v.begin(), v.end());
    int half = N/2 -1;
    if(v[half] == v[half+1]){
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for(int i = v[half]; i < v[half+1]; i++){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
mod = 10**9+7
ans = 0
fac = [1, 1] + [0]*(N-1)
finv = [1, 1] + [0]*(N-1)
inv = [1, 1] + [0]*(N-1)


def cmbInit():
    for i in range(2, N+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod


def cmb(n, r):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        return fac[n] * (finv[r]*finv[n-r] % mod) % mod


cmbInit()

for i in range(N-1, K-2, -1):
    ans = (ans + (A[i]-A[N-1-i]) * cmb(i, K-1)) % mod

print(ans)


Measured memory_bytes: 19668
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int n,k; cin >> n >> k;
  vector<int> a(n,0);
  rep(i,n){ cin >> a[i]; }
  sort(a.rbegin(),a.rend());
  int ans=0;
  rep(i,k){ ans += a[i];}
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

int n;
ll ap, an = INT_MIN, ip = 0x7fffffff, in = 0x7fffffff;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    chmax(ap, x+y);
    chmax(an, x-y);
    chmin(ip, x+y);
    chmin(in, x-y);
  }
  cout << max(ap-ip, an-in) << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
constexpr long long INF = (1LL<<60);
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

auto Warshall_Floyd(vector<vector<ll>>& dist){
  ll v = dist.size();
  rep(i,v)dist[i][i]=0LL;
  rep(i,v)rep(j,v)rep(k,v){
    if(dist[j][i]==INF||dist[i][k]==INF)continue;
    chmin(dist[j][k],dist[j][i]+dist[i][k]);
  }
  bool negative_cycle=false;
  rep(i,v)rep(j,v)rep(k,v){
    if(dist[j][i]==INF||dist[i][k]==INF)continue;
    if( chmin(dist[j][k],dist[j][i]+dist[i][k]) ){
      negative_cycle=true;
    }
  }
  return negative_cycle;
}

void solve(){

  ll v,e;
  cin>>v>>e;

  vector<vector<ll>> dist (v,vector<ll>(v,INF));

  rep(i,e){
    ll u,v,w;
    cin>>u>>v>>w;
    chmin(dist[u][v],w);
  }

  bool negative_cycle=Warshall_Floyd(dist);

  if(negative_cycle)puts("NEGATIVE CYCLE");
  else{
    rep(i,v){
      rep(j,v){
        if(dist[i][j]==INF)cout<<"INF"<<(j+1==v?"\n":" ");
        else cout<<dist[i][j]<<(j+1==v?"\n":" ");
      }
    }
  }

}

main(){
  solve();
}


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

int n;
int a[110];


int main(){
    //freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0); cin.tie(0);
    while(cin >> n){
        int sum = 0;
        for(int i = 0;i < n; ++i) {
            cin >> a[i];
            sum += a[i];
        }
        int idx = 0, minn = abs(sum - n*a[0]);
        for(int i = 1;i < n; ++i){
            if(abs(sum - n*a[i]) < minn){
                minn = abs(sum - n*a[i]);
                idx = i;
            }
        }
        cout << idx << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=1000005;
long long val[N<<1],inc[N<<1];
long long powTen[N],preTen[N];
void pushUp(int u,int len){
	val[u]=(val[u<<1]+val[u<<1|1]*powTen[len])%mod;
}
void pushDown(int u,int len1,int len2){
	if(inc[u]){
		val[u<<1]=inc[u]*preTen[len1-1]%mod;
		val[u<<1|1]=inc[u]*preTen[len2-1]%mod;
		inc[u<<1]=inc[u];
		inc[u<<1|1]=inc[u];
		inc[u]=0;
	}
} 
void update(int u,int l,int r,int x,int y,int d){
	if(x<=l&&r<=y){
		inc[u]=d;
		val[u]=d*preTen[r-l]%mod;
		return;
	}
	int mid=l+r>>1;
	pushDown(u,mid-l+1,r-mid);
	if(x<=mid)update(u<<1,l,mid,x,y,d);
	if(y>mid)update(u<<1|1,mid+1,r,x,y,d);
	pushUp(u,mid-l+1);
}
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	powTen[0]=preTen[0]=1;
	for(int i=1;i<=n;i++){
		powTen[i]=powTen[i-1]*10%mod;
		preTen[i]=(preTen[i-1]+powTen[i])%mod;
	}
	update(1,1,n,1,n,1); 
	while(q--){
		int l,r,d;
		scanf("%d%d%d",&r,&l,&d);
		update(1,1,n,n-l+1,n-r+1,d);
		printf("%lld\n",val[1]);
	}
	return 0;
} 

Measured memory_bytes: 15124
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main(args: Array<String>) {
    val n = readInt()
    val a = readInts()
    var current = 1
    var result = 0
    for(ai in a) {
        if(ai == current) {
            result++
            current++
        }
    }
    println(if (result > 0)  n-result else -1)
}

Measured memory_bytes: 82992
#include <stdio.h>

int main(){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", (a + b) > (b + c) ? ((b + c) > (c + a) ? (c + a) : (b + c)) : ((a + b) > (c + a) ? (c + a) : (a + b)));

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int R[n];
    for(int i = 0; i < n; ++i)
        cin >> R[i];
    
    int mini = R[0];
    int maxi = R[1] - R[0];
    for(int i = 1; i < n; ++i){
        maxi = max(maxi, R[i] - mini);
        mini = min(mini, R[i]);
    }
    cout << maxi << endl;
    return 0;
}

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

#define ll long long

ll int dp[105][100005];
int val[105];
int wgt[105];

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

  for(int i=1;i<=n;i++)
    cin>>wgt[i]>>val[i];

  for(int i=1;i<=n;i++)
  {
      dp[i][wgt[i]] = val[i];
      for(int j=1;j<=w;j++)
      {
        dp[i][j] = max(dp[i][j], dp[i-1][j]);
        if(j - wgt[i] > 0 && dp[i-1][j-wgt[i]] > 0)
          dp[i][j] = max(dp[i][j], dp[i-1][j-wgt[i]] + val[i]);

        dp[i][j] = max(dp[i][j], dp[i][j-1]);
      }
  }

  cout<<dp[n][w]<<endl;

  return 0;
}


Measured memory_bytes: 79360
#include <stdio.h>
int main(void){
    int a,b,c;
    int flg=0;
    scanf("%d %d %d",&a,&b,&c);

    if(a+b==c){
        flg=1;
    }
    if(b+c==a){
        flg=1;
    }
    if(c+a==b){
        flg=1;
    }

    if(flg==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int d,n;
    cin>>d>>n;

    if(n==100){
        n++;
    }

    if(d==0){
        cout<<n<<endl;
    }
    else{
        cout<<(long long)(pow(100,d)*n)<<endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=(l),i##end=(r);i<=i##end;i++)
#define Fordown(i,r,l) for(int i=(r),i##end=(l);i>=i##end;i--)
using namespace std;
typedef long long ll;
const int INF=1e9;
const int N=2e5+10;
ll sum[N];
map <ll,int> mp;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int n=read();
	ll ans=0;
	mp[0]++;
	For(i,1,n)sum[i]=(ll)read()+sum[i-1],ans+=(ll)mp[sum[i]],mp[sum[i]]++;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 14336
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    b = (Y - 2 * X) / 2
    a = X - b


    if b % 1 == 0 and a % 1 == 0 and a >=0 and b>=0:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#include <stdio.h>

int main(void){
	long a, b, i;
	while(scanf("%ld %ld", &a, &b) != EOF){
		if(a>b){
			long tmp=a;
			a=b;
	 		b=tmp;
	 	}
	 	
	 	long max = 1;
	 	for(i=2; i<=a; i++) {
	 		if(a%i==0 && b%i==0) max=i;
	 	}
	 	
		printf("%ld\n", max);
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;

int gcd(int a, int b){
    if (a < b) swap(a, b);
    return b? gcd(b, a%b): a;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi l(n), r(n);
    l[0] = a[0];
    for (int i=1;i<n;i++){
        l[i] = gcd(l[i-1], a[i]);
    }

    r[n-1] = a[n-1];
    for (int i=n-2;i>=0;i--){
        r[i] = gcd(r[i+1], a[i]);
    }

    vi gcd_list(n);
    rep(i, n){
        if (i==0){
            gcd_list[i] = r[i+1];
        }else if (i==n-1){
            gcd_list[i] = l[i-1];
        }else{
            gcd_list[i] = gcd(l[i-1], r[i+1]);
        }
    }
    int ans = 0;
    rep(i, n) ans = max(gcd_list[i], ans);
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn=3e5+100;
int l[maxn],r[maxn];
char s[maxn];
int n;
int main()
{
    while(~scanf("%d",&n))
    {
        scanf("%s",s+1);
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        for(int i=2;i<=n;i++)
            if(s[i-1]=='W')
                l[i]=l[i-1]+1;
            else
                l[i]=l[i-1];
        for(int i=n-1;i>=1;i--)
            if(s[i+1]=='E')
                r[i]=r[i+1]+1;
            else
                r[i]=r[i+1];
        int ans=1e9;
        for(int i=1;i<=n;i++)
            //cout<<l[i]<<" "<<r[i]<<endl;
            ans=min(ans,l[i]+r[i]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2944
import math
N =int(input())
S = input()
# S = "".join(["BWWB" for i in range(25*10**3)])
N = len(S)//2
MOD = 10**9+7

L,R = 1,0
r = []
if S[0] != "B":
    print(0)
    exit()
r.append(L)

for i in range(1,len(S)):
    if S[i]!=S[i-1]:
        r.append(r[-1])
    else:
        r.append(1-r[-1])
if sum(r) != N or r[-1] != R:
    print(0)
    exit()

lc = 0
c = 1
for rr in r:
    if rr == R:
        c = (c*lc)%MOD
        lc -=1
    else:
        lc += 1
print((c*math.factorial(N) )%MOD)



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

int main() {
  int N,M,A,B;
  cin >> N>>M;
  vector<int> V(N);
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for(int i=0;i<M;i++){
    cin >>A>>B;
    if(V.at(A-1)>V.at(B-1)){W.at(B-1)=1;}
    else if(V.at(A-1)==V.at(B-1)){W.at(A-1)=1;W.at(B-1)=1;}
    else{W.at(A-1)=1;}
  }
  int cnt=0;
  for(int i=0;i<N;i++){if(W.at(i)!=1)cnt++;}
  cout<<cnt<<endl;
}


Measured memory_bytes: 4000
/**
 * Created by ko_ji on 2017/09/10.
 */

import java.util.Scanner;
import java.util.Arrays;

class Main{
    public static void main(String args[]){
        int A[] = new int[3];

        Scanner sc = new Scanner(System.in);
        A[0] = sc.nextInt();
        A[1] = sc.nextInt();
        A[2] = sc.nextInt();

        Arrays.sort(A);

        System.out.println(A[0] + A[1]);

    }
}

Measured memory_bytes: 23508
#include<iostream>
using namespace std;
int N,A,B;
int X[3<<17];
main()
{
	cin>>N>>A>>B;
	for(int i=0;i<=N-A;i++)
	{
		if((N-i+A-1)/A+i==B)
		{
			for(int j=0;j<i;j++)X[N-j-1]=j+1;
			int id=0,t=N;
			while(id*A<N)
			{
				for(int j=A;j--;)
				{
					if(id*A+j<N&&X[id*A+j]==0)X[id*A+j]=t--;
				}
				id++;
			}
			for(int j=0;j<N;j++)cout<<X[j]<<(j==N-1?"\n":" ");
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 3328
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

dic = [0]*(N+1)
ans = 0
for i in range(1, N+1):
    for j in range(i, N+1, i):
        dic[j]+=1
    ans += i*dic[i]
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  reverse(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if(i != 0)cout << " ";
    cout << a[i];
  }
  cout << endl;
}


Measured memory_bytes: 3104
#include <stdio.h>
int main (int argc, char * argv[])
{
    int W,H,x,y,r,f;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
//    int w,h,x,y,r,f;
//
//    printf("W H x y r=");
//    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

    f=0;
    if(x+r>W)f=1;
    if(y+r>H)f=1;
    if(r>x)f=1;
    if(r>y)f=1;

    if(f==0)printf("Yes\n");
    else printf("No\n");

    return 0;
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i+=2) {
    int tot = 0;
    for (int j = 1; j <= i; j++) {
      if (i%j==0) tot++;
    }
    if (tot==8) ans++;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();

		if (input.indexOf("N") == -1) {
			if (input.indexOf("S") != -1) {
				System.out.println("No");
				return;
			}

		} else {
			if (input.indexOf("S") == -1) {
				System.out.println("No");
				return;
			}
		}

		if (input.indexOf("E") == -1) {
			if (input.indexOf("W") != -1) {
				System.out.println("No");
				return;
			}
		} else {
			if (input.indexOf("W") == -1) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");

	}
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll big = 1000000007;
const ll mod = 998244353;

ll n,m,k,T;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c;
    ll ans = 0;
    ll r = 10000;
    cin >> n;
    ll prev = -1;
    for(int c1 = 0; c1 < n; c1++){
        cin >> a;
        if(a == prev){
            a = r;
            r--;
            ans++;
        }
        prev = a;
    }
    cout << ans << "\n";
    return 0;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;


void go(int n)
{
	int ans = 0;
	lop(i, 1, n + 1)
	{
		if ( i * i > n ) break;
		lop(j, 1, n + 1)
		{
			if (j * j > n) break;
			if ( i * i + j * j > n ) break;
			lop(k, 1, n + 1)
			{
				if ( k * k > n ) break;
				int res = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (i * k);
				if (  res == n) ans++;
				if ( res > n ) break;

			}
		}
	}

	cout << ans << endl;
}

void solve()
{
	int n; cin >> n;
	lop(i, 1, n + 1) go(i);


}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















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

int main()
{
    unsigned int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
    {
        swap(a, b);
    }
    if (b > c)
    {
        swap(b, c);
    }
    if (a > b)
    {
        swap(a, b);
    }
    cout << a << ' ' << b << ' ' << c << endl;
}



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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	int n; rd(n);
	vector<int> a(n);
	for (int& i : a) rd(i);
	sort(a.rbegin(), a.rend());
	ll ans = a[0];
	for (int it = 2, cnt = 0, cur = 1; it < n; it++) {

		ans += a[cur];
		cnt++;
		if (cnt == 2) {
			cnt = 0;
			cur++;
		}
	}

	printf("%lld\n", ans);
}

Measured memory_bytes: 4000
#include <stdio.h>
#define N 45

int memory[N];
int fib(int n){
  if(n==1 || n==0)return memory[n]=1;
  if(memory[n]!=-1)return memory[n];
  return memory[n]=fib(n-2)+fib(n-1);
}
int main() {
  int n,ans;
  for(int i=0;i<N;i++)memory[i]=-1;
  scanf("%d",&n);
  ans=fib(n);
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll A, B, C, X; cin >> A >> B >> C >> X;
	ll cnt = 0;
	repe(i, 0, A) {
		repe(j, 0, B) {
			repe(k, 0, C) {
				if (X == 500 * i + 100 * j + 50 * k) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}


int main() {
	int N, M;

	cin >> N >> M;

	vector<ll> d(N+2, 0);
	vector<int> a(N+2, 0);

	rep(i, M) {
		int x;
		cin >> x;
		a[x] = 1;
	}

	d[N] = 1;
	for(int i = N-1; i >= 0; i--) {
		if(a[i] > 0) continue;
		d[i] = d[i+1] + d[i+2];
		d[i] %= MOD;
	}
	cout << d[0] << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, ans = 0;
	string S;

	cin >> N >> S;

	for (int i = 0; i + 2 < N; i++) {
		if (S.substr(i, 3) == "ABC") ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

int main()
{
    const double Pi = 3.14159265359;

    int a, b, h, m;
    std::cin >> a >> b >> h >> m;
    double rad_h = (h + m / 60.0) / 12.0 * Pi * 2;
    double rad_m = m / 60.0 * Pi * 2;
    double rx = std::cos(rad_h) * a - std::cos(rad_m) * b;
    double ry = std::sin(rad_h) * a - std::sin(rad_m) * b;
    std::cout << std::fixed << std::setprecision(15) << std::sqrt(rx * rx + ry * ry) << std::endl;
}


Measured memory_bytes: 4100