akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define Input cin
#define Output cout
using int64 = long long int;
using namespace std;

int main() {
  int N, M;
  Input >> N >> M;
  int ans = 1;
  for (int X = 1; X*X <= M; X++) {
    if (M%X != 0) {
      continue;
    }
    int Y = M/X;
    if ((int64)X*N <= M) {
      ans = max(X,ans);
    }
    if ((int64)Y*N <= M) {
      ans = max(Y,ans);
    }
  }
  Output << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;
  REP(i, s.length()) a[i] = 0;

  int sum = 0;
  REP(i, s.length()) {
    if(s[i] == 'R'){
      sum++;
    } else {
      a[i] += sum / 2;
      a[i - 1] += sum - (sum / 2);
      sum = 0;
    }
  }

  sum = 0;
  RREP(i, s.length()) {
    if(s[i] == 'L'){
      sum++;
    } else {
      a[i] += sum / 2;
      a[i + 1] += sum - (sum / 2);
      sum = 0;
    }
  }

  REP(i, s.length()) cout << a[i] << " ";
  cout << endl;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int X, Y;


signed main(){
	cin >> X >> Y;

	if(abs(X-Y) > 1) cout << "Alice" << endl;
	else cout << "Brown" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



lli get(lli a,lli b){
	if(a>b)swap(a,b);
	if(b%a==0)return (a*((b/a)*2-1));
	lli res=get(a,b%a)+(a+a)*(b/a);
	//printf("%lld %lld %lld\n",a,b,res);
	return res;
}

lli n,x;
int main(void){
	scanf("%lld%lld",&n,&x);
	if(n==x*2)printf("%lld\n",x*3);
	else{
		lli ans=0;
		if(x*2<n){
			ans=x+(n-x)+x+x;
			ans+=get(x,n-2*x);
		}
		else{
			ans=x+n-x;
			ans+=get(x,n-x);
		}
		printf("%lld\n",ans);
	}
	return 0;
}






Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <typeinfo>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;






int main(){
    string s;
    while(cin>>s){
        string ans="";
        for(int i=0;i<s.size();i++){
            if(s[i]!='@')ans+=s[i];
            else{
                for(int j=0;j<s[i+1]-'0';j++){
                    ans+=s[i+2];
                }
                i+=2;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
  string S,T;
  cin >> S >> T;
  cout << T << S << endl;
  
  return 0;
}

Measured memory_bytes: 3544
#include<cstdio>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int dp[10000];
signed main(){
    int N,v[100],w[100],W;
    cin>>N>>W;
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<N;i++){
        for(int j=W;j>=w[i];j--){
            dp[j]=max(dp[j-w[i]]+v[i],dp[j]);

        }
    }
    cout<<dp[W]<<endl;
    return 0;
}

Measured memory_bytes: 1232
using System;
using System.Linq;

namespace Contest
{


    class Program
    {


        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var h = input[0];
            var w = input[1];
            var k = input[2];

            string[] c = new string[h];

            for(int i = 0; i < h; i++)
            {
                c[i] = Console.ReadLine();
            }

            int ans = 0;
            for (int i = 0; i < (1 << (h + w)); i++)
            {
                int res = countScore(i, c, h, w);
                if (res == k) ans++;

            }
        

            Console.WriteLine(ans);

        }

        private static int countScore(int bit, string[] c,int h, int w)
        {
            var res = 0;

            for (int i = 0; i < c.Length; i++)
            {
                for (int j = 0; j < c[i].Length; j++)
                {
                    if ((bit & (1 << i)) != 0 || (bit & (1 << (h + j))) != 0)
                    {
                        continue;
                    }
                    else if (c[i][j] == '#')
                    {
                        res++;
                    }
                }
                
            }

            return res;

        }

    }
}


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

int dp[1000][1000];
int f(int i,int j){
  if(~dp[i][j])return dp[i][j];
  int win=0;
  for(int k=1;k*2<=i;k++)if(!f(i-k*2,j+k))win=1;
  for(int k=1;k*2<=j;k++)if(!f(i+k,j-k*2))win=1;
  return dp[i][j]=win;
}

signed main(){
  /*
  memset(dp,-1,sizeof(dp));
  dp[0][0]=dp[1][0]=dp[0][1]=0;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(!f(i,j)^(abs(i-j)<=1))cout<<i<<" "<<j<<" "<<f(i,j)<<endl;
    }
  }
  */
  int x,y;cin>>x>>y;
  if(abs(x-y)<=1)cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100006], t;
int maxn = 0;
int main()
{
	int N; scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &t);
		a[t]++;
	}
	for (int i = 1; i <= 99999; i++) {
		maxn = max(maxn, a[i] + a[i - 1] + a[i + 1]);
	}
	printf("%d", maxn);
}

Measured memory_bytes: 640
s = chomp(readline())
list_A = []
list_Z = []
for i in 1:length(s)
    if string(s[i]) == "A"
        list_A = push!(list_A,i)
    end
    if string(s[i]) == "Z"
        list_Z = push!(list_Z,i)
    end
end
println(list_Z[end]-list_A[1]+1)

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double t = abs((double)(H%12)*30-(double)M*5.5);
  t = min(t, 360-t);
  cout << setprecision(12) << sqrt(pow((double)A, 2)+pow((double)B, 2)-2*A*B*cos(t*M_PI/180)) << endl;
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main(){
    ll n; cin >> n;
    ll m = sqrt(n);
    ll jud = 1;

    rep(i,m+1){
        if(n %(i+1) == 0){
            jud = i+1;
        }
    }

    ll k = n /jud;

    cout << k-1 + jud - 1 << endl;
}

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

using namespace std;
typedef long long ll;
const int N = 1e5+7;
int a[N] , b[N] , c[N];
int dp[N][4];
int n ;
int rec(int i , int prv)
{
    if(i>n)
    {
        return 0;
    }
    int &ret = dp[i][prv];
    if(ret!=-1)
        return ret;

    if(prv!=1)
    {
        ret=max(ret , rec(i+1 , 1)+a[i]);
    }
    if(prv!=2)
    {
        ret=max(ret , rec(i+1 , 2)+b[i]);
    }
    if(prv!=3)
    {
        ret=max(ret , rec(i+1 , 3)+c[i]);
    }
    return ret;
}
int main()
{
    memset(dp , -1 , sizeof dp);
    cin >> n;
    for(int i = 1 ; i <=n ; i++)
    {
        cin >> a[i] >> b[i]  >> c[i];
    }
    cout << rec(1 , 0);
    return 0;
}


Measured memory_bytes: 12568
//
//  main.cpp
//  Computational_Geometry
//
//  Created by ?????£??? on 2017/8/2.
//  Copyright ?? 2017??´ ?????£???. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cmath>
#include <memory>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int MAX=1e1;

int sgn(double x)
{
    if (fabs(x)<eps) return 0;
    if (x<0) return -1;
    else return 1;
}

struct Point
{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x=_x;y=_y;
    }
    Point operator -(const Point &b)const{
        return Point(x-b.x,y-b.y);
    }
    double operator ^(const Point &b)const{
        return x*b.y - y*b.x;
    }
    double operator *(const Point &b)const{
        return x*b.x - y*b.y;
    }
    void transXY(double B){
        double tx=x,ty=y;
        x=tx*cos(B) - ty*sin(B);
        y=tx*sin(B) + ty*cos(B);
    }
};

