akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let y = 2019;
    let mut reader = acio::Reader::new();
    let l = reader.read::<u64>();
    let r = reader.read::<u64>();
    if r < l + y {
        let l = l % y;
        let r = r % y;
        let r = if r < l { r + y } else { r };
        let mut min = std::u64::MAX;
        for f in l..r {
            for s in (f + 1)..(r + 1) {
                let c = (f * s) % y;
                if c < min {
                    //println!("{} * {} % {} == {}", f, s, y, c);
                    min = c;
                }
            }
        }
        println!("{}", min);
    } else {
        println!("0");
    }
}

/// Mathematics Module
#[allow(dead_code)]
mod math {
    trait Math {
        fn lcm(v1: Self, v2: Self) -> Self;
        fn gcd(v1: Self, v2: Self) -> Self;
    }

    macro_rules! integer {
        ($t:ty) => {
            impl Math for $t {
                fn lcm(v1: $t, v2: $t) -> $t {
                    v1 * v2 / Self::gcd(v1, v2)
                }

                fn gcd(v1: $t, v2: $t) -> $t {
                    let (mut v1, mut v2) = (v1, v2);
                    while v1 != v2 {
                        if v1 < v2 {
                            v2 -= v1;
                        } else {
                            v1 -= v2;
                        }
                    }
                    v1
                }
            }
        };
    }

    integer!(i8);
    integer!(i16);
    integer!(i32);
    integer!(i64);
    integer!(isize);
    integer!(u8);
    integer!(u16);
    integer!(u32);
    integer!(u64);
    integer!(usize);
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: usize) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            v
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            while self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


Measured memory_bytes: 4352
//Dice
#include <iostream>
#include <string>

using namespace std;

enum Order{
	North,
	East,
	West,
	South,
	Right,
	Left
};

class Dice{
private:
	enum Side{
		Top_ = 0,
		Bottom_,
		Flont_,
		Right_,
		Back_,
		Left_
	};
	int side[6];
public:
	void Init();
	int Move(Order ord);
};

int main(){
	Dice dice;
	int ordNum;
	int total;
	string loader;
	Order ord;

	while (1){
		//初期化
		dice.Init();
		total = 1;
		//代入+計算
		cin >> ordNum;
		if (ordNum == 0)break;
		for (int i = 0; i < ordNum; ++i){
			cin >> loader;
			if (loader == "North")ord = North;
			if (loader == "East")ord = East;
			if (loader == "West")ord = West;
			if (loader == "South")ord = South;
			if (loader == "Right")ord = Right;
			if (loader == "Left")ord = Left;
			total += dice.Move(ord);
		}
		cout << total << endl;
	}
	return 0;
}

void Dice::Init(){
	side[Top_] = 1;
	side[Bottom_] = 6;
	side[Flont_] = 2;
	side[Right_] = 3;
	side[Back_] = 5;
	side[Left_] = 4;
}

int Dice::Move(Order ord){
	int t;
	switch (ord){
	case North:
		t = side[Top_];
		side[Top_] = side[Flont_];
		side[Flont_] = side[Bottom_];
		side[Bottom_] = side[Back_];
		side[Back_] = t;
		break;
	case East:
		t = side[Top_];
		side[Top_] = side[Left_];
		side[Left_] = side[Bottom_];
		side[Bottom_] = side[Right_];
		side[Right_] = t;
		break;
	case West:
		t = side[Top_];
		side[Top_] = side[Right_];
		side[Right_] = side[Bottom_];
		side[Bottom_] = side[Left_];
		side[Left_] = t;
		break;
	case South:
		t = side[Top_];
		side[Top_] = side[Back_];
		side[Back_] = side[Bottom_];
		side[Bottom_] = side[Flont_];
		side[Flont_] = t;
		break;
	case Right:
		t = side[Flont_];
		side[Flont_] = side[Right_];
		side[Right_] = side[Back_];
		side[Back_] = side[Left_];
		side[Left_] = t;
		break;
	case Left:
		t = side[Flont_];
		side[Flont_] = side[Left_];
		side[Left_] = side[Back_];
		side[Back_] = side[Right_];
		side[Right_] = t;
		break;
	default:
		break;
	}
	return side[Top_];
};

Measured memory_bytes: 1208
N = int(input())
f = [0] * (N+1)
for x in range(1, int(N ** 0.5)):
    for y in range(x, int(N ** 0.5)):
        for z in range(y, int(N ** 0.5)):
            num = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if num <= N:
                if x == y and y == z:
                    f[num] += 1
                elif x != y and y != z and z != x:
                    f[num] += 6
                else:
                    f[num] += 3
for i in range(len(f)):
    if i == 0:
        continue
    print(f[i])

