akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int n;
ll res;

int main ()
{
  R1(n);
  res = 0;
  FOR(i, 1, n + 1) if (i % 3 && i % 5) res += i;
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 3828
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int A[3][3];
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            cin >> A[i][j];
        }
    }

    int N; cin >> N;
    for(int i=0; i<N; i++) {
        int b; cin >> b;
        for(int x=0; x<3; x++) {
            for(int y=0; y<3; y++) {
                if(A[x][y] == b) A[x][y] = -1;
            }
        }
    }

    bool ok = false;
    for(int i=0; i<3; i++) {
        bool valid = true;
        for(int j=0; j<3; j++) {
            valid &= (A[i][j] < 0);
        }
        ok |= valid;
    }

    for(int j=0; j<3; j++) {
        bool valid = true;
        for(int i=0; i<3; i++) {
            valid &= (A[i][j] < 0);
        }
        ok |= valid;
    }

    {
        bool valid = true;
        for(int i=0; i<3; i++) {
            valid &= (A[i][i] < 0);
        }
        ok |= valid;
    }

    {
        bool valid = true;
        for(int i=0; i<3; i++) {
            valid &= (A[i][2-i] < 0);
        }
        ok |= valid;
    }

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A, B, C, D, E, F;
    int max_sugar;
    int ans_water = 0;
    int ans_sugar = 0;
    double rate_max = 0.0;
    bool sugar[3000] = {false};
    int sugar_max[30] = {0};
    cin >> A >> B >> C >> D >> E >> F;
    max_sugar = (F*E)/100;
    
    for(int i = 0; i*C <= max_sugar; i++){
        for(int j = 0; j*D <= max_sugar; j++){
            if(i*C + j*D <= max_sugar){
                sugar[i*C + j*D] = true;
            }
        }
    }
    for(int i = 1; i <= (int)(F/100); i++){
        sugar_max[i-1] = 0;
        for(int j = 0; j <= i*E; j++){
            if(sugar[j] && (i*100+j) <= F){
                sugar_max[i-1] = j;
            }
        }
    }
    for(int i = 0; i*A*100 <= F; i++){
        for(int j = 0; j*B*100 <= F; j++){
            if(i*A*100 + j*B*100 <= F){
                if((i+j) != 0 && (rate_max < (double)sugar_max[i*A + j*B-1]/(double)(i*A*100 + j*B*100))){
                    rate_max = (double)sugar_max[i*A + j*B-1]/(double)(i*A*100 + j*B*100);
                    ans_sugar = sugar_max[i*A + j*B-1];
                    ans_water = i*A*100 + j*B*100;
                }
            }
        }
    }
    if(ans_sugar == 0){
        cout << A*100 << ' ' << ans_sugar << endl;
    }else{
        cout << ans_water+ans_sugar << ' ' << ans_sugar << endl;
    }
}

