akhauriyash/Code-Regression huggingface dataset:
// failed to generate code

#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

ll H, W, N;
vi V;

void think() {
  int M[H][W] = {};
  REP(y, H) REP(x, W) REP(i, N) if (V[i]) {
    V[i]--;
    M[y][x] = i + 1;
    break;
  }

  REP(y, H) {
    if (y % 2 == 0) {
      REP(x, W) {
        cout << M[y][x];
        if (x != W - 1)
          cout << " ";
      }
    } else {
      for (int x = W - 1; x >= 0; --x) {
        cout << M[y][x];
        if (x != 0)
          cout << " ";
      }
    }
    cout << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin >> H >> W >> N;
  V.resize(N);
  REP(i, N) { cin >> V[i]; }

  think();
}


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

int main () {
    string t;
    cin >> t;

    int l = (int)t.length();
    for (int i = 0; i < l; ++i) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;

}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

int main() {
    ll n, m;
    cin >> n >> m;

    vector<ll> as(n);
    rep(i, n) {
        cin >> as[i];
    }

    vector<ll> sum(n + 1);
    sum[0] = 0;
    for (ll i = 0; i < n; i++) {
        sum[i + 1] = (sum[i] + as[i]) % m;
    }

    map<ll, ll> used;

    ll ans = 0;
    for(ll i = 0 ; i < sum.size() ; i ++) {
        ans +=  used[sum[i]];
        used[sum[i]] ++;
    }

    cout << ans << endl;


}


Measured memory_bytes: 5760
import numpy as np

N = int(input())
a = list(map(int, input().split()))
b = []
flag = []

b = sorted(a)

for i in range(0,N-1):
  if (b[i+1]-b[i]) == 0:
    flag.append(0)
  else:
    flag.append(1)

if np.prod(flag) == 0:
  print ("NO")
else:
  print ("YES")

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	int n;cin >> n;
	vector<P> v;
	set<P> s;
	REP(i, n){
		ll a, b;cin >> a >> b;
		v.EB(a, b);
		s.insert(MP(a, b));
	}
	ll ans = 0;
	REP(i, n){
		REP(j, n){
			if(i == j)continue;
			ll now = 0;
			ll y = v[i].FI - v[j].FI;
			ll x = v[i].SE - v[j].SE;
			REP(i, n){
				if(s.find(MP(v[i].FI + y, v[i].SE + x)) != s.end())now++;
			}
			ans = max(ans, now);
		}
	}

	cout << n - ans << endl;

	return 0;
}


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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;

  vector<vector<int>> dist_mat(N, vector<int>(N, 0));
  for (int i = 0; i < N; i++)
    {
      for (int j = i + 1; j < N; j++)
	dist_mat[i][j] = j - i;;
    }
  // bypass
  for (int i = 0; i < N; i++)
    {
      for (int j = i + 1; j < N; j++)
  	{
  	  int i_dist = abs(X - 1 - i);
  	  int j_dist = abs(Y - 1 - j);
  	  dist_mat[i][j] = min(dist_mat[i][j], 1 + i_dist + j_dist);
  	}
    }
  vector<int> counts(N, 0);
  for (const auto& row : dist_mat)
    for (const auto& col : row)
      counts[col] += 1;
  for (int k = 1; k < N; k++)
    cout << counts[k] << endl;
}


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




int main(){
    ll N,H,MAX=-1;cin>>N>>H;
    vector<ll> k(N),t(N);
    rep(i,0,N){
        cin>>k.at(i)>>t.at(i);
        MAX=max(MAX,k.at(i));
    }
    sort(t.begin(),t.end());
    ll cn=0;
    for(int i=N-1;i>=0;i--){
        if(MAX<=t.at(i)&&H>0){
            H=H-t.at(i);
            cn++;
        }
        else break;
    }
    if(H>0)cn+=(H+MAX-1)/MAX;
    cout<<(cn)<<endl;
}







Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		
		if(N.charAt(0) == '9' || N.charAt(1) == '9') {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>

int main() {

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

    //char s[4];
    //scanf("%s",s);
    
    if(x==7 || x==5 || x==3){
        printf("YES");
        
    }else {
        printf("NO");  
    }

    return 0;

}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    static final int MIN = -1000000;
    static final int MAX = 1000000;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();

        for (int i = Math.max(MIN, X - K + 1); i <= Math.min(MAX, X + K - 1); i++) {
            System.out.print(i + " ");
        }
    }
}


