akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

struct Dice{
  
  int t,s,e,w,n,b;
  
  Dice(int n1,int n2,int n3,int n4,int n5,int n6){
    t=n1;//top
    s=n2;//south
    e=n3;//east
    w=n4;//west
    n=n5;//north
    b=n6;//bottom
  }
  
  void roll(char direction){
    if(direction=='S'){
	 int tmp=s;
	 s=t,t=n,n=b,b=tmp;
    }
    if(direction=='N'){
	 int tmp=n;
	 n=t,t=s,s=b,b=tmp;
    }
    if(direction=='E'){
	 int tmp=e;
	 e=t,t=w,w=b,b=tmp;
    }
    if(direction=='W'){
	 int tmp=w;
	 w=t,t=e,e=b,b=tmp;
    }
  }

  int get(char direction){
    if(direction=='T')return t;
    if(direction=='S')return s;
    if(direction=='E')return e;
    if(direction=='W')return w;
    if(direction=='N')return n;
    if(direction=='B')return b;
  }

  bool match(Dice d){
    if(t!=d.get('T'))return false;
    if(s!=d.get('S'))return false;
    if(e!=d.get('E'))return false;
    if(w!=d.get('W'))return false;
    if(n!=d.get('N'))return false;
    if(b!=d.get('B'))return false;
    return true;
  }

  bool equal(Dice d){
    for(int i=0;i<8;i++){
	 if(i==4)d.roll('E');
	 for(int j=0;j<4;j++){
	   if(this->match(d))return true;
	   d.roll('E');
	 }
	 d.roll('S');
    }
    return false;
  }
};

signed main(){
  int n;
  cin>>n;
  vector<Dice> dices;
  for(int i=0;i<n;i++){
    int n1,n2,n3,n4,n5,n6;
    cin>>n1>>n2>>n3>>n4>>n5>>n6;
    Dice dice(n1,n2,n3,n4,n5,n6);
    dices.pb(dice);
  }
  int f=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
	 if(dices[i].equal(dices[j]))f=1;
    }
  }
  if(f)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    ll N,K;
    cin >> N >> K;
    ll ret = 0;
    ll cnt1 = 0;
    ll cnt2 = 0;
    vector<pair<ll,ll>> vec(N + 1);
    for(int i = 0;i < N;i++) {
        cnt1 += i;
        cnt2 += (N - i);
        cnt1 %= MOD;
        cnt2 %= MOD;
        vec.at(i) = make_pair(cnt1,cnt2);
    }
    for(int i = K - 1;i <= N;i++) {
        ret += mod(vec.at(i).second - vec.at(i).first + 1);
        ret %= MOD;
    }
    cout << ret << endl;
}

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