Measured memory_bytes: 256
console.log((args=>{
  const [n,S] = args.trim().split`\n`;
  const N = n|0;
  let r = 0, l = 0;
  for ( let i = N; i--;) l += (S[i]===')')?1:l?-1:0;
  for ( let i = 0; i < N; i++) r += (S[i]==='(')?1:r?-1:0;
  return '('.repeat(l) + S + ')'.repeat(r);
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29588
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

double t = 3.305785;

int main() {
	int a, b;
	cin >> a >> b;
	double S = a*(b / t);
	cout << fixed << setprecision(6);
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
ll sum[200009];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll x,y;
    cin>>x;
    for (int i=1;i<=x;i++){
        cin>>y;
        sum[i]=sum[i-1]+y;
    }
    ll ans=1e18;
    for (int i=1;i<=x;i++){
        if (abs(sum[x]-sum[i]-sum[i])<ans)
        {
            ans=abs(sum[x]-sum[i]-sum[i]);
        }
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc077/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N; 
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    rep(i, N){
        ll k1 = N - (lower_bound(C.begin(), C.end(), B[i] + 1) - C.begin());
        ll k2 = (lower_bound(A.begin(), A.end(), B[i]) - A.begin());
        ans += k1 * k2;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1408
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut have = vec![false; n];
    for i in 0..k {
        let _ = read::<usize>();
        let a = read_vec::<usize>();
        for num in a {
            have[num - 1] = true;
        }
    }
    let ans = have.iter().filter(|&&x| !x).count();
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, ans = INT_MAX;
    cin >> n;

    rep(n+1){
        int tmp = 0, t = i;
        while(t){
            tmp += t%6;
            t /= 6;
        }
        t = n-i;
        while(t){
            tmp += t%9;
            t /= 9;
        }
        ans = min(tmp, ans);
    }
    
    cout << ans << endl;
}


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

int main(){
    int n;cin>>n;
    vector<bool> color(10,false);
    int free=0;
    for(int i=0;i<n;i++){
        int a;cin>>a;

        if(a<3200) color[a/400]=true;
        else free++;
    }

    int sum=0;
    for(int i=0;i<=7;i++)if(color[i]) sum++;

    cout<<max(sum,1)<<' '<<sum+free<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mo=1000000007;
const int N=32800;
int b[20],bit[N];
int f[N],n,m;
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		b[x]|=1<<(y-1);
	}
	for (int i=1;i<1<<n;i++)
		bit[i]=(i&1?bit[i>>1]*2+1:bit[i>>1]);
	f[0]=1;
	for (int i=1;i<1<<n;i++)
		if ((i&3)==3)
			for (int j=i;j;j=(j-1)&i){
				if ((j&3)!=0&&(j&3)!=3) continue;
				int tmp=1;
				for (int k=0;k<n;k++)
					if (i&(1<<k)){
						if (!(j&(1<<k)))
							tmp=1ll*tmp*bit[b[k+1]&j]%mo;
						else tmp=1ll*tmp*(bit[b[k+1]&(i^j)]+1)%mo;
					}
				f[i]=(f[i]+1ll*f[i^j]*tmp)%mo;
			}
		else if ((i&3)==0){
			f[i]=1;
			for (int j=0;j<n;j++)
				if (i&(1<<j))
					f[i]=1ll*f[i]*(bit[b[j+1]&i]+1)%mo;
	}
	int ans=1;
	for (int i=1;i<=m;i++)
		ans=2*ans%mo;
	printf("%d",(ans+mo-f[(1<<n)-1])%mo);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;scanf("%d%d",&n,&m);
	int l=n/2,r=l+1;
	if(n&1)for(int i=0;i<m;i++)printf("%d %d\n",l--,r++);
	else{
		l=1,r=m+1;
		while(l<r)printf("%d %d\n",l++,r--);
		l=m+2,r=2*m+1;
		while(l<r)printf("%d %d\n",l++,r--);
	}
	return 0;
}

Measured memory_bytes: 3868
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;
 
int main(){
 
  int m;
  cin >> m;
  
  int N[55];
  
  int p = 0,n = 0,pmax = 0,nmax = 0,pindex,nindex;
  REP(i,m){
    cin >> N[i];
    if(N[i] > 0){
      p = 1; 
      if(N[i]>pmax){
        pmax = N[i];
        pindex = i+1;
      }
    }
    else	    {
      n = 1;
       if(N[i] < nmax){
        nmax = N[i];
        nindex = i+1;
      }
    }
  }
  
  int x[100],y[100],count = 0;
  
  if(p == 1 && n == 1){
    if(pmax >= nmax*-1){
      REP(i,m){
      N[i] += pmax;
      x[count] = pindex;
      y[count] = i+1;
      count++;
      }
      n = 0;
    }
    
    else               {
      REP(i,m){
      N[i] += nmax;
      x[count] = nindex;
      y[count] = i+1;
      count++;
        }
        p = 0;
    }
  }
  
  if(p == 1){
  REP(i,m-1){
        x[count] = i+1;
        y[count] = i+2;
        count++;        
      }
  }
   else{
   for(int i = m-1; i > 0; i--){
       x[count] = i+1; 
       y[count] = i;
       count++;
      }
   }
      
  
  cout << count << endl;
  
  REP(i,count) cout << x[i] << " " << y[i] << endl;
    
 
 return 0;
}

Measured memory_bytes: 256
use whiteread::*;
use std::collections::HashMap;
fn main() {
    let s: String = parse_line().unwrap();
    let s: Vec<char> = s.chars().collect();
    let mut mods: HashMap<usize, usize> = HashMap::new();
    let e = mods.entry(0).or_default();
    *e += 1;
    let mut now = 0;
    let mut ten = 1;
    for i in s.iter().rev() {
        now = (now + i.to_digit(10).unwrap() as usize * ten) % 2019;
        let e = mods.entry(now).or_default();
        *e += 1;
        ten = ten * 10 % 2019;
    }
    let mut count = 0;
    for (_, v) in mods {
         count += v * (v - 1) / 2;
    }
    println!("{}", count);

}


Measured memory_bytes: 3152
ch = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
    'n','o','p','q','r','s','t','u','v','w','x','y','z']

p = []

a = list(input())
n = len(a)
for i in range(len(ch)):
    p.append(a.count(ch[i]))

res = n*(n-1)//2

for i in range(len(ch)):
    res = res - p[i] * (p[i]-1) //2
print(res+1)


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vi A(N);
  each(x, A) in(x);
  auto a = A;
  sort(all(a), greater<>());
  each(x, A) {
    print(x == a[0] ? a[1] : a[0]);
  }
}


Measured memory_bytes: 3200
x = list(map(int, input().split()))
top_count = 0
ans = 0
for i in x:
  if i == 1:
    ans += 300000
    top_count += 1

  elif i == 2:
    ans += 200000

  elif i == 3:
    ans += 100000

if top_count == 2:
  print(ans + 400000)
else:
  print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	l := []string{"Sunny", "Cloudy", "Rainy"}
	var a string
	fmt.Scan(&a)
	for i, _ := range l {
		if a == l[i] {
			if i == len(l)-1 {
				fmt.Println(l[0])
			} else {
				fmt.Println(l[i+1])
			}
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> low, high;
  for (int i = 0; i < n; ++i)
  {
    int a, b;
    cin >> a >> b;
    low.pb(a);
    high.pb(b);
  }
  sort(low.begin(), low.end());
  sort(high.begin(), high.end());
  if (n % 2 == 1)
  {
    int l = low[n / 2];
    int h = high[n / 2];
    cout << h - l + 1;
  }
  else
  {
    int l = low[n / 2] + low[n / 2 - 1];
    int h = high[n / 2] + high[n / 2 - 1];
    cout << h - l + 1;
  }
}

Measured memory_bytes: 6620
import sys
input = sys.stdin.readline

a, b, x = map(int, input().split())

Smax = a * b
S = x / a

import math
if S <= (Smax/2):
  a_ = S * 2 / b
  print(math.degrees(math.atan(b/a_)))
else:
  a_ = (Smax - S) * 2 / a
  print(math.degrees(math.atan(a_/a)))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0018
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            list.Sort((a, b) => b - a);
            Console.WriteLine("{0} {1} {2} {3} {4}",list[0],list[1],list[2],list[3],list[4]);
        }
    }
}



