akhauriyash/Code-Regression huggingface dataset:
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
bool comp(const pair < pair < ll, ll >, ll >&a,const pair < pair <ll, ll>, ll >&b){
    return (a.ff.ff > b.ff.ff ||(a.ff.ff == b.ff.ff && a.ss > b.ss));
}

signed main(){ 
    IOS
    //io_set();
    ll  tt;
    vector <string> v;
    string s;
    w(tt){
        cin >> s;
        sort(all(s));
        v.pb(s);
    }
    sort(all(v));
    ll c = 1, ans = 0;
    fo(i, 1, sz(v)-1){
        if(v[i] == v[i-1]){
            c++;
        }
        else{
            ans += ((c*(c-1)))/2;
            c = 1;
        }
    }
    ans += ((c*(c-1)))/2;
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 5748
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <algorithm>
#include <limits.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#define ll long long
#define MSET(x) memset((x), 0, sizeof((x)))
#define MMSET(x) memset((x), -1, sizeof((x)))
#define rep(i, a, b) for ( ll (i) = a; (i) < (b) ; (i) ++ )
#define repA(i, a, b) for ( ll (i) = a ;  (i) <= (b) ; (i) ++ )
#define repD(i, a, b) for ( ll (i) = a; (i) >= (b) ; (i) -- )
#define fi first
#define se second
#define pb push_back
#define mfind(m, item) ((m).find((item)) != (m).end())
#define mp(a,b) make_pair((a),(b))
#define mt(a,b,c) make_pair(make_pair((a),(b)), (c))
#define tfi first.first
#define tse first.second
#define tth second
#define prll cout << endl
#define tri pair<pair<ll, ll>, ll>
using namespace std;

int n,m;
int cnt[100002], ans[100002];

void find(int x){
    if ( ans[x] == x ) return;
    find(ans[x]);
    cnt[x] += cnt[ans[x]], ans[x] = ans[ans[x]];
}

bool has = false;

int main(){
    while ( cin >> n >> m ) {
        MSET(cnt); MSET(ans); has = false;
        for ( int i = 1 ; i <= n ; ++ i ) ans[i] = i;
        for ( int i = 0 ; i < m ; ++ i ) {
            int l, r, d;
            scanf("%d %d %d", &l, &r, &d);
            find(l); find(r);
            if ( ans[l] == ans[r] ){
                if ( cnt[l] + d != cnt[r] ) {
                    has = true;
                }
            }
            else {
                cnt[ans[r]] = cnt[l] + d - cnt[r];
                ans[ans[r]] = ans[l];
            }
        }
        cout << (has ? "No" : "Yes" ) << endl;
    }
}


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

using namespace std;

int n, k, v[200002];

int main()
{
  cin >> n;
  int nr = 1;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    if (v[i] == nr) {
      k++;
      nr++;
    }
  }
  if (!k) {
    cout << -1;
    return 0;
  }
  cout << n - k;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll n,m;
  cin>>n>>m;
  ll one;
  one=m*1900+(n-m)*100;
  ll times=pow(2,m);
  cout<<one*times<<endl;
}

Measured memory_bytes: 4008
package main

import "fmt"

func main(){
	var O, E string
	fmt.Scan(&O, &E)

	for i := 0 ; i < len(E) ; i++ {
		fmt.Printf("%c%c", O[i], E[i])
	}
	if len(O) > len(E) {
		fmt.Printf("%c", O[len(O)-1])
	}
	fmt.Println()
}

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

int D;

