akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

void solve() {
    int n;
    cin >> n;
    vl a(n);
    cin >> a;
    string s;
    cin >> s;
    vl es;
    es.pb(0);
    rrep(i,n) {
        ll v = a[i];
        for(ll e : es) chmin(v,v^e);
        if(v) {
            if(s[i] == '1') {
                cout << 1 << '\n';
                return;
            } else es.pb(v);
        }
    }
    cout << 0 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int t;
    cin >> t;
    rep(i,t) solve();
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string n;
    cin >> n;
    bool r = false;
    for (char c : n) {
        if (c == '7') {
            r = true;
            break; 
        }
    }
    cout << (r ? "Yes" : "No") << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data


Measured memory_bytes: 3604
N = int(input())

AS = map(int, input().split())

SAS = sorted(AS, reverse = True)
BAR = 10 ** 18

ans = 0
if SAS[-1] == 0:
	ans = 0
else:
	ans = SAS[0]
	for A in SAS[1:]:
		ans *= A
		if ans > BAR:
			ans = -1
			break
print(ans)

Measured memory_bytes: 21644
#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int shift;
    string s;
    cin >> shift >> s;
    string result_s = "";
    for (int i = 0; i < s.length(); i++) {
        char x = s[i];
        x += shift;
        while (x > 'Z') {
            x = x - ('Z' - 'A') - 1;
        }
        result_s += x;
    }
    cout << result_s;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;cin >> n;
    string s;
    string test = "abcdefghijklmnopqrstuvwxyz";
    vector<string> vec(n);
    REP(i,n)cin >> vec[i];
    for(char x:test){
        int min1 = INF;
        REP(i,n){
            int num = count(vec[i].begin(),vec[i].end(),x);
            min1 = min(num,min1);
        }
        REP(k,min1)cout << x; 
    }
    cout << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n, t, m = 0;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    for (int i = n - 1; i >= 0; --i) {
        m = max(m, a.at(i));
        a.at(i) = m - a.at(i);
    }
    cout << count(a.begin(), a.end(), *max_element(a.begin(), a.end())) << endl;
    return 0;
}


Measured memory_bytes: 640
// はじめての高速ゼータ変換
// 理解度は50%くらい
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;

int main(){
    auto f = [](pii p, pii q)->pii{
        int a[4] = {p.first, p.second, q.first, q.second};
        sort(a, a+4);
        return {a[3], a[2]};
    };
    int n;
    cin >> n;
    vector<pii> v(1<<n, {0,0});
    for(int i = 0; i < 1<<n; i++)   cin >> v[i].first;
    for(int j = 0; j < n; j++){
        for(int i = 0; i < 1<<n; i++){
            if((i>>j)&1){
                v[i] = f(v[i], v[i&~(1<<j)]);
            }
        }
    }
    vector<int> ans(1<<n, 0);
    for(int i = 1; i < 1<<n; i++)   ans[i] = max(ans[i-1], v[i].first+v[i].second);
    for(int i = 1; i < 1<<n; i++)   cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<iostream> 
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];scanf("%d %d %d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	printf("%d",a[3]*10+a[1]+a[2]);
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	S := fsc.Next()
	res := 700
	for _, c := range S {
		if c == 'o' {
			res += 100
		}
	}
	fmt.Println(res)

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

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

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

void rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) rec(T[u].r, p);
	if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) if (T[i].p == NIL) r = i;

	rec(r, 0);

	for (i = 0; i < n; i++) print(i);

	return 0;
}