int main() {
  int i, N;
  cin >> N;
  int a = 0;
  
  for (i = 0; i < N; i++) {
    string color;
    cin >> color;
    if (color == "Y")
      a++;
  }
  if (a)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
#include <vector>
//#include <string>
typedef long long LL;
using namespace std;

int main(){
    LL n;
    LL k;
    LL tmp_a;
    LL ans=1000000000;
    LL tmp_ans;
    vector<LL> a;
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    for(int i=0; i<=n-k; i++){
        if(a[i]<0 && a[i+k-1]>=0){
            if(abs(a[i+k-1])<abs(a[i])){
                tmp_ans=2*a[i+k-1]-a[i];
            }else{
                tmp_ans=a[i+k-1]-2*a[i];
            }
        }else if(a[i]<0 && a[i+k-1]<0){
            tmp_ans=-a[i];
        }else{
            tmp_ans=a[i+k-1];
        }
        //cout << tmp_ans << endl;
        if(ans>tmp_ans){
            ans=tmp_ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int cnt(char tmp[6][6],int h,int w){
    int num=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(tmp[i][j]=='#') ++num;
        }
    }
    return num;
}

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    char c[6][6];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
        }
    }
    int ans=0;
    for(int bith=0;bith<(1<<h);bith++){
        for(int bitw=0;bitw<(1<<w);bitw++){
            char tmp[6][6];
            for(int a=0;a<h;a++){
                for(int b=0;b<w;b++) tmp[a][b]=c[a][b];
            }

            for(int i=0;i<=6;i++){
                if(bith&(1<<i)){
                    for(int j=0;j<w;j++) tmp[i][j]='r';
                }
                if(bitw&(1<<i)){
                    for(int k=0;k<h;k++) tmp[k][i]='r';
                }
            }
            if(cnt(tmp,h,w)==k) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3516
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(s: chars);
    for _ in 0..s.len() {
        puts!("x");
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>

int main(void)
{
    int x, a, b;
    std::cin >> x >> a >> b;
    int left = a - b;
    if (left >= 0)
    {
        std::cout << "delicious";
    }
    else if (left >= -x)
    {
        std::cout << "safe";
    }
    else
    {
        std::cout << "dangerous";
    }
    std::cout << std::endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  vector<int> v(100100,0);
  REP(i,n){
    int x;cin >> x;
    v[x]++;
  }
  vector<int> a;
  ll res = 0;
  for(int i = 1;i <= 100000;i++){
    if(v[i] & 1)res++;
    else if(v[i])a.push_back(i);
  }
  (int)a.size() & 1 ? res += max(0,(int)a.size()-1) : res += a.size();
  cout << res << endl;





  return 0;
}

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

int n, m, k, parent[100004], rank1[100004], size[100004];
vector<int> friendship[100004], block[100004];

void init(){
	for(int i = 0; i <= n; i++)
		parent[i] = i, rank1[i] = 0, size[i] = 1;
}

int find(int a){
	if(parent[a] == a)	return a;
	return parent[a] = find(parent[a]);
}

void uni(int a, int b){
	a = find(a), b = find(b);
	if(a == b)	return;
	if(rank1[a] < rank1[b]){
		size[b] += size[a];
		parent[a] = b;
	}
	else{
		size[a] += size[b];
		parent[b] = a;
	}
	if(rank1[a] == rank1[b])	rank1[a]++;
}

int main() {
	cin>>n>>m>>k;
	int a, b;
	init();
	for(int i = 0; i < m; i++){
		cin>>a>>b;
		friendship[a].push_back(b);
		friendship[b].push_back(a);
		uni(a, b);
	}
	for(int i = 0; i < k; i++){
		cin>>a>>b;
		block[a].push_back(b);
		block[b].push_back(a);
	}
	for(int i = 1; i <= n; i++){
		int ret = size[find(i)];
		for(int j : block[i]){
			if(find(i) == find(j))	ret--;
		}
		for(int j : friendship[i]){
			if(find(i) == find(j))	ret--;
		}
		cout<<ret-1<<' ';
	}
	return 0;
}

Measured memory_bytes: 13048
#include <iostream>

using namespace std;

int main() {
    int N, C;
    cin >> N >> C;
    N += 1;
    int sum_cake = 0;
    for(int i = 0; i < C; i++) {
        int p;
        cin >> p;
        sum_cake += p;
    }
    if(sum_cake % N == 0) {
        cout << sum_cake / N << endl;
    } else {
        cout << (sum_cake / N) + 1 << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll ans = 0;
    ll x, zz = 100;
    cin >> x;
    while(zz<x){
        zz += (zz/100);
        ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

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

fn main() {
    let n: usize = read();
    let mut ans = "No";
    'outer: for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                ans = "Yes";
                break 'outer;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;

int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,ans,mn,mx,sum=0;
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    cin>>n;
    cout<<!n<<endl;


}


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

int main(){
  int N;
  std::cin >> N;
  double temp = 0;
  for (int i = 0; i < N; i++){
    double a;
    std::cin >> a;
    temp += 1/a;
  }
  std::cout << 1/temp << std::endl;
}

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

int main()
{
	int N;
	while( cin >> N ){
		vector< int > A( N, 0 );
		bool ans = true;
		for( int i = 0; i < N; ++i ){
			int a;
			cin >> a;
			A[ a ]++;
			if( A[ a ] > 2 ) ans = false;
			if( N % 2 == 0 ){
				if( a % 2 == 0 ) ans = false;
			}else{
				if( a % 2 == 1 ) ans = false;
				if( a == 0 && A[ a ] > 1 ) ans = false;
			}
		}
		int r = 1;
		if( ans ){
			for( int i = 0 ; i < N / 2; ++i ){
				r *= 2;
				r %= 1000000007;
			}
		}else{
			r = 0;
		}
		cout << r << endl;
	}

	return 0;
}

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

using namespace std;

const int SIZE = 100005;

bool notPrime[SIZE];

typedef pair<int,int> pii;


int dp[1000006][100];

const int MOD = 1e9+7;

int c(int n, int k){
	if(dp[n][k]!=0)
		return dp[n][k];
	if(k==0 or k==n){
		dp[n][k]=1;
		return 1;
	}
	if(k==1){
		dp[n][k]=n;
		return n;
	}
	dp[n][k] = c(n-1,k) + c(n-1,k-1);
	dp[n][k]%=MOD;
	return dp[n][k];
}

void init(){
	notPrime[1] = true;
	notPrime[0] = true;
	for(int i=2;i<SIZE;i++){
		for(int j=i+i;j<SIZE;j+=i){
			notPrime[j] = true;
		}
	}
}

int main(){
	init();
	int n,m;
	cin >> n >> m;
	vector<pii> primeFactors;
	for(int i=1;i*i<=m;i++){
		if(m%i==0){
			if(!notPrime[i]){
				int cnt=0;
				while(m%i==0){
					m/=i;
					cnt++;
				}
				primeFactors.push_back(pii(i,cnt));
			}
		}
	}
	if(m!=1)
		primeFactors.push_back(pii(m,1));
	long long ans=1;
	for(int i=0;i<primeFactors.size();i++){
		ans*=c(primeFactors[i].second+n-1,primeFactors[i].second);
		ans%=MOD;
	}
	cout << ans;
	
}

Measured memory_bytes: 45952
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int n;
	vector<int>a;
	cin >> n;
	int big = 0, sml = n;
	map<int, int>dict;
	for (int i = 0; i < n; ++i)
	{
		int aa; cin >> aa; a.push_back(aa);
		big = max(big, aa);
		sml = min(sml, aa);
		dict[aa]++;
	}
	if (big - sml > 1)
	{
		cout << "No" << endl;
		return 0;
	}
	int S = dict[big - 1], T = dict[big];
	if (T == 1)
	{
		cout << "No" << endl;
		return 0;
	}
	int K = T / 2;
	if (S + 1 <= big && big <= S + K)
	{
		cout << "Yes" << endl;
		return 0;
	}
	if (big == sml && big == n - 1)
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 5368
import java.util.Scanner

case class Output(v: Int) {
  def print() {
    println(v)
  }
}

case class Input(a: Int, b: Int, c: Int) {
  private def enough(d: Int): Boolean = a * d + (d / 7) * b >= c
  private def binsearch {

  }
  def solve(): Output = {
    var lb = 0
    var ub = 1000000
    while (ub-lb > 1) {
      val m = (lb+ub)/2
      if (enough(m)) ub = m
      else lb = m
    }
    Output(ub)
  }
}

object Input {
  def read(): Input = {
    val scanner = new Scanner(System.in)
    Input(scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
  }
}

object Main extends App {
  Input.read().solve().print()
}



Measured memory_bytes: 45136
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int[] y = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int ans = N;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				int p = x[i] - x[j];
				int q = y[i] - y[j];
				int cnt = 0;
				for(int k = 0; k < N; k++) {
					for(int l = 0; l < N; l++) {
						if(k == l)
							continue;
						if(x[k]-x[l] == p && y[k]-y[l] == q)
							cnt++;
					}
				}
				ans = Math.min(ans, N-cnt);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 2e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
char a[N][N];
int dp[N][N];
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			cin >> a[i][j];
		}
	}
	dp[0][1] = 1;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			(dp[i][j] = (a[i][j-1]!='#')*dp[i][j-1] + (a[i-1][j]!='#')*dp[i-1][j]) %= MOD;
		}	
	}
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 12544
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    double a=sc.nextInt();
    double b=sc.nextInt();
    double x=sc.nextInt();
    double S=x/a;

      if(S<=a*b/2){
        double m=2*S/b;
        Math.atan(b/m);
        System.out.println(Math.toDegrees(Math.atan(b/m)));
      }else{
        double N=a*b-S;
        double o=2*N/a;
        System.out.println(Math.toDegrees(Math.atan(o/a)));
      }
    }
  }


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int A, B;

signed main() {
    cin >> A >> B;
    if (A < 6)cout << 0 << endl;
    else if (A <= 12)cout << B / 2 << endl;
    else cout << B << endl;
}

Measured memory_bytes: 384
N=int(input())
A = list(map(int,input().split()))
ok1 = False
ok2 = False

ans = 1
for i in range(N):
    if A[i] == 0:
        ok1 = True
for i in range(N):
    ans *= A[i]
    if ans > 1000000000000000000:
        ok2 = True
        break

if ok1:
    print(0)
elif ok2:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

int main() {
    char a[3][3];
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[3005][3005]; // left, len
long long arr[3005];
int main(){
  int n;cin>>n;
  long long sum = 0;
  for(int i=0;i<n;++i){
    cin>>arr[i];
    dp[i][1] = arr[i];
    dp[i][0] = 0;
    sum += arr[i];
  }
  for(int i=0;i+2<=n;++i){
    dp[i][2] = max(dp[i][1],dp[i+1][1]);
  }
  
  for(int len=3;len<=n;++len){
    for(int l=0;l+len<=n;++l){
      dp[l][len] = max(
        			arr[l] + min(dp[l+1][len-2],dp[l+2][len-2]),
        			arr[l+len-1] + min(dp[l+1][len-2],dp[l][len-2])
      				); 
    }
  }
  /*
  for(int i=0;i<=n;++i){
    for(int j=0;j+i<=n;++j){
    	cout<<dp[i][j]<<" ";  
    }
    cout<<endl;
  }
  
  cout<<endl;
  */
  cout<<2 * dp[0][n] - sum<<endl;
  return 0;
}

Measured memory_bytes: 70016
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=400+19;

struct node{
	int s[4];
	bool operator < (const node &B) const{
		For(i,0,4) if (s[i]!=B.s[i]) return s[i]<B.s[i];
		return 0;
	}
	void gao(){
		int tmp=s[0];
		For(i,0,3) s[i]=s[i+1];
		s[3]=tmp;
	}
	ll num(){
		ll res=0;
		For(i,0,4) res=res*1000+s[i];
		return res;
	}
} A[N];

map<ll,int> M;
int n;
ll B[4],res;

void dfs(int x,ll tmp){
	if (x==4){
		res+=tmp;
		return;
	}
	For(i,0,4){
		if (M[B[x]]){
			dfs(x+1,tmp*(M[B[x]]--));
			M[B[x]]++;
		}
		B[x]=(B[x]/1000)+(B[x]%1000)*ll(1e9);
	}
}

int main(){
	n=IN();
	For(i,1,n+1){
		For(j,0,4) A[i].s[j]=IN();
		M[A[i].num()]++;
	}
	For(i,1,n+1) For(j,i+1,n+1){
		M[A[i].num()]--;
		M[A[j].num()]--;
		For(w,0,4){
			B[0]=((node){A[i].s[0],A[i].s[3],A[j].s[2],A[j].s[1]}).num();
			B[1]=((node){A[i].s[3],A[i].s[2],A[j].s[3],A[j].s[2]}).num();
			B[2]=((node){A[i].s[2],A[i].s[1],A[j].s[0],A[j].s[3]}).num();
			B[3]=((node){A[i].s[1],A[i].s[0],A[j].s[1],A[j].s[0]}).num();
			dfs(0,1);
			A[j].gao();
		}
		M[A[j].num()]++;
		M[A[i].num()]++;
	}
	printf("%lld\n",res/3);
}

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

using namespace std;

struct treap
{
    int num;
    int val;
};

stack<int> st1;
stack<treap> st2;

char s[20005];

int main()
{
    cin >> s;
    int sum = 0;
    int s1 = 0;
    for (int i = 0; s[i] != '\0'; i++)
    {
        if (s[i] == '\\')
            st1.push(i);
        else if (s[i] == '/' && st1.size() > 0)
        {
            treap tmp;
            tmp.num = st1.top();
            tmp.val = i - st1.top();
            sum += s1 = tmp.val;

            //st2.push(tmp);
            while (st2.size() > 0 && st2.top().num > st1.top())
            {
                s1 += st2.top().val;
                st2.pop();
            }
            tmp.val = s1;
            st2.push(tmp);
            st1.pop();
        }
    }

    cout << sum << endl;
    cout << st2.size();
    stack<int> ans;
    while (!st2.empty())
    {
        ans.push(st2.top().val);
        st2.pop();
    }
    while (!ans.empty())
    {
        cout <<  " " <<ans.top();
        ans.pop();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3244
#include<stdio.h>

#define MAXA 100000
#define MAXT 50000
#define NOT_FOUND 0 

int n,q;
int A[MAXA],T[MAXT];

int i,j;
int C=0;

int binarySearch(){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid = (left+right)/2;

    if(A[mid]==T[j])return 1;
    else if(T[j] < A[mid])right=mid;
    else left=mid+1;
  }
  return NOT_FOUND;
}

int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  scanf("%d",&q);

  for(j=0;j<q;j++){
    
    scanf("%d",&T[j]);
	
    C+=binarySearch();
  }


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

  return 0;
}



Measured memory_bytes: 2284
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
h = LI()
ans = 0
for i in range(n):
    for j in range(i):
        if h[i] < h[j]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 38256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int x;
    cin >> x;
    if (x < 30) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 1e5 + 5, K = 11;

int dp[N][K];
int v[N], c[N], d[N];
vector<int> g[N];

void dfs(int u, int dist, int it) {
	if (dp[u][dist] != -1) return;
	dp[u][dist] = it;
	for (int &v : g[u]) {
		if (dist > 0) {
			dfs(v, dist - 1, it);
		}
	}
}
				
int32_t main() {
	fast_cin();  
	int n, m; cin >> n >> m;
	for (int i = 0, u, v; i < m; ++i) {
		cin >> u >> v;
		g[u].push_back(v), g[v].push_back(u);
	}
	int q; cin >> q;
	for (int i = 0; i < q; ++i) {
		cin >> v[i] >> d[i] >> c[i];
	}
	memset(dp, -1, sizeof dp);
	for (int i = q - 1; i >= 0; --i) {
		dfs(v[i], d[i], i);
	}
	for (int v = 1; v <= n; ++v) {
		int ans = -1;
		for (int dist = 0; dist < K; ++dist) {
			ans = max(ans, dp[v][dist]);
		}
		cout << (ans == -1 ? 0 : c[ans]) << endl;
	}
	return 0;
}

Measured memory_bytes: 20408
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int P, Q, R;

int main(){
  cin >> P >> Q >> R;

  cout << P + Q + R - max(max(P, Q), R) << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = (int)1e9 + 7;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e7;
	
	
	void doIt() {
		int N = sc.nextInt();
		System.out.println((1000-(N%1000)) % 1000);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
 
}

Measured memory_bytes: 35688
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:[(usize,usize);a]
    }
    let mut c=0;
    let mut d=0;
    for i in 0..a {
        if b[i].0>c{
            c=b[i].0;
            d=b[i].0+b[i].1
        }
    }
    println!("{}",d)
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 1e5+5;

int N, M;
vector<int> al[MX_N];
bool used[MX_N];

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> M;
    FOR(i,0,M-1){
        int A, B; cin >> A >> B;
        al[A].push_back(B);
        al[B].push_back(A);
    }

    deque<int> dq;
    dq.push_front(1); used[1] = 1;
    dq.push_back(al[1][0]); used[al[1][0]] = 1;
    while (true) {
        bool done = true;
        for (int v : al[dq.front()]) if (!used[v]) {
            dq.push_front(v);
            used[v] = true;
            done = false;
            break;
        }
        if (done) break;
    }
    while (true) {
        bool done = true;
        for (int v : al[dq.back()]) if (!used[v]) {
            dq.push_back(v);
            used[v] = true;
            done = false;
            break;
        }
        if (done) break;
    }

    cout << SZ(dq) << '\n';
    for (auto x : dq) cout << x << ' ';
}



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

typedef long long ll;

int cal(ll x)
{
    int res = 0;
    while(x){
        res++;
        x/=10;
    }
    return res;
}

int main()
{
    ll n;
    scanf("%lld",&n);
    int ans = 20;
    for(int i=1;1LL*i*i<=n;i++){
        if(n%i==0) ans = min(ans,cal(n/i));
    }
    printf("%d\n",ans);
    
}


Measured memory_bytes: 256
x=int(input())
m=0
for i in range(500):
  for k in range(500):
    w=i**5
    e=k**5
    r=k**5*-1
    if w-e==x:
      print(i,end=" ")
      print(k)
      m+=1
      break
    elif w-r==x:
      print(i,end=" ")
      print(k*-1)
      m+=1
      break
  if m==1:
    break

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int A; int B; int C; int D;
  cin>>A>>B>>C>>D;
 if(B<C||A>D)
   cout<<0<<endl;
  else{
    cout<<min(D,B)-max(A,C)<<endl;
  }
}