Measured memory_bytes: 9532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());

		int[][] ground = new int[3][10];
		int[][] second = new int[3][10];
		int[][] third = new int[3][10];
		int[][] forth = new int[3][10];

		int[][][] all = {ground,second,third,forth};

		for(int l = 0; l<N; l++){
			String[] set = br.readLine().split(" ");
			int b = Integer.parseInt(set[0])-1;
			int f = Integer.parseInt(set[1])-1;
			int r = Integer.parseInt(set[2])-1;
			int v = Integer.parseInt(set[3]);

			all[b][f][r] += v;
		}

		for(int i = 0; i < all.length; i++){
			for(int j = 0; j < all[i].length; j++) {
				for(int k = 0; k < all[i][j].length; k++) {
					System.out.print(" " + all[i][j][k]);
				}
				System.out.print("\n");
			}
			if (i != 3) {
				System.out.print("####################\n");
			}
		}

	}

}

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

int n, m, k;
int a[20], b[20];

int ah[4];
int ans = 0;
int bfs(int times)
{
  int ret = 0;
  if(times < k){
    for(int i = 1; i <= n; i++){
      ah[times] = i;
      ret = max(ret, bfs(times + 1));
    }
  }

  else{
    for(int i = 1; i < k; i++){
      if(ah[0] == ah[i]){
	return 0;
      }
    }
    if(k == 3 && ah[1] == ah[2]){
      return 0;
    }
    int remain = m;
    for(int i = 0; i < k; i++){
      ret += a[ah[i]] * min(remain, b[ah[i]]);
      remain = remain <= b[ah[i]] ? 0 : remain - b[ah[i]];
    }
    ret += remain;
  }
  return ret;
}

signed main()
{
  cin >> n >> m >> k;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  for(int i = 1; i <= n; i++){
    cin >> b[i];
  }

  cout << bfs(0) << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ans=1e5;
  for(int i=0;i<=n;i++){
    int count=0;
    int k=i;
    while(k>0){
      count+=k%6;
      k/=6;
    }
    int l=n-i;
    while(l>0){
      count+=l%9;
      l/=9;
    }
  ans=min(ans,count);
  }
  cout << ans << endl;
}


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

int main()
{
  int n;
  cin>>n;
  
  int hieght[n+1];
  int dp[n+1]={0};
  
  for(int i=1;i<=n;++i)
  {
    cin>>hieght[i];
  }
  ll op2=0,op1=INT_MAX;
  for(int i=2;i<=n;++i)
  {
     ll a,b;
      a=abs(hieght[i]-hieght[i-1])+op2;
      
      b=abs(hieght[i]-hieght[i-2])+op1;
      
      op1=op2;
      op2=min(a,b);
  }
  
  cout<<op2<<endl;
    return 0;
}
             

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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 idx=1;
ll a[505][505];
void f(ll l,ll r,ll d){
    if(r-l<=1)return;
    ll m=(l+r)/2;
    fore(i,l,m-1){
        fore(j,m,r){
            a[i][j]=d;
        }
    }
    f(l,m,d+1);
    f(m,r,d+1);
}
void solve(){
    ll n;cin>>n;
    f(0,n,1);
    rep(i,n-1){
        fore(j,i+1,n-1){
            if(j>i+1)cout<<" ";
            cout<<a[i][j];
        }
        cout<<endl;
    }
}

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


Measured memory_bytes: 2432
#include <stdio.h>

int main() {
	int DEBT = 100000;
	int i, n;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		DEBT *= 1.05;
		DEBT = ((DEBT + 999)/ 1000) * 1000;
	}
	printf("%d\n", DEBT);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  
  cin >> a >> b;
  
  if (a<10 && a>0 && b<10 && b>0){
    cout << a*b << endl;
  }else{
    cout << -1 << endl;
  }
}

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

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
 int a,b,c;
  cin >> a;
  if (a<1200  ){
    cout <<"ABC";
  }else{
	cout <<"ARC";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		for (int i = a; i < Math.min(b+1, a+k) ; i++) {
			System.out.println(i);
		}

		for (int i = Math.max(a + k, b - k + 1); i <= b; i++) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 24020
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int64
	fmt.Scanln(&a, &b, &c, &d)
	//max := int64(math.MinInt64)
	var tmp int64
	tmp = a * c
	if tmp < a*d {
		tmp = a * d
	}
	if tmp < b*c {
		tmp = b * c
	}
	if tmp < b*d {
		tmp = b * d
	}
	fmt.Println(tmp)
}


Measured memory_bytes: 1768
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <map>
using namespace std;
struct result {
  int id;
  int score;
  int rank;
};

bool operator<( const result &r1, const result &r2 ) {
  return r1.score < r2.score;
}