Measured memory_bytes: 18452
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
vector<int>x,y,r,c;
vector<int>memo;
int n;
bool intersectCC(int a,int b){
    int dis = (x[a]-x[b])*(x[a]-x[b]) +(y[a]-y[b])*(y[a]-y[b]);
    return dis < (r[a]+r[b])*(r[a]+r[b]);
}
bool toreru(int bit,int id){
    rep(i,id){
        if(intersectCC(i,id) and !(bit >> i & 1)) return false;
    }
    return true;
}
int dfs(int bit){
    if(memo[bit] != -INF)return  memo[bit];
    memo[bit] = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n;j++){
            if( bit >> i & 1 or bit >> j &1)continue;
            if(c[i] != c[j])continue;
            if(toreru(bit, i) and toreru(bit, j)){
                cmax(memo[bit], dfs(bit | 1 << i | 1 << j)+2);
            }
        }
    }
    return memo[bit];
}
signed main(){
    while(cin >> n,n){
        x.clear();y.clear();r.clear();c.clear();
        rep(i,n){
            int _x,_y,_r,_c;
            cin >> _x >> _y >> _r >> _c;
            x.push_back(_x); y.push_back(_y);
            r.push_back(_r); c.push_back(_c);
        }
        memo.assign(1 << n,-INF);
        cout << dfs(0) << endl;
    }
}