Measured memory_bytes: 3588
from collections import Counter
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
q = int(input())
am = sum(a)
a = Counter(a).most_common()
defs = defaultdict(int)
for i in range(len(a)):
    defs[a[i][0]] = a[i][1]

for i in range(q):
    b,c = map(int,input().split())
    ans = am - defs[b]*b + defs[b]*c
    defs[c] += defs[b]
    defs[b] = 0
    print(ans)
    am = ans


Measured memory_bytes: 26952
/* Èå äÇã Çæ */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 100 * 1000 + 5;
int n;
vector<int> adj[MAX_N];

void read_input() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}	
}

int dfs(int v, int pr = -1) {
	int res = 1, cnt = 0;
	for (int u: adj[v])
		if (u != pr) {
			int sz = dfs(u, v);
			res += sz;
			cnt += sz & 1;
		}
	if (cnt > 1 || n & 1) {
		cout << "First" << endl;
		exit(0);
	}
	return res;
}

void solve() {
	dfs(0);
	cout << "Second" << endl;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
}

Measured memory_bytes: 5888
function Main(input) {
  input = input.split(" ");
  const D = parseInt(input[0], 10);
  const T = parseInt(input[1], 10);
  const S = parseInt(input[2], 10);

  var time = ( D / S <= T ) ?  'Yes' : 'No';
  console.log(time);
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29668
import java.util.*

fun main() {
    val (n, m) = readIntList()
    val graph = Array(n + 1) { mutableListOf<Int>() }
    for (i in 0 until m) {
        val (a, b) = readIntList()
        graph[a].add(b)
        graph[b].add(a)
    }
    val memo = Array(n + 1) { -1 }.apply { this[1] = 0 }

    val queue = ArrayDeque<Int>()
    queue.addLast(1)
    while (queue.isNotEmpty()) {
        val room = queue.first()
        queue.removeFirst()
        graph[room].forEach {
            if (memo[it] == -1) {
                memo[it] = room
                queue.addLast(it)
            }
        }
    }

    println("Yes")
    for (i in 2..n) {
        println(memo[i])
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

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

bool solve() {
  int H, W; cin >> H >> W;
  int g1 = H & W & 1;
  int g2 = H % 2 * W / 2 + W % 2 * H / 2;
  vector<int> cnt(26);
  for (int i = 0; i < H*W; i++) {
    char c; cin >> c;
    ++cnt[c-'a'];
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < 26; i++) {
    c1 += cnt[i] & 1;
    c2 += cnt[i] >> 1 & 1;
  }
  return c1 <= g1 && c2 <= g2;
}

int main() {
  if (solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main() {
  //input
  int A,B;
  cin >> A >> B;
  
  //main
  int count = 0;
  while( B > (1+(A-1)*count) ){count++;}
  
  
  //output
  cout << count << endl;
}


Measured memory_bytes: 256
from collections import deque
sin = [i for i in input()]
tin = [i for i in input()]
s = deque(sin)
s_origin = deque(sin)
t = deque(tin)
s.rotate(1)
while s!=s_origin:
    if s == t or s_origin == t:
        print("Yes")
        break
    s.rotate(1)
else:
    if s_origin == t:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    string t;
    cin >> t;
    
    for (int i = 0;i < t.size();i++){
        if (t[i] == '?'){
            t[i] = 'D';
        }
    }
    cout << t << endl;
}


Measured memory_bytes: 3756
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	int n, x, a[101], i, j, tmp, ans = 0;
	scanf("%d%d", &n, &x);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				tmp = a[i];a[i] = a[j];a[j] = tmp;
			}
		}
	}
	for (i = 0; i < n; i++) {
		if (i < n - 1) {
			if (a[i] <= x) {
				x -= a[i];
				ans++;
			}
			else {
				break;
			}
		}
		else {
			if (a[i] == x) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, A;
    cin >> N >> A;
    vector<int> cards(N);
    int maxX = -1*(1<<30);
    for(int i=0; i<N; ++i){
        cin >> cards[i];
        maxX = max(maxX, cards[i]);
        cards[i] -= A;
    }
    const int M = N * maxX;
    vector<vector<long long> > DP(N+1, vector<long long>(2*M+1, 0));
    DP[0][M] = 1;
    for(int i=1; i<=N; ++i){
        for(int j=0; j<2*M+1; ++j){
            DP[i][j] += DP[i-1][j];
            if(j-cards[i-1]>=0 and j-cards[i-1]<=2*M){
                DP[i][j] += DP[i-1][j-cards[i-1]];
            }
        }
    }
    cout << DP[N][M] -1 << endl;
    return 0;
}

Measured memory_bytes: 2304
import std.stdio;
import std.string;
import std.array; // split
import std.conv; // to

void main()
{
   string n = chomp(readln());
   string m = chomp(readln());
   if(n[0] == m[2] && n[1] == m[1] && n[2] == m[0]){
       writeln("YES");
   } else {
       writeln("NO");
   }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,n,u,k,v;
int main()
{
    cin>>N;
    int A[N][N];
    for(int p=0;p<N;p++)
        for(int q=0;q<N;q++)
            A[p][q]=0;
    for(n=0;n<N;n++)
    {
        cin>>u>>k;
        for(int i=0;i<k;i++)
        {
            cin>>v;
            A[u-1][v-1]=1;
        }
    }
    for(int p=0;p<N;p++)
    {
        for(int q=0;q<N-1;q++)
        {
            cout<<A[p][q]<<' ';
        }
        cout<<A[p][N-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


ll a[MAXN];
ll pref_x[MAXN];
ll pref_s[MAXN];
ll ans;

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
	#endif
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    	pref_s[i] = pref_s[i - 1] + a[i];
    	pref_x[i] = pref_x[i - 1] ^ a[i];
    }
    int l = 1;
    for (int r = 1; r <= n; r++) {
    	for(;(pref_s[r] - pref_s[l - 1]) != (pref_x[r] ^ pref_x[l - 1]);l++) {
    	}
    	ans += (r - l + 1);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    for (auto &x : h) cin >> x;
    sort(h.begin(), h.end());
    ll ans = LLONG_MAX;
    for (int i = 0; i + K - 1 < N; ++i) {
        ans = min(ans, h.at(i + K - 1) - h.at(i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
A = list(map(int, input().split()))
A.sort()
ans = 0
ans += A[2] - A[1]
if (A[2] - A[0] - ans) % 2:
    ans += (A[2] - A[0] - ans) // 2 + 2
else:
    ans += (A[2] - A[0] - ans) // 2
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    k-=(n-2)*(n-1)/2;
    if(k>0)
        cout<<-1;
    else{
        cout<<-k+n-1<<endl;
        k=-k+n-1;
        for(int i=1;i<n&&k;++i){
            for(int j=i+1;j<=n&&k;++j){
                cout<<i<<" "<<j<<endl;
                k--;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll A, B;
    cin >> A >> B;
    if (A+B>=10){
    cout  << "error";
    }else {
        cout << A+B;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,s,s2,sum;
    scanf("%d",&n);
    int a[n],b[n],c[n];
    for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    }
    s=0;
    for(i=0;i<n;i++){
    scanf("%d",&b[i]);
    s=s+b[i];
    }
    for(i=0;i<n-1;i++){
    scanf("%d",&c[i]);
    }
    s2=0;
    for(i=1;i<n;i++){
    if(a[i]-a[i-1]==1){
        s2=s2+c[a[i-1]-1];
    }
    }
    sum=s+s2;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int lli;
#define MAX 2000005
#define endl "\n"
lli l[MAX];
lli r[MAX];
lli check(lli a){
	lli ctr = 0;
	for(lli i = 1;; i++){
		if(a - i < 0)
			return ctr;
		else{
			a = a-i;
			ctr++;
		}
	}
	return ctr;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n;
	cin>>n;
	for(lli i = 0; i<n; i++){
		cin>>l[i]>>r[i];
	}
	sort(l,l+n);
	sort(r,r+n);
	if(n%2){
		cout<<r[n/2]-l[n/2]+1<<endl;
	}
	else{
		lli lef = (l[n/2] + l[n/2-1])/2 +(l[n/2] + l[n/2-1])%2 ;
		lli rig = (r[n/2] + r[n/2-1])/2;
		lli ans = 0;
		ans += 2*(rig-lef) + 1;
		ans += (l[n/2] + l[n/2-1])%2;
		ans += (r[n/2] + r[n/2-1])%2;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 6776
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    ll q;
    ll x;
    cin>>n;
    double ans=0.0;
    ans=2.00*3.14159*n;
    cout<<ans<<endl;
    ///printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; (i) < ((int)(n)); ++(i))
const ll INF = 10e10;
const ll MOD = 1000000007;

int main() {
    ll ans = 0;
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    B[N - 1] = 0;
    rep(i, N - 1) {
        B[N - 2 - i] = (B[N - 1 - i] + A[N - 1 - i]) % MOD;
        // cout << B[N - 2 - i] << endl;
    }
    rep(i, N) {
        // cout << A[i] << " " << B[i] << endl;
        ans = (ans + (A[i] * B[i]) % MOD) % MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i < n+1; i++)

int N, x[100010], y[100010], t[100010];

int main(void)
{
    int d;
    cin >> N;
    t[0] = x[0] = y[0] = 0;
    REP1(i, N) { 
        cin >> t[i] >> x[i] >> y[i] ;
    }
    REP1(i, N) {
        d = abs(x[i-1]-x[i])+abs(y[i-1]-y[i]);
        if((t[i]-t[i-1]) < d || (t[i]%2!=(x[i]+y[i])%2)) {
            cout <<"No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
k,n = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

d = 0
for i in range(0,len(A)-1):
    diff = A[i+1]-A[i]
    if diff > d:
        d = diff
diff = k-A[-1]+A[0]
if diff > d:
    d = diff
    
print(k-d)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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() {
  int N; cin >> N;
  vector<int> W(N); REP(i, N) cin >> W[i];

  int ans = pow(10, 6) + 7;
  int sum_n = accumulate(all(W), 0LL);

  REP(i, N) {
    int sum_b = 0;
    for(int k = i + 1; k < N; ++k) {
      sum_b += W[k];
    }
    int sum_a = sum_n - sum_b;
    int tmp = abs(sum_a - sum_b);
    if(tmp < ans) ans = tmp;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if ((n % i == 0)):
            if(i>1):
                divisors.append(i)
            if i != n // i:
                if(n//i>1):
                    divisors.append(n//i)
    return divisors

def test(n,ans_list):
    ans_list.append(n)
    ans_list = ans_list + make_divisors(n-1)
    
    for ans in make_divisors(n):
        nn = n
        while(nn%ans == 0):
            nn = nn/ans
        nn = nn%ans
        if(nn == 1):
            ans_list.append(ans)
    return ans_list

n = int(input())

ans_list = []

answer = list(set(test(n,ans_list)))
#answer.sort()

print(len(answer))

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a;
  string s;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red");
}
#endif


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

int main(){

int X, Y, Z, K;
cin >> X >> Y >> Z >> K;

vector<long long>A(X);
     for(int i = 0; i < X; i++){ 
           cin >> A.at(i);
     }



vector<long long>B(Y);
     for(int i = 0; i < Y; i++){ 
           cin >> B.at(i);
     }

vector<long long>C(Z);
     for(int i = 0; i < Z; i++){ 
           cin >> C.at(i);
     }





vector<long long>AB_sum;
     for(int i = 0; i < X; i++){ 
           for(int j = 0; j < Y; j++){ 
                AB_sum.push_back(A.at(i) + B.at(j));
                 }
           }

sort(AB_sum.begin(),AB_sum.end());
reverse(AB_sum.begin(),AB_sum.end());


vector<long long> ans;

     for(int i = 0; i < min(K, (int)AB_sum.size()); i++){ 
          for(int j = 0; j < Z; j++){ 
                ans.push_back(AB_sum.at(i) + C.at(j));
          }    
     }

sort(ans.begin(),ans.end());
reverse(ans.begin(),ans.end());

     for(int i = 0; i < K; i++){ 
           cout << ans.at(i) << endl;
     }
}
          

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

using namespace std;

void solve()
{
	int m, n;
	while(cin >> m >> n)
	{
		if(!m && !n)
		{
			break;
		}
		priority_queue<int, vector<int> > PQue;
		for(int i = 0; i < m; ++i)
		{
			int price;
			cin >> price;
			PQue.push(price);
		}
		int sum = 0;
		while(true)
		{
			for(int i = 0; i < n - 1; ++i)
			{
				if(PQue.empty())
				{
					break;
				}
				sum += PQue.top();
				PQue.pop();
			}
			if(PQue.empty())
			{
				break;
			}
			PQue.pop();
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 0