akhauriyash/Code-Regression huggingface dataset:
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n>>k;


    cin>>str;

    vector<pll>v;

    v.eb(0,0);

    for(i=0; i<n; i++)
    {
        if(str[i]=='0')
        {
            a=i+1;

            while(i<n && str[i]=='0')i++;

            b=i;

            v.eb(a,b);


        }
    }



    v.eb(n+1,n+1);



    if( (v.size()-2)==0 || (v.size()-2)<=k)
        ans=n;

    n=v.size();

    m=n;




    /*for(auto x : v)
        cout<<x<<" ";

    cout<<endl;*/


   for(i=k+1; i<n && k; i++)
    {
        sum=v[i].F-v[i-(k+1)].S-1;

       // cout<<sum<<endl;

        ans=max(sum,ans);
    }




    n=str.size();

    for(i=0; i<n && k==0; i++)
    {
        cnt=0;

        while(i<n && str[i]=='1')
        {
            i++;
            cnt++;
        }

       // cout<<i<<" "<<cnt<<endl;

        ans=max(cnt,ans);

    }



    cout<<ans<<endl;


}



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

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

int N, Q;
string s;

char t[200005], d[200005];

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

	cin >> N >> Q >> s;

	for (int i = 0;i < Q;i++){
		cin >> t[i] >> d[i];
	}

	int idx = -1;
	for (int i = Q-1;i >= 0;i--){
		if(idx != N-1 && s[idx+1] == t[i] && d[i] == 'L'){
			idx++;
		}else if(idx != -1 && s[idx] == t[i] && d[i] == 'R'){
			idx--;
		}
	}

	int ans = idx+1;

	idx = N;
	for (int i = Q-1;i >= 0;i--){
		if(idx != 0 && s[idx-1] == t[i] && d[i] == 'R'){
			idx--;
		}else if(idx != N && s[idx] == t[i] && d[i] == 'L'){
			idx++;
		}
	}

	ans += N-idx;

	cout << max(0,N-ans) << endl;

	return 0;

}