Measured memory_bytes: 68324
#include <iostream>
#include <vector>
#include <set>


using namespace std;

typedef long long int ll;

#define rep(i,n) for(int i=0;i<(n);++i)


int main()
{
	int n;
	cin>>n;
	vector<ll> p(n),pos(n+1,0);
	rep(i,n){
		cin>>p[i];
		pos[p[i]] = i+1;
	}
	ll ans = 0;

	multiset<ll> s;
	s.insert(0);
	s.insert(0);
	s.insert(n+1);
	s.insert(n+1);
	for (ll now = n; now >= 1; now--){
		auto it = s.lower_bound(pos[now]);
		ll x_r = *it++;
		ll x_rr = *it--;
		it--;
		ll x_l = *it--;
		ll x_ll = *it;

		ans += now*(x_r-pos[now])*(x_l-x_ll);
		ans += now*(x_rr-x_r)*(pos[now]-x_l);

		s.insert(pos[now]);
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 6528
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  set<int> sugar, water;
  REP(i, f+1) REP(j, f+1) {
    int tmp = i*c + j*d;
    if(tmp <= f) sugar.insert(tmp);
  }
  REP(i, f+1) REP(j, f+1) {
    int tmp = 100*i*a + 100*j*b;
    if(tmp <= f) water.insert(tmp);
  }

  int ret1 = 0, ret2 = 100*a;
  for(int i: sugar) for(int j: water) {
    if(i+j <= f && j*e >= 100*i && i*(ret1+ret2) >= ret1*(i+j)) {
      // cout << i << " " << j << endl;
      ret1 = i;
      ret2 = j;
    }
  }
  cout << ret1+ret2 << " " << ret1 << endl;

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題_15
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int hoge = Convert.ToInt32(input[0]);
            int piyo = Convert.ToInt32(input[1]);
            Console.WriteLine(hoge-piyo+1);
        }
    }
}