int main() {
  vector<result> results;
  map<int, int> idx_rel;
  while( 1 ) {
    string line;
    cin >> line;
    replace( line.begin(), line.end(), ',', ' ' );

    istringstream iss( line );
    result r;
    iss >> r.id >> r.score;
    if( !r.id && !r.score ) { break; }
    results.push_back( r );
  }
  sort( results.begin(), results.end() );
  int len = results.size();
  int rank = 1;
  for( int i = len - 1; i >= 0; i-- ) {
    if( i < len - 1 && results[ i ] < results[ i + 1 ] ) {
      rank++;
    }
    results[ i ].rank = rank;
    idx_rel[ results[ i ].id ] = i;
  }
  
  int t;
  while( cin >> t ) {
    cout << results[ idx_rel[ t ] ].rank << endl;
  }
  return EXIT_SUCCESS;
}

Measured memory_bytes: 1240
#include <stdio.h>

void bubble(char cards[36][3], int n) {
	int i, j;
	char tmp[2];

	for (i = 0; i < n; i++) {
		for (j = n-1; j > i; j--) {
			if (cards[j][1] < cards[j-1][1]) {
				tmp[0] = cards[j][0];
				tmp[1] = cards[j][1];
				cards[j][0] = cards[j-1][0];
				cards[j][1] = cards[j-1][1];
				cards[j-1][0] = tmp[0];
				cards[j-1][1] = tmp[1];
			}
		}
	}
}


void selection(char cards[36][3], int n) {
	int i, j, mini;
	char tmp[2];

	for (i = 0; i < n; i++) {
		mini = i;
		for (j = i; j < n; j++) {
			if (cards[j][1] < cards[mini][1]) {
				mini = j;
			}
		}
		if (i != mini) {
			tmp[0] = cards[i][0];
			tmp[1] = cards[i][1];
			cards[i][0] = cards[mini][0];
			cards[i][1] = cards[mini][1];
			cards[mini][0] = tmp[0];
			cards[mini][1] = tmp[1];
		}
	}
}


int stable_test(char orders[9][4], char cards[36][3], int n) {
	int i, j, k, now, prev;

	for (i = 0; i < 9; i++) {
		if (!orders[i][0])
			continue;
		now = -1;
		for (j = 0; j < 4; j++) {
			prev = now;
			for (k = 0; k < n; k++) {
				if (cards[k][1]-'1' == i && cards[k][0] == orders[i][j]) {
					now = k;
					break;
				}
			}
			if (prev > now)
				return 0;
		}
	}
	return 1;
}


void print_result(char cards[36][3], int n, int stable) {
	int i;
	const char *fmt = "%s";

	for (i = 0; i < n; i++) {
		printf(fmt, cards[i]);
		fmt = " %s";
	}
	puts(stable ? "\nStable" : "\nNot stable");
}


int main(void) {
	int n, cnum, i, stable;
	char data1[36][3], data2[36][3];
	char orders[9][4] = {{0}};
	int state[9] = {0};

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf(" %s", data1[i]);
		data2[i][0] = data1[i][0];
		data2[i][1] = data1[i][1];
		data2[i][2] = '\0';
		cnum = data1[i][1] - '1';
		orders[cnum][state[cnum]] = data1[i][0];
		state[cnum] += 1;
	}

	bubble(data1, n);
	stable = stable_test(orders, data1, n);
	print_result(data1, n, stable);

	selection(data2, n);
	stable = stable_test(orders, data2, n);
	print_result(data2, n, stable);
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    string s;
    cin >> s;

    int w = 0;
    for(auto c : s){
        if(c == 'o') ++w;
    }
    if(8-w <= 15-s.size()){
        YES();
    }
    else{
        NO();
    }







    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
int main() {
    using namespace std;
    string s;
    cin >> s;

    int ans_0 = 0;  // 0始まり
    int ans_1 = 0;  // 1始まり
    for (size_t i = 0UL; i < s.length(); ++i) {
        if (i % 2UL) {
            if (s.at(i) == '1') {
                ans_1++;
            } else {
                ans_0++;
            }
        } else {
            if (s.at(i) == '1') {
                ans_0++;
            } else {
                ans_1++;
            }
        }
    }

    cout << min(ans_0, ans_1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1000000000;

typedef struct {
  int to, cost;
}edge;

vector<edge> G[4*30*30+1];
int d[4*30*30+1];


void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+4*30*30+1, INF);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}


