akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAX (int)1e9 + 99
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}


void solve()
{
    int n;
    cin>>n;
    vi a(n+1,0);
    srep(i,1,n) cin>>a[i];
    vi ans(n+1,0);
    ans[2] = abs(a[2]-a[1]);
    srep(i,3,n)
    ans[i] = min(ans[i-1]+abs(a[i]-a[i-1]),ans[i-2]+abs(a[i]-a[i-2]));
    cout<<ans[n];
}

int main()
{
    fastio
    /*int t;
    cin>>t;
    
    rep(i,t)
    {*/
        solve();
        cout<<"\n";
    //}
    return 0;
}

Measured memory_bytes: 1152
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <cassert>

using namespace std;

using int64 = long long;
using ld = long double;
/////////////////////
// Code starts here//
/////////////////////
const ld PI = 3.14159265359;

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

    int A, B, H, M;

    cin >> A >> B >> H >> M;

    ld b = 1.0 * M / 60.0;
    ld a = 1.0 * H / 12.0 + b / 12.0; 

    a *= 2 * PI;
    b *= 2 * PI;

    pair<ld, ld> hours = {A * cos(a), A * sin(a)};
    pair<ld, ld> minutes = {B * cos(b), B * sin(b)};

    cout << fixed << setprecision(10) << hypot(hours.first - minutes.first, hours.second - minutes.second) << "\n";

    return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
    #define ll long long
    #define ull unsigned long long
    #define rep(X,N) for(ll X = 0; X < (N); X++)
    #define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
    #define PI (acos(-1.0))
    #define sorta(V) sort(V.begin(), V.end())
    #define pback push_back
    #define mpair make_pair
    #define MODN 1000000007
    #define ALL(V) (V).begin(),(V).end() 


    using namespace std;


    int main(){

        string s;
        cin >> s;

        int ans = 700;

        rep(i,3){
            if(s[i] == 'o') ans = ans + 100;
        }

        cout << ans << endl;

        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define all(a) a.begin(),a.end()
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; }
using namespace std;

#define no cout<<"No\n"; return 0
#define yes cout<<"Yes\n"; return 0

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;
    map<int,int> mp;
    rep(i,n){
        int a; cin>>a;
        mp[a]++;
    }

    if(mp.size()>3){no;}
    if(mp.size()==3){
        int x=0;
        for(auto p:mp){
            x^=p.first;
            if(p.second*3!=n){no;}
        }
        if(x==0){yes;}
        else{no;}
    }
    if(mp.size()==2){
        if(mp[0]*3==n){yes;}
        else{no;}
    }
    if(mp.size()==1){
        if(mp[0]==n){yes;}
        else{no;}
    }

}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const ll mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> broken(n);
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = true;
  }
  vector<ll> a(n + 1);
  a[0] = 1;
  if(!broken[1]) a[1] = 1;
  rep(i, n - 1) {
    if(!broken[i + 2]) {
      if(!broken[i]) a[i + 2] = (a[i] + a[i + 2]) % mod;
      if(!broken[i + 1])
        a[i + 2] = (a[i + 1] + a[i + 2]) % mod;
    }
  }
  cout << a[n] << endl;
  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    string S;
    cin >> S;

    int f = stoi(S.substr(0, 2));
    int s = stoi(S.substr(2, 2));

    if (f >= 1 && f <= 12 && s >= 1 && s <= 12) {
        cout << "AMBIGUOUS" << endl;
    } else { 
        if (f == 0 || f > 12) {
            //  f は月ではない
            if (s == 0 || s > 12) {
                cout << "NA" << endl;
            } else {
                cout << "YYMM" << endl;
            }
        } else {
            //  f は月である
            if (s >= 1 && s <= 12) {
                cout << "AMBIGUOUS" << endl;
            } else {
                cout << "MMYY" << endl;
            }
        }
    }

    return 0;
}


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

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

use std::cmp::min;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut x: Vec<i64> = vec![];
    let mut ans = 0;

    for _ in 0..n {
        let xi: usize = read();
        ans += min(k - xi, xi);
    }
    println!("{}", ans * 2);
}


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