double CalcArea(Point p[],int n)
{
    double res=0;
    for (int i=0; i<n; i++) {
        res+=(p[i]^p[(i+1)%n])/2;
    }
    return fabs(res);
}

bool isconvex(Point poly[],int n)
{
    bool s[3];
    memset(s, false, sizeof(s));
    for (int i=0; i<n; i++) {
        s[sgn((poly[(i+1)%n]-poly[i])^(poly[(i+2)%n]-poly[i]))+1]=true;
        if (s[0] && s[2]) return false;
    }
    return true;
}
Point p[MAX];
int main(void) {
    //freopen("/Users/mac/Desktop/C++?¨????/Computational_Geometry/Computational_Geometry/test.txt", "r", stdin);
    int n;
    scanf("%d\n",&n);
    for (int i=0; i<n; i++) {
        scanf("%lf%lf\n",&p[i].x,&p[i].y);
    }
    printf("%d\n",isconvex(p, n)?1:0);
    return 0;
}

Measured memory_bytes: 3232
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

class UnionFind
{
private:
  vector<int> par, sizes;

public:
  UnionFind(int n = 200010) : par(n), sizes(n, 1)
  {
    rep(i, n) par[i] = i;
  }

  int root(int x)
  {
    if (x == par[x])
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sizes[x] < sizes[y])
      swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y)
  {
    return root(x) == root(y);
  }

  int size(int x)
  {
    return sizes[root(x)];
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  string s[50];
  rep(i, n) cin >> s[i];
  UnionFind uf;
  rep(i, n) rep(j, m - 1)
  {
    if (s[i][j] == '#' && s[i][j + 1] == '#')
      uf.unite(i * m + j, i * m + j + 1);
  }
  rep(j, m) rep(i, n - 1)
  {
    if (s[i][j] == '#' && s[i + 1][j] == '#')
      uf.unite(i * m + j, (i + 1) * m + j);
  }
  rep(i, n) rep(j, m)
  {
    if (s[i][j] == '.')
      continue;
    if (uf.size(i * m + j) == 1)
    {
      Yes(false);
      return 0;
    }
  }
  Yes(true);
  return 0;
}