Measured memory_bytes: 23252
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9; 
const int N = 6e5+5;                                         
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}

int n;
int x[N], y[N];
int ans[N];
int p[N];
int sz[N];

int get (int x) {
	if(p[x] != x) p[x] = get(p[x]);
	return p[x];
}

void uni (int a, int b) {
	a = get(a), b = get(b);
	if(a==b) return;
	p[a] = b;
	y[b] = max(y[b], y[a]);
	x[b] = min(x[b], x[a]); 
	sz[b] += sz[a];
}

set < pair<int,int> > s;

int id[N];

void tri (int i) {
	while(sz(s) && s.begin() -> first < y[i]) {
		uni(s.begin() -> second, i);
		s.erase(s.begin());
		i = get(i);
	}
}

void add(int i) {
	i = get(i);
	s.insert({x[i], i});
}

int main () {
	SpeedForce;
	
	cin >> n;
	
	for (int i = 1, pos; i <= n; ++i) {
		cin >> pos >> y[i];
		x[i] = y[i];
		id[pos] = i;
	}
	for (int j = 1; j <= n; ++j) {
		int i = id[j];
		p[i] = i;
		sz[i] = 1;
		tri(i);
		add(i);
	}
	
	for (int i = 1; i <= n; ++i)
		cout << sz[get(i)] << '\n';
	
	return Accepted;
}

// B...a


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

int N, K;
vector<ll> A, S;

void input() {
    cin >> N >> K;
    A = vector<ll>(N);
    S = vector<ll>(N+1);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
        S[i+1] = (S[i] + A[i]) % K;
    }
}

int main() {
    input();
    ll ans = 0;
    unordered_map<ll, ll> mp;
    for (int i = 0; i <= N; i++) {
        if (i >= K) mp[S[i-K]]--;
        ans += mp[S[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11592
def inpl(): return list(map(int, input().split()))
N = int(input())
A, B, C = [0]*N, [0]*N, [0]*N

for i in range(N):
    A[i], B[i], C[i] = inpl()

DP = [[0]*3 for _ in range(N)]
DP[0] = [A[0], B[0], C[0]]

for i in range(1, N):
    DP[i][0] = max(DP[i-1][1] + A[i], DP[i-1][2] + A[i])
    DP[i][1] = max(DP[i-1][0] + B[i], DP[i-1][2] + B[i])
    DP[i][2] = max(DP[i-1][0] + C[i], DP[i-1][1] + C[i])

print(max(DP[-1]))

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}


int main() {
  int N;
  cin >> N;
  vector< pair< string, int > > uku(N);
  cin >> uku;
  for(auto &p : uku) p.second *= -1;
  vector< int > ord(N);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), [&](int a, int b) {
    return uku[a] < uku[b];
  });

  for(auto &p : ord) cout << p + 1 << endl;
}





Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM)
import Data.List
import Data.Function (on)

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n (f <$> map read <$> words <$> getLine) <*> replicateM n (f <$> map read <$> words <$> getLine) >>= print
  where f [x, y] = (x, y)

