akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<array>
#include<algorithm>
#include <random>
std::random_device seed_gen;
std::mt19937 engine(seed_gen());
std::uniform_int_distribution<> dD {0, 364};

int const INF = 1e9;
int const M = 12000;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(int& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(int& si: s[d]) std::cin >> si;
  }
  
  // greedy
  std::vector<int> t(D);
  int ans = 0;
  int last[26];
  std::fill_n(last, 26, -1);
  for(int d = 0; d < D; ++d) {
    int ma = -INF;
    t[d] = 0;
    for(int T = 1; T <= 26; ++T) {
      int cur = s[d][T-1];
      int sv = last[T-1];
      last[T-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        cur -= (d-last[cx])*c[cx];
      }
      last[T-1] = sv;
      if(cur > ma) { ma = cur; t[d] = T; }
    }
    ans += ma;
    last[t[d]-1] = d;
  }
  
  auto score = [&]()->int {
    int ans = 0;
    int last[26];
    std::fill_n(last, 26, -1);
    for(int d = 0; d < D; ++d) {
      ans += s[d][t[d]-1];
      last[t[d]-1] = d;
      for(int cx = 0; cx < 26; ++cx) {
        ans -= (d-last[cx])*c[cx];
      }
    }
    return ans;
  };
  
  // modify
  for(int m = 0; m < M; ++m) {
    int d = dD(engine);
    int sv = t[d], tx = 0;
    for(int T = 1; T <= 26; ++T) if(T != sv) {
      t[d] = T;
      int new_ans = score();
      if(new_ans > ans) { ans = new_ans; tx = T; }
    }
    if(tx == 0) t[d] = sv;
    else t[d] = tx;
  }
  for(int ti: t) std::cout << ti << "\n";
  
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    a=fabs(a-x);
    b=fabs(b-x);
    if(a>b)
    {
        cout<<"B"<<endl;
    }
    else
    {
        cout<<"A"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Text;

namespace ConsoleApplication1
{
    class Node
    {
        internal int id;
        internal int key;
        internal int parentId { get { return id / 2; } }
        internal int leftId { get { return id * 2; } }
        internal int rightId { get { return id * 2 + 1; } }

        public Node(int i, int k)
        {
            id = i;
            key = k;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int h = int.Parse(Console.ReadLine());
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Node[] A = new Node[h + 1];

            for (int i = 0; i < h; i++) A[i + 1] = new Node(i + 1, input[i]);

            StringBuilder sb;
            for (int i = 1; i <= h; i++)
            {
                sb = new StringBuilder();
                sb.Append("node " + A[i].id + ": key = " + A[i].key + ", ");
                if (A[i].parentId >= 1) sb.Append("parent key = " + A[A[i].parentId].key + ", ");
                if (A[i].leftId <= h) sb.Append("left key = " + A[A[i].leftId].key + ", ");
                if (A[i].rightId <= h) sb.Append("right key = " + A[A[i].rightId].key + ", ");
                Console.WriteLine(sb);
            }
        }
    }
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  cout << (N % 1000 == 0 ? 0 : 1000 - (N % 1000)) << endl;
  return 0;
}

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

int main(){
  int a[8];
  for(int i=0;i<8;i++)a[i] = i;
  map<string,int> m;
  do{
    string s;
    for(int i=0;i<8;i++)s += a[i]+'0';
    m.insert( map<string,int>::value_type(s,-1) );
  }while(next_permutation(a,a+8));

  m["01234567"] = 0;

  queue<string> q;
  q.push("01234567");

  string str;
  int tmp;
  while(q.size()){
    str = q.front();
    q.pop();
    tmp = m[str];
    
    int pos;
    for(int i=0;i<8;i++){
      if(str[i] == '0')pos = i;
    }
    
    int c[4] = {-4,-1,1,4};
    for(int i=0;i<4;i++){
	if(pos + c[i] < 0 || pos + c[i] > 7 || (pos==3 && c[i]==1) || pos==4 && c[i]==-1 )continue;
	swap(str[pos],str[pos+c[i]]);
	if(m[str]<0){
	  //cout << tmp << ":[" << str << "]" << endl;
	  q.push(str);
	  m[str] = tmp+1;
	}
	swap(str[pos],str[pos+c[i]]);  
      }
    }

  while(cin >> a[0]){
    for(int i=1;i<8;i++)cin >> a[i];
    string s;
    for(int i=0;i<8;i++)s += a[i]+'0';

    cout << m[s] << endl;
  }
}

Measured memory_bytes: 3416
#include <iostream>
#include <algorithm>

int main() 
{
	typedef long long ll;
	ll N, K;
	std::cin >> N >> K;

	ll *H = new ll[N];
	for (ll i = 0; i < N; i++)
	{
		std::cin >> H[i];
	}
	std::sort(H, H + N);
	ll sum = 0;
	for (ll i = 0; i < N - K; ++i)
	{
		sum += H[i];
	}

	std::cout << sum << std::endl;
}

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();
        sc.close();
        boolean ebishu = true;
        int i = 0;
        while(ebishu){
            n -= 100;
            i += 5;
            if(n >= 0 && n <= i){
                ebishu = false;
                System.out.println(1);
            }else if(n < 0){
                ebishu = false;
                System.out.println(0);
            }
        }
    }
}