int main()
{
	int n, k, m = 0, a = 0, b = 0;
	string s;
	bool f = 0;

	cin >> n >> k >> s;

	for (int i = 0; i < n; i++) {
		if (i < n - 1 && s[i] == 'R' && s[i + 1] == 'R')
			m++;
		else if (i > 0 && s[i] == 'L' && s[i - 1] == 'L')
			m++;
		else
			a++;
	}

	if (a >= k * 2 + 2)
		m += k * 2;
	else
		m += a - 1;

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int n,k,a[N];
int main(){
	n=gi();k=gi();
	for(int i=1;i<=n;i++)a[i]=gi();
	sort(a+1,a+n+1,greater<int>());ll ans=0;
	for(int i=k+1;i<=n;i++)ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
from sys import stdin
input = stdin.readline

N = int(input())
list_result = [input() for i in range(N)]

AC_cnt = 0
WA_cnt = 0
TLE_cnt = 0
RE_cnt = 0


for i in list_result:
    if i == "AC\n":
        AC_cnt += 1

    elif i == "WA\n":
        WA_cnt += 1
    elif i == "TLE\n":
        TLE_cnt += 1

    elif i == "RE\n":
        RE_cnt += 1

print("AC x",AC_cnt ,"\n" "WA x",WA_cnt,"\n" "TLE x",TLE_cnt,"\n" "RE x",RE_cnt )




Measured memory_bytes: 16356
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=311,mod=998244353;
int n,a[N],f[N][N*N],g[N][N*N],all,sum,res;

inline void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    all=1;
    rep (i,1,n) cin>>a[i],all=all*3ll%mod;
    f[0][0]=1;
    rep (i,1,n){
        rep (j,0,sum) if (f[i-1][j]){
            upd(f[i][j],f[i-1][j]*2ll%mod);
            upd(f[i][j+a[i]],f[i-1][j]);
        }
        sum+=a[i];
    }
    rep (i,(sum+1)>>1,sum) upd(res,f[n][i]);
    if (!(sum&1)){
        sum=0;
        g[0][0]=1;
        rep (i,1,n){
            rep (j,0,sum) if (g[i-1][j]){
                upd(g[i][j],g[i-1][j]);
                upd(g[i][j+a[i]],g[i-1][j]);
            }
            sum+=a[i];
        }
        upd(res,mod-g[n][sum/2]);
    }
    upd(all,(mod-res)*3ll%mod);
    cout<<all;
    return 0;//
}

Measured memory_bytes: 227584
N,M = map(int,(input().split()))
X = list(map(int,input().split()))

if N >= M:
        print("0")
else :
        Y = [0] * (M-1)
        X.sort()
        for i in range(M-1):
                Y[i] = X[i+1] - X[i]
        Y.sort()
        print(sum(Y[:(M-N)]))



Measured memory_bytes: 13968
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A[100001];
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	sort(A,A+N);
	int M=0;
	vint p,m;
	rep(i,N){
		if(i==0) M-=A[i];
		else if(i==N-1) M+=A[i];
		else{
			M+=abs(A[i]);
			if(A[i]>=0) p.push_back(A[i]);
			else m.push_back(A[i]);
		}
	}
	prin(M);
	int sum1=A[0];
	rep(i,p.size()){
		printf("%d %d\n",sum1,p[i]);
		sum1-=p[i];
	}
	int sum2=A[N-1];
	rep(i,m.size()){
		printf("%d %d\n",sum2,m[i]);
		sum2-=m[i];
	}
	printf("%d %d\n",sum2,sum1);
	return 0;
}


Measured memory_bytes: 2808
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

	int pair = 0;
	for(int i = 0; i < n; i++){
		if(i == a[a[i] - 1] - 1) pair ++;
	}
	cout << pair / 2<< endl;
	return 0;
}