int main() {
	cin >> D;

	if( D == 25) {
		cout << "Christmas" << endl;
	}
	else if( D == 24 ) {
		cout << "Christmas Eve" << endl;
	}
	else if( D == 23 ) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if( D == 22 ) {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

class Solver
{
public:
	int n;
	vector<int> p;


	Solver() {
		cin >> n;
		for (int i = 0; i < n; ++i)
		{
			int tmp;
			cin >> tmp;
			p.push_back(tmp);
		}
		
	}

	void exec() {
		int ans = 0;

		int m = p[0];
		for (int i = 0; i < n; ++i)
		{
			m = min(p[i], m);
			if(p[i] <= m) {
				ans++;
			}
			
		}
		cout << ans << endl;
	}
};


int main(){
	Solver co = Solver();
	co.exec(); 
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
using namespace std;
const int N = 5e5 + 555;
int dp[N][3];
void solve()
{
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for(int i = 1; i < n; ++i){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    rep(i, N){
        string S;
        cin >> S;
        mp[S]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3616
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize
    }
    let mut ans = "No";

    'o: for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                ans = "Yes";
                break 'o;
            }
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
def h_grid1(MOD=10**9 + 7):
    H, W = [int(i) for i in input().split()]
    Grid = [input() for _ in range(H)]

    # path[r][c]: マス(r, c)に(0-based)到達する経路の数
    path = [[0] * W for _ in range(H)]
    path[0][0] = 1  # スタート地点は必ず到達できる

    def can_reach(row, col):
        return 0 <= row < H and 0 <= col < W and Grid[row][col] == '.'

    for row in range(H):
        for col in range(W):
            if Grid[row][col] == '#':
                continue
            for nr, nc in ((row, col + 1), (row + 1, col)):
                if can_reach(nr, nc):
                    path[nr][nc] += path[row][col]
                    path[nr][nc] %= MOD
    return path[H - 1][W - 1]

print(h_grid1())

Measured memory_bytes: 43732
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 1e5 + 7;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <pair <ll, int> > e;
    map <ll, int> ret;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        ret[x] = i;
        e.push_back({x, i});
    }
    sort(e.rbegin(), e.rend());
    ll x = e.back().first;
    vector <int> sz(n, 1);
    vector <ll> dp(n, 0);
    vector <pair <int, int> > ans;
    for (auto c : e)
    {
        if (c.first != x)
        {
            if (sz[c.second] * 2 >= n)
            {
                cout << -1 << '\n';
                return 0;
            }
            ll need = c.first - (n - 2 * sz[c.second]);
            if (!ret.count(need))
            {
                cout << -1 << '\n';
                return 0;
            }
            int par = ret[need];
            dp[par] += dp[c.second] + sz[c.second];
            sz[par] += sz[c.second];
            ans.push_back({c.second + 1, par + 1});
        }
    }
    if (dp[e.back().second] != x)
    {
        cout << -1 << '\n';
        return 0;
    }
    for (auto c : ans)
    {
        cout << c.first << ' ' << c.second << '\n';
    }
}


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

mxcnt = 0
ans = 1
for i in range(1,n+1):
    cnt = 0
    x = i
    for j in range(7):
        if x % 2 != 0:
            break
        cnt += 1
        x //= 2
    if cnt >= mxcnt:
        mxcnt = cnt
        ans = i
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
signed main() {
    while (true) {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0) return 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
               cout << "#";
        }
        cout << endl;
    }
    cout << endl;
    }
}


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