Measured memory_bytes: 35680
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			int[] A = new int[N];
			for(int i = 0; i < N; i++){
				A[i] = sc.nextInt();
			}
			int now = 0;
			for(int i = 0; i < N; i++){
				now = A[now] - 1;
				if(now == 1) {
					System.out.println(i+1);
					return;
				}
			}
			System.out.println(-1);
		}
	}
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N, M, K;
    cin >> N >> M >> K;
    for(i = 0; i < N + 1; i++) {
        for(j = 0; j < M + 1; j++) {
            ll b = i * M;
            ll d = N - i - i;
            b += j * d;
            if(b == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
  int r = 0;
  char s[128];
  while (scanf("%s", s) == 1) {
    int n = strlen(s), c = 1;
    for (int i = 0; i < n - i - 1; i++)
      if (s[i] != s[n-i-1]) {
        c = 0;
        break;
      }
    r += c;
  }
  printf("%d\n", r);
  return 0;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////
ll gcd(ll a,ll b){
    if(a>b)swap(a,b);
    if(a==0)return b;
    return gcd(b%a,a);
}

int main(){fastio
    
    ll n,x,d;cin>>n>>x>>d;
    if(d==0){
        if(x==0){
            cout<<1<<endl;
        }else{
            cout<<n+1<<endl;
        }
        return 0;
    }
    if(d<0){
        x=x+(n-1)*d;
        d=-d;
    }
    ll g=gcd(abs(x),d);
    x/=g;d/=g;
    
    ll ans=0;
    if(n+1>=d){
        vector<ll>v[d];
        rep(i,0,n){
            ll c=(i*x)%d;
            if(c<0)c+=d;
            v[c].pb(i);
        }
        rep(i,0,d-1){
            if(v[i].size()==0)continue;
            vector<l_l>u;
            for(auto y:v[i]){
                u.pb(l_l((y-1)*d*y/2+x*y,x*y+(2*n-1-y)*d*y/2));
            }
            sort(u.begin(),u.end());
            ll us=u.size();
            ll j=0;
            while(j<=us-1){
                ll l=u[j].fi;
                ll r=u[j].se;
                j++;
                while(j<=us-1&&u[j].fi<=r){
                    Min(l,u[j].fi);
                    Max(r,u[j].se);
                    j++;
                }
                ans+=(r-l)/d+1;
            }
        }
        
    }else{
        rep(y,0,n){
            ll l=(y-1)*d*y/2+x*y,r=x*y+(2*n-1-y)*d*y/2;
            ans+=(r-l)/d+1;
        }
    }
    cout<<ans<<endl;
    
    return 0;
    
}


Measured memory_bytes: 8048
//    ABC073B.C

#include<stdio.h>

int N, l[1001] = {0}, r[1001] = {0};

int main(void){
    
    int i, sum = 0;

    scanf("%d", &N);
    for (i = 0; i < N; i++) {
        scanf("%d %d",&l[i], &r[i]);
    }
    
    for (i = 0; i < N; i++) {
        sum += (r[i] - l[i] + 1);
    }
    printf("%d\n", sum);
    
    return 0;
}


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

int main() {
  int n,i;cin >> n;
  vector<pair<int,int>> c(n);
  rep(i,n) cin >> c[i].second >> c[i].first;
  sort(c.begin(),c.end());
  bool flg=1;
  int cnt=0;
  rep(i,n) cnt+=c[i].second,(cnt > c[i].first)?flg=0:0;
  (flg==1)?cout<<"Yes":cout<<"No";
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#define MAXN 10010
using namespace std;
int n,m;
bool dont[MAXN];
int asdf(int now,int wei,int i)
{
    int num=1;
    for(int i=0; i<wei; i++)
        num*=10;
    return now+num*i;
}
int main()
{
    scanf("%d%d",&n,&m);
    int ans=-1;
    memset(dont,false,sizeof(dont));
    for(int i=1; i<=m; i++)
    {
        int temp;
        scanf("%d",&temp);
        dont[temp]=true;
    }
    queue <int> q;
    queue <int> w;
    while(!q.empty()) q.pop();
    while(!w.empty()) w.pop();
    q.push(0);
    w.push(0);
    while(!q.empty()&&!w.empty())
    {
        int now=q.front(),wei=w.front();
        q.pop();
        w.pop();
        for(int i=0; i<10; i++)
        {
            if(!dont[i])
            {
                int rko=asdf(now,wei,i);
                q.push(rko);
                w.push(wei+1);
                if(rko>=n)
                {
                    ans=rko;
                    break;
                }
            }
        }
        if(ans>=0) break;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    scan!(array; Vec<usize>);
    let mut book = vec![0; n];

    for &a in array.iter() {
        book[a - 1] += 1;
    }

    for &b in book.iter() {
        println!("{}", b);
    }
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	int neg = 0;
	int min = 1000000001;
	for (int i = 0; i < n; i++) {
		if (a[i] < 0) neg++;
		min = std::min(min, std::abs(a[i]));
	}
	long long res = 0;
	for (int i = 0; i < n; i++) res += std::abs(a[i]);
	if (neg % 2) res -= min * 2;
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 640
const main = (input) => {
  const [_a, _b] = input.trim().split(' ')
  const a = BigInt(_a)
  const b = BigInt(_b.split('.').join(''))

  return console.log(`${a*b / 100n}`)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29560
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.
unordered_set<int> st;

bool rslt(int N, int K, bool dp[], int a[]){

	if(K == 0) return false;
	if(st.find(K) != st.end()) return dp[K];
	bool flg = false;

	for (int i = 0; i < N; ++i)
	{	
		if(K - a[i] >= 0)
		flg = !rslt(N, K-a[i], dp, a);
		if(flg == true)break;
	}

	st.insert(K);

	dp[K] = flg;
	return dp[K];
}


int main() {
int N, K;
cin >> N >> K;
int a[N];
for (int i = 0; i < N; ++i)
{
	cin >> a[i];
}

bool dp[K+1];

for (int i = 0; i <= K; ++i)
{
	dp[i] = false;
}

bool final = rslt(N, K, dp, a);

if(final) cout << "First" << endl;
else cout << "Second" << endl; 


return 0;
}

Measured memory_bytes: 12324
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,k; cin >> n >> k;
  ll ans = 0;
  if (k == 0) { COUT((ll)n*n); return 0; }
  for (int b=k+1; b<=n; b++) {
    ans += (n/b)*(b-k) + max(0,(n%b)-k+1);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void){
  int a,b,c,n,cnt;

  while(scanf("%d", &n)!=EOF){
    cnt=0; 
    for(a=0;a<=9;a++)
      for(b=0;b<=9;b++)
	for(c=0;c<=9;c++){
	  if(0<=n-(a+b+c) && n-(a+b+c)<=9)
	    cnt++;
	}
    printf("%d\n",cnt);
  }
  
  return 0;
}

Measured memory_bytes: 596
import scala.util.control.Breaks
object Main extends App {
  val b = new Breaks()
  b.breakable {
    while (true) {
      val Seq(h, w) = readLine().split(' ').map(_.toInt).toList

      if ((h, w) == (0, 0)) b.break

      val board = for {
        y <- 0 until h

        chs = for {
          x <- 0 until w
        } yield {
          if ( (x + y) % 2 == 0 ) "#" else "."
        }
      } yield {
        chs.reduce(_+_) + "\n"
      }

      board.foreach(print)
      println()
    }
  }
}


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

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


int main(){

  int a,b,c,d; cin >> a >> b >> c >> d;
  if(d==1){ cout << 1 <<endl; } else { cout << 0 <<endl; }
  return 0;   
}


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

int main() {
  int x;
  cin >> x;
  int res;
  if(x<=599){res = 8;}
  else if(x<=799){res = 7;}
  else if(x<=999){res = 6;}
  else if(x<=1199){res = 5;}
  else if(x<=1399){res = 4;}
  else if(x<=1599){res = 3;}
  else if(x<=1799){res = 2;}
  else if(x<=1999){res = 1;}
  
  cout << res << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 26760
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    ll n, res = 0;
    cin >> n;
    map<string, int> m;
    REP(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        res += m[s];
        m[s]++;
    }

    cout << res << endl;
}


Measured memory_bytes: 11136
from math import sqrt

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        dist = 0
    
        for k in range(D):
            dist += (X[i][k] - X[j][k])**2
        
        if sqrt(dist) % 1 == 0:
            ans += 1
    
print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+100;
int n,m,k,t;
int main()
{
	cin>>n;
	int ans=0;
	FOR(i,1,n)
	{
		int x=read();
		if(x%2&&i%2) ans++;
	} 
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextLong()
    val w = sc.nextLong()

    println(pana2020b(h, w))
}

private fun pana2020b(h: Long, w: Long): Long {
  if (h == 1L || w == 1L ) return 1L

  val h1 = h / 2L
  val h2 = h - h1
  val w1 = w / 2L
  val w2 = w - w1

  var ans = h1 * w1 + h2 * w2

  return ans
}

Measured memory_bytes: 31256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i32>();
    let _b = read::<i32>();
    let _c = read::<i32>();
    let _d = read::<i32>();
    let e = read::<i32>();
    let k = read::<i32>();
    println!("{}", if e - a > k { ":(" } else { "Yay!" });
}


Measured memory_bytes: 4352
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
sum = 0
right = 0
for left in range(N):
    while right < N and sum ^ A[right] == sum+A[right]:
        sum += A[right]
        right += 1
    ans += right-left
    if right == left:
        right += 1
        sum = A[left]
    else:
        sum -= A[left]
print(ans)


Measured memory_bytes: 24424
# -*- coding:utf-8 -*-

def solve():
    N,A = list(map(int, input().split()))
    X = list(map(int, input().split()))

    # dp[i][j][k] := 左からi枚目までに、j枚を選んで、選んだカードの総和がk
    dp = [[[0 for _ in range(50*50+1)] for __ in range(N+1)] for ___ in range(N)]
    dp[0][0][0] = 1
    dp[0][1][X[0]] = 1

    for i in range(1, N):
        for j in range(0, N):
            for k in range(50*50+1):
                dp[i][j][k] += dp[i-1][j][k]
                if k+X[i] < 50*50+1:
                    dp[i][j+1][k+X[i]] += dp[i-1][j][k]
                    

    ans = 0
    for j in range(1, N+1):
        ans += dp[N-1][j][A*j]
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 93788
#include <iostream>
#include <vector>
#include <algorithm>       // for next_permutation
using namespace std;

int n;
int a[16];
std::vector<int> x[16];
std::vector<bool> y[16];

bool foo(vector<bool> ans)
{
    bool ok = true;
    //std::vector<int> ans(n, -1);
    for(int i=0; i<n; i++){
        if(ans[i] == false){
            //cout << i+1 << "さんは不親切な人だと仮定するので飛ばします" << endl;
            continue;
        }
        for(int j=0; j<x[i].size(); j++){
            if(y[i][j] == 1){
                //cout << i+1 << "さん曰く" << x[i][j] << "さんは正直者" << endl;
                //if(ans[i] == -1){
                //    cout << " -> " << x[i][j] << "さんは初めての証言です [OK]" << endl;
                //}else if(ans[i] == 1){
                if(ans[x[i][j]-1] == true){
                    //cout << " -> "  << x[i][j] << "さんは正直者として証言されています [OK]" << endl;
                }else{
                    //cout << " -> "  << x[i][j] << "さんは不親切な人として証言されています [NG!!!]" << endl;
                    ok = false;
                    break;
                }
                //ans[x[i][j]-1] = 1;
            }else{
                //cout << i+1 << "さん曰く" << x[i][j] << "さんは不親切な人" << endl;
                //if(ans[i] == -1){
                //    cout << " -> " << x[i][j] << "さんは初めての証言です [OK]" << endl;
                //}else if(ans[i] == 1){
                if(ans[x[i][j]-1] == true){
                    //cout << " -> "  << x[i][j] << "さんは正直者として証言されています [NG!!!]" << endl;
                    ok = false;
                    break;
                }else{
                    //cout << " -> "  << x[i][j] << "さんは不親切な人として証言されています [OK]" << endl;
                }
                //ans[x[i][j]-1] = 0;
            }
        }
        if(ok == false) break;
    }
    if(ok == true){
        //cout << "矛盾しなかった" << endl;
        return true;
    }else{
        //cout << "矛盾した" << endl;
        return false;
    }
}

int main()
{
    cin >> n;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp; a[i] = tmp;
        for(int j=0; j<tmp; j++){
            int tmpx, tmpy;
            cin >> tmpx >> tmpy;
            x[i].push_back(tmpx);
            y[i].push_back(tmpy);
        }
    }
    
    /*
    for(int i=0; i<n; i++){
        for(int j=0; j<a[i]; j++){
            cout << x[i][j] << " " << y[i][j] << endl;
        }
    }
    */
    
    int cnt = 0;
    for(int i=1; i<n+1; i++){
       int tmpcnt = i-1;
       //cout << "-----" << tmpcnt << "人が正直者のケース"<< endl;
       vector<bool> v(n, false);
       for(int j=0; j<i; j++) v[n-j] = true;
       do {
          //for(auto xx : v) cout << xx << " "; cout << "\n";    // v の要素を表示
          bool ret = foo(v);
          if(ret == true){
              cnt = std::max(tmpcnt, cnt);
          }
       } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    }
    // all 1
    int tmpcnt = n;
    //cout << "-----" << tmpcnt << "人が正直者のケース"<< endl;
    vector<bool> v(n, true);
    //for(auto xx : v) cout << xx << " "; cout << "\n";    // v の要素を表示
    bool ret = foo(v);
    if(ret == true){
        cnt = std::max(tmpcnt, cnt);
    }
    
    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FILEIN freopen("in.txt", "r", stdin)
#define all(c)  c.begin(),c.end()
#define traverse(container,it)  for(auto it = container.begin(); it != container.end(); it++)

int main()
{
    //FILEIN;
    int n,m;
    cin >> n >> m;
    map<int,pair< bool,int > > status;
    for(int i =0;i<m;i++){
        int x,y;
        string s;
        cin >> x >> s;
        if(!s.compare("WA")){
            if(status[x-1].first == false){
                status[x-1].second++;
            }
        }
        else{
            status[x-1].first = true;
        }
    }
    int penalty = 0,ac = 0;
    traverse(status,it){
        if(it->second.first == true){
            penalty += it->second.second;
            ac++;
        }
    }
    cout << ac << " " << penalty << endl;
}


Measured memory_bytes: 6528
#define  REP(i, s, e) for(register long long i = s; i <= e ;i++)
#define DREP(i, s, e) for(register long long i = s; i >= e ;i--)

#define DEBUG fprlong longf(stderr, "Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

#include <bits/stdc++.h>

using namespace std;

template <typename T> T read()
{
	T ans(0), p(1);
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-') p = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * p;
}

long long n, k, ans;

int main()
{
#ifdef CraZYali
	freopen("d.in", "r", stdin);
	freopen("d.out", "w", stdout);
#endif
	cin >> n >> k;
	if (!k) {cout << n * n;return 0;}
	REP(i, k + 1, n)
	{
		ans += (i - k) * ((n - i + 1) / i + 1);
		if ((n - k) / i != (n - i + 1) / i) ans += (n - k) % i + 1;
//		if (n % i - k + 1 >= 0) ans += n % i - k + 1;
//		prlong longf("%d %d\n", i, i - k + k * ((n - i) / i) + n % i + 1 - k);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List

main :: IO ()
main = do
  [n, _] <- f
  solve n <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> Int
solve n = sum . drop (n-1) . sortBy (flip compare) . (tail >>= zipWith (-)) . sort


Measured memory_bytes: 34556
import math

def is_prime(num):
	if num <= 1: return False
	if num == 2: return True
	if num % 2 == 0: return False
	for i in range(3, int(math.sqrt(num)) + 1):
		if num % i == 0: return False
	return True

n = int(input())
count = 0
for i in range(n):
	m = int(input())
	if is_prime(m):
		count += 1
print(count)



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

using namespace std;

	const int MOD = 998244353;
	const int MAXN = 300005;

	int mul (int a, int b){
		return ((long long) a*b) % MOD;
	}
	
	int add (int a, int b){
		a += b;
		if (a >= MOD){
			return (a - MOD);
		}
		return a;
	}

	int rek (int x, int b){
		if (x == 0)return 1;
		if (x == 1)return b;
		
		int aa = rek(x/2, b);
		if (x % 2 == 0){
			return mul(aa,aa);
		} else {
			return mul(mul(aa, aa), b);
		}
	}

	int fak[MAXN];

	int povrh(int n, int k) {
		return mul(fak[n], mul(rek(MOD - 2, fak[k]), rek(MOD - 2, fak[n - k])));
	}

int main (){
	
	fak[0] = 1;
	for (int i = 1; i < MAXN; i++){
		fak[i] = mul(fak[i - 1], i);
	}
	
	int n;
	long long a,b,k;
	cin >> n >> a >> b >> k;
	
	int sol = 0;
	
	for (int i = 0; i <= n; i++){
		long long tren = a*i;
		if (tren > k) break;
		if (((k - tren) % b) == 0){
			long long j = (k - tren) / b;
			if (j > n) continue;
			int curr = mul(povrh(n, i), povrh(n, j));
			//cout << "i je:  " << i << "    j je: " << j << endl;
			//cout << "curr je: " << curr << endl; 			
			sol = add(sol, curr);
		}
	}
	
	cout << sol << "\n";
	
	return 0;
}

Measured memory_bytes: 1408
package main

import "fmt"

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var x, k int
	fmt.Scan(&k, &x)
	for i := max(x-k+1, -100000); i <= min(x+k-1, 100000); i++ {
		fmt.Print(i, " ")
	}
	fmt.Println()
}


Measured memory_bytes: 512
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

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

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

struct Line
{
	mutable ll m, c, p;
	bool operator<(const Line& o) const { return m < o.m; }
	bool operator<(ll x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>>
{
	// (for doubles, use inf = 1/.0, div(a,b) = a/b)
	const ll inf = LLONG_MAX;
	ll div(ll a, ll b)
	{
	    // floored division
		return a / b - ((a ^ b) < 0 && a % b);
    }
	bool isect(iterator x, iterator y)
	{
		if (y == end()) { x->p = inf; return false; }
		if (x->m == y->m) x->p = x->c > y->c ? inf : -inf;
		else x->p = div(y->c - x->c, x->m - y->m);
		return x->p >= y->p;
	}
	void add(ll m, ll c)
	{
		auto z = insert({m, c, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
			isect(x, erase(y));
	}
	ll query(ll x)
	{
		assert(!empty());
		auto l = *lower_bound(x);
		return l.m * x + l.c;
	}
};

void solve()
{
    int n,C;
    cin>>n>>C;

    vi h(n);
    for(int i=0;i<n;++i)
        cin>>h[i];

    int dp[n];
    mem(dp,0);

    LineContainer lc;
    lc.add(2*h[0],-h[0]*h[0]);

    for(int i=1;i<n;++i)
    {
        dp[i]=h[i]*h[i]+C-lc.query(h[i]);
        lc.add(2*h[i],-(h[i]*h[i]+dp[i]));
    }

    cout<<dp[n-1];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 15872
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
#define PI acos(-1)
#define MOD 100000009
using ll = long long;
using ull = unsigned long long;

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

    double ans = 0;
    rep(i, n) {
        double xn;
        string un;
        cin >> xn >> un;

        if(un == "JPY"){
            ans += xn;
        }else{
            ans += xn * 380000.0;
        }
    }

    printf("%.12lf", ans);
}

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


int main() {
    ll N, K;
    cin >> N >> K;
    if (N > K) N -= (N-K)/K*K;
    ll ans = N;
    for (int i = 0; i < 10; i++) {
        N = abs(N-K);
        ans = min(ans, N);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;

int main() {
	int a, b;
	cin >> a >> b;
	vint h(a);
	rep(i, a) cin >> h[i];
	int ans = 0;
	rep(i, a) {
		if (h[i] >= b)ans++;
	}
	cout << ans << endl;
	return 0;
}

/*現在の進行状況
　AtCoder Beginner Contest ： 14２
  AOJ ： プログラミング入門-
*/

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int a, b, c, x, y, z, s;;
int main() {
	cin>>a>>b>>c;
	if(a==b && b==c) {cout<<a%2-1; return 0;}
	for(s=0; !(a%2 || b%2 || c%2); s++) {
		x = (b+c)/2;
		y = (a+c)/2;
		z = (b+c)/2;
		a=x, b=y, c=z;
	}
	cout<<s;
	return 0;
}

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

int main() {
  
  int K,A,B;
  cin>>K;
  cin>>A>>B;
  string ans="NG";
  for(int i=A;i<(B+1);i++){
    if(i%K==0){
      ans="OK";
      break;
    }
  }
  cout<<ans<<endl;
  
  
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

long long dp[510][10010];

int main() {
    int M, N;
    cin >> M >> N;
    vector<long long> P(M), E(N), acc(M + 1, 0);
    vector<int> C(N);
    REP(i, M) { cin >> P[i];}
    sort(ALL(P), greater<long long>());
    REP(i, N) { cin >> C[i] >> E[i]; }
    REP(i, M) { acc[i + 1] += acc[i] + P[i]; }
    fill(dp[0], dp[510], llINF);
    dp[0][0] = 0;

    REP(i, N) {
        REP (j, M) {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
                int next = min(j + C[i], M);
                dp[i + 1][next] = min(dp[i + 1][next], dp[i][j] + E[i]);
        }
    }

    long long ans = 0;
    REP(i, N + 1) {
        REP(j, M + 1) {
            ans = max(ans, acc[j] - dp[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int A, B;
    cin >> A >> B;
    PRINT(6 - A - B);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main()
{
	//Aca va tu codigono se
	int A,B,C,D;
	cin >> A>>B>>C>>D;
	if(A+B>C+D)
	{
		cout << "Left" << endl;
	}else if(A+B<C+D)
	{
		cout << "Right" << endl;
	}else
	{
		cout << "Balanced" << endl;
	}
}


Measured memory_bytes: 256
s = int(input())
MOD = 10**9 + 7
C = [0]*(s + 1)
C[0] = 1
for n in range(3, s+1): # n:[3,s]
    C[n] = sum(C[:n-3+1]) % MOD # sum(C[0,n-3])
print(C[s])


Measured memory_bytes: 9124
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
struct engine {
    ll x = 0;
    ll y = 0;
    ld angle = 0;
    void set(ll x, ll y) {
        this->x = x;
        this->y = y;
        this->angle = atan2l(y, x);
    }
};


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<engine> e(n);
    REP(i, n) {
        ll x, y; cin >> x >> y;
        e[i].set(x, y);
    }

    sort(ALL_OF(e), [](engine &ei, engine &ej) {
        return ei.angle < ej.angle;
    });

    REP(i, n) e.emplace_back(e[i]);

    vector<ll> ximos(n*2+1, 0), yimos(n*2+1);
    REP(i, n*2) {
        ximos[i+1] = ximos[i] + e[i].x;
        yimos[i+1] = yimos[i] + e[i].y;
    }

    ld ans = -114514;
    RANGE(left, 0, n-1) RANGE(right, left + 1, left + n) {
        chmax(ans, hypotl(ximos[right] - ximos[left], yimos[right] - yimos[left]));
    }
    cout << fixed << setprecision(20) << ans;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  //string s; cin>>s;
  if(n>=30){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3616
def calc(m,num):
    ans = 0
    for i in range(num+1):
        ans += m[0][i]
    return ans

n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
m = []
m.append(a)
m.append(b)

ans = []
temp = 0

for i in range(n):
    temp += calc(m,i)
    #print(" "+str(temp))
    for j in range(n):
        if(i <= j):
            temp += m[1][j]
    ans.append(temp)
    temp = 0
    
print(max(ans))
    
         

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        TreeSet<Integer> set1 = IntStream.range(0, n).boxed().collect(Collectors.toCollection(TreeSet::new));
        TreeSet<Integer> set2 = IntStream.range(0, n).boxed().collect(Collectors.toCollection(TreeSet::new));
        int p = count(scanner, n, set1);
        scanner.nextLine();
        int q = count(scanner, n, set2);
        System.out.println(Math.abs(p - q));

    }

    static int count(Scanner sc, int n, TreeSet<Integer> set) {

        int count = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            int a = (set.subSet(set.first(), num).size() - 1) * factoricalLoop(n - i - 1);
            set.remove(num);
            count += a;
        }
        return count + 1;
    }

    static int factoricalLoop(int n) {
        if (n == 0) return 0;
        int num = 1;
        for (int i = 1; i <= n; i++) {
            num = num * i;
        }
        return num;
    }
}


Measured memory_bytes: 28880
using System;
using System.Linq;
 
public class Test
{
	public static void Main()
	{
		int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
		bool ret=false;
		if(x[0]%3==0)ret=true;
		if(x[1]%3==0)ret=true;
		if((x[0]+x[1])%3==0)ret=true;
		Console.WriteLine(ret?"Possible":"Impossible");
	}
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for(int i=0;i<n;i++) cin>>h[i];

    sort(h.begin(),h.end());

    ll min = 1<<30;
    for(int i=0;i<n-k+1;i++){
        if(h[i+k-1] - h[i] < min){
            min = h[i+k-1] - h[i];
        }
    }

    cout << min << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main()
{
    int n, q;
    cin >> n >> q;
    map<int, vector<int> > tree;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
    }
    vector<int> cnt(n, 0);
    for (int i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        cnt[p - 1] += x;
    }
    
    for (auto &&t : tree)
    {
        for (auto &&x : t.second)
        {
            cnt[x - 1] += cnt[t.first - 1];
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << cnt[i];
        if (i != n)
            cout << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 25856
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	int MIN = 0, MAX = 0;
	//bool malti = false;
	vector<int> color(9,0);
	for (int i = 0; i < N; i++) {
		if (a[i] < 400)color[0]++;
		else if (a[i] < 800) color[1]++;
		else if (a[i] < 1200) color[2]++;
		else if (a[i] < 1600) color[3]++;
		else if (a[i] < 2000) color[4]++;
		else if (a[i] < 2400) color[5]++;
		else if (a[i] < 2800) color[6]++;
		else if (a[i] < 3200) color[7]++;
		else color[8]++;
	}
	for (int i = 0; i < 8; i++) {
		if (color[i] > 0) {
			MIN++;
			MAX++;
		}
	}
	MAX += color[8];
	if (MIN != 0) {
		cout << MIN << " " << MAX << endl;
	}
	else {
		cout << 1 << " " << MAX << endl;
	}
}


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

int main() {
  char S[3];
  int maru = 0;
  for(int i = 0; i < 3; i++) {
    cin >> S[i];
    if(S[i] == 'o') maru++;
  }
  
  cout << 700 + 100 * maru << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Avant-garde Art
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;

	int n, k;
	int[] a;

	void run(){
		n=sc.nextInt();
		k=sc.nextInt();
		a=new int[n];
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt()-1;
		}
		solve();
	}

	void solve(){
		int clique=0;
		int[] last=new int[n];
		for(int i=0; i<n; i++){
			int s=min(i, a[i]), t=max(i, a[i]);
			int lis=0;
			fill(last, INF);
			for(int j=0; j<n; j++){
				if((s<j&&j<t)&&!(s<a[j]&&a[j]<t)){
					int v=(a[j]-s+n)%n;
					int k=binarySearch(last, v);
					if(k<0)
						k=-k-1;
					last[k]=v;
					lis=max(lis, k+1);
				}
			}
			clique=max(clique, lis+1);
		}
		int ans=clique+min(n/2-clique, k);
		println(ans+"");
	}

	void println(String s){
		System.out.println(s);
	}

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

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

using namespace std;

main(){
	int a;
	cin>>a;
	int A[a];
	int s=a-1;
	for(int c=0; c<a; c++){
		cin >>A[c];
	}
	while(s>=0){
		printf("%d",A[s]);
		if (s != 0)
		printf(" ");
		s=s-1;
	}
	printf("\n");
}


Measured memory_bytes: 3208
n = int(input())
a = list(map(int,input().split()))

a.sort()
sum_num = 1
std_num = 1000000000000000000
if(a[-1] == 0):
    sum_num = 0
else:
    for i in range(n):
        sum_num = a[i]*sum_num
        if(sum_num > std_num):
            sum_num = -1
            break;
print(sum_num)

Measured memory_bytes: 21652
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 110000
#define LL long long
using namespace std;
int a[N],n,m,p[N],g[N],d[N],t[N];
LL k;
void qmod(LL b)
{
	for(int i=1;i<=n;i++) g[i]=i;
	while(b)
	{
		if(b%2)
		{
			for(int i=1;i<=n;i++) t[i]=g[p[i]];
			for(int i=1;i<=n;i++) g[i]=t[i];
		}
		b/=2;
		for(int i=1;i<=n;i++) t[i]=p[p[i]];
		for(int i=1;i<=n;i++) p[i]=t[i];
	}
	for(int i=1;i<=n;i++) t[i]=d[g[i]];
	for(int i=1;i<=n;i++) d[i]=t[i];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {scanf("%d",&a[i]);d[i]=a[i]-a[i-1];}
	for(int i=1;i<=n;i++) p[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;i++)
	{
		int x;scanf("%d",&x);
		swap(p[x],p[x+1]);
	}
	qmod(k);
	LL now=0;
	for(int i=1;i<=n;i++)
	{
		now+=d[i];
		printf("%lld\n",now);
	}
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  
  int c0 = 0, c1 = 0, c2= 0, c3 = 0;
  rep(i,n) {
    if ( s[i] == "AC" ) c0++;
    else if ( s[i] == "WA" ) c1++;
    else if ( s[i] == "TLE" ) c2++;
    else c3++;
  }
  
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;
  
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    string temp;
    char last;
    map<string, ll> m;
    cin >> N;
    cin >> temp;
    m[temp]++;
    last = temp[temp.size() - 1];
    for(ll i = 1;i < N;i++) {
        cin >> temp;
        m[temp]++;
        if(m[temp] > 1 || temp[0] != last) {
            cout << "No" << endl;
            return 0;
        }
        last = temp[temp.size() - 1];
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256