Measured memory_bytes: 1792
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()

dp = list2d(3, N+1, 0)
dp[0][0] = 1
for i in range(N):
    dp[0][i+1] += dp[0][i] * 8
    dp[1][i+1] += dp[0][i] * 2
    dp[1][i+1] += dp[1][i] * 9
    dp[2][i+1] += dp[1][i]
    dp[2][i+1] += dp[2][i] * 10
    dp[0][i+1] %= MOD
    dp[1][i+1] %= MOD
    dp[2][i+1] %= MOD
ans = dp[2][N]
print(ans)


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

long long k, l = 2, r = 3;
vector<long long> a;

int main() {
  cin >> k;
  a.resize(k);
  for (auto &p : a) cin >> p;
  reverse(a.begin(), a.end());
  if (a[0] != 2) {
    cout << -1 << endl;
    return 0;
  }
  long long inf = (long long)1e18;
  for (int i = 0; i < k; ++i) {
    long long nl = inf, nr = -1;
    long long m = (a[i] - l % a[i]) % a[i];
    if (l + m <= r) nl = l + m;
    m = r % a[i];
    if (r - m >= l) nr = r - m;
    if (nl == inf) {
      cout << -1 << endl;
      return 0;
    }
    l = nl;
    r = nr;
    r += a[i] - 1;
  }
  cout << l << " " << r << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,a1,a2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	a1=a*b;
	a2=c*d;
	if(a1>=a2){
		printf("%d",a1);
	}
	else
	printf("%d",a2);
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    
	void main()
	{
	    int n=qread(),ct=0;while(n--) ct+=qread()&1;puts(ct%2==0?"YES":"NO");
	}
};//(ans+MOD)%MOD
signed main()
{
//	freopen("z.txt","r",stdin);
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int X, Y;

    cin >> X >> Y;

    for (int i = 0;i <= 100;i++) {
        for (int j = 0;j <= 100;j++) {
            if ((i + j == X) && (i*2 + j*4 == Y) && !(i == 0 && j == 0)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}


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



long long mod = 1000000007;



int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long x;
	cin >> x;
	
	long long low = 0;
	long long high = 1023456;
	
	while(true){
		if(low == high - 1) break;
		
		long long s = (low + high) / 2;
		
		long long y = s * 8;
		y /= 100;
		y += s;
		if(y == x){
			cout << s;
			return 0;
		}
		else if(y > x){
			high = s;
		}
		else low = s;
	}
	
	cout << ":(";
	
}


Measured memory_bytes: 256
# C
N, M = map(int, input().split())
L = 1000000007

res = 1

if (M - N) >= 2 or (N - M) >= 2:
    res = 0
else:
    for k in range(M):
        res *= (k+1)
        res = res % L
    for k in range(N):
        res *= (k+1)
        res = res % L
    if M == N:
        res *= 2
        res = res % L
print(res)

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

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

    static class c {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long ans = 0;

            long aux = (long) Math.sqrt(n);

            while (n % aux != 0) {
                aux--;
            }
            long d = n / aux;
            ans += (aux - 1) + (d - 1);

            out.println(ans);
        }

    }

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

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {

                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23380
N, M = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(M)]
 
now = 0
num = 0
d = dict()
for p, y in sorted(data):
    if now != p:
        now = p
        num = 1
    d[(p,y)] = num
    num += 1
 
for p, y in data:
    print('{:06d}{:06d}'.format(p, d[(p,y)]))

Measured memory_bytes: 45832
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;

namespace ConsoleApplication1
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var dic = new Dictionary<string, int>();
            var cnt = 0l;
            for (var i = 0; i < n; i++)
            {
                var input = ReadLine();
                var key = string.Concat(input.OrderBy(c => c));
                if (dic.ContainsKey(key))
                {
                    cnt += dic[key];
                    dic[key]++;
                }
                else
                {
                    dic.Add(key, 1);
                }
            }
            WriteLine(cnt);
        }
    }
}

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