Measured memory_bytes: 11220
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    deque<ll> q;

    if(N%2==0){
        FOR(i, 1, N+1){
            ll a;
            cin >> a;
            if(i%2==0){
                q.push_front(a);
            }else{
                q.push_back(a);
            }
        }
    }
    else{
        FOR(i, 1, N+1){
            ll a;
            cin >> a;
            if(i%2==0){
                q.push_back(a);
            }else{
                q.push_front(a);
            }
        }
    }

    for(ll b : q){
        cout << b << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main()
{
    int n,c=0,c1=0,c2=0,c3=0;
    cin>>n;
    int i;
    char s;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(s=='W')
            c++;
        else if(s=='P')
            c1++;
        else if(s=='G')
            c2++;
        else
            c3++;
    }
    if(c==0||c1==0||c2==0||c3==0)
        cout<<"Three";
    else
        cout<<"Four";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	ull n, k;
	cin >> n >> k;
	ull ans = 0;
	while (n != 0)
	{
		n = (n - n % k) / k;
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3592
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ParseException {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
		Date date = sdf.parse(S);
		Date hikaku = sdf.parse("2019/04/30");
		System.out.println(hikaku.compareTo(date) >= 0 ? "Heisei" : "TBD");
	}
}

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

Measured memory_bytes: 21200
s=input()
table=[[0 for _ in range(4)] for _ in range(len(s)+1)]
table[0][0]=1
abc='ABC'
for i in range(len(s)):
    for j in range(4):
        if s[i]=='?' and j!=0:
            table[i+1][j]=(3*table[i][j]+table[i][j-1])%(10**9+7)
        elif s[i]=='?':
            table[i+1][0]=3*table[i][0]%(10**9+7)
        elif s[i]==abc[j-1] and j!=0:
            table[i+1][j]=(table[i][j]+table[i][j-1])%(10**9+7)
        else:
            table[i+1][j]=table[i][j]%(10**9+7)
#print(table)
print(table[i+1][j]%(10**9+7))

Measured memory_bytes: 27508
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const MOD = 1000000007;

function Main(input){
    let temp = input.trim().split('\n');
    let n = parseInt(temp[0]);
    let d = mapint(temp[1]);

    d.sort((a,b)=>a-b);
    let l = d[n/2-1];
    let u = d[n/2];

    console.log(u-l);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 28220
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mx_Pos = 1e3 + 5;
const int mx_Mask = (1 << 13);
const int INF = 1e9;
ll n, m;
ll lim;
vector<int> S;
vector<int> C;
ll memo[mx_Pos][mx_Mask];
ll dp(int pos, int mask) {
    if (pos == m) {
        if (mask == lim)
            return 0;
        else
            return INF;
    }
    ll &ans = memo[pos][mask];
    if (ans != -1) return ans;
    ans = min(dp(pos + 1, mask), dp(pos + 1, mask | S[pos]) + C[pos]);
    return ans;
}

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    memset(memo, -1, sizeof memo);
    cin >> n >> m;
    lim = (1 << n) - 1;
    forn(i, m) {
        ll ci, bi;
        cin >> ci >> bi;
        ll subset = 0;
        forn(i, bi) {
            ll vi;
            cin >> vi;
            subset += (1 << (vi - 1));
        }
        S.pb(subset);
        C.pb(ci);
    }
    ll ans = dp(0, 0);
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

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

#define LL long long
#define REP(i, n) for(LL i = 0; i < (LL)(n); i++)
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    LL H, W, D;
    cin >> H >> W >> D;
    vector<LL> cost(H*W + 1, 0);
    vector<pair<LL, LL>> A(H*W + 1);
    REP(i, H) {
        REP(j, W) {
            LL a;
            cin >> a;
            A[a] = make_pair(i, j);
        }
    }
    FOR(i, D + 1, H*W + 1) {
        cost[i] = cost[i - D] + abs(A[i].first - A[i - D].first) + abs(A[i].second - A[i - D].second);
    }
    LL Q;
    cin >> Q;
    REP(i, Q) {
        LL l, r;
        cin >> l >> r;
        LL res = cost[r] - cost[l];
        cout << res << endl;
    }
    return 0;
}



Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

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

signed main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[a[i]] == i) ans++;
	}
	dump(ans / 2);

	return 0;
}

Measured memory_bytes: 1024
while True:
	player_nun = int(input())
	if player_nun == 0:
		break
	
	#?????????????????????
	whole_data = []
	for i in range(0, player_nun):
		dat = input().split()
		p_data = []
		p_data.append(dat[0])
		for x in dat[1:]:
			p_data.append(int(x))
		whole_data.append(p_data)
	
	#???????????????????????????????????????
	xel = {}
	for i in whole_data:
		for x in i[2:]:
			if x in xel:
				xel[x] += 1
			else:
				xel[x] = 1
	
	#??????????????????????????¢?????????
	score = {}
	for y in xel.keys():
		score[y] = player_nun + 1 - xel[y]	
	#????????¢??¨????????????????????????????????????
	result = []
	for i in whole_data:
		player_score = []
		player_score.append(i[0])
		player_score.append(0)
		for x in i[2:]:
			player_score[1] += score[x]
		result.append(player_score)
	
	#?????????????????????????¬?????????????????±???????	
	min_score = min(x[1] for x in result)
	winners = []
	for x in result:
		if x[1] == min_score:
			winners.append(x[0])
	print(str(min_score) + " " + sorted(winners)[0])
	
	#??£??????????????????????????????

Measured memory_bytes: 7716
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second

int n,l[200009],r[200009];

int L(){
    int sum=0,t=1e17,s=0;
    r(i,n){
        if(l[i]<0)sum++;
        s+=abs(l[i]);
        t=min(t,abs(l[i]));
    }
    //cout<<s<<' '<<t<<endl;
    if(sum%2==0)return s;
    else return s-t*2;
}

int R(){
    int sum=0,t=1e17,s=0;
    r(i,n){
        if(l[i]<0)sum++;
        s+=abs(l[i]);
        t=min(t,abs(l[i]));
    }
    if(sum%2==0)return s;
    else return s-t*2;
}