int main(){
  int n, k; cin >> n >> k;
  vector <int> cnt(k);
  for (int i = 0; i < n; i++){
    cnt[i%k] += 1;
  }
  sort(cnt.begin(), cnt.end());
  cout << cnt.back() - cnt.front() << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
#具体的な操作を考える必要はなくて，ただ部分和をひたすら考えていけばいい
answer1 = 0
answer2 = 0
sum1 = 0
sum2 = 0
# pmpm...
for i in range(n):
    sum1 += a[i]
    if i % 2 == 1:
        if sum1 >= 0:
            answer1 += sum1 - (-1)
            sum1 = -1
    if i % 2 == 0:
        if sum1 <= 0:
            answer1 += 1 - sum1
            sum1 = 1
# mpmp...
for i in range(n):
    sum2 += a[i]
    if i % 2 == 0:
        if sum2 >= 0:
            answer2 += sum2 - (-1)
            sum2 = -1
    if i % 2 == 1:
        if sum2 <= 0:
            answer2 += 1 - sum2
            sum2 = 1
print(min(answer1, answer2))

Measured memory_bytes: 14468
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    double W,H,x,y;
    int res = 0;
    cin >> W >> H >> x >> y;
    double ans;

    //xで割ったときの最大値(ちいさいほうをとる)
    //対角線
    ans = (double)W * H / 2.00;

    if(x + x == W && y + y == H)
    {
        res = 1;
    }
    else 
    {
        res = 0;
    }

    //printf("%.9f %d\n",ans,res);
    cout << fixed << setprecision(10) << ans << " ";
    cout << res << endl;


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool used[111][111];
int dp[111][111];
int n;
int a[111];
int dfs(int l,int r){
  if(used[l][r]) return dp[l][r];
  if(l+1==r) return 0;
  used[l][r]=1;
  int res=0;
  for(int i=1;(l+i)%n!=r;i++){
    int m=(l+i)%n;
    res=max(res,dfs(l,m)+dfs(m,r)+abs(a[l]-a[m]));
  }
  //cout<<l<<" "<<r<<":"<<res<<endl;
  return dp[l][r]=res;
}
signed main(){
  int T;
  cin>>T;
  while(T--){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    memset(used,0,sizeof(used));
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=0;i<n;i++) ans=max(ans,dfs(i,i));
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[3][n+1];

  for (int i = 1; i <= 2; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }

  int count = 0;
  int break_point = 1;
  while(break_point <= n ) {
    int tmp_count = 0;
    int tmp = 1;
    for (int i = 1; i <= 2; i++) {
      for (int j = tmp; j <= n; j++) {
        tmp_count += a[i][j];
        if (break_point == j and i == 1) {
          tmp = j;
          break;
        }
      }
    }
    count = max(count, tmp_count);
    break_point++;
  }

  cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mark[105],n,temp,a,b,ans,maxn;
void solve() {
	cin>>a>>b;
	mark[n]++;
	mark[a]++;
	mark[b]++;
	for(int i=1;i<=100;i++)
	if(mark[i]!=0)
	ans++;
	cout<<ans;
	return;
}
int main() {
	cin>>n;
	solve();
	return 0;
}

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

using namespace std;

int a[10];

bool dfs(int B, int C, int i)
{
    if(i == 10)
        return true;
    else if(B < a[i])
        return dfs(a[i], C, i + 1);
    else if(C < a[i])
        return dfs(B, a[i], i + 1);
    
    return false;
}

int main()
{
    int N;
    cin >> N;
    while(N--)
    {
        for(int i = 0; i < 10; i++)
            cin >> a[i];
        
        cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
    }
}

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

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

using ll = long long;

void  solve(){

string s,t;
cin>>s>>t;
int ans=0;
rep(i,s.size()){
	if(s[i]!=t[i]){
		ans++;
	}
	
}
cout<<ans;
}

int main(){

		solve();


		

 
}


Measured memory_bytes: 3864
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define memset_clear(_) memset(_,0,sizeof(_))
#define memset_clear_tre(_) memset(_,1,sizeof(_))
#define memset_clear_reg(_) memset(_,-1,sizeof(_))
#define memset_clear_max(_) memset(_,0x3f,sizeof(_))
#define memset_clear_min(_) memset(_,0x80,sizeof(_))
#define sqr(_) ((_)*(_))

#define int long long

inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}

signed main(){
	int x=read(),y=read();
	printf("%lld\n",x*y-x-y+1);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))


ri=0
co=0
su=0

for le in range(n):
    while ri<n and (su+A[ri]==su^A[ri]) :
        su+=A[ri]
        ri+=1
        #print(ri)
        
    co+=ri-le
    if le==ri :
        ri+=1
    else:
        su-=A[le]

print(co)


Measured memory_bytes: 24840
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  string s; cin  >> s;
  ll n = s.size();
  ll mini,maxi;
  REP(i, n){
    if(s[i] == 'A'){
      mini = i;
      break;
    }
  }
  IREP(i, n){
    if(s[i] == 'Z'){
      maxi = i;
      break;
    }
  }
  cout << maxi -mini +1 << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
bool prime(int n) {
	int i = 2;
	if (n == 2)return true;
	else if(n <= 1)return false;
	if (n % i == 0)return false;
	i = 3;
	while (i <= sqrt(n)) {
		if (n % i == 0)return false;
		i += 2;
	}
	return true;
}
signed main() {
	int a, b, c, k; cin >> a >> b >> c >> k;
	cout << a + b + c + (max({ a,b,c }) * (pow(2, k) - 1)) << endl;
}


Measured memory_bytes: 4220
#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