public class Main {
	static FastScanner sc = new FastScanner();
	static PrintStream out = System.out;

	public static void main(String args[]) {
		int N = ni();
		int T = ni();
		int A[] = na(N);

		int max = 0;
		int maxCnt = 0;
		int min = Integer.MAX_VALUE;

		for (int i=0;i<N;i++) {
			min = Math.min(min, A[i]);
			int gain = A[i] - min;
			if (gain > max) {
				max = gain;
				maxCnt = 1;
			} else if (gain == max) {
				maxCnt++;
			}
		}

		System.out.println(maxCnt);
	}

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

	private static int ni() {
		return sc.nextInt();
	}

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

	private static int[] na(int n) {
		int[] a = new int[n];
		for(int i = 0;i < n;i++) a[i] = ni();
		return a;
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for(int i = 0;i < n;i++) a[i] = ni();
		return a;
	}

	private static double nd() {
		return Double.parseDouble( next() );
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 9820
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(k);
  for (int i = 0; i < k; ++i) {
    cin >> v[i];
  }
  bool f;
  for (; ; ++n) {
    f = true;
    for (int m = n; m != 0; m /= 10) {
      for (int i : v) {
        if (m % 10 == i) {
          f = false;
          break;
        }
      }
      if (!f) break;
    }
    if (f) break;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k])

if __name__ == '__main__':
    abc120_b()

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

const ll MAXN = 200000;

string S, T, ST;
set<ll> A[26], B[26];

signed main(){
    cin >> S >> T;
    if(S.size()!=T.size()) {
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<S.size();i++) {
        ll si = S[i]-'a';
        ll ti = T[i]-'a';
        A[si].insert(ti);
        B[ti].insert(si);
    }
    for(int i=0;i<26;i++) {
        //cout << i << " : " << A[i].size() << " : " << B[i].size() << endl;
        if(A[i].size()>=2||B[i].size()>=2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
import sys
sys.setrecursionlimit(1000000000)


def process():
    for data in get_dataset():
        H = len(data)
        W = len(data[0])
        print search(H, W, data)


def search(H, W, data):
    count = 0
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return

def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset

process()

Measured memory_bytes: 15808
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long tnum;

#define loop(i, num) for(int i = 0; i < num; i++)

tnum* tnumAlloc(int num);
tnum getNumStdin();
tnum* getNumsStdin(int);
char* getCharsStdin(int maxlength);
string getStringStdin();
void printlnNums(int count, tnum* nums);
void printlnNum(tnum num);
void printString(string str);

#define min(a,b) (a <= b ? a : b)
#define max(a,b) (a >= n ? a : b)

/*void sort(T* start, T* end) (in <algorithm>)
example:
	int a[5] = {2, 1, 3, 5, 4};
	sort(a, a + 5);
	-> a: {1, 2, 3, 4, 5}
*/


int main() {
	tnum t;
    int flag = 0;

    tnum a = getNumStdin();
    tnum b = getNumStdin();
    tnum c = getNumStdin();
    tnum k = getNumStdin();

    if(k < a){
        t = k;
    }else{
        t = a;
        if(k > a + b) {
            t = a - (k - a - b);
        }
    }

    printf("%lld", t);

    return 0;
}



//have to be free()
tnum* tnumAlloc(int num) {
	return (tnum*)calloc(num,sizeof(tnum));
}

tnum getNumStdin() {
	tnum ret;
	scanf("%lld", &ret);

	return ret;
}

//have to be free()
tnum* getNumsStdin(int num) {
	tnum* buf;
	tnum* tmp;
	buf = tnumAlloc(num);
	for (int i = 0; i < num; i++) {
		scanf("%lld", &buf[i]);
	}

	return buf;
}

//have to be free()
char* getCharsStdin(int maxlength) {
	char* ret = (char*)malloc(maxlength+1);
	scanf("%s", ret);

	return ret;
}

//have to be free()
string getStringStdin() {
	string ret;
	cin >> ret;
	return ret;
}

void printlnNum(tnum num) {
	printf("%lld\n", num);
}

// can be used for debugging
void printlnNums(int count, tnum *nums) {
	loop(i, count) {
		printf("%lld", nums[i]);
		if (i != count - 1) printf(" ");
	}
	printf("\n");
}

void printString(string str) {
	cout << str;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
template<class T> struct ConvexHullTrick {
  struct Line { T a, b; };
  deque<Line> deq;
  bool monotone_query;
  bool need(const Line& l, const Line& m, const Line& r) {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
  ConvexHullTrick(bool monotone_query = false) : monotone_query(monotone_query) {}
  void add(T a, T b) {
    if (deq.empty() or a < deq[0].a) {
      while (deq.size() >= 2 and !need({a, b}, deq[0], deq[1])) {
        deq.pop_front();
      }
      deq.emplace_front(Line{a, b});
    } else if (a > deq.back().a) {
      while (deq.size() >= 2 and !need(deq[deq.size() - 2], deq.back(), {a, b})) {
        deq.pop_back();
      }
      deq.emplace_back(Line{a, b});
    } else assert(false);
  }
  T max(T x) {
    if (deq.empty()) return numeric_limits<T>::min();
    if (monotone_query) {
      while (deq.size() >= 2 and deq[0].a * x + deq[0].b <= deq[1].a * x + deq[1].b) {
        deq.pop_front();
      }
      return deq[0].a * x + deq[0].b;
    }
    int ok = 0, ng = deq.size();
    while (ng - ok > 1) {
      int m = ok + ng >> 1;
      (deq[m - 1].a * x + deq[m - 1].b <= deq[m].a * x + deq[m].b ? ok : ng) = m;
    }
    return deq[ok].a * x + deq[ok].b;
  }
};
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  ConvexHullTrick<lint> cht(true);
  // ConvexHullTrick<lint> cht(false);
  V<lint> dp(n, 1e18);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = -cht.max(h[i]) + h[i] * h[i] + c;
    }
    cht.add(2 * h[i], -(dp[i] + h[i] * h[i]));
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 5632
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
//using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
    vector<string> List(1);
    int Min=100000;
    cin >> List[0];
    rep(i,SZ(List[0])-2){
        Min = min(Min,abs(753-(100*(List[0][i]-'0')+10*(List[0][i+1]-'0')+(List[0][i+2]-'0'))));
        
    }
    cout << Min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
int k[100];
int s[100][100];
int p[100];

int main(){
	cin>>N>>M;
	REP(i,M){
		cin>>k[i];
		REP(j,k[i]){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	REP(i,M){
		cin>>p[i];
	}
	int ans=0;
	REP(i,(1<<N)){
		bool check=true;
		REP(j,M){
			int now=0;
			REP(l,k[j]){
				int a=(i>>(s[j][l]))&1;
				//cout<<a<<" "<<i<<" "<<s[j][l]<<endl;
				now+=a;
			}
			if((now)%2!=p[j])check=false;
		}
		if(check){
			ans++;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if (a>=3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
import static java.util.Arrays.*;

import java.util.Scanner;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	void run() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%.8f\n", a * b / 3.305785);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}
}

Measured memory_bytes: 17340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct Edge {
    ll to, cost, time;
};

struct Data {
    ll v, money, time;
    bool operator<(const Data &b) const { return time > b.time; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll n, m, s;
    cin >> n >> m >> s;
    ll max_money = n * 50;
    vector<vector<Edge>> g(n);
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g[u].push_back((Edge){v, a, b});
        g[v].push_back((Edge){u, a, b});
    }
    vector<ll> c(n), d(n);
    rep(i, n) cin >> c[i] >> d[i];
    vector<vector<ll>> dp(n, vector<ll>(max_money + 1, inf));
    priority_queue<Data> pq;
    auto push = [&](ll v, ll money, ll time) {
        if (money < 0) return;
        money = min(money, max_money);
        if (dp[v][money] <= time) return;
        dp[v][money] = time;
        pq.push((Data){v, money, time});
    };
    push(0, s, 0);
    while(!pq.empty()) {
        Data data = pq.top(); pq.pop();
        if (dp[data.v][data.money] != data.time) continue;
        {
            push(data.v, data.money + c[data.v], data.time + d[data.v]);
        }
        for(auto &x : g[data.v]) {
            push(x.to, data.money - x.cost, data.time + x.time);
        }
    }
    reps(i, 1, n) {
        ll ans = inf;
        rep(j, max_money + 1) ans = min(ans, dp[i][j]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 7288
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      String[] s = next().split(",");
      myout(myconv(s, 8));
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 33048
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long ans;
    foreach (stat; 0 .. (1 << (S.length - 1)))
    {
        long score;
        long tmp = S[0] - '0';
        foreach (i; 1 .. S.length)
        {
            // writeln(tmp, " ", i, " ", stat & (1 << (i - 1)));
            if (stat & (1 << (i - 1)))
            {
                // writeln(tmp);
                score += tmp;
                tmp = S[i] - '0';
                continue;
            }
            tmp = tmp * 10 + (S[i] - '0');
        }
        score += tmp;
        // writefln("%05b %s", stat, score);
        ans += score;
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{

	int r, c, i, j, k[101][101] = {};

	scanf("%d %d", &r, &c);
	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			scanf("%d", &k[i][j]);
			k[i][c] += k[i][j];
			k[r][j] += k[i][j];
		}
	}

	for (i = 0; i < c; i++)
	{
		k[r][c] += k[r][i];
	}

	for (i = 0; i <= r; i++)
	{
		for (j = 0; j <= c; j++)
		{
			printf("%d", k[i][j]);
			if (j < c)
				printf(" ");
			else
				printf("\n");
		}
	}

	return(0);

}

Measured memory_bytes: 652
using System;

namespace A
{
    class Node
    {
        public int key;
        public int parent;
        public int left;
        public int right;
    }

    class A
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            int n = int.Parse(input1), i;
            Node[] node = new Node[n+1];
            string[] input2 = new string[n+1];
            for (i = 1; i <= n; i++)
            {
                node[i] = new Node();
            }
            input2 = Console.ReadLine().Split(' ');
            for (i = 0; i < n; i++)
            {
                node[i+1].key = int.Parse(input2[i]);
            }

            
                

            //出力
            for (i = 1; i <= n; i++)
            {
                Console.Write("node " + i + ": key = " + node[i].key + ", ");
                if (i / 2 > 0)
                {
                    node[i].parent = node[i / 2].key;
                    Console.Write("parent key = " + node[i].parent + ", ");
                }
                if (2*i<=n)
                {
                    node[i].left = node[i * 2].key;
                    Console.Write("left key = " + node[i].left + ", ");
                }
                if (2 * i + 1 <= n)
                {
                    node[i].right = node[2 * i + 1].key;
                    Console.Write("right key = " + node[i].right + ", ");
                }
                Console.WriteLine();
            }

        }
    }
}



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

int main() {
    int n;
    cin >> n;
    vector<int> prefix_sum(n, 0);
    cin >> prefix_sum[0];
    rep(i, n - 1) {
        int w;
        cin >> w;
        prefix_sum[i + 1] = prefix_sum[i] + w;
    }
    int ans = 1e9;
    for (int i = 0; i < n; i++) {
        ans = min(ans, abs((prefix_sum[n - 1] - prefix_sum[i]) - prefix_sum[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}
	void solve() {
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++)A[i]=nextInt();
		int max_num = Math.max(A[0],A[1]);//一番大きい値
		int max_i = A[0]>=A[1]?0:1;//一番大きい数値のindex
		int second_max = Math.min(A[0],A[1]);//二番目に大きい値
		for(int i=2;i<N;i++) {
			if(A[i]>=max_num) {
				second_max = max_num;
				max_num = A[i];
				max_i=i;
			}else if(A[i]>second_max) {
				second_max = A[i];
			}
		}

		StringBuilder buf = new StringBuilder();
		for(int i=0;i<max_i;i++) {
			//out.println(max_num);
			buf.append(max_num+System.getProperty("line.separator"));
		}
		//out.println(second_max);
		buf.append(second_max+System.getProperty("line.separator"));
		for(int i=max_i+1;i<N;i++) {
			//out.println(max_num);
			buf.append(max_num+System.getProperty("line.separator"));
		}

		String res = buf.toString();
		System.out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

}

Measured memory_bytes: 67308
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    char c; cin >> a >> c >> b;

    int res = a - b;
    if(c == '+'){
        res = a + b;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<vector<int> > G;
	vector<int> ans;
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;
	G.resize(n);
	ans.assign(n, inf);
	for(int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		--u;
		--v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	int k;
	cin >> k;
	while(k--) {
		int x, y;
		cin >> x >> y;
		--x;
		ans[x] = y;
		q.emplace(y, x);
	}
	while(!q.empty()) {
		auto o = q.top();
		q.pop();
		int u = o.second;
		for(auto v : G[u]) {
			if(ans[v] == inf) {
				ans[v] = ans[u] + 1;
				q.emplace(ans[v], v);
			}
			if(abs(ans[v] - ans[u]) != 1) {
				cout << "No" << '\n';
				return 0;
			}
		}
	}
	cout << "Yes" << '\n';
	for(int i = 0; i < n; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 7924