signed main(){
    cin>>n;
    r(i,n)cin>>l[i];
    r(i,n)r[i]=l[i];
    cout<<max(L(),R())<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    long long int N, M;
    cin >> N >> M;
    vector<vector<long long int> > E(N+1);
    for(int m=0; m<M; m++) {
        long long int a, b;
        cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    
    queue<long long int> que;
    que.push(1);
    vector<long long int> dist(N+1, -1);
    dist[1]=0;
    while(!que.empty()) {
        long long int cur=que.front();
        que.pop();
        
        for(int i=0; i<E[cur].size(); i++) {
            if(dist[E[cur][i]]!=-1) continue;
            dist[E[cur][i]] = dist[cur]+1;
            que.push(E[cur][i]);
        }
    }
    if(dist[N]==2) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 15208
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n, _ := strconv.Atoi(input())
	k, _ := strconv.Atoi(input())

	rem := n % k
	fmt.Println(min(rem, k-rem))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define llu unsigned long long int
#define ll long long
#define ld long double
#define foi(a, n) for (int i = a; i < n; i++)
#define foj(a, n) for (int j = a; j < n; j++)
#define foin(a, n) for (int i = n; i >= a; i--)
#define fojn(a, n) for (int j = n; j >= a; j--)
#define isp2(x) x && (!(x & (x - 1)))
#define ee 1000000007
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL)
#define cases                                                                  \
  long long t;                                                                 \
  cin >> t;                                                                    \
  while (t--)

using namespace std;

int main() {
  ll t, x;
  cin >> t >> x;
  double ans = 1.0;
  ans = (1.0 * t / x);
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3760
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
const int maxn = 200010;
const int mod = 1e9 + 7;
using namespace std;

int ti[maxn];

int main()
{
	int N, T, i, j;
	long long ans = 0;
	cin >> N >> T;
	for (i = 0; i < N; i ++)
		cin >> ti[i];
	ti[N] = ti[N - 1] + T + 1;
	N ++;
	int l, r;
	l = ti[0];
	r = ti[0] + T;
	for (i = 1; i < N; i ++)
		if (r >= ti[i])
		{
			r = ti[i] + T;
		}
		else
		{
			ans += r - l ;
			l = ti[i];
			r = ti[i] + T;
		}
	cout << ans;
	return 0;
}

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

using namespace std;

const int max_n = 200222, mod = 998244353;

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

int n, pw[max_n], dp[max_n];
string s, t;
vector<int> all;

void get_d(int n) {
    int k = 2;
    while (n % 2 == 0) {
        k *= 2;
        n /= 2;
    }
    for (int i = 1; i <= n; ++i) {
        if (n % i == 0) {
            all.push_back(i * k);
        }
    }
}

bool used[max_n];
vector<int> g[max_n], x[max_n];
vector<int> digits, ids;

void dfs(int v) {
    used[v] = 1;
    for (int to : g[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
}

void restore(int v) {
    used[v] = 1;
    for (int i = 0; i < g[v].size(); ++i) {
        const int to = g[v][i];
        if (!used[to]) {
            t[to] = ((t[v] - '0') ^ x[v][i]) + '0';
            restore(to);
        }
    }
}

void clr() {
    memset(used, 0, sizeof(used));
    for (int i = 0; i < n; ++i) {
        g[i].clear();
        x[i].clear();
    }
    ids.clear();
    digits.clear();
}

int solve(int d) {
    int res = 0;
    if (d == 2 * n) {
        res = 1;
        for (int i = 0; i < n; ++i) {
            if (s[i] == '1') {
                res += pw[n - 1 - i];
                res %= mod;
            }
        }
        return res;
    }
    clr();
    for (int i = 0; i < n; ++i) {
        int from = i, to = (i + n - d) % n;
        if (from > to) {
            swap(from, to);
        }
        const int val = i < d;
        g[from].push_back(to);
        g[to].push_back(from);
        x[from].push_back(val);
        x[to].push_back(val);
    }
    //cout << "###" << d << ": ";
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(i);
            ids.push_back(i);
            digits.push_back(s[i] - '0');
            //cout << i << " ";
        }
    }
    for (int i = 0; i < digits.size(); ++i) {
        if (digits[i]) {
            res += pw[digits.size() - 1 - i];
            res %= mod;
        }
    }
    memset(used, 0, sizeof(used));
    for (int i = 0; i < digits.size(); ++i) {
        t[ids[i]] = s[ids[i]];
        restore(ids[i]);
    }
    //cout << t << " " << s << endl;
    res += (t <= s);
    res %= mod;
    //cout << endl;
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    pw[0] = 1;
    for (int i = 1; i < max_n; ++i) {
        pw[i] = mul(pw[i - 1], 2);
    }
    if (0) {
        n = 200000;
        for (int i = 0; i < n; ++i) {
            s += '1';
        }
    } else {
        cin >> n >> s;
    }
    t = s;
    get_d(n);
    int ans = 0;
    for (int i = 0; i < all.size(); ++i) {
        dp[i] = solve(all[i]);
        for (int j = 0; j < i; ++j) {
            if (all[i] % all[j] == 0) {
                dp[i] += mod - dp[j];
                dp[i] %= mod;
            }
        }
        ans += mul(dp[i], all[i]);
        ans %= mod;
        //cout << all[i] << ": " << dp[i] << endl;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 43520
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, X, Y;
    cin >> N >> X >> Y;
    --X; --Y;

    map<int, int> m;
    REP(i, N) FOR(j, i + 1, N) {
        int a = j - i;
        int b = abs(X - i) + abs(Y - j) + 1;

        m[min(a, b)]++;
    }

    FOR(i, 1, N) {
        cout << m[i] << endl;
    }
    
}


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

int main(void){
        int ans = 0;
        char s[101];
        scanf("%s",s);

        int n = strlen(s);

        for (int i = 0;i < n / 2;i++){
                if (s[i] != s[n - 1 -i]) ans++;
        }

        printf("%d\n",ans);

        return 0;

}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=1000001,INF=1<<30;
int V=MAX,cmp[MAX],when[MAX];
vector<int> G[MAX],rG[MAX],vs;
bool used[MAX];

void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(used[G[v][i]]==0) DFS(G[v][i]);
    }
    vs.push_back(v);
}

void rDFS(int v,int k){
    used[v]=1;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(used[rG[v][i]]==0) rDFS(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(used[v]==0) DFS(v);
    }
    
    memset(used,0,sizeof(used));
    int k=1;
    for(int i=vs.size()-1;i>=0;i--){
        if(used[vs[i]]==0) rDFS(vs[i],k++);
    }
    return k;
}

int DFS2(int u,int p){
    if(G[u].size()==0) return when[u]=1;
    int ans=0;
    for(int i=0;i<G[u].size();i++){
        int a=G[u][i];
        if(a==p) continue;
        if(when[a]) ans=max(ans,when[a]+1);
        else{
            int b=DFS2(a,u);
            ans=max(ans,b+1);
        }
    }
    return when[u]=ans;
}

int main(){
    
    int N;cin>>N;
    vector<vector<int>> A(N,vector<int>(N-1));
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin>>A[i][j];
            A[i][j]--;
            if(j){
                int a=A[i][j-1],b=A[i][j],c=i,d=i;
                if(a>c) swap(a,c);
                if(b>d) swap(b,d);
                add_edge(a*N+c,b*N+d);
            }
        }
    }
    scc();
    
    vector<int> cnt(MAX);
    bool ok=true;
    for(int i=0;i<V;i++){
        cnt[cmp[i]]++;
        if(cnt[cmp[i]]==2) ok=false;
    }
    if(!ok) cout<<-1<<endl;
    else{
        int ans=0;
        for(int i=0;i<V;i++){
            if(rG[i].size()==0){
                ans=max(ans,DFS2(i,-1));
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 99184
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception{
		// System.setIn(new FileInputStream("file"));
		try(BufferedReader  kb = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter out = new PrintWriter(System.out)){
			for(String in; (in= kb.readLine())!= null; ){
				long N = Long.parseLong(in.trim());
				long[] arr = new long[(int)N];
				for(long i = 0; i < N ; i++){
					in = kb.readLine().trim();
					arr[(int)i] = Long.parseLong(in);
				}
				out.println(solve(arr));
			}
		}
	}

	static long solve(long[] arr) {
		long a = 0;
		long b = 0;
		for (int i = 0; i < arr.length-1; i++) {
			a+=arr[i]/2;
			if(arr[i]%2!=0 && arr[i+1]!=0){
				a+=1;
				arr[i+1]--;
			}
		}
		a+=arr[arr.length-1]/2;
//		for (int i = arr.length-1; i > 0; i--) {
//			b+=arr[i]/2;
//			if(arr[i]%2!=0 && arr[i-1]!=0){
//				b+=1;
//				arr[i-1]--;
//			}
//		}
		return a;
	}
}

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

int main() {
  int n,p,d1,d2,top=0,num;
  while(cin >> n,n) {
    top = 0;
    for(int i=0;i<n;i++) {
      cin >> p >> d1 >> d2;
      if(d1+d2 >= top) {
        num = p;
        top = d1+d2;
      }
    }
    cout << num << " " << top << endl;
  }
}

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


int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3, y3, x4, y4;
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x1 - (y2 - y1);
	y4 = y1 + (x2 - x1);
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return  0;
}










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

int main() {
	int a, b;
	cin >> a >> b;

	if ((a + b) / 2 < (double)(a + b) / 2) {
		cout << (a + b + 1) / 2 << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}

	return 0;
}

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

int main(void)
{
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> n(N);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
    n.at(i) = i + 1;
  }
  for (int i=0;i<N;i++){
    cin >> b.at(i);
  }
  
  int A, B, cnt = 1;
  
  do {
    if (n == a){
      A = cnt;
    }
    if (n == b){
      B = cnt;
    }
    cnt++;
  }while (next_permutation(n.begin(), n.end()));
  
  cout << abs(A - B) << endl;
  
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int ans=0;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(i!=n-1){
            ans+=v[i];
        }else{
            ans+=(v[i]/2);
        }
    }
    cout<<ans<<endl;
    return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

