akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int a, b; cin >> a >> b;
  if(1 <= a && a <= 9 && 1 <= b && b <= 9) cout << a * b << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 892
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();

		System.out.println((a * b % 2 == 1) ? "Odd" : "Even");

		sc.close();
	}

}




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

using namespace std;
typedef unsigned long long ll;


int main() {
    ll k, a, b;
    ll ans = 0;

    cin >> k >> a >> b;

    if (a >= b - 2) {
        ans = 1 + k;
    } else {
        if (k < a + 1) {
            ans = 1 + k;
        } else {
            k -= a + 1;
            ans = b;
            if (k % 2 == 0)
                ans += (b - a) * k / 2;
            else
                ans += (b - a) * (k - 1) / 2 + 1;
        }

    }

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

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

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

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

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;}

int main(){
    int L,R,d;cin >> L>>R>>d;
    int ans = 0;
    int count = L;
    while (count<=R)
    {
        if ((count % d)==0){
            ans++;
        }
        count++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}
map<pair<int,int> , int> memo;
int main() {
	int A,B,C;
	int X;
	int cnt = 0;
	cin >> A >> B >> C >> X;
	rep(i,A+1){
		rep(j,B+1){
			rep(k,C+1){
				if(i*500+j*100+k*50 == X){
					++cnt;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long LL;

int n,p,o,e;
int t;
LL ans1,ans2;
LL c[51][51];

int main()
{
	scanf("%d%d",&n,&p);
	o=e=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&t);
		if (t%2) o++;
		else e++;
	}
	
	ans1=1ll<<e;
	ans2=0ll;
	for(int i=1;i<=o;i++)
	{
		for(int j=0;j<=i;j++)
		    if (j==0 || j==i) c[i][j]=1ll;
		    else c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	
	c[0][0]=1ll;
	if (p)
	{
		for(int j=1;j<=o;j+=2)
		    ans2+=c[o][j];
	}
	else
	{
		for(int j=0;j<=o;j+=2)
		    ans2+=c[o][j];
	}
	
	printf("%lld\n",ans1*ans2);
	return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main{
    //WRWWRWRR     wwwrrrrwwwwrrr
    PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->(a[0]-b[0]));
    boolean[] dp = new boolean[100001];
    public void solve(int testNumber, InputReader in, PrintWriter out) {
       long x = Long.parseLong(in.next());
       long k = Long.parseLong(in.next());
       long d = Long.parseLong(in.next());
       x = Math.abs(x);
       long div = x/d;
       if(x<=d){
           if(k%2==0){
               out.println(x);
           }else{
               out.println(d-x);
           }
           //out.println(-1);
           return;
       }
       if(div>=k){
           out.println(x-k*d);
       }else{
           long rem = x%d;
           if((Math.max(div,k)-Math.min(div,k))%2==1){
               out.println(d-rem);
           }else{
               out.println(rem);
           }
       }
    }

//    Boolean[][] dp = new Boolean[100001][2];
//    boolean dfs(int[] arr,int rem,int w){
//        if(rem<0) return true;
//        if(rem==0) return false;
//        boolean fina = false;
//        if(dp[rem][w]!=null) return dp[rem][w];
//        for(int i=0;i<arr.length;i++){
//            fina|=!dfs(arr,rem-arr[i],1-w);
//        }
//        return dp[rem][w] = fina;
//    }


    public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 33816
import math
a,b,C = map(int,input().split())

S = (1/2) *a*b*math.sin(math.radians(C))
L = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**(1/2)+a+b
h = 2*S/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5712
#include<cstdio>
#include<iostream>
#define INF (1ll<<60)
using std::min;
int l[801000],r[801000];long long v[3][801000],lazy[801000];
int A,B,x[201000];
int Abs(int x){return x>0?x:-x;}
void add(int x,long long k){v[0][x]+=k;v[1][x]+=k;v[2][x]+=k;lazy[x]+=k;}
void pd(int x)
{
	if(lazy[x])add(x<<1,lazy[x]),add(x<<1|1,lazy[x]),lazy[x]=0;
}
void pu(int x)
{
	v[0][x]=min(v[0][x<<1],v[0][x<<1|1]);
	v[1][x]=min(v[1][x<<1],v[1][x<<1|1]);
	v[2][x]=min(v[2][x<<1],v[2][x<<1|1]);
}
void build(int x,int L,int R)
{
	l[x]=L;r[x]=R;
	if(L==R){if(L==B)v[0][x]=0;else v[0][x]=INF;v[1][x]=v[0][x]-L;v[2][x]=v[0][x]+L;return;}
	int mid=L+R>>1;
	build(x<<1,L,mid);build(x<<1|1,mid+1,R);
	pu(x);
}
void modify(int x,int L,int R,long long v)
{
	if(l[x]==L&&r[x]==R){add(x,v);return;}
	pd(x);int mid=l[x]+r[x]>>1;
	if(R<=mid)modify(x<<1,L,R,v);
	else if(L>mid)modify(x<<1|1,L,R,v);
	else modify(x<<1,L,mid,v),modify(x<<1|1,mid+1,R,v);
	pu(x);
}
long long query(int x,int L,int R,int t)
{
	if(l[x]==L&&r[x]==R){return v[t][x];}
	pd(x);int mid=l[x]+r[x]>>1;
	if(R<=mid)return query(x<<1,L,R,t);
	else if(L>mid)return query(x<<1|1,L,R,t);
	else return min(query(x<<1,L,mid,t),query(x<<1|1,mid+1,R,t));
}
int main()
{
	int n,q;scanf("%d%d%d%d",&n,&q,&A,&B);
	build(1,1,n);x[0]=A;
	for(int i=1;i<=q;i++)scanf("%d",&x[i]);
	for(int i=1;i<=q;i++)
	{
		long long Min=min(x[i]+query(1,1,x[i],1),-x[i]+query(1,x[i],n,2));
		modify(1,1,n,Abs(x[i]-x[i-1]));
		long long Min2=query(1,x[i-1],x[i-1],0);
		if(Min2>Min)modify(1,x[i-1],x[i-1],-Min2+Min);
	}
	printf("%lld\n",query(1,1,n,0));return 0;
}
/*
dp[i][y]表示一个在x[i],一个在y的最小花费
dp[i][x[i-1]]=dp[i-1][z]+|x[i]-z|
dp[i][y]=dp[i-1][y]+|x[i]-x[i-1]|
线段树维护dp[i][z]及dp[i][z]-z与dp[i][z]+z，扫第一维时更新
*/ 

Measured memory_bytes: 31232
#include <iostream>
using namespace std;
int main()
{
 int m, f, r;
 for(;;)
 {
  cin >> m >> f >> r;
  if(f == -1 && m == -1 && r == -1) break;
  if(m != -1 && f != -1)
  {
    if (m+f >= 80) cout << "A" << endl;
    else if(65 <= m+f && m+f <80) cout << "B" << endl;
    else if(50 <= m+f && m+f <65) cout << "C" <<endl;
    else if(30 <= m+f && m+f <50)
    {
      if(r >= 50) cout << "C" << endl;
      else cout << "D" << endl;
    }
    else cout << "F" << endl;
  }
  else cout << "F" << endl;
 }
 return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    int n,k;
    cin >> n >> k;
    int g;
    cin >> g;
    int mx = g;
    if(k == g){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    for(int i = 0; i < n-1; i++){
        int a; cin >> a;
        mx = max(mx,a);
        g = __gcd(g,a);
        if(k == a){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if(g == 1 && mx > k) cout << "POSSIBLE" << endl;
    else if(k%g == 0 && mx > k) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <cstdint>
#include <vector>
#include <iostream>

using namespace std;

int32_t main()
{
  while(true){
    uint32_t n;
    cin >> n;
    if(n == 0) break;

    vector<pair<uint32_t, uint32_t>> stones;
    vector<pair<uint32_t, uint32_t>> moved;

    pair<uint32_t, uint32_t> pos = {10, 10};
    moved.push_back(pos);

    for(uint32_t i = 0; i < n; i++){
      uint32_t x, y;
      cin >> x >> y;
      stones.push_back({x, y});
    }
    
    uint32_t commands;
    cin >> commands;
    for(uint32_t i = 0; i < commands; i++){
      char d;
      uint32_t dist;
      cin >> d >> dist;

      for(uint32_t i = 0; i < dist; i++){
        switch(d){
          case 'N':
            pos.second += 1;
            break;
          case 'S':
            pos.second -= 1;
            break;
          case 'W':
            pos.first -= 1;
            break;
          case 'E':
            pos.first += 1;
            break;
        }
        moved.push_back(pos);
      }
    }

    bool all_found = true;
    for(uint32_t i = 0; i < stones.size(); i++){
      bool found = false;
      for(uint32_t j = 0; j < moved.size(); j++){
        if(stones[i] == moved[j]){
          found = true;
        }
      }

      if(!found){
        all_found = false;
      }
    }
        
    if(all_found) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int l=(int)(S.length());
    int count=0,max=0,tmp=0;
    for(int i=0;i<l;i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
            count++;
        }
        else if(max<count){
            max=count;
            count=0;
        }
        if(i==l-1&&max<count){
            max=count;
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <typeinfo>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	s=s+t;
	int a=stoi(s);
	for(int i=0;i<a;i++){
		if(i*i==a){
			cout<<"Yes"<<endl;
			return 0;
        }
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(void) {
  int c[4][4];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  for (int i = 1; i <= 2; i++) {
    int d=c[i][0]-c[0][0];
    if(c[i][1]!=c[0][1]+d || c[i][2]!=c[0][2]+d){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    
    nums = [tuple(map(int,input().split())) for _ in range(n)] 
    nums = sorted(nums, key=lambda x: x[1])
    ans = 'Yes'
    
    _time = 0
    for i in nums:
        _time += i[0]
        if _time > i[1]:
            ans = 'No'
            
    print(ans)
    
if __name__ == '__main__':
    main()

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

int main() {
  int N,A=0;
  cin>>N;
  vector<int> p;
  p.insert(p.begin(),0);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(p.at(0)!=a){
      p.insert(p.begin(),a);
    }
  }
  p.insert(p.begin(),0);
  for(int i=1;i<p.size()-1;i++){
    if(p.at(i-1)<p.at(i)&&p.at(i)>p.at(i+1)){
      A+=p.at(i);
    }
    if(p.at(i-1)>p.at(i)&&p.at(i)<p.at(i+1)){
      A-=p.at(i);
    }
  }
  cout<<A<<endl;
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n * 2 <= m) {
        ans += n;
        m -= n * 2;
        ans += m / 4;
    }
    else {
        ans += m / 2;
        m -= m / 2 * 2;
        n -= m / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3520
#include<cstdio>
#include<map>
using namespace std;
map<long long,int>num;

int main()
{
    int N;
    long long a;
    int ans = 0;
    scanf("%d",&N);
    for(int i = 0;i < N;i ++)
    {
        scanf("%I64d",&a);
        num[a] ++;
        if(num[a] > 1)
        {
            num[a] = 0;
            ans --;
        }
        else ans ++;
    }
    printf("%d\n",ans);
}


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

using namespace std;

const int ms = 1e5 + 17;
int arr[ms], sum[ms];

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

    int n, m, x;
    cin >> n >> m >> x;

    for(int i = 0; i < m; ++i)
    {
        int k;
        cin >> k;

        ++arr[k];
    }


    for(int i = 0; i <= n; ++i)
        sum[i] = sum[i - 1] + arr[i];

    cout << min(sum[x], sum[n] - sum[x]) << '\n';

}


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

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t A,B;
  cin>>A>>B;
  int64_t g=__gcd(A,B);
  auto p=prime_factorize(g);
  cout<<p.size()+1<<endl;
  return 0;
}

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

int main() {
    ll H;
    cin >> H;
    ll ans = 0;
    ll tmp = 1;
    while (H) {
    	H /= 2;
    	ans += tmp;
    	tmp *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

//input sample
//5
//0 3 2 3 3 1 1 2
//1 2 0 2 3 4
//2 3 0 3 3 1 4 1
//3 4 2 1 0 1 1 4 4 3
//4 2 2 1 3 3

//output sample
//shortest cost of each node
//0 0
//1 2
//2 2
//3 1
//4 3
//parent id of each node
//0 - 1
//1 0
//2 3
//3 0
//4 2
static const int MAX = 100001;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
vector<pair<int, int>> adj[MAX];

ll pre[MAX];
ll p[MAX];
ll d[MAX];
ll color[MAX];
priority_queue<pair<int, int>>PQ;
ll n;
void dijkstra(int s) {
	repe(i, 1, n) {
		d[i] = INF;
		pre[i] = INF;
		color[i] = WHITE;
	}

	d[s] = 0;
	p[s] = -1;
	PQ.push(make_pair(s, s)); // ?reverse?
	color[s] = GRAY;

	while (!PQ.empty()) {
		pair<ll, ll> f = PQ.top(); PQ.pop();
		ll u = f.second;

		color[u] = BLACK;

		if (d[u] < f.first * (-1)) continue;

		rep(j, 0, adj[u].size()) {
			ll v = adj[u][j].first;
			if (color[v] == BLACK) continue;
			if (d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1), v));
				p[v] = u;
				color[v] = GRAY;
			}
		}
	}
	//rep(i, 0, n) cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	//rep(i, 0, n) cout << i << " " << (p[i] == INF ? -1 : p[i]) << endl;
}

vector<int> get_path(int t) {
	vector<int> path;
	for (; t != -1; t = p[t])path.push_back(t);
	reverse(path.begin(), path.end());
	return path;
}

int main()
{
	cin >> n;
	rep(i, 0, n - 1) {
		ll a, b, c; cin >> a >> b >> c;
		adj[a].push_back(make_pair(b, c));
		adj[b].push_back(make_pair(a, c));
	}
	ll q, k; cin >> q >> k;

	dijkstra(k);

	rep(i, 0, q) {
		ll x, y; cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}

	//int k, u, v, c;
	//cin >> n;
	//rep(i, 0, n) {
	//	cin >> u >> k;
	//	rep(j, 0, k) {
	//		cin >> v >> c;
	//		adj[u].push_back(make_pair(v, c));
	//	}
	//}
	//dijkstra(0);
	//pass start index;

	return 0;
}

Measured memory_bytes: 11636
#include<bits/stdc++.h>
using namespace std;
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; }


int main(){
  int A,P;
  cin>>A>>P;
  P += 3*A;
  int ans = P/2;
  cout << ans << endl;
  }

Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    if (input == "ABC") "ARC" else "ABC"
  }


  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """1 2 3 1""".stripMargin -> """1
                                   |""".stripMargin,
    """2 3 2 0""".stripMargin -> """-1""".stripMargin,
    """1000000000 1000000000 1000000000 1000000000000000000""".stripMargin -> """0""".stripMargin
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 55148
#include <iostream>
using namespace std;
int main() {
    int N; cin >> N;
    int num_four = 0;
    int num_two = 0;
    int num_odd = 0;
    for (int i=0;i<N;i++){
        int ai; cin >> ai;
        if (ai%4==0) num_four++;
        else if (ai%2==0) num_two++;
        else num_odd++;
    }
    if (num_two>=1) num_odd++;
    if (num_four+1>=num_odd) cout << "Yes" << endl;
    else cout << "No" << endl;   
}
    ///22222414141414141

Measured memory_bytes: 256
n=int(input())
if n%2==1:
    print(0)
else:
    c=0
    i=0
    while True:
        i+=1
        c+=int(n//((5**i)*2))
        #print((5**i)*2,c)
        if int(n//(5**i))==0:
            break
        #i+=1 
    print(c)

Measured memory_bytes: 2940
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<iostream>
#include<string.h>
#include<queue>
#include<set>

using namespace std;


set< string >res;
map< string, vector< string > >mmset;
map< string, bool >visited;

int N;
char buf[20];
int main(){
    string fst = "";
    while(true){
        cin>>N; if(N==0)break;
        res.clear();
        mmset.clear();
        visited.clear();
        for(int i=0;i<N;i++){
            int p = 0; char buf1; while((buf1 = getchar())&&buf1!=':'){
                buf[p++] = buf1;
            }
            string t = string(buf,p);
//             cout << "header: " << t << "!" << endl;
            if(i==0) fst = t;
            char inc; p = 0; while((inc = getchar()) && inc!='\n' && inc!='\r'){
                if(inc == ',' || inc == '.'){
                    string tt = string(buf, p);
                    mmset[t].push_back(tt);
//                     cout<<"found: "<<tt<<endl;
                    p = 0;
                } else {
                    buf[p++] = inc;
                }
            }
        }
        queue< string >workingset;
        workingset.push(fst);
        while(!workingset.empty()){
            string pivot = workingset.front(); workingset.pop();
            if(visited[pivot])continue;
            if(mmset.find(pivot)==mmset.end()){
                res.insert(pivot);
                visited[pivot] = true;
            } else {
                for(auto i = mmset[pivot].begin(); i!=mmset[pivot].end(); i++){
                    workingset.push(*i);
                }
                visited[pivot] = true;
            }
        }
        printf("%d\n",res.size());
    }
    return 0;
}

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

int main(){
    int a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a,a+4);
    if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAX(a,b) (a>b?a:b)
using namespace std;

int main(){
  int N;
  cin >> N;
  int l[N], r[N];
  rep(i, N) cin >> l[i] >> r[i];

  int cnt = 0;
  rep (i,N) cnt+= r[i] - l[i] + 1;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int pl[262144] = {0},c,i,j,n;
	pl[2] = 1;
	for(i = 3;i <= 262143;i+=2){
		pl[i] = 1;
	}
	for(i = 3;i <= 599;i+=2){
		if(pl[i]){
			for(j = 3*i;j <= 262143;j+=(2*i)){
				pl[j] = 0;
			}
		}
	}
	
	while(scanf("%d",&n) , n != 0){
		c = 0;
		for(i = n+1;i <= 2*n;i++){
			c+=pl[i];
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 1632
t = gets.chomp

def remove_if_matched_suffix(s, suffix)
  if s.end_with?(suffix)
    s.delete_suffix!(suffix)
  end
end

while t.length > 0
  next if remove_if_matched_suffix(t, 'dream')
  next if remove_if_matched_suffix(t, 'dreamer')
  next if remove_if_matched_suffix(t, 'erase')
  next if remove_if_matched_suffix(t, 'eraser')
  break
end

if t.length == 0
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 14440
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a=sc.nextInt();
    int b=sc.nextInt();
    int w=n*a;

    int min=Math.min(b,w);
    System.out.println(min);
  }
}


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


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

  while(true){
    
  
  if (a == 5 && b == 5 && c == 7) {
    cout << "YES" << endl;
    break;
  }
  if (a == 5 && b == 7 && c == 5) {
    cout << "YES" << endl;
    break;
  } 
  if (a == 7 && b == 5 && c == 5) {
    cout << "YES" << endl;
    break;
  }
  else {
    cout << "NO" << endl;
    break;
  }
  }
}
  
  
  
  

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	printf("ABC%s\n", readString())
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;
    if(S == U) A--;
    else B--;
    cout << A << endl;
    cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int digit_sum(int x)
{
    int sum = 0;
    while(x >= 10)
    {
        sum += x % 10;
        x /= 10;
    }
    return sum + x;
}

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    
    int total_sum = 0;
    
    for(int i = 1; i <= n; ++i)
    {
        int s = digit_sum(i);
        if(a <= s && s <= b)
        {
            total_sum += i;
        }
    }
    
    cout << total_sum << endl;
   
    return 0;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    order = []
    for a in A:
        order.append(((N + 1 + a) // 2, (N + 1 - a) // 2))

    cnt = {}
    for o in order:
        if o not in cnt:
            cnt[o] = 1
        else:
            cnt[o] += 1

    ans = 1
    MOD = 1000000007
    for k, v in cnt.items():
        if k[0] == k[1] and v > 1:
            ans = 0
            break
        elif v > 2:
            ans = 0
            break
        else:
            ans *= v
            ans %= MOD
    print(ans)


Measured memory_bytes: 64888
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define M 100010
using namespace std;
struct point{
	int to,next,f;
}e[M<<1];
int n,m,num;
ll tot1,tot2,ans;
int head[M],co[M];
ll cnt[5];
bool flag;
bool vis[M];
void add(int from,int to,int f)
{
	e[++num].next=head[from];
	e[num].to=to;
	e[num].f=f;
	head[from]=num;
}
void dfs(int x)
{
	vis[x]=true; tot1++;
	cnt[co[x]]++;
	for(int i=head[x];i;i=e[i].next)
	{
		int to=e[i].to;
		tot2+=e[i].f==1;
		if(!vis[to])
		{
			co[to]=(co[x]+e[i].f+3)%3;
			dfs(to);
		}
		else if(co[to]!=(co[x]+e[i].f+3)%3) flag=true;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		add(x,y,1); add(y,x,-1);
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			flag=false;
			tot1=tot2=0;
			cnt[0]=cnt[1]=cnt[2]=0;
			dfs(i);
			if(flag) ans+=tot1*tot1;
			else if(cnt[0]&&cnt[1]&&cnt[2]) ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0];
			else ans+=tot2;
		}
	}
	printf("%lld",ans);
	return 0;
}

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

int main()
{
  int n; cin >> n;
  int SN[55][30] = {}; // n個の文字列それぞれのa～zを数える
  
  for (int i = 0; i < n; i++)
  {
    string S; cin >> S;
    
    for (int j = 0; j < S.length(); j++)
    {
      int k = S[j] - 'a';
      SN[i][k]++;
    }
  }
  
  string ans = "";
  for (int alpha = 0; alpha < 26; alpha++)
  {
    int len = 0;
    
    for (int i = 0; i < n; i++)
    {
      if (SN[i][alpha] == 0)
      {
        len = 0;
        break;
      }
      else if (SN[i][alpha] != 0 && len == 0)
      {
        len = SN[i][alpha];
      }
      else // SN[i][alpha] != 0 && len != 0
      {
        len = min(len, SN[i][alpha]);
      }
    }
    
    for (int l = 0; l < len; l++)
    {
      ans += 'a' + alpha;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma clang optimize on
#include <stdio.h>

constexpr int MAX_INPUT_SIZE = 2000'000; //'
char Input[MAX_INPUT_SIZE];
char* input = Input;

inline int getint(void){
    int res = 0, c; while((c = *input++ - '0') >= 0) res = 10 * res + c;
    return res;
}

constexpr int MAX_N = 500;
constexpr int shift = 12;
constexpr int mask = (1 << shift) - 1;
int Q[MAX_N * MAX_N];
int dist[MAX_N][MAX_N];
bool vacant[MAX_N][MAX_N];

int main(void){
    fread_unlocked(Input, 1, MAX_INPUT_SIZE, stdin);
    const int n = getint();
    {
        // initial distance
        const int p = n - 1;
        for(int i = 0; i < n; ++i){
            const int d1 = (i > p - i) ? p - i : i;
            for(int j = 0; j < n; ++j){
                const int d2 = (j > p - j) ? p - j : j;
                dist[i][j] = (d1 > d2) ? d2 : d1;
            }
        }
    }
    int res = 0;
    for(int _ = n * n; _--;){
        {
            const int p = getint() - 1;
            const int px = p / n, py = p % n;
            res += dist[px][py];
            vacant[px][py] = true;
            Q[0] = (px << shift) | py;
        }
        int head = 0, tail = 1;
        while(head != tail){
            const int x = Q[head] >> shift, y = Q[head] & mask; ++head;
            const int nd = dist[x][y] + !vacant[x][y];
            if(x - 1 >= 0 and dist[x - 1][y] > nd){ dist[x - 1][y] = nd; Q[tail++] = ((x - 1) << shift)| y; }
            if(y - 1 >= 0 and dist[x][y - 1] > nd){ dist[x][y - 1] = nd; Q[tail++] = (x << shift) | (y - 1); }
            if(y + 1 <  n and dist[x][y + 1] > nd){ dist[x][y + 1] = nd; Q[tail++] = (x << shift) | (y + 1); }
            if(x + 1 <  n and dist[x + 1][y] > nd){ dist[x + 1][y] = nd; Q[tail++] = ((x + 1) << shift) | y; }
        }
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 6692
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int w, h, n, x, y, a;

	cin >> w >> h >> n;

	int x_lower = 0;
	int x_upper = w;
	int y_lower = 0;
	int y_upper = h;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;

		switch (a) {
			case 1: x_lower = max(x_lower, x); break;
			case 2: x_upper = min(x_upper, x); break;
			case 3: y_lower = max(y_lower, y); break;
			case 4: y_upper = min(y_upper, y); break;
			default: break;
		}
		// printf("%d %d, %d %d %d %d\n", x, y, x_lower, x_upper, y_lower, y_upper);
	}

	int ans = 0;
	if (x_upper < x_lower || y_upper < y_lower) {
	} else {
		ans = (x_upper - x_lower) * (y_upper - y_lower);
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;


bool palindrome1 (string s) {
    string ss = s;
    reverse(ss.begin(), ss.end());
    return s == ss;
}


bool palindrome2 (string s) {
    string ss = s.substr(0, (s.size()-1)/2);
    string ss_ = ss;
    reverse(ss_.begin(), ss_.end());
    return ss == ss_;
}


bool palindrome3 (string s) {
    int cursor = (s.size()+3)/2 - 1;
    string ss = s.substr(cursor);
    string ss_ = ss;
    return ss == ss_;
}


int main () {
    string s; cin >> s;

    if (palindrome1(s) and palindrome2(s) and palindrome3(s)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int N,A,B,C;
vector<int> l;
int ans=INF;

void dfs(int a,int aa,int b,int bb,int c,int cc,int d,int i){
  if(i==N){
    if(aa>0&&b>0&&c>0){
      int sum=abs(a-A)+abs(b-B)+abs(c-C)+10*(aa-1)+10*(bb-1)+10*(cc-1);
      if(sum<ans)
        ans=sum;
    }
    return;
  }
  dfs(a+l[i],aa+1,b,bb,c,cc,d,i+1);
  dfs(a,aa,b+l[i],bb+1,c,cc,d,i+1);
  dfs(a,aa,b,bb,c+l[i],cc+1,d,i+1);
  dfs(a,aa,b,bb,c,cc,d+l[i],i+1);
  return;
}

int main(){
  cin >> N >> A >> B >> C;
  l.resize(N);
  rep(i,N){
    cin >> l[i];
  }
  dfs(0,0,0,0,0,0,0,0);
  cout << ans << endl;
  
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
N = int(input())

# create and init dictionary
heads_and_tails = {}
for head in range(1, 10):
    for tail in range(1, 10):
        heads_and_tails[(head, tail)] = 0

# create dictionary contents
for num in range(1, N+1):
    if num%10 == 0:
        continue
    head = int(str(num)[0])
    tail = int(str(num)[-1])
    heads_and_tails[(head, tail)] +=1

# count
count = 0
for head in range(1, 10):
    for tail in range(1, 10):
        count += heads_and_tails[(head, tail)] * heads_and_tails[(tail, head)]

print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=1e6+10;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}

int N,a[maxn],L;

int main(){
    //freopen("","r",stdin);
    N=rd();L=rd();
    int mi=1e9,s=0;
    for(int i=1;i<=N;i++){
    	a[i]=L+i-1;s+=a[i];
    	if(abs(a[i])<abs(mi)) mi=a[i];
    }
    printf("%d\n",s-mi);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <map>
using namespace std;

vector<string> split(const string & str, char sep) {
  istringstream iss(str);
  string tmp;
  vector<string> ret;
  while (getline(iss, tmp, sep)) ret.push_back(tmp);
  return ret;
}

double stack[80];
int top;

void push(double e) {
  stack[top++] = e;
}

double pop(void) {
  return stack[--top];
}

int main(void) {
  string line;
  map<char, int> isop;
  isop['+'] = 1;
  isop['-'] = 1;
  isop['*'] = 1;
  isop['/'] = 1;
  while (getline(cin, line)) {
    vector<string> input = split(line, ' ');
    top = 0;
    for (auto e : input) {
      if (e.size() == 1 && isop[e[0]] == 1) {
        double rhs = pop();
        double lhs = pop();
        switch(e[0]){
          case '+':
            push(lhs + rhs);
            break;
          case '-':
            push(lhs - rhs);
            break;
          case '*':
            push(lhs * rhs);
            break;
          case '/':
            push(lhs / rhs);
            break;
        }
      } else {
        push(stod(e));
      }
    }
    cout << setprecision(6) << fixed << pop() << endl;
  }
  return 0;
}

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

int query(int x) {
	printf("%d\n", x);
	fflush(stdout);
	char buff[15];
	scanf("%s", buff);
	if (buff[0] == 'V')
		exit(0);
	return buff[0] == 'M';
}

int main() {
	int N;
	scanf("%d", &N);
	
	int lo = 0, hi = N;	
	int a = query(lo), b = a;
	while (1) {
		int mid = (lo + hi) / 2;
		int tmp = query(mid);
		if ((a + tmp + mid - lo) % 2) {
			hi = mid;
			b = tmp;
		}
		else {
			lo = mid;
			a = tmp;
		}
	}
	
	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  vector<int> board = {A, B, C};
  sort(board.begin(), board.end());
  for (int i=0; i<K; i++) {
    board.at(2) *= 2;
  }
  int ans = accumulate(board.begin(), board.end(), 0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// 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 main() {
  ll a,b,q; cin >> a >> b >> q;
  a += 2; b += 2;
  ll s[a],t[b];
  s[0] = -pow(10,18);
  t[0] = -pow(10,18);
  FOR(i,1,a-2) cin >> s[i];
  FOR(i,1,b-2) cin >> t[i];
  s[a-1] = pow(10,18);
  t[b-1] = pow(10,18);
  
  FOR(i,0,q-1) {
    ll x; cin >> x;
    ll ans = pow(10,18);

    auto positions = lower_bound(s, s+a, x);
    auto positiont = lower_bound(t, t+b, x);
    int idx_lowers = distance(s, positions);
    int idx_lowert = distance(t, positiont);

    chmin(ans,abs(s[idx_lowers]-x) + abs(t[idx_lowert] - s[idx_lowers]));
    chmin(ans,abs(s[idx_lowers-1]-x) + abs(t[idx_lowert] - s[idx_lowers-1]));
    chmin(ans,abs(s[idx_lowers]-x) + abs(t[idx_lowert-1] - s[idx_lowers]));
    chmin(ans,abs(s[idx_lowers-1]-x) + abs(t[idx_lowert-1] - s[idx_lowers-1]));
    chmin(ans,abs(t[idx_lowert]-x) + abs(t[idx_lowert] - s[idx_lowers]));
    chmin(ans,abs(t[idx_lowert-1]-x) + abs(t[idx_lowert-1] - s[idx_lowers]));
    chmin(ans,abs(t[idx_lowert]-x) + abs(t[idx_lowert] - s[idx_lowers-1]));
    chmin(ans,abs(t[idx_lowert-1]-x) + abs(t[idx_lowert-1] - s[idx_lowers-1]));

    cout << ans << endl;
  }
}

Measured memory_bytes: 2816
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int main() {
    long int n;
    scanf("%ld", &n);

    vector<long int> vec(n);
    vector<long int> bit_vec(60);

    long int one = 1;

    for (long int i=0; i < n; i++) {
        scanf("%ld", &vec[i]);
        for (long int j=0; j < 60; j++) {
            if (one << j & vec[i]) {
                bit_vec[j]++;
            }
        }
    }

    long int div = 1000000007;

    long int ans = 0;


    for (long int i=0; i < 60; i++) {
        ans += (((bit_vec[i] * (n-bit_vec[i])) % div) * ((one << i) % div)) % div;
        ans = ans % div;
    }

    printf("%ld", ans);



}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	cin>>n;
	if(n%2==0){
		cout<<n/2 - 1<<endl;
	}else{
		cout<<(n-1)/2<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
	int x,y,z,res=0;
	for(x=1;x<=n;x++)
	{
		for(y=1;y<=n;y++)
		{
			for(z=1;z<=n;z++)
			{
				if(x*x+y*y+z*z+x*y+y*z+z*x==n)
					res++;
				if(x*x+y*y+z*z+x*y+y*z+z*x>n)
					break;
			}
			if(z==1)
				break;
		}
		if(y==1)
			break;
	}
	return res;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		printf("%d\n",f(i));
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int res[11111];
main(){
  int N;
  res[0]=1;
  res[1]=2;
  int co=2;
  for(int i=2;i<=10000;i++){
    res[i]=res[i-1]+co;
    co++;
  }
  while(~scanf("%d",&N)) printf("%d\n",res[N]);
}

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e16;
const int MB = 20;
const int MOD = 1e9 + 7;


void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(rall(a));
	int ans = 0;
	for (int i = 1; i < n; i++) {
		ans += a[i / 2];
	}
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 4760
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,y = Is()
for i in range(min(n+1,2001)):
    for j in range(min(n-i+1,4001)):
        k = n-i-j
        if k < 0:
            continue
        if y == i*10000 + j*5000 + k*1000 and i + j + k == n:
            print(i,j,k)
            exit()
print(-1,-1,-1)
        

Measured memory_bytes: 3564
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef queue< pair<int, int> > qpii;
typedef vector<int> vi;
typedef vector<int, int> vii;
typedef vector<string> vs;
typedef vector< pair<int, int> > vpii;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

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

  string in;
  cin >> in;

  bool flag = false;
  rep(i,0,in.size()) {
    if (in[i] == 'C') flag = true;
    else if (in[i] == 'F' && flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    string s;
    
    cin >> s;
    

    for(char i = 'a';i <= 'z';i++){
        if(s.find(i) == -1){
            cout << i;
            return 0;
        }
    }
    cout << "None";

}
   

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

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

    if (R < 1200)cout << "ABC" << endl;
    else if(1200<=R&&R<2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    ll a[n],g=0;
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        g=__gcd(g,a[i]);
    }
    cout<<g<<endl;
}

Measured memory_bytes: 1024
S=list(map(int,list(input())))
def manyformulas(s):
    if len(s)==1:
        return s[0]
    return s[0]*2**(len(s)-2)+manyformulas(s[1:])+manyformulas([s[0]*10+s[1]]+s[2:])
print(manyformulas(S))

Measured memory_bytes: 3060
import numpy as np

n = int(input())
x = list(map(int,input().split()))
x2 = np.power(x,2)

p1 = sum(x)//n
p2 = -(-sum(x)//n)

w1 = n*(p1**2) -2*sum(x)*p1 +sum(x2)
w2 = n*(p2**2) -2*sum(x)*p2 +sum(x2)

print(min(w1,w2))

Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        string s,t; cin >> s >> t;
        ll f=0;
        rep(i,sz(t)-1){
            if(t[i]!=s[i]){
                f=1; break;
            }
        }
        if(!f and sz(t)==sz(s)+1){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3652