int main() {
  while (true) {
     int w, h;
  scanf("%d%d", &w, &h);
  if (w == 0 and h == 0) break;
  int s[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  int c[4];
  for (int i = 0; i < 4; i++)
    scanf("%d", &c[i]);



  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  for (int i = 0; i < 4*30*30+1; i++) {
    G[i].clear();
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k < 4; k++) {
	for (int l = 0; l < 4; l++) {
	  int t = (k + l) % 4;
	  int x = j + dx[t], y = i + dy[t];
	  if (0 <= x and x < w and 0 <= y and y < h) {
	    G[4*(w*i+j)+k].push_back(l == s[i][j] ? edge{4*(w*y+x)+t, 0} : edge{4*(w*y+x)+t, c[l]});
	  }
	}
      }
    }
  }
  
    dijkstra(0);
    printf("%d\n", min(d[4*(w*(h-1)+w-1)], d[4*(w*(h-1)+w-1)+1]));
 
  }
}

Measured memory_bytes: 1520
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
	init();
	ll N,M;cin>>N>>M;
	vector<ll>s[M];
	vector<ll>k(M);
	for(int i=0;i<M;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			ll _s;cin>>_s;_s--;
			s[i].push_back(_s);
		}
	}
	vector<ll>p(M);
	for(int i=0;i<M;i++){
		cin>>p[i];
	}
	ll ans=0;
	
	for(int i=0;i<pow(2,N);i++){
		bool isOK=true;
		for(int j=0;j<M;j++){
			ll count=0;
			for(int a=0;a<k[j];a++){
				if(i>>s[j][a]&1)count++;
			}
			if(count%2!=p[j])isOK=false;
		}
		if(isOK){
			ans++;
			//cout<<i<<endl;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# #! /bin/python

# a = int(input())
# b,c = map(int,input().split())
# s = input()

# print('{} {}'.format(a+b+c,s))

# 11 22 といった形で標準入力を数値で受け取る。
a,b = map(int,input().split())
# if (not (1 <= a <= 10000)) or (not (1 <= b <= 10000)):
#     print('over flow argument!')
#     exit()


if 1 <= a <= 10000:
    if 1 <= b <= 10000:
        pass
else:
    exit()


def checkEvenOdd(a,b):
    mult = a * b

    if mult % 2:
        print('Odd')
    else:
        print('Even')

checkEvenOdd(a,b)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int B[60]={0},C[200001];
int t(int x,int y){
    int p=x;
    for(int i=0;p>0;i++){
        if(p%2==1&&C[y]==-1) C[y]=i;
        B[i]+=p%2;
        p=p/2;
    }
}
int main(){
    int n,A[200001],D[60]={0};
    cin>>n;
    rep(i,n) C[i]=-1;
    rep(i,n) cin>>A[i],t(A[i],i);
    rep(i,n) D[C[i]]++;
    int x=0,z=1;
    for(int i=31;i>=0;i--){
        if((x+B[i])%2){
            if(D[i]) x++;
            else z=0;
        }
    }
    if(z) cout<<x;
    else cout<<-1;
}

Measured memory_bytes: 1024
k = int(input())
s = input()
p = 1000000007
x = 0
inv = [0, 1]
fact = [1, 1]
factinv = [1, 1]
for i in range(2, k+len(s)+1):
    inv.append(-inv[p%i]*(p//i)%p)
    fact.append(fact[-1]*i%p)
    factinv.append(factinv[-1]*inv[-1]%p)
def cmb(n, r, p):
    return fact[n]*factinv[r]*factinv[n-r]%p
a = [1]
b = [1]
for _ in range(k):
    a.append(a[-1]*25%p)
    b.append(b[-1]*26%p)
for i in range(k+1):
    x = (x+a[i]*b[k-i]*cmb(i+len(s)-1, i, p))%p
print(x)

Measured memory_bytes: 244076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    vector<vector<pair<int, int>>> G(N);
    for (int i = 0; i < N; i++) {
        int u, k; cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c; cin >> v >> c;
            G[u].push_back(make_pair(v, c));
        }
    }
    vector<int> d(N, MAX);
    vector<bool> checked(N, false);
    priority_queue<pair<int, int>> pq;
    d[0] = 0;
    pq.push(make_pair(0, 0));

    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        int v = p.second;
        
        if (d[v] < p.first * (-1)) continue;
        checked[v] = true;


        for (auto np : G[v]) {
            int nv = np.first;
            if (checked[nv]) continue;

            if (chmin(d[nv], d[v] + np.second)) pq.push(make_pair(d[nv] * (-1), nv));
        }
    }

    for (int v = 0; v < N; v++) {
        cout << v << " " << d[v] << "\n";
    }
    return 0;
}


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

int main() {
  while(1) {
    int n, k, max=-100000000, a[1000000],sum=0,z=0;
    cin >> n >> k;
    if(n==0 && k==0) break;

    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) {
      if(z<k-1) {
	sum+=a[i];
	z++;
      } else {
	sum-=a[i-k];
	sum+=a[i];
	if(max<sum) max=sum;
      }
    }
    cout << max << endl;
  }
  return 0;
}


