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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 300, MAXN = 300;
struct edge
{
	int u,v;
	ll cap,flow;
};
vector<edge>e;

vector<int>graph[maxn];

int dist[maxn];
int ptr[maxn];


void add_edge(int u , int v, ll cap)
{
	edge e1 = {u,v,cap,0LL};
	edge e2 = {v,u,0LL,0LL};

	graph[u].push_back(e.size());
	e.push_back(e1);
	
	graph[v].push_back(e.size());
	e.push_back(e2);
}


bool bfs(int s, int t)
{
	memset(dist,-1, sizeof(dist));
	queue<int>q;
	q.push(s);
	dist[s] = 0;
	while(q.size() && dist[t] == -1)
	{
		int u = q.front();
		q.pop();

		for(int i = 0; i < graph[u].size(); i++)
		{
			int id = graph[u][i];
			int v = e[id].v;

			if(dist[v] == -1 && e[id].cap > e[id].flow)
			{
				q.push(v);
				dist[v] = dist[u] + 1;
			}
		}
	}

	return dist[t] != -1;
}

ll dfs(int u , ll flow, int t)
{
	if(!flow)
		return 0;
	if(u == t)
		return flow;
	for(; ptr[u] < graph[u].size(); ptr[u]++)
	{
		int id = graph[u][ptr[u]];
		int v = e[id].v;

		if(dist[v] != dist[u] + 1)
			continue;
		
		ll pushed = dfs(v, min(flow, e[id].cap - e[id].flow), t);
		
		if(pushed)
		{
			e[id].flow += pushed;
			e[id^1].flow -= pushed;
			return pushed;
		}

	}
	return 0;
}


ll dinic(int s, int t)
{
	ll ans = 0;
	while(bfs(s,t))
	{
		memset(ptr,0,sizeof(ptr));
		while(ll pushed = dfs(s, (1LL << 45) + 1, t) )
			ans += pushed;
	}
	return ans;
}


ll v[MAXN + 5];
int main(){
	ios::sync_with_stdio(0);
	//cin.tie(0); cout.tie();
	int N;
	cin >> N;
	ll sum = 0;
	for(int i = 2; i <= N+1; i++) {
		cin >> v[i];
		if(v[i] > 0) sum += v[i];
	}


	for(int i = 2; i <= N+1; i++){
		if(v[i] > 0) add_edge(i, N+2, v[i]);
		else add_edge(1, i, -v[i]);
	}

	for(int i = 1; i <= N; i++)
		for(int j = i+i; j <= N; j+=i)
			add_edge(i+1, j+1, (1LL << 45));

	ll ans = dinic(1, N+2);

	cout << sum - ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		int A[n + 1];
		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			cin >> A[i];
			sum += A[i];
		}
		int avg = sum / n;
		sort(A, A + n);
		int cnt = 0;
		for(int i = 0; i < n; i++)
		{
			if(A[i] <= avg)
				cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}





Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111,M=111111;
int l,m,n,t,C,x;
int a[N][N];
pii nxt(pii a){
    if(a.X%2==0){
        if(a.Y==1)return mp(a.X+1,a.Y);
        else return mp(a.X,a.Y-1);
    }else{
        if(a.Y==n)return mp(a.X+1,a.Y);
        else return mp(a.X,a.Y+1);
    }
}
int main(){
#ifdef LOCAL
	freopen("D.in","r",stdin);//freopen("D.out","w",stdout);
#endif
	scanf("%d%d",&m,&n);
    scanf("%d",&t);
    pii pos=mp(1,1);
    rep(i,1,t){
        scanf("%d",&x);
        rep(_,1,x){
            a[pos.X][pos.Y]=i;
            pos=nxt(pos);
        }
    }
    rep(i,1,m){rep(j,1,n)printf("%d ",a[i][j]);puts("");}
	return 0;
}







































Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
        int n, t;
        vector<int> vt;
        int m, p, x;

        cin >> n;
        for (int i = 0; i < n; i++) {
                cin >> t;
                vt.push_back(t);
        }
        cin >> m;
        for (int i = 0; i < m; i++) {
                cin >> p >> x;
                p--;
                int sum = 0;
                for (int j = 0; j < n; j++)
                        sum += (j == p) ? x : vt[j];
                cout << sum << endl;
        }

        return 0;
}

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