solve :: [(Int, Int)] -> [(Int, Int)] -> Int
solve rs bs = loop 0 srs sbs
  where
    srs = sortBy (flip compare `on` fst) rs
    sbs = sortBy (flip compare `on` fst) bs
    loop ct [] _ = ct
    loop ct ((a, b) : xs) ys = if null zs then loop ct xs ys
                               else if null zs' then loop ct xs ys
                                    else loop (ct + 1) xs (delete p ys)
      where zs = takeWhile (\(c, _) -> c > a) ys
            zs' = filter (\(_, d) -> d > b) zs
            p = minimumBy (compare `on` snd) zs'


Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath> 
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
int main(void) {
	int n, k, q; cin >> n >> k >> q;
	vector<ll> v(q);
	vector<ll> aa(n, k);
	ll xx = 0;
	rep(i, q) {
		cin >> v[i];
		aa[v[i] - 1]++;
		xx++;
	}
	rep(i, n) {
		if (aa[i]-xx <= 0)cout << "No" << endl;
		else cout << "Yes" << endl;	
	}
	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

typedef long long ll;

using namespace std;

int gcd(int a, int b)
{
	if (a < b)
		return gcd(b, a);
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
int main()
{
	int a[3], m[3];
	while (scanf("%d %d %d %d %d %d", a, m, a+1, m+1, a+2, m+2), a[0])
	{
		int x[3];
		int c[3];
		for (int i = 0; i < 3; ++i)
		{
			x[i] = 1;
			for (int j = 1; ; ++j)
			{
				x[i] = a[i] * x[i] % m[i];
				if (x[i] == 1)
				{
					c[i] = j;
					break;
				}
			}
		}
		ll t = (ll)c[0]*c[1] / gcd(c[0], c[1]);
		printf("%lld\n", t*c[2] / gcd(t, c[2]));
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, start, end) for (int i=start, i##Len=(end); i < i##Len; ++i)
#define REPR(i, start, end) for (int i=start, i##Len=(end); i > i##Len; --i)
using ll = int64_t;
using namespace std;


int main() {
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;

    if (s.size() == 2) {
        if (s[0] == s[1]) cout << "1 2" << endl;
        else cout << "-1 -1" << endl;
        return 0;
    }

    REP(i, 0, s.size()-2) {
        if (s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;

    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    cin>>N;
    vint A(N);rep(i,N)cin>>A[i];

    int ans=0;
    while(true){
        int latte=0;
        rep(i,N){
            if(A[i]<N)continue;
            int tmp=A[i]-(N-1);
            tmp=(tmp+N)/(N+1);
            latte+=tmp;
            A[i]-=tmp*(N+1);
        }
        if(latte==0)break;
        rep(i,N)A[i]+=latte;
        ans+=latte;
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	string s;
	cin >> s;

	int y = atoi(s.substr(0,4).c_str());
	int m = atoi(s.substr(5,2).c_str());
	int d = atoi(s.substr(8,2).c_str());
	bool tbd = true;
	if(y <= 2018){
		tbd = false;
	}else if(y == 2019){
		if(m <= 4){
			tbd = false;
		}
	}

	println(((tbd)?"TBD":"Heisei"));

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

total = B[A[0]-1]
for i in range(1,len(A)):
    total += B[A[i]-1]
    if A[i] - A[i-1] == 1:
        total += C[A[i-1]-1]

print(total)


Measured memory_bytes: 3064
/*
t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

const double EPS = 1e-5;
const int mod = 1e9 + 7;
const ll INFLL = 1e18;
const int INF = 1e9;
const int maxn = 1e5 + 3;

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

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

bool is_prime(ll a){
    if (a == 2 || a == 3 || a == 5 || a == 7) return true;
    if (a % 2 == 0 || a%3 == 0 || a%5 == 0 || a%7 == 0)
        return false;
    for (ll i = 11; i * i <= a; i += 2){
        if (a % i == 0)
            return false;
    }
    return true;
}

ll binpow(ll a, int n){
    if (a == 0)
        return 1;
    if (a % 2 == 0){
        ll q = binpow(a, n / 2);
        return (q * q)  ;
    }else return (a * binpow(a, n - 1) ) ;
}

istream& operator>>(istream &in, pair<int, int> &p) {
    in >> p.fi >> p.se;
    return in;
}

ostream& operator<<(ostream &out, pair<int, int> &p) {
    out << p.fi << " " << p.se << endl;
    return out;
}



















main(){
    int n;
    cin >> n;
    int ans = 1e9;
    for (int i = 1; i < n; i++){
        int j = n - i;
        int f = i;
        int ce = 0;
        while(f){
            ce += f%10;
            f/=10;
        }
        while(j){
            ce += j%10;
            j/=10;
        }
        ans = min(ans,ce);
    }
    cout << ans;


}


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

int N , M ;
cin >> N >> M ;
if (M%N == 0 )  cout << M+N <<endl ;
  else cout << M-N <<endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool pali(string s,int l,int r){
  while(l<=r){
    if(s[l]!=s[r]){
      return false;
    }
    l++;r--;
  }
  return true;
}
int main(){

  string s;
  cin>>s;
  int n=s.size();
  bool r1 = pali(s,0,n-1);
  bool r2 = pali(s,0,(n-1)/2-1);
  bool r3 = pali(s,(n+3)/2-1,n-1);
  if(r1&&r2&&r3)
  cout<<"Yes";
  else
  cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	vector<vector<int>> to(n), cost(n);
	rep (i, n - 1) {
		int a, b, w;
		cin >> a >> b >> w;
		a--; b--;
		to[a].push_back(b); cost[a].push_back(w);
		to[b].push_back(a); cost[b].push_back(w);
	}
	vector<int> ans(n, -1);
	queue<int> q;
	ans[0] = 0;
	q.push(0);
	while(!q.empty()) {
		int v = q.front(); q.pop();
		rep (i, to[v].size()) {
			int u = to[v][i];
			int w = cost[v][i];
			if (ans[u] != -1) continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}
	rep (i, ans.size()) {
		cout << ans[i] << endl;
	}
	return;
}

int main() {
	solve();
  return 0;
}

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

const int N = 105;

int n, m;
char s[N][N];

bool vis[N][N];
int dist[N][N];

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

int solve() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }

  deque<tuple<int, int, int>> dq;
  dq.push_back(make_tuple(0, 0, s[0][0] == '#'));

  while (dq.size()) {
    int x, y, d;
    tie(x, y, d) = dq.front();
    dq.pop_front();

    if (vis[x][y]) continue;
    dist[x][y] = d;
    vis[x][y] = true;

    for (int k = 0; k < 2; ++k) {
      int nx = x + dx[k];
      int ny = y + dy[k];
      if (nx == n || ny == m) continue;

      if (vis[nx][ny]) continue;
      if (s[x][y] == '.' && s[nx][ny] == '#') dq.push_back(make_tuple(nx, ny, d+1));
      else dq.push_front(make_tuple(nx, ny, d));
    }
  }

  printf("%d\n", dist[n-1][m-1]);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<char> s;
int main() {
	int m, f, r;
	for (;;) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
			break;
		if (m + f >= 80)
			s.push_back('A');
		if (m + f < 80 && m + f >= 65)
			s.push_back('B');
		if (m + f < 65 && m + f >= 50)
			s.push_back('C');
		if (m + f < 50 && m + f >= 30) {
			s.push_back('D');
			if (r >= 50) {
				s.pop_back();
				s.push_back('C');
			}
		}
		if (m + f < 30)
			s.push_back('F');
		if (m == -1 || f == -1) {
			s.pop_back();
			s.push_back('F');
		}
	}
	for (int i = 0; i < s.size(); i++) {
		cout << s[i] << endl;
	}
}


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

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

Measured memory_bytes: 256
//
//  main.cpp
//  temp
//
//  Created by 松本拓真 on 2018/02/25.
//  Copyright © 2018年 TakumaMatsumoto. All rights reserved.
//

#include <iostream>
using namespace std;

bool pay(int val, int cent) {
    val %= 500;
    return cent - val >= 0;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    int n, a;
    cin >> n; cin >> a;
    auto res = pay(n, a);
    cout << (res ? "Yes" : "No");
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())

lines = defaultdict(set)
for i in range(N-1):
	a,b,c = inpl()
	a -= 1
	b -= 1
	lines[a].add((b,c))
	lines[b].add((a,c))

Q,s = inpl()
s -= 1
ss = [-1]*N
ss[s] = 0

def check(a,w):
	global ss
	for b,c in lines[a]:
		if ss[b] == -1:
			ss[b] = w + c
			check(b,w+c)

check(s,0)

for i in range(Q):
	x,y = inpl()
	print(ss[x-1]+ss[y-1])


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

int main() {
  string s;
  cin >> s;
  int result; //結果を記録する変数ACなら1,WAなら2
  int big_char = 0; //大文字の個数を記録する変数

    //最初の文字がAかどうか，3文字目以降後ろから2文字目までにCが含まれるかどうかの判定
    if (s.at(0) != 'A') {
      result = 2;
    } else {
      for (int i = 2; i < s.size() -1; i++) {
        if (s.at(i) == 'C') {
          result = 1;
        } else if(result != 1) {
          result = 2;
        }
        if (s.at(s.size() - 1) == 'C') {
          result = 2;
        }
      }
    }

    //小文字かどうかの判定
    if (!(result == 2)) {
      for (int j = 1; j < s.size(); j++) {
        if (!(s.at(j) >= 'a' && s.at(j) <= 'z')) {
          if (j != 1 && j != s.size()  && s.at(j) == 'C') {
            result = 1;
          } else {
            result = 2;
            break;
          }
        }
      }
    }
    for (int k = 0; k < s.size(); k++) {
      if (s.at(k) >= 'A' && s.at(k) <= 'Z') {
        big_char++;
      }
    }

    //Cを含んでいるかどうかの判定
    for (int l = 0; l < s.size(); l++) {
      int test;
      if (s.at(l) != 'C') {
        test = 1;
        break;
      }
      if (test != 1) {
        result = 2;
      }
    }

  //出力
  if (result == 1 && big_char < 3) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
  return 0;
}


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


def solve(N: int, a: "List[int]"):
    print(sum(a)-N)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

ll RepeatSquare(ll x,ll n,ll mod){
    if(n==0) return 1;
    if(n==1) return x%mod;
    if(n%2==0){
        ll half=RepeatSquare(x,n/2,mod);
        return (half*half)%mod;
    }
    if(n%2==1){
        return x*RepeatSquare(x,n-1,mod)%mod;
    }
}

int main(){
    ll n;
    cin >> n;
    vector<ll> c(n);
    rp(i,n) cin >> c.at(i);
    sort(c.begin(),c.end());
    reverse(c.begin(),c.end());
    ll ans=0;
    rp(i,n){
        ans += c.at(i)*(i+2);
        ans %= 1000000007;
    }
    ans*=RepeatSquare(4,n-1,1000000007);
    ans%=1000000007;
     cout << ans << endl;
     return 0;
}

Measured memory_bytes: 1792
import java.util.*;

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

		int n = sc.nextInt();
		int p[];
		//N <= 20
		p = new int[20];

		for(int i = 0 ; i < n ; i++)
		{
			p[i] = sc.nextInt();
		}

		int ans = 0;
		for(int i = 1 ; i < n-1 ; i++)
		{
			if( ((p[i] - p[i-1]) > 0) ^ ((p[i] - p[i+1]) > 0) )
			{
				ans++;
			}
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
using namespace std;
ll a[1000000+1]={0};
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll i,g=0,p,flag=0,j,k=0;
        for(i=0;i<n;i++)
        {
            cin>>p;
            a[p]++;
            if(a[p]>1 && p>1)
                flag=1;
            if(i==0)
                g=p;
            else
                g=__gcd(p,g);
        }
        if(flag==0){

            for(i=2;i<=1000000;i++)
            {
                k=a[i];
                for(j=i*2;j<=1000000;j+=i)
                {
                    if(a[j]>0)
                        k++;
                    if(k>1)
                        break;
                }
                if(k>1)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0)
        {
            cout<<"pairwise coprime";
        }
        else if(g==1)
            cout<<"setwise coprime";
        else
            cout<<"not coprime";
    }
    return 0;
}


Measured memory_bytes: 11392
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int n = (int)s.length();
	int ans = n;
	for (int i = 0; i < 2; ++i) {
		int cnt = 0;
		for (int j = 0; j < n; ++j) {
			cnt += ((i + j) % 2) != (s[j] - '0');
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(max({a,b,c})==a){
    cout << a*10+b+c << endl;
  }
  else if(max({a,b,c})==b){
    cout << b*10+c+a << endl;
  }
  else if(max({a,b,c})==c){
    cout << c*10+a+b << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int f[4][5];
int main() {
	string s;
	int k;
	cin >> s >> k;
	rep(i, 0, s.size()) {
		s[i] -= 'a';
		if (s[i] && 26 - s[i] <= k)k -= (26 - s[i]), s[i] = 0;
	}
	k %= 26;
	s[s.size() - 1] += k;
	s[s.size() - 1] %= 26;
	rep(i, 0, s.size())s[i] += 'a';
	puts(s.c_str());
	return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;

    const int MOD = 1000000007;
    vector<long long> ex(N+1, 0); // exp[p] := p の指数
    for (long long n = 2; n <= N; ++n) {
        const auto &res = prime_factorize(n); // n の素因数分解
        for (auto p : res) ex[p.first] += p.second;
    }
    long long res = 1;
    for (int p = 2; p <= N; ++p) {
        res *= ex[p] + 1; // 約数の個数は (exp + 1) の積
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

char n, m;
int main(){
    cin >> n >> m;
    cout << (n == m ? "=" : n > m ? ">" : "<") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

struct ordered_pair {
  int n_, n2_;
  explicit ordered_pair(int n): n_(n), n2_(n*2-3) {}
  int64_t operator()(int x, int y) const {
    int z = std::min(x, y);
    return z*(n2_-z)/2 + std::max(x, y) - 1;
  }
};

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int const MAXN = 1000;
int const MAXV = MAXN*(MAXN-1)/2;
int const INF = MAXV+5;
std::vector<int> G[MAXV], rG[MAXV], vs;
bool used[MAXV];
int cmp[MAXV];
void dfs(int v) {
  used[v] = true;
  for(auto c: G[v]) if(!used[c]) dfs(c);
  vs.push_back(v);
}
void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for(auto c: rG[v]) if(!used[c]) rdfs(c, k);
}
int scc(int V) {
  std::fill_n(used, V, false);
  vs.clear();
  for(int v = 0; v < V; ++v) if(!used[v]) dfs(v);
  std::fill_n(used, V, false);
  int k = 0;
  for(int i = vs.size()-1; i >= 0; --i) {
    if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}

int depth[MAXV];
int calc_depth(int v) {
  if(depth[v] >= 0) return depth[v];
  int res = -1;
  for(auto c: G[v]) res = std::max(res, calc_depth(c));
  ++res;
  return depth[v] = res;
}

int main() {
  int N = getZ();
  ordered_pair P(N);
  for(int i = 0; i < N; ++i) {
    int A = getZ()-1;
    int pV = P(i, A);
    for(int j = 1; j < N-1; ++j) {
      int cV = P(i, getZ()-1);
      G[pV].push_back(cV); rG[cV].push_back(pV);
      pV = cV;
    }
  }
  int maxv = N*(N-1)/2;
  if(scc(maxv) < maxv) fin(-1);
  std::fill_n(depth, maxv, -1);
  int ans = 0;
  for(int i = 0; i < maxv; ++i) {
    ans = std::max(ans, calc_depth(i)+1);
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 61424
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int a,b,c,d,e,A,B,C,D,E;
  cin >> a >> b >> c >> d >> e;
  
  A = a % 10; B = b % 10;
  C = c % 10; D = d % 10; E = e % 10;
  int x[] = {a,b,c,d,e};
  int y[] = {A,B,C,D,E};
  int mi = 130, t;
  for(int i = 0; i < 5; i++) {
    if(y[i] != 0 & mi > y[i]) {
      mi = y[i];
      t = i;
    }
  }
  int sum = 0;
  for(int i = 0; i < 5; i++) {
    if(i == t || y[i] == 0) sum += x[i];
    else sum += x[i] + (10-y[i]);
  }
  cout << sum << endl; 
}

Measured memory_bytes: 3564
import sys

n = int(sys.stdin.readline().strip())
a = {}
for line in sys.stdin.readlines():
	b = {}
	for x in line.strip():
		if x not in b:
			b[x]=0
		b[x]=b[x]+1
	
	if a=={}:
		a = b
	else:
		for key in a.keys():
			if key not in b:
				a[key] = 0
			else:
				a[key]=min(a[key],b[key])
result = ""
for key in sorted(a.keys()):
	result = result + key*a[key]
print(result)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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


int main() {
	int n, m;
	while (cin >> n >> m, n){
		vector<vector<int>> dl(n,vector<int>(n,1e8));
		vector<vector<int>> ds(n, vector<int>(n,1e8));
		REP(i, n){
			dl[i][i] = 0;
			ds[i][i] = 0;
		}
		REP(i, m){
			int u, v, t;
			char c;
			cin >> u >> v >> t >> c;
			u--; v--;
			if (c == 'L'){
				dl[u][v] = t;
				dl[v][u] = t;
			}
			else{
				ds[u][v] = t;
				ds[v][u] = t;
			}
		}
		REP(i,n)
			REP(j, n)
				REP(k, n){
			dl[j][k] = min(dl[j][k], dl[j][i] + dl[i][k]);
			ds[j][k] = min(ds[j][k], ds[j][i] + ds[i][k]);
		}
		int r;
		cin >> r;
		vector<int> goal(r);
		REP(i,r){
			cin >> goal[i];
			goal[i]--;
		}
		vector<vector<int>> dp(r, vector<int>(n, 1e8));
		dp[0][goal[0]] = 0;
		FOR(i,1, r){
			REP(j, n){
				REP(k, n){
					dp[i][k] = min(dp[i][k],dp[i - 1][j] + dl[goal[i - 1]][j] + ds[j][k] + dl[k][goal[i]]);
					if (j == k)dp[i][k] = min(dp[i][k], dp[i - 1][j] + dl[goal[i - 1]][goal[i]]);
				}
			}
		}
		int ans = 1e8;
		REP(i, n)
			ans = min(ans, dp[r-1][i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3808
N = int(input())
H = [0]+list(map(int, input().split()))

'''dp[i] : 足場 i にたどり着くまでに支払うコストの総和の最小値'''
dp = [0]*(N+1)
dp[2] = abs(H[1]-H[2])
for i in range(3, N+1):
    dp[i] = min(dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i]))
    
print(dp[N])

Measured memory_bytes: 13928
S=input()
if S[0]==S[1] and S[1]==S[2] and S[0]=='R':
    print(3)
    exit()
if (S[0]=='R' and S[1]=='R') or (S[1]=='R' and S[2]=='R'):
    print(2)
    exit()
if not 'R' in S:
    print(0)
    exit()
    
print(1)

Measured memory_bytes: 61660
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    int N;
    int[] L;
    int[] ABC = new int[3], WK = new int[3];
    int calc(int now, int mp) {
    	if(now >= N) {
    		for (int i = 0; i < 3; i++) {
    			if(WK[i] == 0)		return 999999999;
				mp += Math.abs(ABC[i] - WK[i]);
			}
    		return mp;
    	}
    	int ans = 999999999;
    	ans = Math.min(ans, calc(now+1, mp));
    	for (int i = 0; i < 3; i++) {
    		if(WK[i] == 0) {
    			WK[i] += L[now];
    			ans = Math.min(ans, calc(now+1, mp));
    			WK[i] -= L[now];
    		} else {
    			WK[i] += L[now];
    			ans = Math.min(ans, calc(now+1, mp + 10));
    			WK[i] -= L[now];
    		}
		}
    	return ans;
    }
    public void solve() {
    	N = Integer.parseInt(sc.next());
    	ABC[0] = Integer.parseInt(sc.next());
    	ABC[1] = Integer.parseInt(sc.next());
    	ABC[2] = Integer.parseInt(sc.next());
    	L = new int[N];
    	for (int i = 0; i < N; i++) {
			L[i] = Integer.parseInt(sc.next());
		}
    	out.println(calc(0, 0));
    }
}


Measured memory_bytes: 24532
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int n = sc.nextInt();
      if(n==-1) {
        break;
      }

      double x = Math.cos(0);
      double y = Math.sin(0);
      double r  = Math.PI / 2;

      for(int i=1; i<n; i++) {
        x += Math.cos(r);
        y += Math.sin(r);
        r -= Math.PI / 2 - Math.asin(1 / Math.sqrt(i + 1));
        r += Math.PI / 2;
      }
      System.out.println(x);
      System.out.println(y);
    }
  }
}

Measured memory_bytes: 26144
#include <stdio.h>
#include <string.h>

int main(){
	int Tim, Min, Max;  //Times, Minimum, Maximum
	scanf("%d", &Tim);
	scanf("%d %d", &Min, &Max);
	
	for (Min==Min; Min<=Max; Min++){
		if (Min % Tim == 0){
			printf("OK\n");
			return 0;
		} else {
			continue;
		}

	}
	printf ("NG\n");
return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include <cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main(){
	string S;
	cin >> S;
	ll c = 0;
	rep(i, S.size()) { c += S[i] - '0'; }
	if (c % 9 == 0) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}



Measured memory_bytes: 3708
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.map(String).reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && Number(arr[left]) > Number(arr[i])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(n / 2 - 1); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 157780
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	//for(int i=0;i<N;i++) {}
	static int a[]=new int[51];
	static int b[]=new int[51];
	static int c[]=new int[51];
	static int d[]=new int[51];
	
	
	static int N,M,Q;
	
	public static void main(String[] args) {
		N=sc.nextInt();
		M=sc.nextInt();
		Q=sc.nextInt();
		
		for(int i=0;i<Q;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();
			d[i]=sc.nextInt();
		}
		
		int a[]=new int[N+1];
		a[N]=M;
		for(int i=0;i<N;i++) {
			a[i]=M;
		}
		
		
		dfs(a,N-1);
		p(ans);
		
		
	}
	static int ans=0;
	
	static void dfs(int g[],int i) {
		if(i==-1) {
			
			for(int t:g) {
				//System.out.print("="+t+"=");
			}
			//p();
			
			
			int sum=0;
			for(int cc=0;cc<Q;cc++) {
				if(g[b[cc]-1]-g[a[cc]-1]==c[cc]) {
					sum+=d[cc];
				}
				
				ans=Math.max(ans, sum);
				
			}
			
			
		}
		else {
			for(int v=1;v<=g[i+1];v++) {
				g[i]=v;
				dfs(g,i-1);
			}
		}
		
		
	}
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 38160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		long x = sc.nextInt(), y = sc.nextInt();
		long ans = Long.MAX_VALUE;
		for(int i = 0; i <= Math.max(x, y); i++) {
			long xx = x-i;
			if(xx < 0) {
				xx = 0;
			}
			long yy = y-i;
			if(yy < 0) {
				yy = 0;
			}
			ans = Math.min(ans, a*xx+b*yy+c*2*i);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define N 100010
#define ll long long
using namespace std;
ll an[N];
struct Node{
  int to;
  ll cost;
};
vector<Node> v[N];
void dfs(int x,int fa){
  for(int i=0;i<v[x].size();i++){
    if(v[x][i].to==fa)
      continue;
    an[v[x][i].to]=an[x]+v[x][i].cost;
    dfs(v[x][i].to,x);
  }
}
int main(){
  int n;
  scanf("%d", &n);
  int x,y;
  ll z;
  for(int i=1;i<n;i++){
    scanf("%d%d%lld",&x,&y,&z);
    v[x].push_back({y,z});
    v[y].push_back({x,z});
  }
  int q,t;
  scanf("%d%d",&q,&t);
  dfs(t,0);
  while(q--){
    scanf("%d%d",&x,&y);
    printf("%lld\n",an[x]+an[y]);
  }
  return 0;
}

Measured memory_bytes: 15872