Measured memory_bytes: 1556
#include<bits/stdc++.h>
using namespace std; 
int main(){
int n; cin>>n;
string s; cin>>s;
for(int i=0;i<s.length();i++){
s[i]=(char)(((s[i]-65)+n)%26+65);
}
cout<<s<<endl; 
return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  string s;
  cin>>s;
  int sum=0;
  int MAX=0;
  for(int i=0;i<N;i++){
    if(s[i]=='I'){sum++;}
    else{sum--;}
    chmax(MAX,sum);
  }
  cout<<MAX<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
class Solver{
public:
  int w,h,ans;
  int gx,gy,sx,sy;
  vector<vector<int>> g;
  bool input(){
    cin >> w >> h;
    if(w + h == 0)return false;
    g = vector<vector<int>>(h,vector<int>(w));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> g[i][j];
        if(g[i][j] == 2){
          sx = j;
          sy = i;
          g[i][j] = 0;
        }else if(g[i][j] == 3){
          gx = j;
          gy = i;
          g[i][j] = 0;
        }
      }
    }
    return true;
  }
  void dfs(int x, int y, vector<vector<int>>& g,int d){
    // cerr << x << " " << y << endl;
    if(x == gx && y == gy){
      ans = min(d,ans);
      return;
    }
    if(d==10)return;
    for(int i=0;i<4;i++){
      for(int t=1;t<20;t++){
        int nx = x + dx[i] * t, ny = y + dy[i] * t;
        if (nx < 0 || ny < 0 || nx >= w || ny >= h){
        //   dfs(nx-dx[i],ny-dy[i],g,d+1);
          break;
        }
        if (nx == gx && gy == ny) {
          ans = min(d+1, ans);
          break;
        }
        if (g[ny][nx] == 1) {
          if (ny-dy[i] == y && nx-dx[i] == x) break;
          g[ny][nx] = 0;
          dfs(nx-dx[i],ny-dy[i],g,d+1);
          g[ny][nx] = 1;
          break;
        }
      }
    }
  }

  void run(){
    ans = 1e9;
    dfs(sx,sy,g,0);
    if(ans == 1e9)
      cout << -1 << endl;
    else
      cout << ans << endl;
  } 
};

int main(void) {

  Solver sl;
  while(sl.input()){
    sl.run();
  }

  return 0;
}

Measured memory_bytes: 3100
use std::collections::*;
use std::io;
use std::io::prelude::*;

fn main() {
    let t_cases = 1usize;
    (0..t_cases).for_each(|_| solve()); // run every test case
}

// solve every test case
fn solve(){
    let mut buf  = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().to_owned().parse::<f64>().unwrap();
    println!("{}",2f64*3.14159265*n);
}

Measured memory_bytes: 2192
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
be = 0
af = -1
for i in range(0, n):
    if x <= y:
        x += a[be]
        be += 1
    else:
        y += a[af]
        af -= 1
print(abs(x - y))

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

using namespace std;

int A, B, C, D, E, F;