Measured memory_bytes: 976
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int pa,pz;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            pa=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z'){
            pz=i;
            break;
        }
    }
    cout<<pz-pa+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a[3];
    rep(i, 0, 3) cin >> a[i];
    sort(a, a + 3);
    if (a[0] == a[1] && a[0] != a[2]) cout << "Yes" << endl;
    else if (a[1] == a[2] && a[1] != a[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<ll> sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + A[i];
    vector<ll> S;
    for (int l = 0; l < N; ++l) {
        for (int r = l + 1; r <= N; ++r) {
            S.push_back(sum[r] - sum[l]);
        }
    }
    
    ll ans = 0;
    for (int i = 60; i >= 0; --i) {
        int cnt = 0;
        for (auto s : S) {
            if ((s >> i) & 1) ++cnt;
        }
        if (cnt < K) continue;
        ans += (1LL << i);
        vector<ll> T;
        for (auto s : S) {
            if ((s >> i) & 1) T.push_back(s);
        }
        swap(S, T);
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=5000
etemp=1
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.9:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(10)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)


Measured memory_bytes: 10540
#include <iostream>

using namespace std;

int main(){
    int A[3] = {0};
    cin >> A[0] >> A[1] >> A[2];
    int a01 = abs(A[0]-A[1]);
    int a02 = abs(A[0]-A[2]);
    int a12 = abs(A[1]-A[2]);
    int min = a01+a12; //012
    if(min>a02+a12){ //021
        min = a02+a12;
    }
    if(min>a01+a02){ //102
        min = a01+a02;
    }
    if(min>a12+a02){ //120
        min = a12+a02;
    }
    if(min>a12+a01){ //210
        min=a12+a01;
    }
    if(min>a02+a01){ //201
        min = a02+a01;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int[] l=new int[n+1];
    l[0]=0;
    for(int i=1;i<=n;i++){
        l[i]=l[i-1]+sc.nextInt();
    }
    for(int i=1;i<=n;i++){
        if(l[i]>x){
            System.out.println(i);
            return;
        }
    }
    System.out.println(n+1);
  }
}


Measured memory_bytes: 23124
import sys
sdin = sys.stdin.readline

N,M = map(int, sdin().split())
AB = []
for i in range(M):
    AB.append(tuple(map(int, sdin().split())))
    
to_mid = set()
from_mid = set()

for a,b in AB:
    if a==1:
        to_mid.add(b)
    if b==N:
        from_mid.add(a)
        
if to_mid & from_mid:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

#define MAX 200005
#define INFTY 1e13

int main() {
	int N;
	vector<int> A(MAX);
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	vector<long long> ans(MAX);
	for (int i = 0; i < N; i++) ans[i] = 0;
	
	long long sum = 0;
	for (int i = 1; i < N; i++) sum += A[i];
	ans[0] = (long long)A[0] - sum;
	for (int i = 1; i < N; i++) {
		//if ((ans[i - 1] + 2LL * (long long)A[i]) > INFTY) ans[i] = INFTY;
		 ans[i] = ans[i - 1] + 2LL * (long long)A[i];
	}
	//for (int i = 0; i < N-1; i++) cout << ans[i] << " ";

	long long minl = INFTY;
	for (int i = 0; i < N-1; i++) {
		if (minl > llabs(ans[i])) minl = llabs(ans[i]);
	}

	cout << minl << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    string s;
    cin >> s;
    int ans = 0;
    int cont = 0;
    for ( auto l : s ) {
        if ( l == 'R' ) {
            cont++;
            ans = max(cont, ans);
        } else {
            cont = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int n;

    cin >> n;
    cout << 180*(n-2) << '\n';

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll x;
    cin >> x;
    cout << 1 - x << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main() {
	int n = 0;
	int output = 0;
	cin >> n;
	int d[50];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			output += d[i] * d[j];
		}
	}
	cout << output << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, m;
int main() {
    while (cin>>n>>m) {
        if (!n) break;
        string key[n];
        ll score[n];
        for (int i=0; i<n; i++) {
            string str; cin>>str>>score[i];
            key[i]=str;
        }
        ll sum=0;
        for (int i=0; i<m; i++) {
            string str; cin>>str;
            for (int j=0; j<n; j++) {
                int k=0;
                while ((key[j][k]=='*'||key[j][k]==str[k])&&k<8) k++;
                if (k==8) {
                    sum+=score[j];
                    break;
                }
            }
        }
        cout<<sum<<endl;
    }
}

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



int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    ll a[n],dp[n];
    for(int i=0;i<n;i++)cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> T(N);
  int S=0;
  for (int &t: T) {
    scanf("%d", &t);
    S += t;
  }

  int M;
  scanf("%d", &M);

  for (int i=0; i<M; ++i) {
    int P, X;
    scanf("%d %d", &P, &X);
    printf("%d\n", S+X-T[P-1]);
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using namespace std;
int main()
{
  int n,f0,f,day;
  int i,j,k;
  while(cin>>n,n){
    vector< vector<bool> >v(n,vector<bool>(31,false));
    for(i=0;i<n;i++){
      for(cin>>f0;f0-->0;){
	cin>>f;
	v[i][f]=true;
      }
    }

    day=-1;
    vector< vector< set<int> > >dp( n,vector< set<int> >(31) );
    set<int>::iterator it;
    for(i=0;i<n;i++)dp[i][0].insert(i);
    for(j=1;j<31;j++){
      for(i=0;i<n;i++){
	for(k=i;k<n;k++)dp[k][j]=dp[k][j-1];

	if(v[i][j]){
	  for(k=i;k<n;k++){
	    if(v[k][j]){
	      for(it=dp[k][j].begin();it!=dp[k][j].end();it++){
		dp[i][j].insert(*it);
	      }
	    }
	  }
	  for(k=i;k<n;k++){
	    if(v[k][j]){
	      for(it=dp[i][j].begin();it!=dp[i][j].end();it++){
		dp[k][j].insert(*it);
	      }
	    }
	  }
	  if(dp[i][j].size()==n)day=j;
	  break;
	}

	if(day>=0)break;
      }
      if(day>=0)break;
    }

    cout<<day<<endl;
  }
}

Measured memory_bytes: 2640
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = 0;
    let mut p = 0;
    for _ in 0..n {
    	let mut x = get!();
        let mut k = 0;
        while x % 2 == 0 {
        	x /= 2;
            k += 1;
        }
        ans += k; 
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];
main(){
  ll n,m,ans=0,sum=1,cnt=0;
  cin>>n>>m;
  rep(i,0,n){cin>>a[i];a[i]/=2;}
  bool fuck=true;
  rep(i,0,n)sum=sum/GCD(sum,a[i])*a[i];
  ll k=1;
  while(sum*k<=m){ans++,k+=2;}
  rep(i,0,n){
    if((sum/a[i])%2==0)fuck=false;
  }
  if(fuck)cout<<ans;
  else cout<<0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	
	int n, m;
	cin >> n >> m;
	unordered_map<int, int> ac, wa;
	int cor = 0, pen = 0;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		string s;
		cin >> s;
		if (s == "AC") {
			if (ac[t] == 0) {
				cor++;
				pen += wa[t];
				ac[t] = 1;
			}
		}
		else {
			if (ac[t] == 0) {
				wa[t]++;
			}
		}
	}
	cout << cor << " " << pen << endl;
}









Measured memory_bytes: 8520
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	string s;
	cin >> s;
	int a,b,f[n+1];
	f[0]=0;
	for(int i=1;i<n;i++)
	{
		f[i]=f[i-1];
		if(s[i]=='C'&&s[i-1]=='A') f[i]++;
	}
	for(int i=1;i<=m;i++)
	{
		cin >> a >> b;
		cout << f[b-1]-f[a-1] << endl;
	}
	return 0; 
}


Measured memory_bytes: 1488
import math

def get_distance(x1, y1):
	d = math.sqrt((x1) ** 2 + (y1) ** 2)
	return d


N, D  = map(int, input().split())
count = 0
num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))


for i in range (N):
	if abs(num_list[i][0]<= D) and abs(num_list[i][1]) <= D:
		
		k = get_distance(num_list[i][0], num_list[i][1])
		if k <= D:
			count += 1


print(count)

Measured memory_bytes: 45476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
ll N, X;

ll Gcd(ll b, ll d){
    if (d == 0) return b;
    else return Gcd(d, b % d);
}

int main(void){
	
	scanf("%lld %lld", &N, &X);
	vector<ll> x(N);
	for(int i = 0; i < N; ++i) scanf("%lld", &x[i]);
	
	if(N == 1){ printf("%lld\n", abs(x[0] - X)); return 0; }
	
	x.push_back(X);
	sort(x.begin(), x.end());
    
	vector<ll> v;
	for(int i = 0; i < x.size() - 1; ++i) v.push_back(x[i + 1] - x[i]);
	
	ll ans = v[0];
	for(int i = 1; i < v.size(); ++i){
	    ans = Gcd(ans, v[i]);
	}
	printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 2800
import Foundation

func solve(_ n: inout Int, _ aSizes: inout [Int], _ bSizes: inout [Int], _ cSizes: inout [Int]) -> Int {

    aSizes.sort()
    cSizes.sort()

    var bPassed = [Int: Int]()

    return bSizes
        .map {
            if let cases = bPassed[$0] {
                return cases
            }
            let lowerCases = corneredBounds(searchValue: $0, list: &aSizes, policy: .lower).left + 1
            let upperCases = n - corneredBounds(searchValue: $0, list: &cSizes, policy: .upper).right
            let cases = lowerCases * upperCases
            bPassed[$0] = cases
            return cases
        }
        .reduce(0, +)
}

func corneredBounds(searchValue: Int, list: inout [Int], policy: Direction) -> (left: Int, right: Int) {

    var openedLeft = -1
    var openedRight = list.count

    while openedRight - openedLeft > 1 {

        let mid = (openedRight + openedLeft) / 2

        func midValueShouldBeInLeftSide() -> Bool {
            policy.midValueShouldBeInLeftSide(at: mid, on: list, with: searchValue)
        }

        if midValueShouldBeInLeftSide() {
            openedLeft = mid
        }
        else {
            openedRight = mid
        }
    }

    return (openedLeft, openedRight)
}

enum Direction {

    case lower
    case upper

    func midValueShouldBeInLeftSide(at index: Int, on list: [Int], with searchValue: Int) -> Bool {

        switch self {
            case .lower: return list[index] <  searchValue ? true : false
            case .upper: return list[index] <= searchValue ? true : false
        }
    }
}

var n = Int(readLine()!)!
var aSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }
var bSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }
var cSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }

let answer = solve(&n, &aSizes, &bSizes, &cSizes)
print(answer)


Measured memory_bytes: 27628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<pii,int> mpi;
typedef vector<bool> vb;
typedef vector<vb> mtx;

/* global variables */

int n, m, z;
vi nbrs[MAX_N];
int gn;
mpi gmap;

/* subroutines */
void initmat(mtx& m) {
  for (int i = 0; i < gn; i++) fill(m[i].begin(), m[i].end(), false);
}

void mulmat(mtx& mm, const mtx& m0, const mtx& m1) {
  for (int i = 0; i < gn; i++)
    for (int j = 0; j < gn; j++) {
      bool b = false;
      for (int k = 0; ! b && k < gn; k++)
	b = (m0[i][k] & m1[k][j]);
      mm[i][j] = b;
    }
}

void powmat(mtx& mm, mtx m0, int e) {
  mtx m1(gn, vb(gn, false));
  initmat(mm);
  for (int i = 0; i < gn; i++) mm[i][i] = true;

  while (e > 0) {
    if (e & 1) {
      mulmat(m1, mm, m0);
      mm = m1;
    }

    mulmat(m1, m0, m0);
    m0 = m1;

    e >>= 1;
  }
}

/* main */

int main() {
  for (;;) {
    cin >> n >> m >> z;
    if (n == 0) break;

    for (int i = 0; i < n; i++) nbrs[i].clear();

    gn = 0;
    gmap.clear();
    gmap[pii(0, 0)] = gn++;
    
    for (int i = 0; i < m; i++) {
      int si, di;
      cin >> si >> di;
      si--, di--;
      nbrs[si].push_back(di);
      nbrs[di].push_back(si);
      gmap[pii(si, di)] = gn++;
      gmap[pii(di, si)] = gn++;
    }

    mtx m(gn, vb(gn, false));

    for (int i = 0; i < n; i++) {
      vi& nbri = nbrs[i];
      for (vi::iterator vit0 = nbri.begin(); vit0 != nbri.end(); vit0++) {
	int i0 = gmap[pii(i, *vit0)];
	for (vi::iterator vit1 = nbri.begin(); vit1 != nbri.end(); vit1++)
	  if (*vit1 != *vit0)
	    m[i0][gmap[pii(*vit1, i)]] = true;
      }
    }

    for (vi::iterator vit = nbrs[0].begin(); vit != nbrs[0].end(); vit++)
      m[0][gmap[pii(*vit, 0)]] = true;

    mtx mp(gn, vb(gn, false));
    powmat(mp, m, z);

    bool ok = false;
    for (vi::iterator vit = nbrs[n - 1].begin(); vit != nbrs[n - 1].end(); vit++) {
      if (mp[0][gmap[pii(n - 1, *vit)]]) {
	ok = true;
	break;
      }
    }    

    cout << (ok ? "yes" : "no") << endl;
  }

  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define int 			long long int
#define ld 				long double
#define ff 				first
#define ss 				second
#define P 				pair<int,int>
#define pb 				push_back
#define mod             1000000007
#define inf             1e18
#define endl			'\n'

const int N = 305;//change it when needed
int n;
int a[N];
double dp[N][N][N];
double F(int x, int y, int z) {
	if (x < 0 or y < 0 or z < 0)
		return 0;
	if (x == 0 and y == 0 and z == 0) {
		return 0;
	}
	double &ans = dp[x][y][z];
	if (ans != -1)return ans;
	ans = n;
	ans += x * F(x - 1, y, z);
	ans += y * F(x + 1, y - 1, z);
	ans += z * F(x, y + 1, z - 1);
	ans /= (x + y + z);
	return ans;

}
void solve() {
	int x = 0, y = 0, z = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int j;
		cin >> j;
		if (j == 1)x++;
		else if (j == 2)y++;
		else z++;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
	// db(x, y, z);
	cout << fixed << setprecision(10) << F(x, y, z) << endl;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 222080
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long a,b,c,d;
    long long arr[4];
    cin>>a>>b>>c>>d;
    arr[0]=a*c;
    arr[1]=b*c;
    arr[2]=a*d;
    arr[3]=b*d;
    sort(arr,arr+4);
    cout<<arr[3];
    

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define dump(x)  cerr << #x << " = " << (x) << endl;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

 

//ここから書き始める
int main(int argc, char const *argv[])
{
	LL N;
	cin >> N;
	LL x[N],y[N],h[N];
	tuple<long long, long long, long long> G = make_tuple(-1,-1,-1);
	REP(i, N)
	{
		cin >> x[i] >> y[i] >> h[i];
		if(h[i] >= 1) 
		{
			G = make_tuple(x[i], y[i], h[i]);
		}
	}
	//頂上探索
	REP(xkouho, 101)
	{
		REP(ykouho, 101)
		{
			LL hkouho = get<2>(G) + abs(xkouho - get<0>(G)) + abs(ykouho - get<1>(G));
			bool flag = true;
			REP(i,N)
			{
				LL height = max(0LL, hkouho - abs(xkouho - x[i]) - abs(ykouho - y[i]));
				if(height != h[i]) flag = false;
			}
			if(flag == true) cout << xkouho << " " << ykouho << " " << hkouho << endl;
		}
	}



}


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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;

int main() {
    cin >> N;

    int ans = N;
    for (int i = 0; i <= N; ++i) {
        int cur = 0;
        int residual = i;
        while (residual > 0) {
            cur += residual % 6;
            residual /= 6;
        }
        residual = N - i;
        while (residual > 0) {
            cur += residual % 9;
            residual /= 9;
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    X = [list(map(int,input().split())) for _ in range(M)]
    X.sort(key=lambda X:(X[1],-X[0]))
    count = 1
    left = X[0][1]
    for i in range(M):
        if X[i][0] >= left:
            count += 1
            left = X[i][1]

    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38564
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;


void Bubblesort(string card[],int n){
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if (card[j][1] < card[j-1][1]){
				string c =card[j];
				card[j] = card [j-1];
				card[j-1] = c;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(i!=n-1) cout << card[i] << " ";
		else cout << card[i] << endl;
	}
}

void SelectionSort(string card[],int n){
	for(int i=0;i<n;i++){
		int minj =i;
		for(int j=i;j<n;j++){
			if(card[j][1]<card[minj][1]){
				minj=j;
			}
		}
		string c =card[i];
		card[i] = card[minj];
		card[minj] = c;
	}
	for(int i=0;i<n;i++){
		if(i!=n-1) cout << card[i] << " ";
		else cout << card[i] << endl;
	}
}

int main () {
	int n,i,k=1;
	cin >> n;
	string card1[n],card2[n];
	for(i=0;i<n;i++){
		cin >> card1[i];
		card2[i]=card1[i];
	}
	Bubblesort(card1,n);
	cout << "Stable" << endl;
	SelectionSort(card2,n);
	for(i=0;i<n;i++){
		if(card1[i]!=card2[i]) k=0;
	}
	if(k==1) cout << "Stable"<< endl;
	else cout << "Not stable" << endl;

	return 0;
}

Measured memory_bytes: 1212
public class Main {
    public static void main(String[] args) {

         java.util.Scanner sc = new java.util.Scanner(System.in);
        String W = sc.next();

         int count = 0;
        String T;
        while (true) {
            T = sc.next();
            if (T.equals("END_OF_TEXT")) { break; }
            if (T.equalsIgnoreCase(W)) { count ++; }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main

//-----------------//
ll dp[1000050]={0};
int countWays(int n) 
{ 
    // To store count of such pairs 
    int count = 0; 
  
    // Counting number of pairs 
    // upto sqrt(n) - 1 
    for (int i = 1; i * i < n; i++) 
        if (n % i == 0) 
            count++; 
  
    // To return count of pairs 
    return count; 
} 
  


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll ans = 0;
	dp[1]=0;
	dp[2]=1;
	for(i=1;i<n-1;i++)
	{
		ll k = n-i;
		ans += countWays(k)*2;
		ld x=k;
		x = sqrt(x);
		if(x-floor(x)==0)
			ans++;
		
		


	}
	cout<<ans+1<<endl;
	
	


	
	return 0;
}

Measured memory_bytes: 3692
A, B, K = map(int, input().split())
def split_A_K_B(A, B, K):
    if K >= A:
        K -= A
        A = 0
    else:
        A -= K
        return A, B
    if K >= B:
        K -= B
        B = 0
    else:
        B -= K
    return A, B
A, B = split_A_K_B(A, B, K)
print("{} {}".format(A, B))

Measured memory_bytes: 3060
#include <iostream>
#include <map>
using namespace std;
int main()
{
  long s;
  cin >> s;
  long f[1000001] = {};
  f[1] = s;
  long idx = 2;
  map<long, long> m;
  m[f[1]] = 1;
  while (true)
  {
    long val = 0;
    if (f[idx - 1] % 2 == 0)
    {
      val = f[idx - 1] / 2;
    }
    else
    {
      val = 3 * f[idx - 1] + 1;
    }
    f[idx] = val;
    if (m.find(f[idx]) == m.end())
    {
      m[f[idx]] = 1;
    }
    else
    {
      cout << idx << endl;
      return 0;
    }
    idx++;
  }
  return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
//int dp[1000001] = {0};
void solve(){
	string s;
	cin>>s;
	int cnt=0;
	FOR(i, 0, sz(s)/2){
		if(s[i]!=s[sz(s)-i-1]) cnt++;
	}	
	cout<<cnt;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	return 0;
 
}


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

int main(){

	int H, W;
	
	while(1){
		cin >> H >> W;
		if( H == 0 && W == 0)break;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if( (i+j)%2 == 0 ){
	            		cout <<"#";
	        				} else{
	            		cout << "."; 
        }
			}
					cout << endl;
			}
			cout << endl;
		}
		
	
return 0;
}

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

using namespace std;

namespace {

#define VEVE(i, a, b) for (int i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (int i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;

void Solve(ll) {
  string str;
  cin >> str;
  if (SIZE(str) < 26) {
    VEVE(c, 'a', 'z' + 1) if (str.find(c) == string::npos) {
        cout << (str + char(c)) << endl;
        return;
      }
  }
  if (str == "zyxwvutsrqponmlkjihgfedcba") {
    cout << "-1\n";
    return;
  }
  string res(str);
  next_permutation(ALL(res));
  ll i = 0;
  while (str[i] == res[i])
    ++i;
  res.erase(res.begin() + i + 1, res.end());
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 1;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


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


int main () {
	int N, K;
	cin >> N >> K;
	bool has[200] = {false};
	for (int i = 0; i < K; i++) {
		int D;
		cin >> D;
		for (int j = 0; j < D; j++) {
			int snuke;
			cin >> snuke;
			snuke--;
			has[snuke] = true;
		}
	}
	int ans = 0 ;
	for (int i = 0; i < N; i++) {
		if (!has[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3564
// http://www.cplusplus.com/reference/algorithm/next_permutation/

#include<bits/stdc++.h>
using namespace std;
#define oo 1e18

long long n, m, rn, r[100], c[300][300], ans = oo;

int main(){
    cin >> n >> m >> rn;
    for (int i = 0; i < rn; i++) cin >> r[i];
    
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) c[i][j] = oo;
        
    for (int i = 1; i <= n; i++) c[i][i] = 0;
    
    for (int i = 1; i <= m; i++){
        int x, y, w;
        cin >> x >> y >> w;
        c[x][y] = w;
        c[y][x] = w;
    }
    
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
    sort(r, r + rn);        
    do{
        long long sum = 0;
        for (int i = 0; i < rn - 1; i++) sum += c[r[i]][r[i+1]];
        ans = min(ans, sum);
    } while(next_permutation(r, r + rn));
    
    cout << ans;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
#define PI 3.141592653589793
typedef long long ll;
double a,b,h,m;
int main(){
  cin >> a >> b >> h >> m; //a and h, b and m
  h = h * 30 + (m/60)*30;
  m = m * 6;
  double ang = abs(h-m);
  ang = min(ang, (360-ang));
  double radian = ang * (PI / 180.0);
  double dis = sqrt(a*a + b*b -2*a*b*cos(radian));
  cout <<setprecision(20) << dis  <<endl;
  return 0;
}

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

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

  vector<pair<int, int>> pos, neg;
  for (string s: ss) {
    int cnt = 0;
    int min_cnt = 0;
    for (char c: s) {
      if (c == '(') {
        ++cnt;
      } else {
        --cnt;
        min_cnt = min(cnt, min_cnt);
      }
    }
    if (cnt >= 0) {
      pos.push_back(make_pair(min_cnt, cnt));
    } else {
      neg.push_back(make_pair(min_cnt - cnt, -cnt));
    }
  }
  sort(pos.begin(), pos.end());
  reverse(pos.begin(), pos.end());
  int acc1 = 0;
  for (auto p: pos) {
    if (acc1 + p.first < 0) {
      cout<<"No"<<endl;
      return 0;
    }
    acc1 += p.second;
  }
  sort(neg.begin(), neg.end());
  reverse(neg.begin(), neg.end());
  int acc2 = 0;
  for (auto p: neg) {
    if (acc2 + p.first < 0) {
      cout<<"No"<<endl;
      return 0;
    }
    acc2 += p.second;
  }
  if (acc1 == acc2) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 42468
//8 Queens Problem
#include <iostream>

using namespace std;

static const int N = 8;
static const int FREE = -1;
static const int NOT_FREE = 1;

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];
bool X[N][N];

void initialize() {
    for(int i = 0; i < N; i++) {row[i] = FREE; col[i] = FREE;}
    for(int i = 0; i < 2 * N - 1; i++) {dpos[i] = FREE; dneg[i] = FREE;}
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) X[i][j] = false;
    }
}

void printBoard() {
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(X[i][j]) {
                if(row[i] != j) return;
            }
        }
    }

    for(int i = 0; i < N; i++) {
        X[i][row[i]] = true;
        for(int j = 0; j < N; j++) {
            cout << (X[i][j] ? "Q" : ".");
        }
        cout << endl;
    }
}

void recursive(int i) {
    if(i == N) {
        printBoard();
        return;
    }
    for(int j = 0; j < N; j++) {
        if(col[j] == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + (N - 1)] == NOT_FREE) continue;
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = NOT_FREE;
        recursive(i + 1);
        col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = FREE;
    }
}

int main() {
    initialize();

    int k, r, c;
    cin >> k;
    for(int i = 0; i < k; i++) {
        cin >> r >> c;
        X[r][c] = true;
    }

    recursive(0);
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> cnt(N,0);
  cin>>A;
  ll mx=0;
  for(auto &I:A){mx=max(mx,I); cnt[I]++;}
  bool jd=true;
  for(int i=0;2*i<mx;i++){jd&=cnt[i]==0;}
  for(int i=mx/2+1;i<=mx;i++){jd&=cnt[i]>=2;}
  if(mx&1){jd&=cnt[(mx+1)/2]==2;}
  else{jd&=cnt[(mx+1)/2]==1;}  
  cout<<(jd?"Possible":"Impossible")<<endl;
  

  return 0;
}


Measured memory_bytes: 256
fn main() {
    let a = read::<usize>();
    let s = read::<String>();

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


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

typedef long long LL;
typedef long double LD;
typedef string ST;


void aaa( LL x , vector<LL> &S, LL &sl, LL &su)
{
  LL A = S.size();
  LL lbs = lower_bound(S.begin(), S.end(), x) - S.begin();
  //cerr << lbs << endl;

  if (lbs == A) {
    sl = S[lbs-1];
    su = S[lbs-1];
    return;
  }

  if (x == S[lbs]) {
    sl = S[lbs];
    su = S[lbs];
  }
  else if (x < S[lbs]) {
    if (lbs > 0) {
      sl = S[lbs - 1];
      su = S[lbs];
    }
    else {
      sl = S[lbs];
      su = S[lbs];
    }
  }
  else if (x > S[lbs]) {
    if (lbs < A - 1) {
      sl = S[lbs];
      su = S[lbs + 1];
    }
    else {
      sl = S[lbs];
      su = S[lbs];
    }
  }

}


void func()
{

  LL A, B, Q;
  cin >> A >> B >> Q;
  vector<LL> S(A);
  vector<LL> T(B);
  for (LL i = 0; i < A; i++) {
    cin >> S[i];
  }
  for (LL i = 0; i < B; i++) {
    cin >> T[i];
  }
  sort(S.begin(), S.end());
  sort(T.begin(), T.end());

  for (LL i = 0; i < Q; ++i) {
    LL x;
    cin >> x;
    //LL lbt = lower_bound(T.begin(), T.end(), x) - T.begin();
    //LL lbs = *lower_bound(S.begin(), S.end(), x);
    //LL lbt = *lower_bound(T.begin(), T.end(), x);


    LL sl, su;
    LL tl, tu;
    aaa(x, S, sl, su);
    aaa(x, T, tl, tu);
    //cerr << sl << " : " << x << " : " << su << endl;
    //cerr << tl << " : " << x << " : " << tu << endl;

    vector<LL> Costs(8);
    Costs[0] = abs(sl - x) + abs(sl - tl);
    Costs[1] = abs(sl - x) + abs(sl - tu);
    Costs[2] = abs(su - x) + abs(su - tl);
    Costs[3] = abs(su - x) + abs(su - tu);
    Costs[4] = abs(tl - x) + abs(sl - tl);
    Costs[5] = abs(tl - x) + abs(su - tl);
    Costs[6] = abs(tu - x) + abs(su - tu);
    Costs[7] = abs(tu - x) + abs(sl - tu);

    for (auto cost : Costs) {
      //cerr << cost << endl;
    }

    LL cost_min = *min_element(Costs.begin(), Costs.end());
    cout << cost_min << endl;;
  }
  //cout << lbt << endl;
  // cout << ubt << endl;




}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





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


int main(){
    string S;
    cin >> S;
    if(S == "SUN") cout << 7 << endl;
    if(S == "MON") cout << 6 << endl;
    if(S == "TUE") cout << 5 << endl;
    if(S == "WED") cout << 4 << endl;
    if(S == "THU") cout << 3 << endl;
    if(S == "FRI") cout << 2 << endl;
    if(S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	int h,w;
	h=sqrt((x-a)*(x-a));
	w=sqrt((x-b)*(x-b));
	if(h<w) {cout<<"A"<<endl;}
	if(h>w) {cout<<"B"<<endl;}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
m = int(input())
a = list(map(int, input().split()))
for i in range(m):
    num = a[i]
    if x[num-1] + 1 in x:
        continue
    elif x[num-1] == 2019:
        continue
    else:
        x[num-1] += 1
for i in range(n):
    print(x[i])


Measured memory_bytes: 5608
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))
#define PI 3.14159265358979

int int_sort(const void* a,const void* b)
{
	if(*(int*)a > *(int*)b)
	{
		return 1;
	}
	else if(*(int*)a == *(int*)b)
	{
		return 0;
	}
	return -1;
}

int main()
{
	int w,h,n;
	int i,j;
	scanf("%d %d",&w,&h);
	scanf("%d",&n);
	int** list = mem(int*,2);
	int** data = mem(int*,n);
	list[0] = mem(int,n);
	list[1] = mem(int,n);
	for(i = 0;i < n;i++)
	{
		data[i] = mem(int,2);
		scanf("%d %d",&data[i][0],&data[i][1]);
		list[0][i] = data[i][0];
		list[1][i] = data[i][1];
	}
	qsort(list[0],n,sizeof(int),int_sort);
	qsort(list[1],n,sizeof(int),int_sort);
	int a,b,c,d;
	a = list[0][(n-1)/2];
	b = list[1][(n-1)/2];
	c = list[0][n/2];
	d = list[1][n/2];
	long long int time = 0;
	long long int maxtime = 0;
	int maxp = 0;
	for(i = 0;i < n;i++)
	{
		int times[4];
		const int dis[4] = {abs(a-data[i][0]),abs(b-data[i][1]),abs(c-data[i][0]),abs(d-data[i][1])};
		times[0] = dis[0]+dis[1];
		times[1] = dis[0]+dis[3];
		times[2] = dis[2]+dis[1];
		times[3] = dis[2]+dis[3];
		time += times[0];
		for(j = 0;j < 4;j++)
		{
			if(times[j] > maxtime)
			{
				maxtime = times[j];
				maxp = j;
			}
			else if(times[j] == maxtime)
			{
				if(maxp > j)
				{
					maxp = j;
				}
			}
		}
	}
	printf("%lld\n",time*2-maxtime);
	switch(maxp)
	{
		case 0:
			printf("%d %d\n",a,b);
			break;
		case 1:
			printf("%d %d\n",a,d);
			break;
		case 2:
			printf("%d %d\n",c,b);
			break;
		case 3:
			printf("%d %d\n",c,d);
			break;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = (a + b) % 24;
    cout << ans << endl;
    return 0;
}


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

int main()
{
  std::string S;
  std::cin>>S;
  
  const int Red='0';
  const int Blue='1';
  int redCount=0;
  int blueCount=0;
  for(auto i=S.crbegin();i!=S.crend();i++)
  {
    if(*i==Red)
    {
      redCount++;
    }
    else
    {
      blueCount++;
    }
  }
  
  std::cout<<(std::min)(redCount,blueCount)*2<<std::endl;
  
  return 0;
}

Measured memory_bytes: 512
import numpy as np

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = np.zeros(w+1)

for w, v in wv:
    dp[w:] = np.maximum(dp[:-w]+v,dp[w:])
print(int(dp[-1]))

Measured memory_bytes: 29732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    int n,m,x; cin>>n>>m>>x;
    int l=0,r=0;
    rep(i,0,m){
        int y; cin>>y;
        if(y<x) l++;
        else r++;
    }
    cout<<min(l,r)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int a[110];
int main()
{
    int i,j,k,m,n,sum=0;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a+1,a+1+n);
    if(sum%10!=0)
        cout<<sum<<endl;
    else
    {
        for(i=1; i<=n; i++)
        {
            if(a[i]%10!=0)
            {
                cout<<sum-a[i]<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
if A%D==0:
	x=A//D
else:
	x=A//D +1
if C%B==0:
	y=C//B
else:
	y=C//B +1
if y<=x:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9176