Measured memory_bytes: 640
using System;
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            double [,]hen=new double[n,3];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                hen[i, 0] = int.Parse(s[0]);
                hen[i, 1] = int.Parse(s[1]);
                hen[i, 2] = int.Parse(s[2]);
            }
            for (int i = 0; i < n; i++)
            {
                hen[i, 0] = Math.Pow(hen[i, 0], 2);
                hen[i, 1] = Math.Pow(hen[i, 1], 2);
                hen[i, 2] = Math.Pow(hen[i, 2], 2);
                if (hen[i, 0] == (hen[i, 1] + hen[i, 2]) || hen[i, 1] == (hen[i, 0] + hen[i, 2])||hen[i, 2] == (hen[i, 0] + hen[i, 1])) 
                { 
                    Console.WriteLine("YES"); 
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }

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

int jishojun(vector<int> s) {
    vector<int> a(s.size());
    int kotae = 1;
    rep(i, a.size())a[i] = i + 1;

    for (vector<int> i = a;i != s;next_permutation(i.begin(), i.end())) {
        kotae++;
    }
    return kotae;
}

int main() {

    int n;
    cin >> n;
    vector<int>p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    cout << abs(jishojun(p) - jishojun(q)) << endl;
}

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

int euclide(int m, int n)
{
  int tmp;
  if(n == 0)
    return m;
  tmp = n;
  n = m % n;
  m = tmp;
  euclide(m, n);
}

int main()
{
  int a, b;
  while(cin >> a >> b){
    if(a < b){
      int tmp = a;
      a = b;
      b = tmp;
    }
    int gcd = euclide(a, b);
    cout << gcd << ' ' << a * (b / gcd) << endl;
  }
}
    

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int a,b;
	cin>>a>>b;
	cout<<max(0,(a-2*b))<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//https://atcoder.jp/contests/abc124/tasks/abc124_b
using namespace std;

int main(){

 int n,a ;
 vector<int> vec;
 cin>>n;
 for(int i = 0 ; i < n ; i++){
 cin>>a;
 vec.push_back(a);
 }
 int sum = 0 ;
 int may ; 
 (vec[0] > vec[1]) ? may = vec[0] : may = vec[1];
 for(int i = 1 ; i < n ; i++){
 if(may <= vec[i]){
  sum++;
  may = vec[i];
  }  
 }
 cout<<sum+1<<endl; 
 return 0; 
 }

Measured memory_bytes: 256
input_count = gets.chomp.to_i
input_num = gets.chomp.split.map!(&:to_i).sort{|a,b| (-1)*(a <=> b)}
alibob = [0 ,0]
(0..input_count - 1).each{ |i|
  alibob[i % 2] += input_num[i]
}
puts alibob[0] - alibob[1]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, m;
    cin >> n >> m;
    
    int table[100001] = {0};
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        table[l]++;
        table[r + 1]--;
    }
    rep3(i, 1, 100001) {
        table[i] += table[i - 1];
    }
    int cnt = 0;
    rep(i, 100001) if (table[i] == m) cnt++;
    out(cnt);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int H,W,A,B;  cin>>H>>W>>A>>B;
  int s[H][W];
  rep(i,0,H-B){
    rep(j,0,W-A) s[i][j] = 0;
    rep(j,W-A,W) s[i][j] = 1;
  }
  rep(i,H-B,H){
    rep(j,0,W-A) s[i][j] = 1;
    rep(j,W-A,W) s[i][j] = 0;
  }
  rep(i,0,H){
    rep(j,0,W){
      cout<<s[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = IntStream.range(0, n - 1).map(e -> sc.nextInt()).toArray();

        a[0] = b[0];
        for (int i = 1; i < n - 1; i++) {
            a[i] = Math.min(b[i], b[i - 1]);
        }
        a[n - 1] = b[n - 2];

        System.out.println(IntStream.of(a).sum());
        sc.close();
    }
}

Measured memory_bytes: 26964
Sa = input()
Sb = input()
Sc = input()
Sa_list = []
Sb_list = []
Sc_list = []

for i in Sa:
    Sa_list.append(i)
for j in Sb:
    Sb_list.append(j)
for k in Sc:
    Sc_list.append(k)
string = Sa_list[0]
del Sa_list[0]

while True:
    if string == "a":
        if len(Sa_list) > 0:
            string = Sa_list[0]
            del Sa_list[0]
        else:
            print("A")
            break
    if string == "b":
        if len(Sb_list) > 0:
            string = Sb_list[0]
            del Sb_list[0]
        else:
            print("B")
            break
    if string == "c":
        if len(Sc_list) > 0:
            string = Sc_list[0]
            del Sc_list[0]
        else:
            print("C")
            break


Measured memory_bytes: 3064
import sys
import math
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

for q in range(10 ** 9):
    n, x = map(int, input().split())
    if n == x == 0:
        break
    ans = 0
    for i in range(1, n + 1):
        for l in range(i + 1, n + 1):
            for k in range(l + 1, n + 1):
                if i + l + k == x:
                    ans += 1
    print(ans)



Measured memory_bytes: 6372
import sys
n = int(input())
w = []
for x in range(n):
    w.append(input())

sw = sorted(w)
for i in range(1, len(sw)):
    if sw[i - 1] == sw[i]:
        print("No")
        sys.exit()
for i in range(1, len(w)):
    if w[i - 1][-1] != w[i][0]:
        print("No")
        sys.exit()
print("Yes")

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

int main() {
	while (cin){
		string n1;
		cin >> n1;
		int m1 = 0, m2 = 0;
		if (cin. eof()) break;
		for (int i = 0; i < n1.size(); i++){
			if (n1[i] == 'J'){
				if (n1[i + 1] == 'O'){
					if (n1[i + 2] == 'I'){
						m1 += 1;
					}
				}
			}
			else if (n1[i] == 'I'){
				if (n1[i + 1] == 'O'){
					if (n1[i + 2] == 'I'){
						m2 += 1;
					}
				}
			}
		}
		cout << m1 << endl;
		cout << m2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;
int dy[6] = {0, 1, 1, 0, -1, -1};
int dx[6] = {1, 0, -1, -1, 0, 1};

int dfs(int y, int x, int c, bool &z, vector<vector<int> > &s){
    if(s[y][x] == 0) z = true;
    if(s[y][x] != c) return 0;
    s[y][x] = -1;

    int ret = 1;
    for(int i=0; i<6; i++){
        ret += dfs(y+dy[i], x+dx[i], c, z, s);
    }
    return ret;
}

int solve(int y, int x, int c, vector<vector<int> > s){
    s[y][x] = c;
    int n = s.size()-2;
    int ret = 0;
    for(int i=n; i>0; i--){
        for(int j=1; j<=n-i+1; j++){
            if(s[i][j] <= 0) continue;
            bool z = false;
            int sign = (s[i][j] == c)? -1: 1;
            int score = dfs(i, j, s[i][j], z, s);
            if(!z) ret += sign *score;
        }
    }
    return ret;
}

int main(){
    while(1){
        int n,c;
        cin >> n >> c;
        if(n==0) break;

        vector<vector<int> > s(n+2, vector<int>(n+2, -1));
        for(int i=n; i>0; i--){
            for(int j=1; j<=n-i+1; j++){
                cin >> s[i][j];
            }
        }

        int ans = -inf;
        for(int i=n; i>0; i--){
            for(int j=1; j<=n-i+1; j++){
                if(s[i][j] == 0){
                    int score = solve(i, j, c, s);
                    ans = max(ans, score);
                }   
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var h = o.a();
  var w = o.a();
  var n = o.a();
  var p = Math.max(h,w);
  return (n+p-1)/p|0;
}

Measured memory_bytes: 22076
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std; 

const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}

void ok() {
    cout << "YES" << '\n';
}

void no() {
    cout << "NO" << '\n';
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    vector<int> a(5);
    generate(all(a), nxt);
    cout << find(all(a), 0) - a.begin() + 1;
    return 0;
}


Measured memory_bytes: 3652
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
ans = 0
for hbit in range(1<<h): # red row bit
    for wbit in range(1<<w): # red col bit
        c = 0
        for i in range(h):
            for j in range(w):
                if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '#': c += 1
        if c == k: ans += 1
print(ans)


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

int gcd(int a,int b){
    if(b ==0) return a;
    return gcd(b,a%b);
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int m = 0;
    int mx = 0;
    rep(i,n) m = gcd(m,a[i]),mx = max(a[i],mx);
    cout << ( k%m ==0  && k <= mx ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int n, m; cin >> n >> m;
    vector<string> a(n);
    rep(i, n) cin >> a[i];
    vector<string> b(m);
    rep(i, m) cin >> b[i];

    bool found = false;
    rep(i, n-m+1) rep(j, n-m+1) {
        bool ok = true;
        rep(k, m) rep(l, m) {
            debug(i, j, k, l);
            if (a[i+k][j+l]!=b[k][l]) ok = false;
        }
        if (ok) found = true;
    }
    if (found) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ret = (abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d);
    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
   int a,p;
   cin>>a>>p;
   p += a*3;
   cout<<p/2<<endl;
   return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
// ll A[100010];
int main(){
    cin>>N>>M;
    priority_queue<ll> pq;
    for(ll i=0;i<N;i++){
        ll A;
        cin>>A;
        pq.push(A);
    }
    ll ans=0;
    for(ll cnt=0;cnt<M;cnt++){
        ll n=pq.top();pq.pop();
        pq.push(n/2);
    }
    while(!pq.empty()){
        ll n=pq.top();pq.pop();
        ans+=n;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) (v).begin(),(v).end()
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
ll A[100000];
int main() {
	int N;
	cin >> N;
	priority_queue<ll, vector<ll>, greater<ll>> pos;
	priority_queue<ll> neg;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] >= 0) pos.push(A[i]);
		else neg.push(A[i]);
	}
	if (N == 2) {
		if (A[0] <= A[1]) {
			cout << A[1] - A[0] << endl;
			cout << A[1] << " " << A[0] << endl;
		}
		else {
			cout << A[0] - A[1] << endl;
			cout << A[0] << " " << A[1] << endl;
		}
		return 0;
	}
	vector<P> vec;
	if (pos.size() == N) {
		ll x = pos.top(); pos.pop();
		ll y = pos.top(); pos.pop();
		vec.emplace_back(x, y);
		neg.push(x - y);
	}
	else if (neg.size() == N) {
		ll x = neg.top(); neg.pop();
		ll y = neg.top(); neg.pop();
		vec.emplace_back(x, y);
		pos.push(x - y);
	}
	ll p = pos.top(); pos.pop();
	ll q = neg.top(); neg.pop();
	while (!pos.empty()) {
		ll y = pos.top(); pos.pop();
		vec.emplace_back(q, y);
		q -= y;
	}
	while (!neg.empty()) {
		ll y = neg.top(); neg.pop();
		vec.emplace_back(p, y);
		p -= y;
	}
	cout << p - q << endl;
	vec.emplace_back(p, q);
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i].first << " " << vec[i].second << endl;
	}
}

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

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

    int arr[n];

    int k =1;
    int l = 0;
    for (int i=0;i<n;i++)
    {
        cin>>arr[i];

        if (arr[i]==k)
            k++;
        else
            {
                arr[i]=0;
                l++;
            }
    }
    bool as = false;
    for (int i=0;i<n;i++)
    {
        if (arr[i]>0)
            as = true;

    }

    if (as==false)
        cout<<"-1"<<endl;
    else
        cout<<l<<endl;

}


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



int main(){
  while(1){
  int n;
  //  set<int> taro,hana;                                                                                                     
  vector<int> taro,hana;

  cin >> n;
  if(n==0)break;
  for(int i=0;i<n;i++){
    int tmp; cin >> tmp;
    taro.push_back(tmp);
  }
  sort(taro.begin(),taro.end());
  int j=0;
  for(int i=1;i<=2*n;i++){
    if(taro[j] == i){
      j++; continue;
    }
    hana.push_back(i);
  }
  sort(hana.begin(),hana.end());
  for(int i=0;i<n;i++){
    // cout << taro[i] << " " << hana[i] << endl;                                                                             
  }
  int open = taro[0];
  taro.erase(taro.begin());
  bool f=1;
  while(taro.size() != 0 && hana.size() != 0){
    if(f){// hana                                                                                                             
      bool g=1;
      for(int i=0;i<hana.size();i++){
        if( open < hana[i] ){
          open = hana[i];
          hana.erase(hana.begin()+i);
          g=0;
          break;
        }
      }
      if(g){
        open =-1;
      }
      f=0;
    }
    else{//taro                                                                                                               
      bool g=1;
      for(int i=0;i<taro.size();i++){
        if( open < taro[i] ){
          open = taro[i];
          taro.erase(taro.begin()+i);
          g=0;
          break;
        }
      }
      if(g){
        open =-1;
      }
      f=1;
    }
  }
  cout << hana.size() <<endl << taro.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
A.sort()
def gcd(a, b): # 最大公約数
    a = abs(a)
    b = abs(b)
    while b:
        a, b = b, a % b
    return a
g0 = reduce(gcd,A[1:])

now = A[0]

id = 0
for i in range(1,N):
    ne = gcd(now,A[i])
    if ne < now:
        id = i
        now = ne
A.pop(id)

g = reduce(gcd,A)
print(max(g,g0))



Measured memory_bytes: 14576
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    map<int, int> a;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;

        if (!a.insert({in, 1}).second) {
            a[in]++;
        }
    }

    int ans = 0;
    for (int i = 1; i < 100000; i++) {
        int tem = 0;
        tem += a[i - 1] + a[i] + a[i + 1];

        ans = max(ans, tem);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
# coding: utf-8

A, B, C, D, E = [int(input()) for i in range(5)]

time = 0
if A < 0: time += (min(B, 0) - A)*C
if A*B <= 0: time += D
if B > 0: time += (B - max(A, 0))*E
print(time)



Measured memory_bytes: 5608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
map<string,int>q;
vector<string>res;
string a;
int n,mx; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a,q[a]++,mx=max(mx,q[a]);
	for(auto v:q)
		if(v.second==mx)res.push_back(v.first);
	sort(res.begin(),res.end());
	for(auto v:res)
		cout<<v<<endl;
	return 0;
}

Measured memory_bytes: 25584
import java.util.*;
 
class Main{
	public static void main(String args[]){
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt(),b = stdIn.nextInt();
		
		if ((a%3)==0 || (b%3)==0 || ((a+b)%3)==0){
			System.out.println("Possible");
		}
		else System.out.println("Impossible");
 
		
	}
}

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

void factorization(long long n,map<long long ,long long>& mp){
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
      }
      if(!(n == 1)) mp[n]++;
}
int main() {
  ll n,p;
  cin>>n>>p;
  map<ll,ll> mp;
  factorization(p,mp);
  ll ans=1;
  for(auto x : mp){
    ll a,b;
    a=x.second/n;
    ans*=pow(x.first,a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
Bs = list(map(int,input().split()))
ans = 0

if n==2:
    ans = Bs[0]*2

elif n==3:
    ans += sum(Bs)
    ans += min(Bs)
else:
    ans += Bs[0]
    ans += Bs[-1]
    for i in range(len(Bs)-1):
        ans += min(Bs[i],Bs[i+1])
        
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
const int MAXN = 50 + 5;
const int mod = 1e9 + 7;

using namespace std;

int n, V[MAXN];
int dp[105][MAXN][MAXN];

int rec(int k, int l, int r) {
  if (l > r || k == 0) return 0;
  int &ret = dp[k][l][r];
  if (ret != -1) return ret;
  ret = max(0,V[l]+rec(k-1,l+1,r));
  ret = max(ret, V[r]+rec(k-1,l,r-1));
  if (k>1) {
    ret = max(ret,rec(k-2,l+1,r));
    ret = max(ret,rec(k-2,l,r-1));
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> n >> k;
  memset(dp,-1,sizeof dp);
  for (int i = 0; i < n; i++)
    cin >> V[i];
  cout << rec(k,0,n-1);
  return 0;
}

Measured memory_bytes: 1536
#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 long long INF = 1LL << 60;

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);

    set<int> st;
    rep(i, n) st.insert(p.at(i));

    int ans1 = x;
    int ans2 = x;
    for (int i = 0; i <= 100; i++)
    {
        if (st.count(ans1) == 0)
        {
            cout << ans1 << endl;
            break;
        }
        if (st.count(ans2) == 0)
        {
            cout << ans2 << endl;
            break;
        }
        ans1--;
        ans2++;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 3e5 + 233;
int n, m, pro[N], sz[N];

int main(void) {
	read(n); read(m);
	pro[1] = true;
	rep (i, n) sz[i] = 1;
	rep (i, m) {
		int x, y;
		read(x); read(y);
		if (pro[x]) pro[y] = 1;
		sz[x]--; sz[y]++;
		if (!sz[x]) pro[x] = 0;
	}
	int ans = 0;
	rep (i, n) ans += pro[i];
	cout << ans << "\n";
}
				


Measured memory_bytes: 1152
def main(s):
    s = "".join(list(s.split()))
    bra1 = 0
    bra2 = 0
    for i in range(len(s)):
        if s[i] != "(" and s[i] != ")" and s[i] != "[" and s[i] != "]":
            continue
        if s[i] == "(":
            if bra1 == 0:
                bra10 = i
            bra1 += 1
        if s[i] == ")":
            bra1 -= 1
            if bra1 == 0:
                if not main(s[bra10 + 1:i]):
                    return False
        if s[i] == "[":
            if bra2 == 0:
                bra20 = i
            bra2 += 1
        if s[i] == "]":
            bra2 -= 1
            if bra2 == 0:
                if not main(s[bra20 + 1:i]):
                    return False
        if bra1 < 0 or bra2 < 0:
            return False
    if bra1 > 0 or bra2 > 0:
        return False
    return True

while 1:
    s = input()
    if s == ".":
        break
    print("yes" if main(s) else "no")
    


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

// x^n
ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

// x^{-1}
ll mod_inv(ll x) { return mod_pow(x, MOD - 2); }

vector<ll> fact;
vector<ll> fact_inv;

void init_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = fact_inv[0] = 1;
  REP(i, n) {
    fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_inv[i + 1] = fact_inv[i] * mod_inv(i + 1) % MOD;
  }
}

ll nCr(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
}

ll nPr(ll n, ll r) { return nCr(n, r) * fact[r] % MOD; }

int main() {
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  int m = (2 * y - x) / 3;
  int n = (2 * x - y) / 3;
  if (m < 0 || n < 0) {
    cout << 0 << endl;
    return 0;
  }
  init_fact(m + n);
  cout << nCr(m + n, m) << endl;
  return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string ans = "No";
    if (s[2] == s[3] && s[4] == s[5]) {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int Y = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        PriorityQueue<Integer> q1 = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < A; i++) {
            q1.add(scan.nextInt());
        }
        PriorityQueue<Integer> q2 = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < B; i++) {
            q2.add(scan.nextInt());
        }
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < X; i++) {
            queue.add(q1.poll());
        }
        for (int i = 0; i < Y; i++) {
            queue.add(q2.poll());
        }
        for (int i = 0; i < C; i++) {
            queue.add(scan.nextInt());
        }
        long ans = 0;
        for (int i = 0; i < X + Y; i++) {
            ans += queue.poll();
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 98668
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,d;
  long long int count=0;
  cin>>n>>d;
  while(n--){
   double b,c,e;
    cin>>b>>c;
    
    e=sqrt(pow(b,2) + pow(c,2));
    if(e<=d)
      count++;
  }
  cout<<count;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


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

int n,m;
int a[50],b[50],c[50],d[50];

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

	cin>>n>>m;
	REP(i,n) cin>>a[i]>>b[i];
	REP(i,m) cin>>c[i]>>d[i];

	REP(i,n) {
		int pos,D=INF;
		REP(j,m) {
			if(abs(a[i]-c[j])+abs(b[i]-d[j])<D) pos=j+1,D=abs(a[i]-c[j])+abs(b[i]-d[j]);
		}
		cout<<pos<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  auto K = scan!int;

  long solve() {
    int unitMod = 7 % K;
    if (unitMod == 0) return 1;

    int mod = unitMod;

    foreach(i; 0..K) {
      mod = (mod * 10) + unitMod;
      mod %= K;
      
      if (mod == 0) return 2 + i;
    }
    
    return -1;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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

int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0) cout << " " << i;
		else {
			int X = i;
			while (X != 0) {
				if (X % 10 == 3) {
					cout << " " << i;
					break;
				}
				X /= 10;
			}
		}
	}
	cout << endl;
}


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

using namespace std;

int wg[105] = {0};
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> wg[i];
		wg[i] = wg[i - 1] + wg[i];
	}
	int ans = 10000000;
	for (int i = 1; i <= n-1; i++) {
		if (ans > abs((wg[n] - wg[i]) - wg[i]))ans = abs((wg[n] - wg[i]) - wg[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int( input() )
p = tuple( map( int, input().split() ) )
q = tuple( map( int, input().split() ) )

import itertools
permutations = list( itertools.permutations( range( 1, n + 1 ) ) )
p_order = permutations.index( p )
q_order = permutations.index( q )

print( abs( p_order - q_order ) )

Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define INF 100000000
int main(){
    ll X,A;
    cin>>X>>A;
    if(X<A) cout<<0;
    else cout<<10;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int x3 = x2 + y1 - y2;
		int y3 = y2 + x2 - x1;

		int x4 = x1 + y1 - y2;
		int y4 = y1 + x2 - x1;

		System.out.println(x3+" "+y3+ " "+x4+" "+y4);
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(H);
    scanInt(W);
    scanInt(K);
    vector<vector<char>> board(H, vector<char>(W));
    using coordinate = pair<int, int>;
    coordinate start;
    loop(y, H){
        loop(x, W){
            board[y][x] = getchar();
            if (board[y][x] == 'S'){
                start = make_pair(x, y);
            }
        }
        getchar();
    }
    queue<tuple<coordinate, int>> q;
    q.emplace(start, 0);
    auto add_to_queue = [&](int x, int y, int times){
        if (x < 0 || x >= W || y < 0 || y >= H || board[y][x] == '#') return;
        // printf("%d %d\n", x, y);
        q.emplace(make_pair(x, y), times);
        board[y][x] = '#';
    };
    int distance = INT_MAX;
    while (!q.empty()){
        int x = get<0>(q.front()).first;
        int y = get<0>(q.front()).second;
        int times = get<1>(q.front());
        q.pop();
        board[y][x] = '#';
        distance = min(distance, min(min(x, W - 1 - x), min(y, H - 1 - y)));
        // printf("%d %d %d %d\n", x, y, times, distance);
        if (times < K){
            add_to_queue(x - 1, y, times + 1);
            add_to_queue(x + 1, y, times + 1);
            add_to_queue(x, y - 1, times + 1);
            add_to_queue(x, y + 1, times + 1);
        }
    }
    // printf("%d\n", distance);
    if (distance == 0){
        printf("%d\n", 1);
    }else{
        printf("%d\n", 2 + (distance - 1) / K);
    }
}


Measured memory_bytes: 896
// Length of largest subarray with 0 Sum
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int a[5];
	for(int i=0;i<5;i++)
		cin >> a[i];
	for(int i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout << i+1 << endl;
			break;
		}
	}
	return 0;
}

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

  int len=s.size();
  bool flag=true;

  if(s.at(0)!='A') flag=false;

  int cnt=0,tmp;
  for(int i=2;i<len-1;i++)
  {
    if(s.at(i)=='C')
    {
      cnt++;
      tmp=i;
    }
  }

  if(cnt!=1) flag=false;

  for(int i=1;i<len;i++)
  {
    if(i==tmp) continue;
    else if(s.at(i)>='A' && s.at(i)<='Z') flag=false;
  }

  if(flag) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;

}

Measured memory_bytes: 256