int main(int argc, char *argv[]) {
	cin >> A >> B >> C >> D >> E >> F;

	vector<int> water;
	vector<int> sugar;

	for (int i = 0; 100 * A * i < F; i++) {
		for (int j = 0; 100 * A * i + 100 * B * j < F; j++) {
			int w = 100 * A * i + 100 * B * j;
			if (w > 0) water.push_back(w);
		}
	}

	for (int i = 0; C * i < F; i++) {
		for (int j = 0; C * i + D * j < F; j++) {
			int s = C * i + D * j;
			sugar.push_back(s);
		}
	}

	double d_max = -1.0;
	int ans_w = 0, ans_s = 0;
	for (int i = 0; i < water.size(); i++) {
		for (int j = 0; j < sugar.size(); j++) {
			int w = water[i], s = sugar[j];
			double d = 100.0 * s / (w + s);
			if (w * E < 100 * s) continue;
			if (w + s > F) continue;
			if (d_max < d) {
				ans_w = w; ans_s = s;
				d_max = d;
			}
		}
	}

	cout << ans_w + ans_s << " " << ans_s << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
  
using namespace std;
  
int main(void){
  int x[10000];  
  int a=1;
  int i=0;
  
  while(a!=0){
      cin >> a;
      x[i]=a;
      i++;
  }
  
  for(int j=0;j<i-1;j++){
      cout <<"Case "<< j+1 << ": "<<x[j]<<endl;
  }
  
  return 0;
  
}



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

#define eb emplace_back
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long

const int N = 2e6;
const int INF = 1e9;

void solve() {
	int a, b;
	cin >> a >> b;
	cout << a / b + (a % b != 0 ? 1 : 0);
}

int main () {
	cerr << "Ready\n";
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first 
#define Y second 
using namespace std;
typedef pair<double,double> P;
vector<P> ans;
void kohho(P b,P e,int c){
  //cout << b.X << " " << b.Y << " " <<e.X<<" "<<e.Y<<endl;
  if(!c)return;
  P s,u,t;
  s.X=(-b.X+e.X)/3.0+b.X;
  s.Y=(-b.Y+e.Y)/3.0+b.Y;
  t.X=s.X+s.X-b.X;
  t.Y=s.Y+s.Y-b.Y;
  u.X=t.X-s.X;
  u.Y=t.Y-s.Y;
  double st = u.X;
  u.X = u.X*cos(60.0*M_PI/180.0)-u.Y*sin(60.0*M_PI/180.0);
  u.Y = st*sin(60.0*M_PI/180.0)+u.Y*cos(60.0*M_PI/180.0);
  u.X+=s.X;
  u.Y+=s.Y;
  
  kohho(b,s,c-1);
  cout << s.X << " " << s.Y << endl;
  kohho(s,u,c-1);
  cout << u.X << " " << u.Y << endl;
  kohho(u,t,c-1);
  cout << t.X << " " << t.Y << endl;
  kohho(t,e,c-1);
  ans.push_back(s);
  ans.push_back(t);
  ans.push_back(u);
}
  
int main(){
  int n;
  cin >> n;

  P st,en;
  st.X=0;
  st.Y=0;
  en.X=100.0;
  en.Y=0;
  ans.push_back(st);
  ans.push_back(en);
  cout << st.X <<" "<< st.Y << endl;
  kohho(st,en,n);
  sort(ans.begin(),ans.end());
  // for(int i=0;i<ans.size();i++){
  // printf("%.10f %.10f\n",ans[i].X,ans[i].Y);
  //}
  cout << en.X << " " << en.Y << endl;
  return 0;
}
 

Measured memory_bytes: 3352
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    string s, t;    cin >> s >> t;
    int ans = 99999;
    for (int i = 0; i < s.length(); i++) {
        if (t.length() + i > s.length())
            break;
        int tmp = 0;
        for (int j = 0; j < t.length(); j++) {
            if (s[i+j] != t[j])
                tmp++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
# AtCoder Beginner Contest 047 B - すぬけ君の塗り絵 2 イージー / Snuke's Coloring 2 (ABC Edit)
import numpy as np

w, h, n = map(int, input().split())
rectangle = np.zeros((w, h))

for i in range(n):
    xi, yi, a = map(int, input().split())
    if a == 1: #x <= xi
        rectangle[:xi, :] = 1
    elif a == 2: # x >= xi
        rectangle[xi:, :] = 1
    elif a == 3: #y <= yi 
        rectangle[:, :yi] = 1
    else: # y >= yi 
        rectangle[:, yi:] = 1
print(int(w*h - np.sum(rectangle)))


Measured memory_bytes: 21540
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
 
using namespace std;
 
int main() {
  fast_io;

  ll k,n;
  cin >> k >> n;
  ll a[n];
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<ll> v;
  ll sum =0;

  for (ll i = 1; i < n; i++) {
    v.push_back(a[i] - a[i - 1]);
    sum += a[i] - a[i - 1];
  }

  v.push_back(a[0] + k - a[n - 1]);
  sum += a[0] + k - a[n - 1];
  sort(v.begin(),v.end());
  cout << sum - v[n - 1];
 
  return 0;
}

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
	ll s=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) s=s*10+ch-'0',ch=getchar();
	return s;
}
int n;
int main(){
	cin>>n;
	cout<<(n-1)/2;
	return 0;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let a = read_one::<String>().chars().collect::<Vec<char>>();
    let b = read_one::<String>().chars().collect::<Vec<char>>();

    let mut flg = "EQUAL";
    if a.len() > b.len() { flg = "GREATER"; }
    else if b.len() > a.len() { flg = "LESS"; }
    else {
        for i in 0..a.len() {
            if a[i] > b[i] { flg = "GREATER"; break; }
            else if a[i] < b[i] { flg = "LESS"; break; }
        }
    }
    println!("{}", flg);
}



#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  ll y;
  for(ll i = 1; i <= min(n,(ll)1e7); i ++ ){
    ans = max(ans, (a*i)/b - a*(i/b));
    y = min(n,(b/i));
    ans = max(ans, (a*y)/b - a*(y/b));
    y = min(n,(a/i));
    ans = max(ans, (a*y)/b - a*(y/b));
    y = max(n-i,1ll);
    ans = max(ans, (a*y)/b - a*(y/b));
    y = min(max(b-i,1ll),n);
    ans = max(ans, (a*y)/b - a*(y/b));
  }
  y = n;
  ans = max(ans, (a*y)/b - a*(y/b));
  cout << ans << "\n";
  return 0;
}

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

int main(){
	int n;
	cin>>n;
	int arr[n];
	int count=0;
	int min=n+1;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		if(arr[i]<min){
			min=arr[i];
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
const int INF = 2e9 + 1;
int x[4] = {-1, 0, 1, 0};
int y[4] = {0, 1, 0, -1};
int dp[1010][1010];
void Main(){
    int h, w;
    cin >> h >> w;
    h += 2;
    w += 2;
    int sh, sw, gh, gw;
    cin >> sh >> sw >> gh >> gw;
    vector<string> s(h);
    string str = "";
    For(i,0,w) str += '#';
    s[0] = str;
    s[h-1] = str;
    For(i,1,h-1){
        cin >> s[i];
        s[i] = '#' + s[i] + '#';
    }
    For(i,0,h) For(j,0,w) dp[i][j] = INF;
    dp[sh][sw] = 0;
    priority_queue<pair<int,pair<int,int>>, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int>>>> que;
    que.push({0, {sh, sw}});
    while(!que.empty()){
        pair<int,int> now;
        int dist;
        tie(dist,now) = que.top();
        que.pop();
        if(now.first == gh && now.second == gw) break;
        bool flag = false;
        For(i,0,4){
            if(s[now.first + x[i]][now.second + y[i]] == '#'){
                flag = true;
                continue;
            }
            if(dp[now.first + x[i]][now.second + y[i]] > dist){
                dp[now.first + x[i]][now.second + y[i]] = dist;
                que.push({dist, {now.first + x[i], now.second + y[i]}});
            }
        }
        if(flag){
            For(i, -2, 3){
                if(clamp(now.first + i, 0, h-1) != now.first + i) continue;
                For(j, -2, 3){
                    if(clamp(now.second + j, 0, w-1) != now.second + j) continue;
                    if(s[now.first + i][now.second + j] == '#') continue;
                    if(dp[now.first + i][now.second + j] > dist + 1){
                        dp[now.first + i][now.second + j] = dist + 1;
                        que.push({dist + 1, {now.first + i, now.second + j}});
                    }               
                }
            }
        }
    }
    /*For(i,0,h){
        For(j,0,w){
            cout << dp[i][j] << " \n"[j==w-1];
        }
    }*/
    if(dp[gh][gw] == INF) cout << -1 << endl;
    else cout << dp[gh][gw] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main() {
    int A, B;
    string S;
    cin >> A >> B >> S;
    for (int i = 0; i < S.size(); i++) {
        if (i == A) {
            if (S[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if ('0' > S[i] || S[i] > '9') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

const ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        ll n, sum = 0, ans = 0;
        cin >> n;
        vl v(n), V(n, 0);
        flu(i, 0, n)
        {
            cin >> v[i];
            sum += v[i];
            sum = sum % MOD;
        }
        V[n - 1] = 0;
        blu(i, n - 2, 0)
            V[i] = (v[i + 1] + V[i + 1]) % MOD;
        flu(i, 0, n)
            V[i] = ((v[i] % MOD) * (V[i] % MOD)) % MOD;
        ll c = 0;
        flu(i, 0, n)
            c = (c + V[i] % MOD) % MOD;
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<string> vec={"abc","acb","bac","bca","cba","cab"};
  string flag = "No";
  for(string i:vec){
    if (s == i) flag = "Yes";
  }
  cout << flag << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
 
namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split(' ');
            var a = long.Parse(tmp[0]);
            var b = long.Parse(tmp[1]);
 
            var xor = XorRange(a, b);
            Console.WriteLine(xor);
            //var nomal = XorOld(a, b);
            //Console.WriteLine(nomal);
 
            //Console.WriteLine(Convert.ToString(xor, 2));
            //Console.WriteLine(Convert.ToString(nomal, 2));
        }
 
        /// <summary>普通に解く</summary>
        static long XorOld(long a, long b)
        {
            var ret = 0L;
            for (var i = a; i <= b; i++)
            {
                ret ^= i;
            }
            return ret;
        }
 
        static long XorRange(long a, long b)
        {
            var ret = 0L;
            var aPlus = a + (16 - (a % 4));            
            var nowA = a;
            while (nowA < aPlus)
            {
                ret ^= nowA;
                nowA++;
            }
            var bMinus = b - (b % 4);
            var nowB = bMinus;
            while(nowB <= b)
            {
                ret ^= nowB;
                nowB++;
            }
 
            return ret;
        } 
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    bool flag = false;
    rep(i,0,SZ(s)){
        rep(j,i+1,SZ(s)){
            if(s[i] == 'C' && s[j] == 'F') flag = true;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;    
#define int long long        
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar) for(int pen=0;pen<sizeof(ar)/8;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rt return 0;
#define mod 1000000007
const int N= 8*1e5+ 10;
int st[N]={0};
void update(int ss, int se, int i, int diff, int si)  
{  
    // Base Case: If the input index lies outside the range of  
    // this segment  
    if (i < ss || i > se)  
        return;  
  
    // If the input index is in range of this node, then update  
    // the value of the node and its children  
    st[si] = st[si] + diff;  
    if (se != ss)  
    {  
        int mid = (ss+se)/2;  
        update(ss, mid, i, diff, 2*si);  
        update(mid+1, se, i, diff, 2*si + 1);  
    }  
}  
int get_sum(int ss, int se, int qs, int qe, int si)  
{  
    // If segment of this node is a part of given range, then return  
    // the sum of the segment  
    if (qs <= ss && qe >= se)  
        return st[si];  
  
    // If segment of this node is outside the given range  
    if (se < qs || ss > qe)  
        return 0;  
  
    // If a part of this segment overlaps with the given range  
    int mid = (ss+se)/2;
    return get_sum(ss, mid, qs, qe, 2*si) +  
        get_sum(mid+1, se, qs, qe, 2*si+1);  
} 
signed main()
{
    int n;
    cin>>n;
    int ar[n];
    sc(ar,n);
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vl divisor(ll k){
	vl c;
	for(ll i=1; i*i<=k; i++){
		if(k % i == 0){
			c.push_back(i);
			if((k / i) != i){
				c.push_back(k/i);
			}
		}
	}
	sort(c.rbegin(), c.rend());
	return c;
}

int main(){
	ll n,k; cin >> n >> k;
	vl a(n); rep(i,n) cin >> a[i];
	ll sum = 0;
	rep(i,n) sum += a[i];
	vl div = divisor(sum);
	for(auto v : div){
		vl up, down;
		rep(i,n){
			if(a[i] % v == 0) continue;
			down.push_back(a[i] % v);
		}
		if(down.empty()){
			cout << v << endl;
			return 0;
		}
		sort(all(down));
		ll siz = down.size();
		vl acc(siz+1,0);
		for(ll i=siz-1; i>=0; i--){
			acc[i] = acc[i+1] + v - down[i];
		}
		ll cnt = 0;
		rep(i,siz-1){
			if(cnt == acc[i]) break;
			cnt += down[i];
		}
		if(min(cnt,v*siz-cnt) <= k){
			cout << v << endl;
			return 0;
		}
	}
}


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

using ll = unsigned long long;
using namespace std;

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


    if ( b + c > a ) {
        cout << c - (a - b) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  lint l, r; cin >> l >> r, ++r;
  V<lint> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  int n0 = n >> 1, n1 = n - n0;
  V<lint> s0(1 << n0);
  for (int bit = 0; bit < 1 << n0; ++bit) for (int i = 0; i < n0; ++i) if (bit & 1 << i) s0[bit] += a[i];
  V< pair<int, lint> > s1(1 << n1);
  for (int bit = 0; bit < 1 << n1; ++bit) {
    s1[bit].first = __builtin_popcount(bit);
    for (int i = 0; i < n1; ++i) if (bit & 1 << i) s1[bit].second += a[i + n0];
  }
  sort(begin(s1), end(s1));
  lint res = 0;
  for (int bit = 0; bit < 1 << n0; ++bit) {
    int m = __builtin_popcount(bit);
    res += distance(lower_bound(begin(s1), end(s1), make_pair(k - m, l - s0[bit])), lower_bound(begin(s1), end(s1), make_pair(k - m, r - s0[bit])));
  }
  cout << res << '\n';
}


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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()


typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}


int main()
{
	int a, b;
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;
	return 0;
}


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

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    int index_not0 = N;
    bool flag = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    ll ans = 0;
    vector<ll> sum(N);
    ll t1 = 0, t2 = 0;
    for(int i = 0; i < N; i++){
        if(i == 0) sum[i] = A[i];
        else sum[i] = sum[i-1] + A[i];

        if(i % 2 == 0 && sum[i] < 1){
            t1 += 1 - sum[i];
            sum[i] = 1;
        }else if(i % 2 == 1 && sum[i] > -1){
            t1 += sum[i] + 1;
            sum[i] = -1;
        }
    }

    for(int i = 0; i < N; i++){
        if(i == 0) sum[i] = A[i];
        else sum[i] = sum[i-1] + A[i];

        if(i % 2 == 1 && sum[i] < 1){
            t2 += 1 - sum[i];
            sum[i] = 1;
        }else if(i % 2 == 0 && sum[i] > -1){
            t2 += sum[i] + 1;
            sum[i] = -1;
        }
    }
    //cout << t1 << " " << t2 << endl;
    ans = min(t1, t2);

    cout << ans << endl;
}

Measured memory_bytes: 1792