akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}
int main()
{

    ll wa = 0, target = 0, n, sa = INF;

    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        target += a[i];
    }
    rep(i, n)
    {
        wa += a[i];
        sa = min(sa, abs(wa * 2 - target));
    }

    cout << (int)sa << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol x;
  cin >> x;
  lol ans = 0;
  ans = UPDigit(x, 11);
  ans *= 2;
  x %= 11;
  if(x != 0 && x <= 6){
    ans --;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		ArrayList<Integer> calclist = new ArrayList<Integer>();
		int[] calcarray = new int[10000];

		for (int x = 0; x < 100; x++) {
			for (int y = 0; y < 100; y++) {
				for (int z = 0; z < 100; z++) {
					int subans = subcalc(x + 1, y + 1, z + 1);
					if (subans > 10000)
						break;
					calcarray[subans - 1]++;
				}
			}
		}

		for (int i = 0; i < N; i++) {
			System.out.println(calcarray[i]);

		}
	}

	private static int subcalc(int x, int y, int z) {
		return x * x + y * y + z * z + x * y + x * z + y * z;
	}

}


Measured memory_bytes: 39228
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	A[N] = mod;
	int ans = 0, cnt = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] == A[i + 1]) cnt++;
		else {
			if (cnt % 2 == 1) ans++;
			cnt = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left)  + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	int deg = 0;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	if(T[u].left  != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL) {
		printf("root\n");
	} else if(T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main(void) {
	int i, v, l, r, root = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++) T[i].parent = NIL;
	for(i=0;i<n;i++) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].left  = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for(i=0; i<n; i++)
	if(T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(i=0;i<n;i++) print(i);
	
	return 0;
}



Measured memory_bytes: 2080
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;

int dx[4]={1,-1,4,-4};
map<string,int>res;


void solve(void){
  queue<string>que;

  que.push("01234567");

  while(!que.empty()){

    string v=que.front();

    que.pop();

    int pos=0;
    for(int i=0;i<8;i++)
      if(v[i]=='0')pos=i;

    for(int i=0;i<4;i++){
      if(0 <= pos+dx[i] && pos+dx[i]<8 && 
	 !(pos==3 && i==0) && !(pos==4 && i==1)){
	string u=v;
	swap(u[pos],u[pos+dx[i]]);

	if(res[u]==0){
	  que.push(u);
	  res[u]=res[v]+1;
	}
      }
    }
  }

}

int main(void){
  int in;
  
  res["01234567"]=1;

  solve();

  while(true){
    string s;
    for(int i=0;i<8;i++){
      if(!(cin >> in))return 0;
      s+=in+'0';
    }

    cout << res[s]-1 << endl;
  }

  return 0;
}

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