int main(){
    int x1, y1, x2, y2, dx, dy, d;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = abs(x1 - x2);
    dy = abs(y1 - y2);
    //d = sqrt(dx*dX + dy*dy);
    if(x1 > x2){
        if(y1 > y2){
            cout << x2 + dy << ' ';//x3
            cout << y2 - dx << ' ';//y3
            cout << x1 + dy << ' ';//x4
            cout << y1 - dx << endl;//y4
        }else{
            cout << x2 - dy << ' ';//x3
            cout << y2 - dx << ' ';//y3
            cout << x1 - dy << ' ';//x4
            cout << y1 - dx << endl;//y4
        }
    }else{  //x1 < x2
        if(y1 < y2){
            cout << x2 - dy << ' ';//x3
            cout << y2 + dx << ' ';//y3
            cout << x1 - dy << ' ';//x4
            cout << y1 + dx << endl;//y4
        }else{
            cout << x2 + dy << ' ';//x3
            cout << y2 + dx << ' ';//y3
            cout << x1 + dy << ' ';//x4
            cout << y1 + dx << endl;//y4
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N,K;
	scanf("%d %d",&N,&K);
	double ret = 0;

	for (int i = 1; i <= N; i++) {
		double tmp = 1.0 / N;
		int now = i;
		while (now < K) {
			now *= 2;
			tmp /= 2;
		}
		ret += tmp;
	}
	printf("%.12f\n",ret);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

		int n = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		int[] ans = new int[4];
		for (int i = 0; i < n; i++) {
			if (s[i].equals("AC"))
				ans[0]++;
			if (s[i].equals("WA"))
				ans[1]++;
			if (s[i].equals("TLE"))
				ans[2]++;
			if (s[i].equals("RE"))
				ans[3]++;
		}

		System.out.println("AC x " + ans[0]);
		System.out.println("WA x " + ans[1]);
		System.out.println("TLE x " + ans[2]);
		System.out.println("RE x " + ans[3]);

	}

}


Measured memory_bytes: 63836
#include <iostream>
#include <vector>
using namespace std;
int A[100001];
int main(){
    int n, q, tmp;
    cin >> n;
    long long sum = 0;
    for(int i=0; i<n; i++){
        cin >> tmp;
        ++A[tmp];
        sum += tmp;
    } 
    cin >> q;
    int b, c;
    for(int ii=0; ii<q; ii++){
        cin >> b >> c;
        sum -= 1LL*A[b]*b;
        sum += 1LL*A[b]*c;
        A[c] += A[b];
        A[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    set<int> st;
    for (int i=0; i<N; i++) {
        int d;
        cin >> d;
        st.insert(d); 
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x, y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &i : a) cin >> i;
  int Mx = a[0];
  int ans = 0;
  for(int i = 1; i < n; i++) {
    if(a[i] < Mx) {
      ans += Mx - a[i];
      a[i] = Mx;
    }
    Mx = max(Mx , a[i]);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 105;
int n, a[N];

int main() {
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 && a[i] % 5) {
                puts("DENIED"); return 0;
            }
        }
    }
    puts("APPROVED");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll ;

int main()
{
  
  int n,r;
  cin>>n>>r;
  if(n>=10) cout<<r;
  else cout << r+1000-(100*n);
  
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int n,c,k; scanf("%d%d%d",&n,&c,&k);
   vector<int> t(n); rep(i,0,n)scanf("%d",&t[i]);
   sort(ALL(t));
   int res=1,lim=t[0]+k,cnt=0;
   rep(i,0,n){
      if(t[i]<=lim&&cnt<c)cnt++;
      else{
         res++; cnt=1; lim=t[i]+k;
      }
   } printf("%d\n",res);
   return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
using ll = unsigned long long;


struct Node{
    ll val;
    Node *lhs, *rhs;
    Node(ll x = 0):val(x), lhs(nullptr), rhs(nullptr){}
};


Node* update(Node* t,ll k,int x,ll l=0,ll r = -1){
    if(!t)t = new Node();
    ll mid = (r==-1? (1ll<<63)+l/2 : (l+r)/2);
    if(r-l==1){
        t->val += x;
        return t;
    }
    else {
        if(k<mid)t->lhs = update(t->lhs,k,x,l,mid);
        else t->rhs = update(t->rhs,k,x,mid,r);
        t->val += x;
        return t;
    }
}

ll find(Node* t, int k, ll l = 0, ll r = -1){
    if(r-l==1)return l;
    ll mid = (r==-1? (1ll<<63)+l/2 : (l+r)/2);
    if(t->rhs&&t->rhs->val>=k)return find(t->rhs,k,mid,r);
    if(t->rhs)k-=t->rhs->val;
    return find(t->lhs,k,l,mid);
}
int main(){
    int n;
    cin>>n;
    int q;
    cin>>q;
    Node* sg = new Node();
    vector<ll> a(n);
    rep(i,n){
        sg = update(sg,99999-i,1);
    }
    while(q--){
        int type;
        cin>>type;
        if(type){
            int m;
            cin>>m;
            ll res = find(sg,m);
            cout<<100000-(res%100000)<<" "<<res/100000<<endl;
        }
        else {
            ll t, p;
            cin>>t>>p;
            --t;
            ll cur = a[t]*100000+(99999-t);
            sg = update(sg,cur,-1);
            a[t]+=p;
            ll nxt = a[t]*100000+(99999-t);
            sg = update(sg,nxt,1);
        }
    }
}


Measured memory_bytes: 67796
#include <bits/stdc++.h>
using namespace std;
int a, b, n;

int main()
{
    cin >> a >> b;
    if(b < 10)
    {
        n = b + 10*a;
    }
    else if(b < 100)
    {
        n = b + 100*a;
    }
    else
    {
        n = b + 1000*a;
    }
    for(int i = 0; i < 1000; i++)
    {
        if(pow(i, 2) == n)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

typedef long long ll;
typedef pair <ll, double> pii;

ll pot[20];
vector <pii> v;

double calc(ll x) {
	ll sum = 0, y = x;
	for (; x; x /= 10)
		sum += x % 10;
	return (double)y / sum;
}

int main() {
	pot[0] = 1;
	for (int i = 1; i < 20; i++)
		pot[i] = pot[i - 1] * 10;
		
	for (int i = 17; i > 6; i--)
		for (int j = 999; j >= 100; j--) {
			ll tmp = (ll)(j + 1) * pot[i - 3] - 1;
			double ratio = calc(tmp);
			if (v.empty() || ratio <= v.back().second)
				v.push_back({tmp, ratio});
		}
	
	for (int i = 1e6 - 1; i; i--) {
		double ratio = calc(i);
		if (ratio <= v.back().second)
			v.push_back({i, ratio});
	}
	
	reverse(v.begin(), v.end());
	
	int K;
	scanf("%d", &K);
	
	for (int i = 0; i < K; i++)
		printf("%lld\n", v[i].first);
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int H,W; cin >> H >> W;
    int N; cin >> N;
    int A=max(H,W);
    cout << (N+A-1)/A << endl;
}

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

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

using namespace std;
typedef long long ll;
char c[2005][2005];
int a[2005][2005],d[2005][2005];
int main()
{
    memset(d,0,sizeof(int));
    memset(a,0,sizeof(int));
    int n,m;
    int mi=0;
    scanf("%d %d ",&n,&m);
    for(int i=0; i<n; i++)
    {
        int j;
        char k;
        {
            for(j=0; j<m-1; j++)
            {
                scanf("%c",&c[i][j]);
                if(c[i][j]=='.')
                    d[i][j]=1;
                else
                    d[i][j]=0;
            }
            if(j==m-1)
            {
                scanf("%c%c",&c[i][j],&k);
                if(c[i][j]=='.')
                    d[i][j]=1;
                else
                    d[i][j]=0;
            }
        }
    }
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            if(c[i][j]=='.')
            {
                int s=0;
                int k;
                for(k=j; k<m; k++)
                {
                    if(c[i][k]=='.')
                        s++;
                    else
                        break;
                }
                for(int l=j; l<k; l++)
                {
                    a[i][l]=s;
                }
                j=k;
            }
    for(int i=0; i<m; i++)
        for(int j=0; j<n; j++)
            if(d[j][i]==1)
            {
                int s=0;
                int k;
                for(k=j; k<n; k++)
                    if(c[k][i]=='.')
                        s++;
                    else
                        break;
                for(int l=j; l<k; l++)
                    d[l][i]=s;
                j=k;
            }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            int k;
            k=a[i][j]+d[i][j]-1;
            //printf("%2d ",k);
            if(k>mi)
                mi=k;
        }
        //printf("\n");
    }
    cout<<mi;
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 1;
bool ok = true;


ll checkMul(ll a, ll b) {
  ll l = 1000000000000000000;
  while (l > 0) {
    ll d = b / l;
    l /= 10;
    if (a * d > 1000000000000000000) {
      ok = false;
      return -1;
    }
  }
  return a * b;
}

int main(void){
  
  I(N);
  vl A(N);
  REP(i, N) {
    ll x;
    I(x);
    A[i] = x;
    if (x == 0) {
      P(0);
      return 0;
    }
  }

  REP(i, N) {
    ll _ret = ret;
    ret = checkMul(ret, A[i]);
  }
  P(ok?ret:-1);

}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
struct dsu {
    vector<int> p;
    int d;
    dsu(int n) : p(n, -1) {d = n;}
    int find(int a) {
        if (p[a] < 0) return a;
        return p[a] = find(p[a]);
    }
    void unite(int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;
        p[b] = a;
        d--;
    }
};
int main() {
    int n, m;
    cin >> n >> m;
    dsu uf(n);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--, y--;
        uf.unite(x, y);
    }
    cout << uf.d << endl;
    return 0;
}

Measured memory_bytes: 3772
people_count, time = gets.chomp.split(" ").map(&:to_i)
pushes = gets.chomp.split(" ").map(&:to_i)

x = 0
pushes.push(-1).each_cons(2) do |(t1, t2)|
  if t2 == -1
    x += time
    next
  end
  x += (t2 - t1 < time) ? t2 - t1 : time
end

puts x


Measured memory_bytes: 21892
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
#define C(x,y) memset(x,y,sizeof(x))
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
const int INF=1e9;
struct E{
	int to,nt,id,w;
}e[404000];
#define T e[k].to
struct P{
	int x,id;
	friend bool operator < (P a,P b){
		return a.x<b.x;
	}
}p[101000];
int n,m,head[101000],tot,X,Y,vis[101000],l,sn,ans[202000],now,r[101000];
I add(int x,int y,int id){
	e[++tot].to=y;
	e[tot].nt=head[x];
	head[x]=tot;
	e[tot].w=0;e[tot].id=id;
}
int main(){
	read(n);read(m);C(head,-1);C(vis,-1);
	F(i,1,n)read(p[i].x),p[i].id=i;
	sort(p+1,p+1+n);tot=-1;
	F(i,1,n)r[p[i].id]=i;
	F(i,1,m){
		read(X);read(Y);add(X,Y,i);add(Y,X,i);
	}
	l=1;sn=1;
	F(i,1,n){
		if(!sn)break;
		//cout<<"!";
		re d=p[i].id;sn=0;
		if(vis[d]!=-1){
			sn=1;continue;
		}
		now=0;
		for(re k=head[d];k!=-1;k=e[k].nt){
			if(vis[T]==-1&&p[r[T]].x==p[i].x){
				now=k;break;
			}
		}
		//cout<<now<<endl;
		if(now){
			vis[e[now].to]=1;vis[d]=0;e[now].w=e[now^1].w=p[i].x;sn=1;continue;
		}
		for(re k=head[d];k!=-1;k=e[k].nt){
			if(vis[T]!=-1){
				vis[d]=vis[T]^1;e[k].w=e[k^1].w=p[i].x;sn=1;break;
			}
		}
	}
	if(!sn){
		cout<<"-1";return 0;
	}
	F(i,1,n){
		for(re k=head[i];k!=-1;k=e[k].nt){
			if(e[k].w)ans[e[k].id]=e[k].w;
			else ans[e[k].id]=INF;
		}
	}
	F(i,1,n){
		if(vis[i])cout<<"B";
		else cout<<"W";
	}
	cout<<endl;
	F(i,1,m)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 11392
s = input()
 
l = len(s)
 
if l % 2 != 0:
    print("No")
else:
    for i in range(0, l, 2):
        if s[i:i+2] == "hi":
            if i == l-2:
                print("Yes") 
            else:
                continue

        else:
            print("No")
            break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

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

    int total = 0;
    vector<int> t(n), v(n);
    REP(i, n){
        int a;
        cin >> a;
        t[i] = t[max(0, i-1)] + a;
    }
    for(int& i : v){
        cin >> i;
    }
    v.push_back(0);

    double speed = 0.0, ans = 0.0;
    int area = 0;

    for(double i = 0.0; i < t.back(); i += 0.5){
        double speed2 = speed;
        bool down = false;
        if(i == t[area]){
            area++;
        }
        for(int j = area; j < n; j++){
            if(speed - v[j+1] >= t[j] - i){
                down = true;
                break;
            }
        }
        if(down){
            speed2 -= 0.5;
        }else if(speed < v[area]){
            speed2 += 0.5;
        }
        ans += (speed + speed2) * 0.25;
        speed = speed2;
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()

former = int(s[:2])
later = int(s[2:])


if 0<former<13 and 0<later<13:
  print("AMBIGUOUS")
elif 0<former<13:
  print("MMYY")
elif 0<later<13:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct P {
  int id, score;
  vector<int> pin;
  P() {}
  P(int id, vector<int> pin) : id(id), pin(pin) {
    int game = 0, turn = 0, pz = pin.size(), pos = -1;
    for (int i = 0; i < pz; i++) {
      if (pos < 0 && game == 9) pos = i;
      if (pin[i] == 10 || turn == 1) {
        game++; turn = 0;
      } else {
        turn = 1;
      }
    }
    turn = 0;
    int res = 0;
    for (int i = 0; i < pos; i++) {
      if (turn == 0 && pin[i] == 10) {
        res += pin[i] + pin[i + 1] + pin[i + 2];
        turn = 0;
      } else if (turn == 1 && pin[i - 1] + pin[i] == 10) {
        res += pin[i] + pin[i + 1];
        turn = 0;
      } else {
        res += pin[i];
        turn ^= 1;
      }
    }
    for (int i = pos; i < pz; i++) {
      res += pin[i];
    }
    score = res;
  }
  bool operator < (P other) {
    return score != other.score ? score > other.score : id < other.id;
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int m;
  while (cin >> m, m) {
    cin.ignore();
    vector<P> ps;
    for (int i = 0; i < m; i++) {
      string s;
      getline(cin, s);
      stringstream ss;
      ss << s;
      ss >> s;
      int id = stoi(s);
      vector<int> a;
      while (ss >> s) {
        a.emplace_back(stoi(s));
      }
      ps.emplace_back(P(id, a));
    }
    sort(ps.begin(), ps.end());
    for (int i = 0; i < m; i++) {
      cout << ps[i].id << " " << ps[i].score << endl;
    }
  }

  return 0;
}


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

long long knapSack(int W, int *wt, int *val, int n)
{
   int i, w;
   long long K[n+1][W+1];

   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main()
{
    int n,W;
    cin>>n>>W;
    int w[n];
    int v[n];
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    cout<<knapSack(W,w,v,n);
    return 0;
}


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

int main() {
  string main = "aiueo";
  char c;
  cin >> c;
  int i, flag = 0;
  for(i=0; i<5; i++){
    if(c == main.at(i)){
      flag = 1; break;
    }
  }
  if(flag) cout << "vowel" << endl;
  else cout << "consonant" << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2*100000 + 10;

int n,mxDist = -1 , mxNode;
vector<int> g[N];

void dfs(int u , int parent , int dist){
	if(dist > mxDist){
		mxDist = dist;
		mxNode = u;
	}
	for(auto v: g[u]){
		if(v == parent)continue;
		dfs(v,u,dist+1);
	}
}
int main() {
	cin >> n;
	for (int a,b,i = 0; i < n-1; ++i){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,-1,0);
	mxDist = -1;
	dfs(mxNode,-1,0);
	if(mxDist == 0){
		puts("First");
		return 0;
	}
	if((mxDist-1)%3 == 0){
		puts("Second");
		return 0;
	}
	puts("First");
	
	return 0;
}

Measured memory_bytes: 20608
n,k=map(int,input().split())
mod=10**9+7


FACT=[1]
for i in range(1,5*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(5*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0
for i in range(min(k+1,n)):
    ANS+=Combi(n-1,n-i-1)*Combi(n,i)
    #print(i,ANS)

print(ANS%mod)


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


int main() {
  int n;
  cin >> n;
  int count = 0;
  rep(i,n){
    int a, b;
    cin >> a >> b;
    if(a == b){
      count++;
    }
    else{
      count = 0;
    }
    
    if(count == 3){
      cout << "Yes";
      return 0;
    }
    
  }
  
  cout << "No";
  
  return 0;
}




Measured memory_bytes: 3584
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e10+100;

class DisjointSet{
    public:
    vector<ll> rank,p;
    DisjointSet(){}
    DisjointSet(ll size){
        rank.resize(size,0);
        p.resize(size,0);
        rep(i,size) makeSet(i);
    }
    void makeSet(ll x){
        p[x]=x;
        rank[x]=0;
    }
    bool same(ll x,ll y){
        return findSet(x)==findSet(y);
    }
    void unite(ll x, ll y){
        link(findSet(x),findSet(y));
    }
    void link(ll x, ll y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++;
            }
        }
    }
    ll findSet(ll x){
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};


int main()
{
    ll n,q;
    cin >> n >> q;
    ll t,a,b;
    DisjointSet ds=DisjointSet(n);
    rep(i,q){
        cin >> t >> a >> b;
        if(t==0){
            ds.unite(a,b);
        }
        else if(t==1){
            if(ds.same(a,b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
} 


Measured memory_bytes: 3248
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();

    int patterns = 1;
    for(int i=0; i<k; i++){
      patterns *= 3;
    }
    int[][][] choice = new int[patterns][k+1][3];

    boolean flag = false;

    for(int i=0; i<patterns; i++){
      int copy = i;
      choice[i][0][0] = a;
      choice[i][0][1] = b;
      choice[i][0][2] = c;

      for(int j=1; j<k+1; j++){
        int amari = copy % 3;

        choice[i][j][0] = choice[i][j-1][0];
        choice[i][j][1] = choice[i][j-1][1];
        choice[i][j][2] = choice[i][j-1][2];

        choice[i][j][amari] = (choice[i][j-1][amari] << 1);

        if(choice[i][j][0] < choice[i][j][1] && choice[i][j][1] < choice[i][j][2]){
          flag = true;
          break;
        }
  
        copy = (copy - amari) / 3;
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 36236
#include<iostream>
#include<algorithm>
#include<vector>
#include<iterator>
#include<string>
#include<map>
#include<set>
#include<list>
using namespace std;
#define endl "\n"
#define ll long long
const int N = 1e5 + 5;
const unsigned int M = 1000000007;
ll a[N]; 
 
int main ()
{
  ios_base::sync_with_stdio (false);
  cin.tie (NULL);
  int x; cin>>x;
   
   if(x>=400 and x<=599)
    cout<<8;
  else  if(x>=600 and x<=799)
    cout<<7;
  else if(x>=800 and x<=999)
    cout<<6;
   else if(x>=1000 and x<=1199)
    cout<<5;
   else if(x>=1200 and x<=1399)
    cout<<4;
   else if(x>=1400 and x<=1599)
    cout<<3;
   else if(x>=1600 and x<=1799)
    cout<<2;
   else if(x>=1800 and x<=1999)
    cout<<1;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
   int a,b;
   cin>>a>>b;
   if(a%3==0){cout<<"Possible";return 0;}
   if(b%3==0){cout<<"Possible";return 0;}
   if((a+b)%3==0){cout<<"Possible";return 0;}
    cout<<"Impossible";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[2005][2005];
int h[2005][2005];
int w[2005][2005];
int main(void){
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++)cin >> s[i];
	int ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='.'&&h[i][j]==0){
				h[i][j]++;
				int nx = i + 1;
				while(s[nx][j]=='.'){
					h[i][j]++;
					nx++;
					if(nx>=H)break;
				}
				for(int k=i;k<nx;k++){
					h[k][j]=h[i][j];
				}
			}
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='.'&&w[i][j]==0){
				w[i][j]++;
				int ny = j + 1;
				while(s[i][ny]=='.'){
					ny++;
					w[i][j]++;
					if(ny>=W)break;
				}
				for(int k=j;k<ny;k++){
					w[i][k]=w[i][j];
				}
			}
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='.')ans=max(ans,w[i][j]+h[i][j]);
		}
	}
	cout << ans-1 << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    int n;
    cin >> n;

    ll sum = 0;

    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5==0) continue;
        sum += i;
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  string s;
  cin >> s;
  vint e(s.size()+1);
  vint w(s.size()+1);
  rep(i, s.size()) {
    e[i+1] = e[i]+(s[i]=='E');
    w[i+1] = w[i]+(s[i]=='W');
  }

  int ans = inf;
  rep(i, s.size()) {
    chmin(ans, w[i]+e[s.size()]-e[i+1]);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 5396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OthloKyopro
{
    class Program
    {
        static void Main(string[] args)
        {

            /* 2 */
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var own = input[0];
            var a = input[1];
            var book = input[2];
            if(own >= book)
            {
                Console.WriteLine(0);
            }
            else if(own + a >= book)
            {
                Console.WriteLine(book - own);
            }
            else
            {
                Console.WriteLine("NA");
            }

        }
    }
}

Measured memory_bytes: 9556
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LLONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

signed main() {
	int x, y;
	cin >> x >> y;
	cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn dp(i: usize, h_vec: &Vec<i64>, cache: &mut Vec<i64>, k: i32) -> i64 {
    // println!("{}", i);
    if i >= h_vec.len() - 1 {
        return 0;
    }

    if cache[i] != -1 {
        // println!("cache hit!: {} -> {}", i, cache[i]);
        return cache[i];
    }

    let mut min = std::i64::MAX;
    for dist in 1..(k+1) as usize {
        if i + dist >= h_vec.len() {
            break;
        }
        let res = dp(i + dist, h_vec, cache, k) + (h_vec[i] - h_vec[i + dist]).abs(); 
        if res < min {
            min = res;
        }
    }
    // println!("i = {}, res = {}", i, min);
    cache[i] = min;
    return min;
}

fn main() {
    let (n, k) = input_tuple();
    let h_vec = input_vec();
    let mut cache = vec![-1i64; n as usize];
    println!("{}", dp(0, &h_vec, &mut cache, k));
}


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

ll divv[1000000];
ll l=1,A[1000000],m=1;

void printDivisors(ll n) 
{ 
    // Note that this loop runs till square root 
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
           { divv[l]=i;
               l++;
           }
              //  printf("%d ", i); 
  
            else
            // Otherwise print both
            {
                
                divv[l]=i;
                l++;
                divv[l]=n/i;
                l++;
            }
             //   printf("%d %d ", i, n/i); 
        } 
    } 
} 


int main()
{
    ll N,i,t,r1,sum=0;
    cin>>N;
    printDivisors(N); 
    
  //  for(i=1;i<=l-1;i++)
  //  {
  //      cout<<divv[i]<<" ";
        
 //   }
  //  cout<<endl;
    
    for(i=1;i<=l-1;i++)
    {
        t = N/divv[i] -1 ;
        if(t>0)
        {
            A[m]=t;
            m++;
        }
    }
    
   // for(i=1;i<=m-1;i++)
 //   {
  //      cout<<A[i]<<" ";
 //       
  //  }
 //   cout<<endl;
    
    
    for(i=1;i<=m-1;i++)
    {
        r1 = N/(A[i]+1);
        if(r1>=A[i])
        A[i]=0;
    }
    for(i=1;i<=m-1;i++)
    {
        sum = sum + A[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 2812
fun main(args: Array<String>) = yorukatsu22e()

fun yorukatsu22e() {
    operator fun List<Int>.component6() = this[5]
    val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }

    val sugarSet = mutableSetOf<Int>()
    for (cw in 0..f step c) for (dw in 0..f step d) sugarSet.add(cw + dw)

    val sugarPatterns = sugarSet.sorted().toIntArray()

    fun upperBound(list: IntArray, key: Int): Int {
        var ng = -1
        var ok = list.size

        while (ok - ng > 1) {
            val mid = (ok + ng) / 2
            if (list[mid] > key) ok = mid else ng = mid
        }
        return ok
    }


    var pair = a * 100 to 0
    var maxPercentage = 0.0

    for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {
        val waterWeight = aw + bw
        val maxOfSugarWeight = Math.min(e * waterWeight / 100, f - waterWeight)
        if (maxOfSugarWeight < 0) continue

        val ub = upperBound(sugarPatterns, maxOfSugarWeight) - 1
        if (ub !in sugarPatterns.indices) continue

        val sugarWeight = sugarPatterns[ub]
        val sumWeight = sugarWeight + waterWeight

        val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()

        if (percentage > maxPercentage) {
            maxPercentage = percentage
            pair = sumWeight to sugarWeight
        }
    }

    val answer = "${pair.first} ${pair.second}"

    println(answer)
}


Measured memory_bytes: 40656
<?php

myClass::main($argv);

function log_message(& $handle, $msg) {
    if (true !== MyClass::$testenv) return;
    fwrite($handle, $msg);
}

class myClass {

    static public $testenv = false;
    static public $stdout = STDOUT;
    static public $stdin = STDIN;

    static public function main($argv) {

        //1<=A,B,C<=5000
        //1<=X,Y<=100000
        //入力中のすべての値は整数である。
        fscanf(self::$stdin, "%d %d %d %d %d", $a, $b, $ab, $x, $y);

        // ハーフ＆ハーフが割高
        if ($ab*2 > $b+$a) {
            //別々購入
            $sum = $a*$x + $b*$y;
            log_message(self::$stdout, sprintf("%d*%d + %d*%d = %d\n", $a,$x,$b,$y,$sum));
        }

        // ハーフ＆ハーフが割安
        else {

            //枚数を少ない方はとりあえず0枚
            if ($x > $y) {
                $xy = $y * 2;
                $x = $x - $y;
                $sum = self::calc($a, $x, $ab, $xy);
            }
            else {
                $xy = $x * 2;
                $y = $y - $x;
                $sum = self::calc($b, $y, $ab, $xy);
            }
        }

        fwrite(self::$stdout, sprintf("%d\n", $sum));
    }

    // ハーフ＆ハーフの価格崩壊
    static function calc($k, $z, $ab, $xy) {

        //もしハーフ＆ハーフの金額を２倍してもピザA・Bより安い場合は
        //全てハーフ＆ハーフで注文
        if ($ab*2 < $k) {
            $xy = $xy + $z*2;
            $sum = $ab*$xy;
            log_message(self::$stdout, sprintf("%d*%d = %d\n", $ab,$xy,$sum));
            return $sum;
        }

        //ピザA・Bが多少過剰になっても安くなる時？
        $sum = $k*$z + $ab*$xy;
        $old = $sum;

        while(1) {

            $xy += 2;
            $z -= 1;
            $new = $k*$z + $ab*$xy;

            // 金額が高くなった時終わり
            if ($old < $new) {
                $sum = $old;
                break;
            }

            // ピザA・Bが0枚になったら終了
            if ($z < 1) {
                $sum = $new;
                break;
            }

            $old = $new;
        }

        log_message(self::$stdout, sprintf("%d*%d + %d*%d = %d\n", $k,$z,$ab,$xy,$sum));
        return $sum;
    }
}



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

int main(){
    string n;
    int k;
    char notuse[k];

    cin >> n >> k;
    

    //num = stoi(n);

    for(int i = 0; i < k; i++){
        cin >> notuse[i];
    }

    string num_s = n;
    int num;
    while(1){
        bool see = false;
        for(int i = 0; i < k; i++){
            if(num_s.find(notuse[i]) == string::npos){
                continue;
            }else{
                see = true;
                break;
            }
        }

        if(see == true){
            num = stoi(num_s);
            num = num + 1;
            num_s = to_string(num);
        }
        else{
            break;
        }
    }

    cout << num_s << endl;

    return 0;


    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[1000], y,x;
		cin >> x;
		y = x;
		for (int i = 0; i < x; i++){
			cin >> a[i];
	}
		for (int k = 0; k < x; k++){
			y--;
			if (y == 0){
				cout << a[y] << endl;
			}
			else cout << a[y] << " ";
		}
	return 0;
}

Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int dp[100001];
bool vis[100001];

void dfs(int curr, vvi &edges) {
    if (vis[curr])
        return;
    for (auto &e : edges[curr]) {
        dfs(e, edges);
        chmax(dp[curr], dp[e] + 1);
    }
    vis[curr] = true;
}

int main() {
    int n, m;
    cin >> n >> m;
    vvi revedges(n);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        revedges[x].push_back(y);
    }
    for (int i = 0; i < n; ++i) {
        dfs(i, revedges);
    }
    int ret = 0;
    for (int i = 0; i < n; ++i) {
        chmax(ret, dp[i]);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 8192
#input
N,M,C=input().split(" ")
B=input().split(" ")
N=int(N)
M=int(M)
C=int(C)
B=[int(b) for b in B]
A=[]
for i in range(N):
	l=input().split(" ")
	A.append([int(a) for a in l])

import numpy as np

c=0
for a in A:
	if(np.dot(a,B)+C>0):
		c+=1
print(c)
	







Measured memory_bytes: 21516
using System;
using System.Linq;
class Program {
	static void Main() {
		int n = int.Parse(Console.ReadLine());
		int[,] a = new int[n, 3];
		for(int i = 0; i < n; i++) {
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			for(int j = 0; j < 3; j++) a[i, j] = x[j];
		}
		int[] s = new int[n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 3; j++) {
				int cnt = 0;
				for(int k = 0; k < n; k++) {
					if(a[i, j] == a[k, j]) cnt++;
				}
				if(cnt == 1) s[i] += a[i, j];
			}
		}
		for(int i = 0; i < n; i++) {
			Console.WriteLine(s[i]);
		}
	}
}

Measured memory_bytes: 9640
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  int C;
  cin >> A>> B>> C;
  if((A==B) &&(A !=C) ) {
    cout <<"Yes" << endl;
  }
  else if ((A==C) && (A !=B)) {
    cout << "Yes" << endl;
  }
  else if ((B==C) && (A !=B)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>//coded by Nurstan ^_^

#define ll long long
#define pb push_back

#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define all(x) x.begin(), x.end()
#define F first
#define S second

// fixed << setprecision
// next_permutation(a, a + n)
// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){
	boost();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll a, b, c;
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0;
		return 0;
	} 
	
	else {
		cout << min(b * c, min(c * a, b * a)); 
	}
	exit(0);
}



Measured memory_bytes: 256