int main()
{
	long long N;
	cin >> N;
	long long A[N], dA[N];
	long long sum = 0;//Aの和
	long long x = 0;//取った回数
	REP(i,N){
		cin >> A[i];
		sum+=A[i];
	}
	if(sum % (N*(N+1)/2) != 0){
		cout << "NO" << endl;
	}else{
		x = sum/(N*(N+1)/2);
		REP(i,N){
			dA[i] = A[(i+1)%N]-A[i];
			if((x-dA[i])%N != 0 || (x-dA[i])<0){
				cout << "NO" << endl;
				return 0;
			}
		}
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;cin >> n;
  vector<pair<ll,ll>> p(n);

  rep(i,n) cin >> p[i].first >> p[i].second;

  double sum = 0;

  auto length = [](auto a, auto b){
    ll x = abs(a.first - b.first);
    ll y = abs(a.second - b.second);

    double leng = sqrt(x * x + y * y);
    return leng;
  };

  ll cnt = 0;

  for(ll i = 0; i < n; ++i)
  {
    for(ll j = i + 1; j < n; ++j)
    {
      sum += length(p[i], p[j]);
      cnt++;
    }
  }

  double ans = sum /cnt * (n - 1);

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  VECINT CS(N-1);
  VECINT SS(N-1);
  VECINT FS(N-1);
  VECINT ans(N);
  REP(i,N-1) {
    cin>>CS[i]>>SS[i]>>FS[i];
  }

  // 一人一人見ていった場合、O(N*N)なので2500となりいけそう
  // 時間をメモしていって、駅に着く->出発時刻までまつ→次の駅への経過時間を追加を繰り返す
  // 今の時間が、「S以上のFの倍数」になったらCを追加して次へ
  // 人のidx
  REP(i,N-1) {
    // 駅のidx
    // 最後の駅に着くまでans[i]に足し続ける
    FOR(j,i,N-1) {
      while (true) {
        if (ans[i]>=SS[j] && ans[i]%FS[j]==0) break;
        ans[i]++;
      }
      ans[i] += CS[j];
    }
  }
  REP(i,N) OUT(ans[i]);

  return 0;
}

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

int main() {
 	int n;
  int d[50];
  cin >> n;
  for(int i=0; i!=n; i++){
    cin >> d[i];
  }
  int ans = 0;
  for(int i=0; i!=n; i++){
    for(int j=i+1; j!=n; j++){
      ans += d[i] * d[j];
    }
  }
  cout << ans << '\n';
	return 0;
}


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

int main(){
  long long  n,nm=0;
  cin>>n;
  int m=n;
  while(m>0){
    nm+=m%10;
    m/=10;
  }
  if(n%nm==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  


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

int main()
{
  const int digits = 4;
  int n;
  cin >> n;

  int A[digits];
  char B[digits - 1];

  for (int i = digits - 1; i >= 0; --i)
  {
    A[i] = n % 10;
    n /= 10;
  }

  int status = 1 << (digits - 1);
  string ans;
  for (; status > 0; --status)
  {
    int total = A[0];
    for (int i = 0; i < digits - 1; ++i)
    {
      if ((status >> i) & 0x01)
      {
        total += A[i + 1];
        B[i] = '+';
      }
      else
      {
        total -= A[i + 1];
        B[i] = '-';
      }
    }

    if (total == 7)
    {
      stringstream ss;
      for (int i = 0; i < digits - 1; ++i)
      {
        ss << A[i] << B[i];
      }
      ss << A[digits - 1];

      ans = ss.str();
      break;
    }
  }

  cout << ans << "=7" << endl;

  return 0;
}


Measured memory_bytes: 256
O = input()
E = input()

res = ""
o_cnt = 0
e_cnt = 0
while True:
    if o_cnt == len(O) and e_cnt == len(E):
        break
    if o_cnt < len(O):
        res += O[o_cnt]
        o_cnt += 1

    if e_cnt < len(E):
        res += E[e_cnt]
        e_cnt += 1

print(res)

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

int main(){
  int a,b; cin>>a>>b;
  if(0<a&&0<b) cout<<"Positive"<<endl;
  else if(a<=0&&0<=b) cout<<"Zero"<<endl;
  else{
    if((b-a+1)%2==1) cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
  }
  
}

Measured memory_bytes: 256
using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
     
    namespace ConsoleApp1
    {
        class Program
        {
            static void Main(string[] args)
            {
                var line = Console.ReadLine().Split();
                var a = line[0];
                var b = line[1];
     
                Console.WriteLine(b + a);
                Console.ReadLine();
            }
        }
    }

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

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

Measured memory_bytes: 3068
n = int(input())
a = []
b = []
for i in range(n):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)

count = 0
for i in range(n-1,-1,-1):
    if (a[i]+count)%b[i] > 0:
        count += b[i]-(a[i]+count)%b[i]
print(count)

Measured memory_bytes: 56920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int k, s;
int cnt;
int main()
{
	cin >> k >> s;
	for (int x = 0; x <= k; x++)
	{
		for (int y = 0; y <= k; y++)
		{
			int z = s - x - y;
			if (0 <= z && z <= k)
			{
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3624
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

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

fn calc_primes(n: u64) -> Vec<(u64, u64)>{
    if n == 2{
        return vec![(2, 1)];
    }

    let mut n = n;
    let mut ans = vec![];
    for i in 2..=(n as f64).sqrt().ceil() as u64{
        let mut div_counter: u64 = 0;
        while n%i == 0{
            div_counter += 1;
            n /= i;
        }
        if div_counter > 0{
            ans.push((i, div_counter));
        }

    }
    if n > 1{
        ans.push((n, 1));
    }
    return ans;
}

fn main(){
    let n = read_as_vec::<u64>()[0];
    if n == 1{
        println!("0");
        return;
    }
    let primes = calc_primes(n);
    //println!("{:?}", primes);

    //let mut s_acc = 0;
    let mut ans = 0;
    for (prime, count) in primes{
        let mut num = ((count*2) as f64).sqrt().floor() as u64;
        if num*(num+1) == count*2{
            ans += num;

        }else{
            if num*(num+1) > count*2{
                num -= 1;
            }
            ans += num;
        }

    }
    print!("{}", ans);
}


Measured memory_bytes: 2664
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	vector<long long int>v(3);
	for (auto &i : v)cin >> i;
	cin >> M;
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i < M; i++)v[0] <<= 1;
	cout<<accumulate(v.begin(), v.end(), 0LL) << endl;
}


Measured memory_bytes: 256
#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,string>;

int main() {
 int a,b;
 cin >> a >> b;
 string s;
  cin >> s;
 bool ans = true;
 rep(i,s.size()){
   if(i != a && s.at(i) == '-') ans = false;
   else if(i == a && s.at(i) != '-') ans = false;
 }
 cout << (ans?"Yes":"No") << endl;
 }


Measured memory_bytes: 3568
function Main(input) {
    // console.log(input);
    
    const N = parseInt(input[0].split(" ")[0]);
    const Q = parseInt(input[0].split(" ")[1]);
    const S = input[1];
    
    var ctArr = new Array(N);

    var count = 0;
    ctArr[0] = 0;
    for(var i = 1; i < N; i++) {
        if(S[i-1] == "A" && S[i] == "C") {
            count++;
        }
        ctArr[i] = count;
    }

    for(var i = 2; i < input.length; i++) {
        var l = input[i].split(" ")[0];
        var r = input[i].split(" ")[1];
        console.log(ctArr[r-1] - ctArr[l-1]);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i>=b;i--)

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double

#define V vector<ll>
#define pp pair<ll,ll>
#define pb push_back
#define mp make_pair
#define Pr pair<ll,ll>
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin().A.rend()

#define ff first
#define ss second
#define len length()
ll max3(ll a,ll b,ll c)
{
    if(a>=b&&a>=c)
        return a;
    else if(b>=a&&b>=c)
        return b;
    else
        return c;
}
int min3(int a,int b,int c)
{
    if(a<=b&&a<=c)
        return a;
    else if(b<=a&&b<=c)
        return b;
    else
        return c;
}
int binarySearch(ll arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;

        if (arr[mid] == x)
            return mid;

        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);


        return binarySearch(arr, mid + 1, r, x);
    }

    return -1;
}
int main()
{
	fast;

      int n;
      cin>>n;
      double a[n];
      rep(i,0,n)cin>>a[i];
      sort(a,a+n);
      double ans=0.0;
      ans=(a[0]+a[1])/2.0;
      rep(i,2,n)
          ans=(ans+a[i])/2.0;
      cout<<fixed<<setprecision(6)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int a = scan.nextInt();
	int b = scan.nextInt();
	if (a + b <= 16 && a <= 8 && b <= 8) {
	    System.out.println("Yay!");
	} else {
	    System.out.println(":(");
	}
    }
}


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

int main() {
  int N;
  cin>>N;
    for(int i=0;i<N;i++){
      string s;
      cin>>s;
      if (s=="Y"){
        cout<<"Four"<<endl;
        break;
      }
      else if(i==N-1){
        cout<<"Three"<<endl;
      }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N, K;
int x[100005];
vector<int> mx, px;

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

	cin >> N >> K;

	for (int i = 0;i < N;i++){
		cin >> x[i];
		if(x[i] < 0)mx.push_back(-x[i]);
		else px.push_back(x[i]);
	}

	reverse(mx.begin(), mx.end());

	int ans = INT_MAX;

	for (int i = 0;i < mx.size();i++){
		int numc = i+1;
		if(numc == K){
			ans = min(ans, mx[i]);
			break;
		}
		if(K-numc-1 >= px.size()) continue;
		int t = mx[i]*2 + px[K-numc-1];
		ans = min(ans,t);
	}

	for (int i = 0;i < px.size();i++){
		int numc = i+1;
		if(numc == K){
			ans = min(ans, px[i]);
			break;
		}
		if(K-numc-1 >= mx.size()) continue;
		int t = px[i]*2 + mx[K-numc-1];
		ans = min(ans, t);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS (1e-9)
typedef complex<double> Point;
 
int main()
{
    int N;
    while(cin >> N, N){
	Point p[N];
	for (int i = 0; i < N; i++) {
	    scanf("%lf,%lf", &p[i].real(), &p[i].imag());
	}
	int res = 1;
	for (int i = 0; i < N-1; i++) {
	    for (int j = 0; j < N; j++) {
		Point np = p[j]-p[i];
		double d = abs(np);
		if(d + EPS > 2.0) continue;
		np /= d;
		np *= Point(0,1);
		Point cp = (p[i]+p[j])/2.0;
		Point v = sqrt(1.0-d*d/4.0)*np;
		int cnt = 2;
		Point center = cp + v;
		for (int k = 0; k < N; k++) {
		    if (i == k || j == k) continue; 
		    Point diff = center-p[k];
		    if (norm(diff) < 1.0 + EPS) {
			cnt++;
		    }
		}
		res = max(res, cnt);
	    }
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1292
city = int(input())
monster = list(map(int, input().split()))
hero = list(map(int, input().split()))
cnt = 0
for i, m in enumerate(monster):
    if i == 0:
        if m <= hero[i]:
            cnt = m
            hero[i] -= m
        else:
            cnt = hero[i]
            hero[i] = 0
    elif i <= len(hero) - 1:
        if m <= hero[i-1]:
            cnt += m
        elif m <= hero[i] + hero[i-1]:
            cnt += m
            hero[i] -=  m - hero[i-1]
        else: # m > hero[i] + hero[i-1]
            cnt += hero[i] + hero[i-1]
            hero[i] = 0
    else: # i > len(hero) - 1
        if m <= hero[i-1]:
            cnt += m
        else:
            cnt += hero[i-1]
print(cnt)

Measured memory_bytes: 18624
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

A, B, C = LI()

nums = sorted([A,B,C])
set_nums = list(set([A,B,C]))
result = 0
if len(set_nums) == 1:
    print(0)
elif len(set_nums) == 2:
    # 2種類は一緒
    #前２つが一緒かつはぐれが大きい
    if nums[0] == nums[1]:
        result += nums[2]-nums[1]
        print(result)
        exit()
    elif nums[1] == nums[2]:
        # 後ろ２つが等しく、はぐれが最小
        result += (nums[1] - nums[0])//2
        if (nums[1]-nums[0]) % 2 != 0:
            result += 2
        print(result)
        exit()
else:
    # 全数字が異なる
    result += nums[2]-nums[1]
    nums[0] += nums[2]-nums[1]
    result += (nums[2] - nums[0]) // 2
    if (nums[2] - nums[0]) % 2 != 0:
        result += 2

    print(result)



Measured memory_bytes: 5716
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;

int main()
{
	double a, b, x, t, s, h, w, rad, ans;
	cin >> a >> b >> x;
	t = acos(-1);
	s = (x/a);
	if( s >= (a*b)/2 ){
		h = (2/a)*(a*b-s); 
		rad = atan(h/a);
	}else{
		w = (2/b)*s;
		rad = atan(b/w);
	}
	ans = 180*(rad/t);
   printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

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


void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    ll i;
    mll m;
    ll res=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        ll no=a[i]+i;
        ll no2=a[i]-i;
        res+=m[no2];
        m[-no]++;
    }
    cout<<res<<"\n";

}

// void solve()
// {
//     ll x;
//     cin>>x;

//     vector<pll> v;
// }

// void solve()
// {
//     ll n,m;
//     cin>>n>>m;
//     ll h[n];
//     ll i,j;
//     for(i=0;i<n;i++)
//     {
//         cin>>h[i];
//     }
//     ll x,y;
//     ll ind[n];
//     for(i=0;i<n;i++)
//     {
//         ind[i]=-INF;
//     }
//     for(i=0;i<m;i++)
//     { 
//        cin>>x>>y;
//        x--,y--;
//        ind[x]=max(ind[x],h[y]);
//        ind[y]=max(ind[y],h[x]);
//     }
//     ll res=0;
//     for(i=0;i<n;i++)
//     {
//         if(ind[i]<h[i])
//         {
//             res++;
//         }
//     }
//     cout<<res<<"\n";
// }


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 27932
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  long long ans;
  if(k % 2){
    ans = pow(floor(n/k), 3);
  }
  else{
    ans = pow(floor(n/k), 3) + pow(floor((n+k/2)/k), 3);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
Var n,i,sum:Int64;
Begin
    Readln(n);
    If odd(n) then sum:=0
    Else begin
      sum:=n div 10+n div 50+n div 250+n div 1250+n div 6250+n div 31250+n div 156250+n div 781250+n div 3906250+n div 19531250
      +n div 97656250+n div 488281250+n div 2441406250+n div 12207031250+n div 61035156250
      +n div 305175781250+n div 1525878906250+n div 7629394531250+n div 38146972656250
      +n div 190734863281250+n div 953674316406250+n div 4768371582031250
      +n div 23841857910156250+n div 119209289550781250+n div 596046447753906250
      +n div 2980232238769531250
    End;
    Writeln(sum);
End.

Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[] a = new int[n];
			int sum = 0;
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				sum += a[i];
			}
			
			Arrays.sort(a);
			boolean[] f = new boolean[sum+1]; 
			f[0] = true;
			int max = 0;
			for(int i=0;i<n;i++){
				for(int j=max;j>=0;j--){
					if(f[j]) f[j+a[i]] = true;
				}
				max += a[i];
			}
			
			for(int i=0;;i++){
				if(f[sum/2+i] || f[sum/2-i]){
					System.out.println(i*2+sum%2);
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 20832
#include <iostream>

using namespace std;

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

    int city[51] = {};
    for (int j = 0; j < m; ++j) {
        int a, b;
        cin >> a >> b;
        city[a]++;
        city[b]++;
    }
    for (int i = 1; i <= n; ++i) {
        cout << city[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define y1 asdflasdkf
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
inline int qpow(int bas,int pw)
{
	int ans=1; for(;pw;pw>>=1,bas=1ll*bas*bas%mod)
		if(pw&1) ans=1ll*ans*bas%mod; return ans;
}
int inv[3000010],fac[3000010];
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int Ans;
inline void Add(int &x,int y)
{
	x+=y; if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
inline int C(int n,int m)
{
	if(m==0) return 1;if(n==m) return 1;
	return 1ll*fac[n]*inv[n-m]%mod*inv[m]%mod;
}
inline int calc(int x1,int y1,int x2,int y2)
{
	int X=x2-x1, Y=y2-y1;
	//printf("retangle %d %d %d %d ",x1,y1,x2,y2);
	//cout << X << " " <<  Y << " " << C(X+Y,X) << endl;
	return C(X+Y,X);
}
inline int ssolve(int x1,int y1,int x2,int y2)
{
//	printf("%d %d %d %d ",x1,y1,x2,y2);
	int ret=0;
	for(int i=x3;i<=x4;i++)
	{
		Add(ret,1ll*(-i-y3)*calc(x1,y1,i,y3-1)%mod*calc(i,y3,x2,y2)%mod);
		Add(ret,1ll*(i+y4+1)*calc(x1,y1,i,y4)%mod*calc(i,y4+1,x2,y2)%mod);
	}
	for(int i=y3;i<=y4;i++)
	{
		Add(ret,1ll*(-i-x3)*calc(x1,y1,x3-1,i)%mod*calc(x3,i,x2,y2)%mod);
		Add(ret,1ll*(i+x4+1)*calc(x1,y1,x4,i)%mod*calc(x4+1,i,x2,y2)%mod);
	}
	//printf("%d\n",ret);
	return ret;
}
inline int solve(int x1,int y1)
{
	int ret=0; 
	Add(ret,ssolve(x1,y1,x5,y5)); Add(ret,ssolve(x1,y1,x6+1,y6+1));
	Add(ret,-ssolve(x1,y1,x5,y6+1)); Add(ret,-ssolve(x1,y1,x6+1,y5));
	return ret;
}
signed main()
{
	fac[0]=1; for(int i=1;i<=2000000;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[2000000]=qpow(fac[2000000],mod-2);
	for(int i=1999999;i>=1;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	x1=read(); x2=read(); x3=read(); x4=read();
	x5=read(); x6=read(); y1=read(); y2=read();
	y3=read(); y4=read(); y5=read(); y6=read();
	Add(Ans,-solve(x1-1,y2)); Add(Ans,-solve(x2,y1-1));
	Add(Ans,solve(x1-1,y1-1)); Add(Ans,solve(x2,y2));
	cout << Ans << endl; return 0;
}

Measured memory_bytes: 18816
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>
typedef long long int LLI;
using namespace std;

//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}



void func() {
    LLI H ,W;
    cin >> H >> W;
    if(W == 1 || H == 1) {
        cout << 1 << endl;
        return;
    }
    cout << W * (H >> 1) + (H % 2 == 0 ? 0 : (W / 2 + (W % 2 == 0 ? 0 : 1)))  << endl;

}

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

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

int main() {
  int N, K, x;
  cin >> N >> K;//N と K を代入
  int sum = 0;//sum を 0 だと宣言
  for(int i = 0; i < N; i++){
    cin >> x;//x を代入(ループ)
    if(K < x){//K が x より小さい時(x - K)
      x = min(x * 2, (x - K) * 2);//タイプA と タイプB は それぞれ往復
      sum += x;//sum に 合計していく
    }else{
      x = min(x * 2, (K - x) * 2);
      sum += x;
    }
  }
  cout << sum << endl;
}

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

// x1 * y2 - x2 * y1
using LL = long long;

int main() {
    LL S;
    cin >> S;
    LL k = sqrt(S);
    while (k * k < S) {
        k++;
    }
    LL w = k * k - S;
    cout << k << ' ' << w << ' ' << 1 << ' ' << k << ' ' << 0 << ' ' << 0 << endl;
    return 0;
}


Measured memory_bytes: 3652
using System;

namespace _9_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var taro = 0;
            var jiro = 0;
            for(var i=0;i<n;i++)
            {
                var s = Console.ReadLine().Split(' ');
                var s1 = s[0];
                var s2 = s[1];
                if (s1.CompareTo(s2) < 0)
                {
                    jiro += 3;
                }
                else if(s1.CompareTo(s2) == 0)
                {
                    taro++;
                    jiro++;
                }
                else
                {
                    taro += 3;
                }
            }
            Console.WriteLine("{0} {1}", taro, jiro);
        }
    }
}



Measured memory_bytes: 18740
N = gets.to_i
$adjacency_list = []
N.times{
  u, k, *v = gets.split.map &:to_i
  $adjacency_list[u] = v
}
$d = Array.new(N)
$f = Array.new(N)
$time = 1
def record_time v
  unless $d[v]
    $d[v] = $time
    $time += 1
  end
  $adjacency_list[v].each{|arr_v|
    record_time arr_v unless $d[arr_v]
  }
  unless $f[v]
    $f[v] = $time
    $time += 1
  end
end
(1..N).each{|i|
  record_time(i) unless $d[i]
}
(1..N).each{|i|
  puts "#{i} #{$d[i]} #{$f[i]}"
}

Measured memory_bytes: 8904
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		doIt();
	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int ans = 0;
			for(int i = n; i > 1; i--){
				ans += i;
			}
			//System.out.println(ans);
			ans += 2;
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 12000
N, C, K = map(int, input().strip().split(" "))
t = sorted([int(input().strip()) for _ in range(N)])

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if idx == N:
                break
            if tmp == C:
                bus += 1
                tmp = 0
                bus_go = t[idx] + K
        else:
            break
    if tmp > 0:
        bus += 1

print(bus)


Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int A,B;
    cin >> A >> B;
    REP(i,10000) {
        if(((8*i)/100 == A) && (10*i)/100 == B) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

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


Measured memory_bytes: 3620
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n; int a[n]; rep(i,n)cin>>a[i]; sort(a,a+n); Int ans=0;
  rep(i,n-1)rer(j,i+1,n-1){
    int ed=a[i]+a[j];
    auto it=lower_bound(a+j+1,a+n,ed);
    if(it==a+j)continue;
    ans+=distance(a+j+1,it);
  }
  END
}

Measured memory_bytes: 256