int main() {

  vector<int> a(9);
  REP(i,9) {
    cin >> a[i];
  }
  
  int n;
  cin >> n;
  
  int b;
  REP(j,n) {
    cin >> b;
    REP(k,9) {
      if(b == a[k]) a[k] = 0;
    }
  }
  
  bool ans = false;
  
  if(a[0] == 0 && a[3] == 0 && a[6] == 0) ans = true;
  if(a[1] == 0 && a[4] == 0 && a[7] == 0) ans = true;
  if(a[2] == 0 && a[5] == 0 && a[8] == 0) ans = true;
  if(a[0] == 0 && a[1] == 0 && a[2] == 0) ans = true;
  if(a[3] == 0 && a[4] == 0 && a[5] == 0) ans = true;
  if(a[6] == 0 && a[7] == 0 && a[8] == 0) ans = true;
  if(a[0] == 0 && a[4] == 0 && a[8] == 0) ans = true;
  if(a[2] == 0 && a[4] == 0 && a[6] == 0) ans = true;
  
  cout << ((ans) ? "Yes" : "No") << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;



ll f(ll n) {
  ll r=n%4;
  if(r==0) {
    return n;
  }else if(r==1) {
    return 1;
  }else if(r==2) {
    return n^1;
  }else if(r==3) {
    return 0;
  }
  
  return 0;
}

int main(void) {
  ll A, B;
  cin >> A >> B;
  
  pt((f(A-1)^f(B)));
  
  
  
  
}






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

typedef long long lint;
typedef long double louble;

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

int main()
{
	lint a=ty(),b=ty(),c=ty(),tim=ty();
	if(tim&1)cout<<b-a<<lf;
	else cout<<a-b<<lf;

	return 0;
}


Measured memory_bytes: 256
n = int(input())

house = [[[0] * 10 for _ in range(3)] for _ in range(4)]
for _ in range(n):
    a = input()
    b, f, r, v = map(int, a.split())
    house[b - 1][f - 1][r - 1] += v
    if house[b - 1][f - 1][r -1] < 0:
        house[b - 1][f-1][r-1] = 0
    elif house[b - 1][f-1][r-1] >= 10:
        house[b - 1][f-1][r-1] = 9


for i in range(len(house)):
    for j in house[i]:
        word=''
        for k in range(10):
            word += ' ' + str(j[k])
        print(word)
    if i + 1 == len(house):
        pass
    else:
        print('#' * 20)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;
  Vll a(n); cin >> a;
  sort(all(a));

  auto f = [&] (ll x) {
    ll now = 0;
    int i = 0;
    for (; i < n && a[i] <= x; ++i) now += a[i];
    for (; i < n && a[i] <= 2*now; ++i) now += a[i];
    return i == n;
  };

  ll ok = ll(2e10) + 5;
  ll ng = 0;
  while (llabs(ok - ng) > 1) {
    ll md = (ok + ng) / 2;
    if (f(md)) ok = md;
    else ng = md;
  }

  int ans = n;
  ans -= lower_bound(all(a), ok) - a.begin();
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3988
import Control.Monad (replicateM)
import Data.List (group, sort, length, maximum, (\\))

import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main = do
  n  <- readInt
  ss <- replicateM n C.getLine
  m  <- readInt
  ts <- replicateM m C.getLine
--  print $ maximum . uncurry diff $ f ss ts
  print $ solve ss ts

type CB = C.ByteString

f :: [CB] -> [CB] -> ([[CB]],[[CB]])
f ss ts = (gs ss, gs ts) 

gs = group . sort

diff :: [[CB]] -> [[CB]] -> [Int]
diff [] _ = [0]
diff s [] = map length s
diff sss@(s:ss) ttt@(t:ts)
  | head s >  head t =  0 : diff sss ts
  | head s == head t = (length s - length t) : diff ss ts
  | head s <  head t = length s : diff ss ttt

-- https://atcoder.jp/contests/abc091/submissions/2219255
solve ss ts = f . map length . group . sort $ ds
  where
    f xs
      | null xs   = 0
      | otherwise = maximum xs
    ds = ss \\ ts


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
LL n,m;
int main(){
	cin>>n>>m;
	if(n==1||m==1){
		if(n==m)cout<<1<<endl;
		else cout<<max(n,m)-2<<endl;
	}
	else if(n==2||m==2){
		cout<<0<<endl;
	}
	else{
		cout<<n*m-min(n,m)*2-(max(n,m)-2)*2<<endl;
	}
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] abc = br.readLine().split(" ");
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);                                     
        System.out.println(a*b/2);
    }
}


Measured memory_bytes: 22996
'use strict';
(function(stdin) {

  var inputs  = stdin.toString().trim().split('\n');
  var EOF = inputs.indexOf('0 0');
  var matrics = inputs.slice(0, EOF).map(function(v) {
    return v.split(' ').map(Number);
  });

  matrics.map(function(v){
    return v.sort(function(a, b){ return a - b;})
  });

  function print(line){
  return line.map(function(v){return v.join(' ');}).join('\n');
    }

  console.log(print(matrics));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 18396
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long x = long.Parse(ReadLine());
            long now = 0;
            long i = 0;
            while (now < x)
            {
                now += i;
                i++;
            }
            WriteLine(i - 1);
        }
    }
}