Measured memory_bytes: 7672
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int  N, ans=0, abcount =0, acount=0, bcount=0;
  std::cin >> N;
  range(i, N) {
    string s;
    std::cin >> s;
    if(s[0]=='B' && s[s.length()-1]=='A') abcount++;
    else if(s[0]=='B') bcount++;
    else if(s[s.length()-1]=='A') acount++;
    range(j, s.length()-1) if(s[j]=='A') if(s[j+1]=='B') ans++;
  }
  if(abcount==0){
    std::cout << ans+min(acount, bcount) << '\n';
  }else{
   std::cout << ans + (acount==0&&bcount==0?abcount-1:abcount+min(acount, bcount)) << '\n';
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
int main(){
	int a,b,c,i,d=0;
	cin>>a;
	cin>>b;
	for(i=1; i<=a; i++){
	cin>>c;
	if(c<(b-c))
		d+=c;
	else
		d+=b-c;
	}
	cout<<d*2;
	
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> w(n);
    lint s1, s2;
    REP(i, n){
        cin >> w[i];
    }
    lint ans = LINF;
    for (int i=0; i<n; ++i){
        s1 = 0;
        s2 = 0;
        for (int j=0; j<=i; ++j){
            s1 += w[j];
        }
        for (int j=i+1; j<n; ++j){
            s2 += w[j];
        }
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
//============================================================================
// Name        : test1.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b;

	cin >> a >> b;

	int count = 0;

	if(a>b){
		count += a;
		a -= 1;
	}
	else{
		count += b;
		b -= 1;
	}

	if(a>b){
		count += a;
	}
	else{
		count += b;
	}

	cout << count << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  vector<ll> p(200000);
  rep(i,n){
    cin>>p[i+1];
  }

  vector<ll> ans(200000,INF);
  ans[1]=0;
  for(ll i=2;i<=n;i++){
    for(ll j=1;j<=k;j++){
      if(i-j>=1) chmin(ans[i],ans[i-j]+abs(p[i]-p[i-j]));
    }
  }

  cout << ans[n] << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main () {
    int a, b, c;
    cin >> a >> b >> c;
    int k = a;
    for (int i = 0; i < 1000; i++) {
        if (k % b == c) {
            puts("YES");
            return 0;
        }
        k += a;
    }
    puts("NO");
}

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

int main(){
    ll n,m,X,Y;
    cin>>n>>m>>X>>Y;
    vector<ll> x(n);
    vector<ll> y(m);
    bool flag=false;
    for(ll i=0;i<n;++i){
        cin>>x[i];
    }
    sort(x.begin(), x.end());
    for(ll i=0;i<m;++i){
        cin>>y[i];
    }
    sort(y.begin(), y.end());
    
    for(ll i=X+1;i<=Y;++i){
        if(x[n-1]<i and i<=y[0]){
            flag=true;
            break;
        }
    }

    if(flag){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){
    int n;cin>>n;
    int ans=0;
    rep(1,n+1){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout<<ans;



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
package main

import "fmt"

func main() {
	var a, c int
	var ans int = 0
	fmt.Scan(&a)
	for i := 0; i < 3; i++ {
		c = a % 10
		if c == 7 {
			ans++
		}
		a = a / 10
	}

	if ans > 0 {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No")
	}
}


Measured memory_bytes: 1820
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll arr[300000] = {};

int main(void)
{
	// N >= A + B - 1
	// N <= A * B

	ll N, A, B, T = 0;
	cin >> N >> A >> B;

	ll M = A * B - N;//減らさなきゃいけない数

	std::set<ll> s;

	if (N >= A + B - 1 && N <= A * B) {

		for (int i = A - 1; i >= 0; i--) {

			ll sz = min(N - i, B);
			
			for (int j = 0; j < sz; j++)
				cout << T + sz - j << " ";

			T += sz;
			N -= sz;

		}

	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

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

long long l(long long z)
{
 if(z < 0) return -z;
 else return z;
}

int main()
{
 int N;
 int A[100000+5];
 long long ans = 0;
 cin >> N;
 for(int i = 0; i < N; i++) cin >> A[i];
 bool fa = true;
 bool f0 = false;
 int o0 = 0;//プラスの数
 long long minA = 1LL << 60; //絶対値の最小値
 //数列が全て正
 for(int i = 0; i < N; i++){
  if(A[i] < 0) fa = false;
 }
 if(fa == true){
  for(int i = 0; i < N; i++) ans += A[i];
  cout << ans;
  return 0;
 }
 else{
  //数列に0がある
  for(int i = 0; i < N; i++){
   if(A[i] == 0) f0 = true; 
  }
  if(f0){
   for(int i = 0; i < N; i++) ans += l(A[i]);
   cout << ans;
   return 0;
  }
  //偶奇判定
  else
  {
   for(int i = 0; i < N; i++){
    if(A[i] > 0) o0++;
   }
   //nが偶数
  // if(N%2 == 0){
    if((N-o0)%2 == 0){
     for(int i = 0; i < N; i++) ans += l(A[i]);
     cout << ans;
     return 0;
    }
    else{
     for(int i = 0; i < N; i++) minA = min(l(A[i]),minA);
     for(int i = 0; i < N; i++) ans +=l(A[i]);
     ans -= 2*minA;
     cout << ans;
     return 0;
    }
   }
 // }
 }
 return 0;
}


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

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint com(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;

modint dp[102][10];
modint fibs[10];

modint fib(int n) {
    if (n < 2) return n;
    if (fibs[n]) return fibs[n];
    return fibs[n] = fib(n-1) + fib(n-2);
}

int main(void){
    int Y,X,K;
    cin>>Y>>X>>K;
    dp[0][1] = 1;
    rep(y,Y){
        rep1(x,X){
            dp[y+1][x-1] += dp[y][x] * fib(x-1) * fib(X+1-x);
            dp[y+1][x]   += dp[y][x] * fib(x)   * fib(X+1-x);
            dp[y+1][x+1] += dp[y][x] * fib(x)   * fib(X-x);
        }
    }
    cout << dp[Y][K] << endl;
    return 0;
}


Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local edge, len = {}, {}
local taskstate = {}
for i = 1, n do
  edge[i] = {}
  len[i] = 0
  taskstate[i] = false
end
len[1] = 1
taskstate[1] = true

for i = 1, m do
  local a, b = io.read("*n", "*n")
  edge[a][b], edge[b][a] = true, true
end

local tasks = {1}
while 0 < #tasks do
  local src = tasks[#tasks]
  taskstate[src] = false
  table.remove(tasks)
  local f1 = len[src] % 2 == 1
  local f2 = 1 < len[src]
  for dst, _u in pairs(edge[src]) do
    local up = false
    if f1 and len[dst] <= 1 then
      len[dst] = len[dst] + 2
      up = true
    end
    if f2 and len[dst] % 2 == 0 then
      len[dst] = len[dst] + 1
      up = true
    end
    if up and not taskstate[dst] then
      taskstate[dst] = true
      table.insert(tasks, dst)
    end
  end
end
local t1num, t2num = 0, 0
for i = 1, n do
  if len[i] == 1 then
    t1num = t1num + 1
  elseif len[i] == 2 then
    t2num = t2num + 1
  end
end
print(
  math.floor(n * (n - 1) / 2)
  - math.floor(t1num * (t1num - 1) / 2)
  - math.floor(t2num * (t2num - 1) / 2)
  - m
)


Measured memory_bytes: 14832
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

ans = [-1]*N
for i in range(N-1, -1, -1):
    a = As[i]
    idx = i+1
    if idx*2>N:
        ans[i] = a
        continue
    cnt = 2
    per = 0
    while cnt*idx<=N:
        per += ans[cnt*idx-1]
        cnt += 1
    per %= 2
    ans[i] = 1 if per!=a else 0
print(sum(ans))
if sum(ans):
    print(*[i+1 for i, x in enumerate(ans) if x!=0])

Measured memory_bytes: 98052
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] c = S.toCharArray();
        int len = S.length();
        int count = 0;
        // boolean judge = false;

        for (int i = 0; i < len; i++) {
            if (i%2 == 0 && (c[i] == 'R' || c[i] == 'U' || c[i] == 'D')) {
                
            } else if (i%2 == 1 && (c[i] == 'L' || c[i] == 'U' || c[i] == 'D')) {
                
            } else {
                count++;
            }
        }
        if (count == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n, 1);
  vector<bool> b(n + 1);
  i64 i = 1, cnt = 0;
  while (!b[i]) {
    b[i] = true;
    i = a[i];
    ++cnt;
    if (i == 2) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int n, a[100009], b[100009], col[100009]; vector<int>x[100009], y[100009];

void dfs(int pos) {
	if (col[pos] != 0) return;
	col[pos] = 2;
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i]);
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	for (int i = 0; i < n; i++) {
		if (x[i].size() >= 3) col[i] = 1;
	}
	for (int i = 0; i < n; i++) {
		if (col[i] == 0 && x[i].size() == 1) dfs(i);
	}
	for (int i = 0; i < n - 1; i++) {
		if (col[a[i]] <= 1 && col[b[i]] <= 1) {
			y[a[i]].push_back(b[i]);
			y[b[i]].push_back(a[i]);
		}
	}
	int s = 0;
	for (int i = 0; i < n; i++) {
		if (col[i] == 2) continue;
		s += max(0, (int)x[i].size() - (int)y[i].size() - 1);
	}
	if (s == 0) s = 1;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 12416
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0),b=s(1)
    Dim ans=a-b+1
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22352
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void f()
{
	cout<<"UNRESTORABLE\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string x,y;
	cin>>x>>y;

	int a=x.length(),b=y.length();
	if(b>a)
	{
		f();
		return 0;
	}
	int pos=-1;
	for(int i=a-b;i>=0;--i)
	{
		int fo=1;
		for(int j=i;j<=i+b-1;++j)
		{
			if(x[j]!='?'&&x[j]!=y[j-i])
			{
				fo=0;
				break;
			}
		}
		if(fo==1)
		{
			pos=i;
			break;
		}
	}
	if(pos==-1)
	{
		f();
		return 0;
	}
	for(int i=0;i<pos;++i)
	{
		if(x[i]=='?')cout<<'a';
		else cout<<x[i];
	}
	cout<<y;
	for(int i=pos+b;i<a;++i)
	{
		if(x[i]=='?')cout<<'a';
		else cout<<x[i];
	}
	cout<<'\n';
}
















Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    private static final Scanner scn = new Scanner(System.in);
     
    public static void main(String[] args) {
        int n = scn.nextInt();
        String str = scn.next();
        for(int i = 1; i < n; i++) {
            str = new String(scn.next() + " " + str);
        }
        System.out.println(str);
    }
}

Measured memory_bytes: 26276
import std.stdio;
import std.conv;
import std.string;

void main()
{
  int n = to!(int)(chomp(readln()));
  int result;
  double xa, ya, ra, xb, yb, rb;

  for (int i = 0; i < n; i++) {
    readf("%f %f %f %f %f %f\n", &xa, &ya, &ra, &xb, &yb, &rb);
    double dp = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
    double r = (ra + rb) * (ra + rb);
    double dr = (ra - rb) * (ra - rb);

    if (dp > r) {
      result = 0;
    } else if (dp < dr) {
      if (ra > rb) result = 2;
      else result = -2;
    } else {
      result = 1;
    }

    writeln(result);
  }
}

Measured memory_bytes: 1092
import bisect
s = input()
t = input()
lens=len(s)
lent=len(t)
d = {}
s2=s+s
lens2=len(s2)

for i in range(lens2):
    if s2[i] in d:
        d[s2[i]].append(i)
    else:
        d[s2[i]] = [i]

tmp=0
r=0
snum=0
for i in range(lent):
    if(lens<tmp):
        snum+=lens
        tmp-=lens
        
    if d.get(t[i],None)==None:
        print("-1")
        exit()
    else:
        lis=d[t[i]]
        r = bisect.bisect_left(lis,tmp)
        tmp=lis[r]+1
print(snum+tmp)




Measured memory_bytes: 12148
numLength = int(input())
numList = input().split()
count = 0
flag = True
while flag:
  for i in range(numLength):
    numList[i] = int(numList[i])
    if not numList[i] % 2 == 0:
      print(count)
      flag = False
      break
    numList[i] /= 2
  count += 1

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int ans=60*(H2-H1)+M2-M1-K;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int num[101];
vector<int> G[101];
int n,m,K;
int mem[1<<16],used[1<<16];
int dfs(int bit){
  if(bit == 0) return 0;
  if(used[bit]++) return mem[bit];
  int &res = mem[bit] = 1e9;
  for(int k=0;k<K;k++){  
    int nbit = 0;
    for(int i=0;i<n;i++){
      int nx = G[i][k];
      if(num[i]<0||num[nx]<0||!(bit>>num[i]&1))continue;
      nbit |= (1<<num[nx]);
    }
    res = min(res,1+dfs(nbit));
  }
  return res;
}

int main(){

  cin>>n>>m>>K;
  memset(num,-1,sizeof(num));
  for(int i=0,a;i<m;i++)cin>>a,num[a-1]=i;
  
  for(int i=0;i<n;i++){
    G[i].resize(K);
    for(int j=0;j<K;j++)cin>>G[i][j],G[i][j]--;
  }
  cout<<dfs((1<<m)-1)<<endl;
  return 0;
}

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

int main(){
    int N,M;
    cin>>N>>M;
    char num[4];
    for(int i=0;i<4;i++){
        num[i]='s';
    }
    for(int i=1;i<=M;i++){
        int s;
        char c;
        cin>>s>>c;
        if(num[s]=='s'||num[s]==c){
            num[s]=c;
        }else{
            cout<<"-1"<<endl;
            return 0;
        }
    }
    if(N!=1&&num[1]=='0'){
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i=1;i<=N;i++){
        if(num[i]=='s'){
            if(i==1&&N!=1){
                cout<<"1";
            }else{
                cout<<"0";
            }
            continue;
        }
        cout<<num[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
def bellmanford(v,s,path):
    # 距離をinfで初期化
    d = [float('inf')]*v

    # startの頂点までの距離 = 0
    d[s] = 0
    for j in range(v):
        update = False

        # 各頂点までの距離を更新
        # 全辺について、"頂点bまでの距離"が"aまでの距離"+"aからbまでの辺"よりも大きいとき更新
        for a,b,c in path:
            if d[b] > d[a] + c:
                d[b] = d[a] + c
                update = True

        # 更新が行われない場合はやめる。
        if not update:
            break
        # 負の閉路の検出。負の閉路を求めないならいらない。
        # v-1回更新しても、さらに更新できるときは負の閉路が存在することになる。
        elif j == v-1:
            return -1

    return d

n,m,p = map(int,input().split())

path = [[] for i in range(n)]
path_inv = [[] for i in range(n)]

for i in range(m):
    a,b,c = map(int,input().split())
    a-=1
    b-=1
    c-=p
    path[a].append([b,-c])
    path_inv[b].append([a,-c])

a = [0]*n
s = 0
a[0]=1
stack = [s]
while stack:
    p = stack.pop()
    for q,r in path[p]:
        if a[q]==0:
            a[q]=1
            stack.append(q)

b = [0]*n
g = n-1
b[n-1]=1
stack = [g]
while stack:
    p = stack.pop()
    for q,r in path_inv[p]:
        if b[q]==0:
            b[q]=1
            stack.append(q)

c = [i for i in range(n) if a[i]==b[i]==1]

path2 = []
for i in c:
    for to,cost in path[i]:
        path2.append([i,to,cost])

d = bellmanford(n,0,path2)
if d==-1:
    print(-1)
else:
    print(max(0,-d[-1]))

Measured memory_bytes: 53848
import java.util.Scanner;
import java.util.Arrays;

// ALDS1_2_C
public class Main {
	boolean safetyJudge(String[] oldarray, String[] newarray) {
		for (int i = 1; i < newarray.length; i++) {
			if (newarray[i].charAt(1) != newarray[i-1].charAt(1)) continue;
			if (Arrays.asList(oldarray).indexOf(newarray[i]) < Arrays.asList(oldarray).indexOf(newarray[i-1]))
				return false;
		}
		return true;
	}

	String[] bubbleSort(String[] oldarray, int n) {
		String[] newarray = oldarray.clone();
		boolean flag = true;
		String tmp;
		while (flag) {
			flag = false;
			for (int j = n - 1; j > 0; j--) {
				if (newarray[j].charAt(1) - '0' < newarray[j-1].charAt(1) - '0') {
					tmp = newarray[j]; newarray[j] = newarray[j-1]; newarray[j-1] = tmp;
					flag = true;
				}
			}
		}
		return newarray;
	}

	String[] selectionSort(String[] oldarray, int n) {
		String[] newarray = oldarray.clone();
		int minj;
		String tmp;
		for (int i = 0; i < n; i++) {
			minj = i;
			for (int j = i; j < n; j++) {
				if (newarray[j].charAt(1) - '0'< newarray[minj].charAt(1) - '0') minj = j;
			}
			if (minj != i) {
				tmp = newarray[i]; newarray[i] = newarray[minj]; newarray[minj] = tmp;
			}
		}
		return newarray;
	}

	void print(String[] oldarray, String[] newarray) {
		for (int i = 0; i < newarray.length; i++) {
			System.out.print(newarray[i]);
			if (i < newarray.length - 1) System.out.print(" ");
		}
		System.out.println();
		if (safetyJudge(oldarray, newarray))
			System.out.println("Stable");
		else
			System.out.println("Not stable");
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String str = sc.nextLine();
		String[] array = new String[n];
		array = str.split(" ", 0);
		String[] bsortarray = bubbleSort(array, n);
		String[] ssortarray = selectionSort(array, n);
		print(array, bsortarray); print(array, ssortarray);
	}

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


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

int DP[5005][5005] = { 0 };

int main() {
	int N, M;
	cin >> N >> M;
	
	DP[1][N] = 1;
	for (int i = 1; i < N; i++) {
		for (int j = N; j > 0; j--) {
			if (DP[i][j]) {
				for (int k = j; k > 0; k -= min(i, N + 1 - i)) {
					DP[i + 1][k] = (DP[i][j] + DP[i + 1][k]) % M;
				}
			}
		}
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = ((long long)i * DP[N][i] + ans) % M;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 97920
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<int> adj[100000];
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b%2) {ans*=a;b--;}
        b/=2;
        a*=a;
    }
    return(ans);
}
ll closestNumber(ll a, ll b, ll x) {
    if(b<0) return(0);
    ll m=power(a,b),n=(a%x,b);
    return(m-n);
}
int main(){
    int k;
  	cin>>k;
  int sum=0;
  for(int a=1;a<=k;a++)
    for(int b=1;b<=k;b++)
      for(int c=1;c<=k;c++)
        sum+=__gcd(a,__gcd(b,c));
  cout<<sum;
}

Measured memory_bytes: 5980
#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  int maxv = -2000000000;
  int minv;
  cin >> minv;
  for (int i = 1; i < n; i++) {
    int r;
    cin >> r;
    maxv = max(maxv, r - minv);
    minv = min(minv, r);
  }
  cout << maxv << endl;
  return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b,c;
    cin>>a>>b>>c;
    //cout <<fixed<<setprecision(16)<< << endl;

    if(b-a==c-b)cout << "YES" <<endl;
    else cout << "NO" <<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];

        int[] rsp = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var r = rsp[0];
        var s = rsp[1];
        var p = rsp[2];

        var t = Console.ReadLine();

        char[] own = new char[n];
        for (int i = 0; i < n; i++)
        {
            if (t[i] == 'r') own[i] = 'p';
            else if (t[i] == 's') own[i] = 'r';
            else own[i] = 's';
        }

        for (int i = 0; i < n - k; i++)
        {
            if (own[i] == own[i + k])
            {
                own[i + k] = '?';
            }
        }

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (t[i] == 'r' && own[i] == 'p') ans += p;
            else if (t[i] == 's' && own[i] == 'r') ans += r;
            else if (t[i] == 'p' && own[i] == 's') ans += s;
        }

        // 出力
        Console.WriteLine(ans);
    }
}

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

#define MAX 16777215

int Hash[MAX];
char str[13];

int getChar(char);
int getKey();
int find();
void insert();

int main(){
  int n;
  char com[7];

  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,str);

    if(com[0] == 'i'){
      insert();
    }else{
      if(find()){
	puts("yes");
      }else{
	puts("no");
      }
    }
  }

  return 0;
}

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(){
  int sum = 0, p = 1, i;

  for(i = 0 ; i < strlen(str) ; i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(){
  int key = getKey();

  if(Hash[key]){
    return 1;
  }

  return 0;
}

void insert(){
  Hash[getKey()] = 1;
}

Measured memory_bytes: 38624
#include <iostream>
#include <string>

int main() {
  int ans = 0, tmp = 0;
  std::string str;
  std::cin >> str;

  bool flag = false;
  for(int i = 0; i < str.length(); i++) {
    char c = str[i];

    if(c == 'S') tmp = 0;
    else if(++tmp > ans) ans = tmp;
  }

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


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string s, t;

int dp[3000][3000];

int lcs(int i, int j){

    if(i == -1 || j == -1){
        return 0;
    }
    else if(dp[i][j] != -1){
        return dp[i][j];
    }
    else{
        int temp = 0;
        if(s[i] == t[j]){
            temp = lcs(i - 1, j - 1) + 1;
        }
        else{
            temp = max(lcs(i, j - 1), lcs(i - 1, j));
        }
        dp[i][j] = temp;
        return temp;
    }
}

int main(){

    cin >> s;
    cin >> t;

    for(int i = 0; i < (int)s.size(); i++){
        for(int j = 0; j < (int)t.size(); j++){
            dp[i][j] = -1; 
        }
    }

    int len = lcs((int)s.size() - 1, (int)t.size() - 1);

    string ans = "";
    int temp = len;

    int i = (int)s.size() - 1;
    int j = (int)t.size() - 1;

    while(i != 0 && j != 0){

        if(s[i] == t[j]){
            ans = s[i] + ans;
            i--;
            j--;
            temp--;
        }
        else if(dp[i - 1][j] >= dp[i][j - 1]){
            i--;
        }
        else{
            j--;
        }
    }

    if(i == 0 && temp != 0){
        ans = s[0] + ans;
    }
    else if(j == 0 && temp != 0){
        ans = t[0] + ans;
    }

    cout << ans << "\n";

    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  map<int, int> A;
  vi A_cand;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a]++;
    if (A[a] == 2) {
      A_cand.push_back(a);
      A[a] = 0;
    }
  }
  if (A_cand.size() > 1) {
    sort(rall(A_cand));
    cout << (ll)A_cand[0] * A_cand[1] << endl;
  } else {
    cout << 0 << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll N;
    cin >> N;
    ll h[N];
    REP(i, ARRAY_LENGTH(h)) cin >> h[i];

    const ll INF = 1LL << 60;
    ll dp[100010];
    REP(i, 100010) dp[i] = INF;
    
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    FOR(i, 2, N) {
        chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 5064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

    int main(){
      int n,m;
      cin >> n >> m;
      pair<ll,ll> a[n];
      rep(i,n)cin >> a[i].first >> a[i].second;
      sort(a,a+n);
      ll ans=0;
      int cnt=0;
      rep(i,n){
        if(a[i].second+cnt<=m){
         ans+=a[i].first*a[i].second;
          cnt+=a[i].second;
        }
        else{
         ans+=a[i].first*(m-cnt);
          break;
        }
      }
      cout << ans << endl;
      return 0;}

Measured memory_bytes: 1792
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;


int main(){
  int n;
  cin>>n;
  int f=0,t=n-1;
  string bs,as;
  cout<<0<<endl;
  cin>>bs;
  if(bs[0]=='V')return 0;
  int bef=0;
  for(int i=1;i<19;i++){
    int mid=(f+t)/2;
    cout<<mid<<endl;
    cin>>as;
    if(as[0]=='V') return 0;
    else if((max(mid,bef)-min(mid,bef))%2==0){
       if(bs[0]==as[0]){
         f=mid;
         bs[0]=as[0];
         bef=mid;
       }
       else t=mid;
    }
    else{
      if(bs[0]==as[0]){
        t=mid;
      }
      else {
        f=mid;
        bs[0]=as[0];
        bef=mid;
      }
    }

  }
  cout<<t<<endl;
  cin>>as;
  return 0;
}

Measured memory_bytes: 852
def main():
    N = int(input())
    Wl = list(map(int,input().split(" ")))

    ansmin = sum(Wl)
    for i in range(N):
        sum1 = sum(Wl[:i])
        sum2 = sum(Wl[i:])
        condmin = abs(sum1-sum2)
        if(condmin<ansmin):
            ansmin = condmin

    print(ansmin)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

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

	vector<string> vec1(n);
	for (int i = 0; i < n; i++) {
		cin >> vec1.at(i);
	}

	sort(vec1.begin(), vec1.end());
	vector<pair<string, int>> vec2(n);
	int cnt = 1;
	int index = 0;
	int m = -1;
	for (int i = 1; i < n; i++) {
		if (vec1.at(i) == vec1.at(i - 1)) {
			cnt++;

			if (i == n - 1) {
				vec2.at(index).first = vec1.at(i - 1);
				vec2.at(index).second = cnt;
				m = max(m, cnt);
				cnt = 1;
				index++;
			}
		}
		else {
			vec2.at(index).first = vec1.at(i - 1);
			vec2.at(index).second = cnt;
			m = max(m, cnt);
			cnt = 1;
			index++;

			if (i == n - 1) {
				vec2.at(index).first = vec1.at(i);
				vec2.at(index).second = cnt;
				m = max(m, cnt);
				cnt = 1;
				index++;
			}
		}
	}


	for (int i = 0; i < index; i++) {
		if (vec2.at(i).second == m) {
			cout << vec2.at(i).first << endl;
		}
	}
}


Measured memory_bytes: 17408