int main(){
	ll n,k;cin>>n>>k;
	ll a = (n/2)+n%2;
	if(a>=k) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
int main() {
  int n,k,l=0,r=1e9;
  cin >> n>>k;
  vi v(n);
  cins(n,v);
  while (r-l > 1) {
    int x = (l+r)/2;
    auto f = [&](int x) {
      ll now = 0;
      rep(i,n) now += (v[i]-1)/x;
      return now <= k;
    };
    if (f(x)) r = x; else l = x;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define alpha 26

const int N = 2e5 + 10;

int n, m;
int visited[N], dist[N], par[N];
vector<int> g[N];

void BFS(int k) {
  queue<int> Q;
  Q.push(k);
  visited[k] = 1;
  while (!Q.empty()){
    int node = Q.front();
    Q.pop();
    for (auto it : g[node]){
      if (!visited[it]){
        dist[it] = dist[node] + 1;
        visited[it] = 1;
        par[it] = node;
        Q.push(it);
      }
    }
  }
}


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  
  cin >> n >> m;
  for (int i = 1; i <= m; i++){
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  BFS(1);

  for (int i = 1; i <= n; i++){
    if (!visited[i]){
      cout << "No" << endl;
      exit(0);
    }
  }

  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++)
    cout << par[i] << endl;
}

Measured memory_bytes: 16972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair <int,int> P;
const ll MAX_N = 100000;
int main() {
//input
int n,m;
cin >> n>>m;
//compute
if(n==m)cout<<"Yes";
else cout<<"No";
//output

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.chomp.split.map(&:to_i)
end

dp = Array.new(1000001).map{Array.new(4, 0)}
n.times do |i|
  3.times do |j|
    3.times do |k|
      next if j == k
      dp[i + 1][k] = [dp[i + 1][k], dp[i][j] + a[i][k]].max
    end
  end
end

puts dp[n].max

Measured memory_bytes: 143740
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int linearSearch(int A[], int n, int key) {
    int i = 0;
    A[n] = key;  // 番兵を置く
    while (A[i] != key) i++;
    return i != n;
}

int main(void)
{
    int n, q, i, count;
    int S[10000] = {};
    int T[500] = {};

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

    count = 0;
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &T[i]);
        if (linearSearch(S, n, T[i])) count++; 
    }
    
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2076