Measured memory_bytes: 13140
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(ll(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int N, ans;
    cin >> N >> ans;
    for (int i = 0; i < N - 1; ++i) {
        int a;
        cin >> a;
        ans = gcd(ans, a);
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N;
    cin>>N;
    v A(N);
    rep(i,0,N)cin>>A[i];

    ll zero,one;
    ll ans = 0;
    ll now_2 = 1;
    rep(i,0,62){
        zero=0;one=0;
        rep(j,0,N){
            if(A[j]%2 == 0)zero++;
            else one++;
            A[j] /= 2;
        }
        ans += ((zero*one)%MOD)*now_2;
        ans %= MOD;
        now_2*=2;
        now_2 %=MOD;
    }
    ans%=MOD;
    while(ans < 0)ans += MOD;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
import sys
X, Y, Z, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
AB = []
ans = []
for a in A:
    for b in B:
        AB.append(a + b)
AB.sort(reverse=True)
AB = AB[:min(3001, X*Y*Z+1)]
for c in C:
    for ab in AB:
        ans.append(c + ab)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])


Measured memory_bytes: 141580
N = gets.to_i
a_list = gets.split.map(&:to_i)

f_list = Array.new(N)
f_list[0] = a_list[0]
(1...(a_list.size)).each do |i|
  f_list[i] = f_list[i - 1] + a_list[i]
end

b_list = Array.new(N)
b_list[0] = a_list[-1]
(1...(a_list.size)).each do |i|
  b_list[i] = b_list[i - 1] + a_list[-(i + 1)]
end

min = 2 << 60
(0...(a_list.size - 1)).each do |i|
  j = -i - 1 - 1
  min = [(f_list[i] - b_list[j]).abs, min].min
end
puts min


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {

  int N; cin >> N;
  cout << N / 3 << endl;

  

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

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  int n;
  string s;
  cin >> n >> s;

  map<char, int> cnt;
  rep(i, 0, n){
    cnt[s[i]]++;
  }

  if(cnt['R'] > cnt['B']) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int a[3000],b[3000];
int i;
scanf("%d %d",&a[0],&b[0]);

while(a[i]!=0 || b[i]!=0){
if(b[i]<a[i]) 
printf("%d %d\n",b[i],a[i]);
else
printf("%d %d\n",a[i],b[i]);
i++;
scanf("%d %d",&a[i],&b[i]);
}
return 0;
}


Measured memory_bytes: 2040
#疑似コード読み違えた
N=int(input())
L=input().split( )
A=[int(L[i]) for i in range(N)]
c=0
j=N-1
flag=1
while flag:
    flag=0
    for j in range(N-1):
        if A[j+1]<A[j]:
            temp=A[j]
            A[j]=A[j+1]
            A[j+1]=temp
            c+=1
            flag=1
for j in range(N):
    if j<N-1:
        print(A[j],end=" ")
    else:
        print(A[j])
print(c)



Measured memory_bytes: 5612
import java.io.*;
import java.util.*;

class Ring{
	String str1;
	
	Ring(String str1){
		this.str1 = str1 + str1;
	}
}

class Keyword{
	String str2;
	
	Keyword(String str2){
		this.str2 = str2;
	}
}

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Ring x = new Ring(br.readLine());
		Keyword y = new Keyword(br.readLine());
		
		if(x.str1.contains(y.str2)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
ll T;
ll t[200010];
int main(void){
	cin >> N >> T;
	rep(i, N) cin >> t[i];

	ll ans = T;
	ll now = T;
	reps(i, 1, N){
		if(t[i] - t[i - 1] > T){
			// printf("k %d\n", t[i]);
			now = t[i] + T;
			ans += T;
		}else{
			ll now1 = t[i] + T;
			ans += now1 - now;
			now = now1;
		}
		// printf("%lld %lld\n", now, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

//ll x[51] = {};
//ll m[51][51][2501] = {};
//ll n;
int N, A;
int x[51];
ll dp[51][51][3010];
void print(ll p) {
	cout << endl;
	cout << "  ";
	rep(i, 0, 50) {
		cout << i % 10;
	}
	cout << endl;
	repe(i, 0, N) {
		cout << i << " ";
		rep(j, 0, 50) {
			cout << dp[p][i][j] % 10;
		}
		cout << endl;
	}
}

int main() {
	ll a; cin >> N >> a;
	repe(i, 1, N)cin >> x[i];

	dp[0][0][0] = 1;

	repe(i, 1, N) {
		ll X = x[i];
		repe(h, 0, i) {
			rep(w, 0, 2501) {
				if (dp[i - 1][h][w] != 0) {
					dp[i][h][w] += dp[i - 1][h][w];
				}

				if (w - X >= 0 && h - 1 >= 0 && dp[i - 1][h - 1][w - X] != 0) {
					dp[i][h][w] += dp[i - 1][h - 1][w - X];
				}
			}
		}

		//print(i);
	}

	ll ans = 0;
	repe(i, 1, N) {
		ans += dp[N][i][a*i];
	}
	cout << ans << endl;
	return 0;
}

//-----------------------------------------------------------------
//int main() {
//	cin >> N >> A;
//	rep(i, 0, N) cin >> x[i];
//
//	dp[0][0][0] = 1;
//	rep(i, 0, N) {
//		rep(j, 0, N) {
//			rep(k, 0, 2500) {
//				if (dp[i][j][k]) {
//					dp[i + 1][j][k] += dp[i][j][k];
//					dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
//				}
//			}
//		}
//		print(i + 1);
//	}
//
//	ll ans = 0;
//	rep(i, 1, N + 1) ans += dp[N][i][i*A];
//	cout << ans << endl;
//}

Measured memory_bytes: 58240
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double hAngle = H * 30 + M / 2.0;
    double mAngle = M * 6.0;

    hAngle = hAngle * M_PI / 180.0;
    mAngle = mAngle * M_PI / 180.0;

    double hx = A * cos(hAngle), hy = A * sin(hAngle);
    double mx = B * cos(mAngle), my = B * sin(mAngle);

    double dist = (hx - mx) * (hx - mx) + (hy - my) * (hy - my);
    cout << fixed << setprecision(10) << sqrt(dist) << endl;
    return 0;
};

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

    int n; cin >> n;
    vector<int> x(n), y(n), h(n);
    int resx, resy, resh;
    for(int i=0; i<n; ++i){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0)  { resx = x[i], resy = y[i], resh = h[i]; }
    }

    for(int X=0; X<=100; ++X){
        for(int Y=0; Y<=100; ++Y){
            bool all_ok = true;
            int H = resh + abs(resx - X) + abs(resy - Y);
            if(H == 0) continue;

            for(int i=0; i<n; ++i){
                if(h[i] != max(0, H-abs(X-x[i])-abs(Y-y[i]))){
                    all_ok = false;
                    break;
                }
            }

            if(all_ok) {
                printf("%d %d %d\n", X, Y, H);
            }
        }
    }
    
	return 0;
}

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

int main(){
    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    sa+='x',sb+='x',sc+='x';
    char f;
    int y;
    string sn=sa;
    while(1){
        if(sn==sa) {
            f=sa[0];
            sa.erase(0,1);
        }
        else if(sn==sb) {
            f=sb[0];
            sb.erase(0,1);
        }
        else if(sn==sc) {
            f=sc[0];
            sc.erase(0,1);
        }
        if(f=='a') {
            sn=sa;
            y=0;
        }
        else if(f=='b') {
            sn=sb;
            y=1;
        }
        else if(f=='c') {
            sn=sc;
            y=2;
        }
        else if(f=='x') break;
    }
    if(y==0) cout << 'A' << endl;
    else if(y==1) cout << 'B' << endl;
    else if(y==2) cout << 'C' << endl;
    //else cout << "error" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <queue>
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define REP(i,a,n) for(int i=a;i<=n;++i)
using namespace std;
const int N = 1e6+10;
int n,k,a[N],b[N],deg[N];
vector<int> g[N];
set<int> L,R;
priority_queue<int> q;
int main() {
	scanf("%d%d",&n,&k);
	REP(i,1,n) scanf("%d",a+i),b[a[i]]=i;
	REP(i,1,k) R.insert(a[i]);
	REP(i,1,n) {
		auto p = L.upper_bound(a[i]);
		if (p!=L.end()) g[b[*p]].push_back(i),++deg[i];
		p = R.upper_bound(a[i]);
		if (p!=R.end()) g[b[*p]].push_back(i),++deg[i];
		L.insert(a[i]),R.erase(a[i]);
		if (i-k+1>0) L.erase(a[i-k+1]);
		if (i+k<=n) R.insert(a[i+k]);
	}
	REP(i,1,n) if (!deg[i]) q.push(i);
	PER(i,1,n) {
		int u = q.top(); q.pop();
		a[u] = i;
		for (int v:g[u]) if (!--deg[v]) q.push(v);
	}
	REP(i,1,n) printf("%d\n",a[i]);
}


Measured memory_bytes: 77952
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
using ll = long long int;

int n, ret = 0;
vector<int> p;

inline void pswap(int i, int j) {
	int tmp = p[i] + 1;
	p[i] = p[j] - 1;
	p[j] = tmp;
}

int swap(int left, int right) {
	int cnt = 0;
	for (int i = left; i < right; i++) {
		pswap(left, left + 1);
		cnt++;
	}
	return cnt;
}

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int pi;
		cin >> pi;
		p.push_back(pi - i - 1);
	}

	for (int i = 0; i < n; i++) {
		if (p[i] == 0) {
			ret += swap(i, i + 1);
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 892
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


vector<bool> isp;
void sieve(int N) {
	isp.assign(N+1, true);
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

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

	int N = pow(p, 0.5)+1;
	// cout << M << endl ;
	sieve(N);

	map<ll, ll> mi;
	ll P = p;
	rep(i, N) {
		if (isp[i]) {
			while (P>1 && P%i==0) {
				P /= i;
				mi[i] += 1;
			}
		}
	}

	if (n==1) cout << p << endl;
	else if (mi.size()==0) cout << 1 << endl;
	else {
		ll ans = 1;
		for (const auto& m: mi) {
			ll k=m.first, v=m.second;
			// cout << k << " " << v << endl;
			if (v >= n) ans *= pow(k, (v/n));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, 0, n) {
        int h;
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fastIO  std::ios::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define rep(i, l, r) for (long long i = (l); i < (r); i++)
#define repb(i, r, l) for (long long i = (r); i > (l); i--)
#define ll long long
#define pb push_back
#define SZ(x) ((int) (x).size())
 
using namespace std;
 
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull; 
const int MAX_CHAR=256;
 


bool palin(string s){
    string s1=s;
    reverse(s.begin(),s.end());
    return s==s1;
}

ll exp(lli b,lli e){
    ll sum=1;
    b=b%1000000007;
    while(e!=0){
        if(e&1) sum=(sum* b)%1000000007;
        e=e>>1;
        b=(b*b)%1000000007;
    }
    return sum;
}

bool sam(string s){
    for(int i=1;i<s.length();i++){
        if(s[i]!=s[i-1])    return false;
    }
    return true;
}

int k;

bool bool_comp(vector<ll>& v1,vector<ll>& v2){
    if(abs(v1[1]-v2[1])<abs(v1[0]-v2[0]))   return v1[1]<v2[1];
    return v1[0]<v2[0];
}
bool bool_comp1(vector<ll>& v1,vector<ll>& v2){
    
    return v1[1]<v2[1];
}
bool bool_comp2(vector<ll>& v1,vector<ll>& v2){
    
    return v1[0]<v2[0];
}

int main(){
	fastIO;
	int n;
	cin>>n;
	ll l[n];
	for(int i=0;i<n;i++)cin>>l[i];
	sort(l,l+n);
	int count=0;
	for(int i=0;i<n-2;i++){
	    for(int j=i+1;j<n-1;j++){
	        if(l[i]==l[j])continue;
	        int x=l[i]+l[j];
	        for(int k=j+1;k<n;k++){
	            if(l[i]==l[k]||l[j]==l[k])continue;
	            if(l[k]<x)count++;
	            else break;
	        }
	    }
	}
	cout<<count;
}
// static int a=20; 
// void xyz() 
// { 
// 	printf("%d, ", a); 
// 	a = 100; 
// } 
// int main() 
// { 
// 	printf("%d, ", a); 
// 	{ 
// 		static int a = 10; 
// 		printf("%d, \n", a); 
// 		xyz(); 
// 	} 
// 	printf("%d", a); 
// } 

Measured memory_bytes: 3656
/**
 *    author:  yoseph
 *    created: 25.07.2020 08:46:29      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin >> c;
	if (c >= 'a' && c <= 'z')
		cout << "a\n";
	else
		cout << "A\n";
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int a, b;
	cin>>a>>b;
	if(a>9 || b>9)
	{
		cout<<-1<<"\n";
		return;
	}
	cout<<a*b<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int a[100001];

int minCost(int arr[], int& n, int k, int i, int sum){
    if(i==n-1){
        return sum;
    }
    int x = INT_MAX, temp = sum;
    sum = 0;
    for(int j = 1; j <= k && i+j<n; j++){
        sum += abs(arr[i+j]-arr[i]);
        if(a[i+j]!=-1) x = min(x, sum + a[i+j]);
        else x = min(x, minCost(arr, n, k, i+j, sum));
        sum -= abs(arr[i+j]-arr[i]);
    }
    // if(i+k>n-1) x = min(x, minCost(arr, n, k, n, sum));
    a[i] = x;
    return temp + a[i];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, k;
    cin >> n >> k;
    memset(a, -1, sizeof(a));
    int m = 0;
    int arr[n];
    
    for(int i = 0; i < n; i++){
        cin >> arr[i] ;
    }
    
    m = minCost(arr, n, k, 0, m);
    
    cout << m;
    
    return 0;
}

Measured memory_bytes: 15304
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let n: usize = util::get();
    let a: Vec<usize> = util::gets();

    let mut counts = HashMap::new();

    for &x in &a {
        *counts.entry(x).or_insert(0) += 1;
    }

    let d = counts
        .values()
        .filter(|&&x| x > 0)
        .map(|&x| x - 1)
        .sum::<usize>();

    println!("{}", a.len() - d - (d % 2))
}


Measured memory_bytes: 12540
n = int(input())
p = [int(x) for x in input().split()]

flag = all(p[i] <= p[i+1] for i in range(n - 1))

for i in range(n):
	for j in range(i + 1, n):
		p[i], p[j] = p[j], p[i]
		if all(p[i] <= p[i+1] for i in range(n - 1)):
			flag = True
			break
		p[i], p[j] = p[j], p[i]
	
if flag:
	print("YES")
else:
	print("NO")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b, ans = 0;
   cin >> a >> b;
   if (a > 12)
      ans = b;
   else if (a > 5)
      ans = b / 2;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  
  var inp = input.split(' ');
  var a = parseInt(inp[0]);
  var b = parseInt(inp[1]);

  if(a * b % 2 === 1){
    console.log('%s', 'Odd');  
  } else {
    console.log('%s', 'Even');  
  }
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    char a = in<string>()[0] + 'A' - 'a';
    char b = in<string>()[0] + 'A' - 'a';
    char c = in<string>()[0] + 'A' - 'a';
    cout << a<<b<<c << "\n";
}

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

int main() {
	int n, k;
	int sum;
	int l[55];
	cin >> n >> k;
	for (int i=0; i<n; ++i) cin >> l[i];
	sort(l, l+n, greater<int>());
	for (int i=0; i<k; ++i) sum+=l[i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
using ll = long long;

int main() {
    vector<bool> c(3, false);
    for (int i = 0; i < 2; i++)
    {
        int a; cin >> a;
        a--;
        c[a] = true;
    }
    for (int i = 0; i < 3; i++)
    {
        if (!c[i]) {
            cout << i+1 << endl;
            return 0;
        } 
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> G[n];
    rep(i, m){
        int u, v;
        scanf("%d%d", &u, &v);
        G[--u].push_back(--v);
    }
    int s, t;
    scanf("%d%d", &s, &t);
    --s; --t;
    int d[n][3];
    rep(i, n)rep(j, 3) d[i][j] = -1;
    queue<pip> que;
    d[s][0] = 0;
    que.push(pip(0, pii(s, 0)));
    while(!que.empty()){
        pip p = que.front(); que.pop();
        int v = p.se.fi;
        int td = p.fi;
        int r = p.se.se;
        if(v == t && r == 0){
            printf("%d\n", td/3);
            return 0;
        }
        for(int nv: G[v])if(d[nv][(r+1)%3] < 0){
            d[nv][(r+1)%3] = td + 1;
            que.push(pip(td + 1, pii(nv, (r+1)%3)));
        }
    }
    printf("-1\n");
}

Measured memory_bytes: 6912
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            if(N % 2 == 0){
              System.out.println(N);
            } else {
              System.out.println(N * 2);
            }
      }
}

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

int main(){
    int n, m, i, j;
    while (cin >> n >> m && (n != 0 || m != 0)){
        for (i = 0; i < n; i++){
            for (j = 0; j < m; j++){
                if (i == 0 || i == n - 1 || j == 0 || j == m - 1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 4e5 + 5;
const int MOD = 1e9 + 7;

int n, m, k;
int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}


int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	precompute();
	int ans = 0;
	int always = nCr(n * m - 2, k - 2);
  	// We can split the part for calculating Manhattan distance into two seperate parts
    // one for x distance (m*m*(n - dist))
    // one for y distace (n*n*(m - dist))
	for(int dist = 1; dist <= n - 1; dist++)
	{
		int cur = dist;
		int pairs = m * m;
		pairs %= MOD;
		pairs *= (n - dist);
		pairs %= MOD;
		cur *= pairs;
		cur %= MOD;
		cur *= always;
		cur %= MOD;
		ans += cur;
		ans %= MOD;
	}
	for(int dist = 1; dist <= m - 1; dist++)
	{
		int cur = dist;
		int pairs = n * n;
		pairs %= MOD;
		pairs *= (m - dist);
		pairs %= MOD;
		cur *= pairs;
		cur %= MOD;
		cur *= always;
		cur %= MOD;
		ans += cur;
		ans %= MOD;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6528
N=int(input())
A = []
for i in range(N):
    s,p = input().split()
    p = int(p)
    A.append((s,p,i+1))
A = sorted(A,key=lambda x:x[1],reverse=True)
A = sorted(A,key=lambda x:x[0])
for i in range(N):
    s,p,k = A[i]
    print(k)

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

int main(){
  string S;
  cin >>S;
  
  string ans;
  if(S=="Sunny") ans = "Cloudy";
  else if(S=="Cloudy") ans = "Rainy";
  else if(S=="Rainy") ans = "Sunny";

  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <iostream> 
using namespace std;
long long knapsack(int W,int wt[],int val[],int n)
{
	long long k[n+1][W+1];
	int i,w;
	for(int i=0;i<n+1;i++)
	{
		for(int w=0;w<W+1;w++)
		{
			if(i==0||w==0)
			k[i][w]=0LL;
			else if(wt[i]<=w)
			k[i][w]=max(val[i]+k[i-1][w-wt[i]],k[i-1][w]);
			else
			k[i][w]=k[i-1][w];
		}
	}
    return k[n][W];

}
int main()
{
	int n,W;cin>>n>>W;
	int val[n+1],wt[n+1];
	for(int i=1;i<n+1;i++)cin>>wt[i]>>val[i];
	cout<<knapsack(W,wt,val,n)<<endl;	
}

Measured memory_bytes: 79104
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
int a,b;
int main()
{
	re(a),re(b);
	if(a<=0 && 0<=b)puts("Zero");
	else if(b<0)puts((b-a)&1?"Positive":"Negative");
	else puts("Positive");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    int div_count = 0;
    vector<int> count;

    for (int i = 1; i<=100; i++) {
        //cout << i << " " << A/i << " " << B/i << "\n";
        if (A%i == 0 && B%i == 0 ) {
            count.push_back(i);
        }
    }
    cout << count[count.size()-K];

    return 0;
}   


Measured memory_bytes: 256
import java.util.*; 
import java.io.*;

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

        int a = nextInt();

        int ans = a + a*a + a*a*a;
        
        System.out.println(ans);

    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32612