akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    LRs = []
    Ls, Rs = [], []
    for _ in range(N):
        L, R = map(int, input().split())
        LRs.append((L, R))
        Ls.append(L)
        Rs.append(R)

    Ls.sort(reverse=True)
    Rs.sort()

    maxL, maxL2 = Ls[:2]
    minR, minR2 = Rs[:2]

    # 1個にする要素を全探索
    ans = 0
    for L, R in LRs:
        num = R-L+1
        A, B = maxL, minR
        if L == maxL:
            A = maxL2
        if R == minR:
            B = minR2
        num += max(0, B-A+1)
        ans = max(ans, num)

    # 区切りを全探索
    LRs.sort(key=lambda x: x[0])

    minR = LRs[0][1]
    accMinRs = [minR]
    for L, R in LRs[1:]:
        minR = min(minR, R)
        accMinRs.append(minR)
    minR = LRs[-1][1]
    accMinRRevs = [minR]
    for L, R in reversed(LRs[:-1]):
        minR = min(minR, R)
        accMinRRevs.append(minR)
    accMinRRevs = accMinRRevs[::-1]

    for i in range(N-1):
        num = max(0, accMinRs[i] - LRs[i][0] + 1)
        num += max(0, accMinRRevs[i+1] - LRs[-1][0] + 1)
        ans = max(ans, num)

    # 区切りを全探索
    LRs.sort(key=lambda x: x[1])

    maxL = LRs[0][0]
    accMaxLs = [maxL]
    for L, R in LRs[1:]:
        maxL = max(maxL, L)
        accMaxLs.append(maxL)
    maxL = LRs[-1][0]
    accMaxLRevs = [maxL]
    for L, R in reversed(LRs[:-1]):
        maxL = max(maxL, L)
        accMaxLRevs.append(maxL)
    accMaxLRevs = accMaxLRevs[::-1]

    for i in range(N-1):
        num = max(0, LRs[0][1] - accMaxLs[i] + 1)
        num += max(0, LRs[i+1][1] - accMaxLRevs[i+1] + 1)
        ans = max(ans, num)

    print(ans)


solve()


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

int n;

int main()
{
	while (scanf("%d", &n), n){
		vector<int> h(n + 1);
		for (int i = 0; i < n + 1; i++){
			scanf("%d", &h[i]);
		}
		
		int res = 0;
		for (int i = 0; i < n + 1; i++){
			vector<int> v = h;
			v.erase(v.begin() + i);
			bool f = true;
			int df = v[1] - v[0];
			for (int j = 1; j < v.size() - 1; j++){
				if (v[j + 1] - v[j] != df){
					f = false;
					break;
				}
			}
			if (f){
				res = h[i];
				break;
			}
		}
		
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <stack>
#include <set>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
    } else {
        int cntC = 0;
        int indexC = -1;
        for (int i = 2; i < s.length() - 1; ++i) {
            if (s[i] == 'C') {
                cntC++;
                indexC = i;
            }
        }
        if (cntC != 1) {
            cout << "WA" << endl;
        } else {
            bool flag = true;
            for (int i = 1; i < s.length(); ++i) {
                if (i == indexC) {
                    continue;
                } else {
                    if (s[i] >= 'a' && s[i] <= 'z') {
                        continue;
                    } else {
                        cout << "WA" << endl;
                        flag = false;
                        break;
                    }
                }
            }
            if (flag)
                cout << "AC" << endl;
        }

    }
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    happiness = [list(map(int, input().split(' '))) for _ in range(N)]
    dp = [[0 for _ in range(3)] for _ in range(N)]
    dp[0] = happiness[0]
    for i in range(1, N):
        for j in range(3):
            dp[i][j] = max([
                dp[i][j],
                happiness[i][j] + dp[i - 1][(j + 1) % 3],
                happiness[i][j] + dp[i - 1][(j + 2) % 3]
            ])
    print(max(dp[N - 1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 47332
use std::cmp::{min, Ordering};
use std::collections::VecDeque;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
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")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let aa = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut x = aa
        .iter()
        .enumerate()
        .map(|(a, &b)| (b, a))
        .collect::<Vec<_>>();
    x.sort();

    let mut space = false;
    for (b, a) in x {
        if space {
            print!(" ");
        }

        print!("{}", a + 1);
        space = true;
    }
}


Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pii pair<int, int>
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = (1 << 26) + 10;
string s;
int n, ans, a[N];
int main()
{
	cin >> s;
	n = s.size();
	s = " " + s;
	int now = 0;
	a[0] = 1;
	ans = 2e9;
	rep(i, 1, n)
	{
		now = now ^ (1 << (s[i] - 'a'));
		int tmp = 2e9;
		if(a[now]) tmp = a[now];
		rep(j, 0, 25)
		{
			int ret = now ^ (1 << j);
			if(a[ret]) tmp = min(tmp, a[ret]);
		}
		if(i == n) ans = tmp + 1;
		if(!a[now]) a[now] = tmp + 1;
		else a[now] = min(a[now], tmp + 1);
	}
	cout << ans - 1;
	return 0;
}

Measured memory_bytes: 262464
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    string n;cin>>n;
    if(n[0]==n[1]&&n[1]==n[2]){
        cout<<"Yes"<<endl;
    }else if(n[1]==n[2] && n[2]==n[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import math

N, M = [int(_) for _ in input().split()]


sr = int(math.sqrt(M))

result = 1

for i in range(sr, 0, -1):
    if M % i == 0:
        r = i
        if M >= N * r:
            result = max(r, result)
        r = M // i
        if i >= N:
            result = max(r, result)

print(result)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  int N;
  in(N);
  map<int,int>m;
  rep(i,N-1){
    int A;
    in(A);
    m[--A]++;
  }
  vector<int>c(N);
  for(auto e:m){
    c[e.first]=e.second;
  }
  outol(c);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int k, n, m;
int a[200000];

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

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

	m = k - a[n - 1] + a[0];

	for (int i = 1; i < n; i++)
		m = max(m, a[i] - a[i - 1]);

	cout << k - m << endl;
}


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

int main(){
  int K,X;
  cin >> K >> X;
  for(int i=X-K+1;i<X+K;i++){
    if (i==X+K-1)
      cout << i << endl;
    else
      cout << i << " ";
    
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll K,A,B; cin>>K>>A>>B;
    
    if(B-A<=2) cout<<K+1<<endl;
    else{
        ll rem=K; //のこり回数
        ll now=1;
        if(A-1<K){
            rem-=(A-1);
            now=A;
        }
        else{
            cout<<K+1<<endl;
            return 0;
        }
        
        now+=(rem/2)*(B-A);
        now+=rem%2;
        
        cout<<now<<endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,tienle;
	cin>> n;
	if (n%1000==0){tienle=0;
	}
	else tienle=1000-(n%1000) ;
	cout<< tienle << endl ;
	
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll tx; tx=1; while(tx--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll n,m;
        cin>>n>>m;
        n>m ? cout<<"safe\n" : cout<<"unsafe\n";
    }
	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
class Bitter_Alchemy
{
public:
    int solve(vector<int>&v,int n,int k)
    {
        sort(v.begin(),v.end());
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(k>=v[i])
            {
                k-=v[i];
                cnt++;
            }
        }
        if(k>=v[0])
        {
            cnt+=k/v[0];
        }
        return cnt;
    }
};
int main()
{
    vector<int>v;
    int n,k;
    scanf("%d %d",&n,&k);
    int x;
    Bitter_Alchemy B;
    for(int i=0;i<n;i++)
        {scanf("%d",&x);v.push_back(x);}
    cout<<B.solve(v,n,k)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,tot[19][19][1<<18];
ll a[1<<18],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		double x;scanf("%lf",&x);
		a[i]=x*1e9+.5;
	}
	for(int i=0;i<=18;i++)
		for(int j=0;j<=18;j++){
			ll v=powl(2,i)*powl(5,j)+.5;
			for(int k=1;k<=n;k++)tot[i][j][k]=tot[i][j][k-1]+(a[k]%v==0);
		}
	for(int i=1;i<=n;i++){
		ll x=1e18,v=x/__gcd(x,a[i]),k=1,t=0;
		for(;t<18 && v%(k*2)==0;k*=2,t++);
		k=1;ll t5=0;
		for(;t5<18 && v%(k*5)==0;k*=5,t5++);
		ans+=tot[t][t5][i-1];
	}
	printf("%lld\n",ans);
	return 0;
}

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

const int MAX=510000;
const int MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

ll COM(int n,int k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  COMinit();
  int n;
  cin>>n;
  int seen[n+1]={};
  int x;
  int vec[n+1];
  for(int i=0;i<n+1;i++){
    cin>>vec[i];
    seen[vec[i]]++;
    if(seen[vec[i]]==2){
      x=vec[i];
    }
  }
  int p=-100,q=-100;
  for(int i=0;i<n+1;i++){
    if(vec[i]==x){
      if(p==-100){
        p=i;
      }
      else{
        q=i;
      }
    }
  }
  int z=p+n-q;
  for(int i=1;i<=n+1;i++){
    if(i==1){
      cout<<n<<endl;
      continue;
    }
    if(i>z+1){
      cout<<COM(n+1,i)<<endl;
      continue;
    }
    ll q=COM(n+1,i)-COM(z,i-1);
    while(q<0){
      q+=MOD;
    }
    cout<<q%MOD<<endl;
  }
}

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
s = input()


if s[-1] =='<':
  s = s+'>'
  
if s[0] =='>':
  s = '<'+s

n = len(s)+1


def rui(n):
  return n*(n+1)//2
  

tani = []
yama = []

if s[0] =='<':
  tani.append(0)
elif s[0] =='>':
  yama.append(0)


for i in range(n-1):
  if s[i:i+2] =='><':
    tani.append(i+1)
  elif s[i:i+2] =='<>':
    yama.append(i+1)
    
if s[-1] =='>':
  tani.append(n-1)
elif s[-1] =='<':
  yama.append(n-1) 


count = 0
for i in range(len(yama)):
  d1 = yama[i]-tani[i]
  d2 = tani[i+1]- yama[i]
  count += rui(max(d1,d2)) + rui(min(d1,d2)-1)
  
print(count)
  

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


int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<vector<int> > map(21,vector<int>(21,0));
    for(int i = 0;i < n;i++){
      int x,y;
      cin >> x >> y;
      map[x][y] = 1;
    }
    int m;
    cin >> m;
    pair<int,int> current(10,10);
    for(int i = 0;i < m;i++){
      string d;
      int l;
      cin >> d >> l;
      if(d == "N"){
	for(int i = 0; i < l;i++){
	  current.second++;
	  map[current.first][current.second] = 0;
	}
      }else if(d == "S"){
	for(int i = 0; i < l;i++){
	  current.second--;
	  map[current.first][current.second] = 0;
	}
      }else if(d == "W"){
	for(int i = 0; i < l;i++){
	  current.first--;
	  map[current.first][current.second] = 0;
	}
      }else if(d == "E"){
	for(int i = 0; i < l;i++){
	  current.first++;
	  map[current.first][current.second] = 0;
	}
	
      }

    }
    int flag = 0;
    for(int i = 0;i <= 20;i++){
      for(int j = 0;j <= 20;j++){
	if(map[i][j] == 1) {
	  cout << "No" << endl;
	  flag = 1;
	  break;
	}
      }
      if(flag == 1)break;
    }
    if(flag == 0)cout << "Yes" << endl;
  }
  return 0;
}

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

int main(void){
  int n;
  cin >> n;
  
  long long a = 2;
  long long b = 1;
  long long l = 0;
  
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  
  for(int i = 2; i <= n; i++){
    l = b + a;
    a = b;
    b = l;
  }
  
  cout << l << endl;
  return 0;
     
}

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

signed main() {
    int ans;
    string s, t;
    
    cin >> s >> t;
    ans = 0;
    for ( int i = 0; i < 3; i++ ) {
        if ( s[i] == t[i] ) {
            ans ++;
        }
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3564
n = int(input())
tmp = list(map(int, input().split()))

arr = [tmp[0]]

for i in range(1, n):
    if arr[-1] != tmp[i]:
        arr.append(tmp[i])

m, s = 1000, 0
for i in range(1, len(arr)):
    if arr[i - 1] < arr[i]:
        s += m // arr[i - 1]
        m -= m // arr[i - 1] * arr[i - 1]
        m += s * arr[i]
        s = 0

print(m)

Measured memory_bytes: 9188
#!/usr/bin/python
# coding: UTF-8
n,m = map(int,input().split())

res = [0 for _ in range(m)]

for i in range(n):
  for j in list(map(int,input().split()))[1:]:
    res[j-1] += 1

print(sum([res[i]==n for i in range(m)]))

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		while(n-- > 0){
			Card[] card = new Card[9];
			int[] num = new int[9];
			for(int i=0;i<9;i++) num[i] = sc.nextInt();
			for(int i=0;i<9;i++) card[i] = new Card(num[i],sc.next());

			boolean[] flg = new boolean[9];

			System.out.println(judge(card,flg,9)?1:0);
		}
	}

	public static boolean judge(Card[] card,boolean[] flg,int rem){
		if(rem == 0) return true;

		for(int i=0;i<7;i++){
			for(int j=i+1;j<8;j++){
				for(int k=j+1;k<9;k++){
					if(!flg[i] && !flg[j] && !flg[k] &&
						 Card.isSet(card[i],card[j],card[k])){
						flg[i] = flg[j] = flg[k] = true;
						if(judge(card,flg,rem-3)) return true;
						flg[i] = flg[j] = flg[k] = false;
					}
				}
			}
		}

		return false;
	}
}

class Card{
	int num;
	String color;

	Card(int num,String color){
		this.num = num;
		this.color = color;
	}

	static boolean isSet(Card a,Card b,Card c){
		return
			a.color.equals(b.color) && a.color.equals(c.color) &&
			(a.num == b.num && a.num == c.num || 
			 a.num == b.num-1 && a.num == c.num-2 ||
			 a.num == c.num-1 && a.num == b.num-2 ||
			 b.num == a.num-1 && b.num == c.num-2 ||
			 b.num == c.num-1 && b.num == a.num-2 ||
			 c.num == a.num-1 && c.num == b.num-2 ||
			 c.num == b.num-1 && c.num == a.num-2
			 );
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	veci d(n);
	rep(i, n) cin >> d[i];
	sort(all(d));
	cout << d[n / 2] - d[n / 2 - 1] << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a + b >= 10){
            System.out.println("error");
        }else{
            System.out.println(a + b);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x -= (x / b) * b;
    cout << x;
    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int comp(const void *p1,const void *p2);

int main(void){
	int k,t,i,*cakes;
	int first,second;
	int tmp,next;

	scanf("%d %d",&k,&t);
	cakes=(int *)calloc(t,sizeof(int));
	for(i=0;i<t;i++){
		scanf("%d",&cakes[i]);
	}
	qsort(cakes,t,sizeof(int),comp);
	
	first=0;
	second=1;
	next=2;
	
	//printf("%d\n",cakes[0]);
	while(first<t && second<t){
		tmp=cakes[first]-cakes[second];
		if(tmp>0){
			cakes[first]-=cakes[second];
			cakes[second]=0;
			second=next++;
		}else if(tmp==0){
			cakes[first]=0;
			for(;cakes[next]==cakes[second];next++){
				cakes[next]=0;
			}
			cakes[second]=0;
			first=next++;
			second=next++;
		}else{
			cakes[second]-=cakes[first];
			cakes[first]=0;
			first=next++;
		}
		//printf("next::%d\n",next);
	}
	if(first==t && second<t){
		printf("%d\n",cakes[second]-1);
	}else if(second==t && first<t){
		printf("%d\n",cakes[first]-1);
	}else{
		printf("%d\n",0);
	}
	free(cakes);
	return 0;
}

int comp(const void *p1,const void *p2){
	int n1,n2;
	n1=*((const int *)p1);
	n2=*((const int *)p2);
	return n2-n1;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>


int main(){
    int S;
    int W;

    scanf("%d %d", &S, &W);

    if(S <= W){
        printf("unsafe");
        return 0;
    }else{
        printf("safe");
        return 0;
    }

    return 0;
}


Measured memory_bytes: 1688
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Fri Mar 23 21:12:19 2018
//
package main

import (
	"fmt"
)

var N, W int

type item struct {
	v, w int
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&N, &W)

	items := make([]item, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&items[i].v, &items[i].w)
	}

	dp := make([][]int, N+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
	}

	for i := range items {
		v := items[i].v
		w := items[i].w
		for j := 0; j <= W; j++ {
			s := 0
			if 0 <= j-w {
				s = dp[i+1][j-w] + v
			}
			dp[i+1][j] = max(dp[i][j], s)
		}
	}

	m := 0
	for i := range dp[N] {
		m = max(m, dp[N][i])
	}

	fmt.Println(m)
}



Measured memory_bytes: 9688
#include<stdio.h>
#define N 100

int main(void){

  int A[N], n, i, j, minj, c=0, x;

  scanf("%d",&n);

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

  for(i = 0; i < n; i++){

    minj = i;

    for(j = i; j < n; j++){
      
      if(A[j] < A[minj]){
	
	minj = j;
      }
    }
    if(minj != i) c++;
    x = A[i];
    A[i] = A[minj];
    A[minj] = x;
  }
  
  for(i=0;i<n;i++){
    
    printf("%d",A[i]);
    if(i != n-1) printf(" ");
  }

  printf("\n%d\n",c);
  return 0;
}



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

int main() {
    int N, D, A;
    A = 0;
    double X, Y, Z;
    cin >> N >> D;

    for (int i = 0; i < N; i++) {
        cin >> X >> Y;
        Z = sqrt(X * X + Y * Y);
        if (Z <= D) {
            A++;
        }
        else{}
    }

    cout << A << endl;
}

Measured memory_bytes: 3748
#include <cstdio>
#include <cstdint>

template <typename T>
T gcd(T a, T b) {
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int n;
int64_t ans = 1, a;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a);
        ans = lcm(ans, a);
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 128
/*input
5 2 3
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	if (a % 2 == b % 2)
		cout << (b - a + 1) / 2 << "\n";
	else
	{
		ll d = min((a - 1) + (b - 1), (n - b) + (n - a));
		cout << (d + 1) / 2 << "\n";
	}
}

Measured memory_bytes: 764
n, m = map(int, input().split())

if n == 1 or m == 1:
    if n == 1 and m == 1:
        print(1)
        exit(0)
    else:
        mx = max([n, m])
        print(mx - 2)
        exit(0)
val = (n - 2) * (m-2)
print(val)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
	int n,k;
	cin>>n>>k;
	int a[n+5];
	for(int i=1; i<=n; i++) cin>>a[i];
	int dp[n+5][k+5]; //nth element k used
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	for(int i=1; i<=n; i++){
		int sm=0;
		for(int j=0; j<=k; j++){
			if(j<=a[i]) sm+=dp[i-1][j];
			else {
				sm-=dp[i-1][j-a[i]-1];
				sm+=dp[i-1][j];
			}
			sm %= MOD;
			if(sm < 0) sm+=MOD;
			dp[i][j] = sm;
		}
	}
	cout<<dp[n][k];
}

Measured memory_bytes: 41216
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		boolean b = true;
		for (int i = 0; i<t; i++) {
			a[i] = sc.nextInt();
			if (a[i]%2 == 0) {
				if (a[i] % 3 == 0 || a[i] % 5 == 0) {
					b = true;
				}
				else {
					b = false;
					break;
				}
			}

		}

		System.out.println (b ? "APPROVED" : "DENIED");
	}
}


Measured memory_bytes: 35836
#include <cstdio>
#include <algorithm>
using namespace std;
long long int knapsack[51][3000]={};
long long int ans=0;
int main(){
	int n,a,t;
	knapsack[0][0]=1;
	scanf("%d %d",&n,&a);
	for(int i=1;i<=n;i++){
		scanf("%d",&t);
		for(int k=i-1;k>=0;k--){
			for(int j=2500;j>=t;j--){
				knapsack[k+1][j]+=knapsack[k][j-t];
			}
		}
	}
	for(int i=1;i<=n;i++)
		ans+=knapsack[i][a*i];
	printf("%lld",ans);
}

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

ll n,t,porche=0,porbe=0,p,tot=0;

vector<ll>v;

int main()
{
    scanf("%lld %lld",&n,&t);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&p);

        if((p+t)>porbe && p<=porbe)
        {
            tot+=p+t-porbe;
            porbe=p+t;
        }

        else if((p+t)>porbe && p>porbe)
        {
            tot+=t;
            porbe=p+t;
        }

    }
    cout<<tot<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin>>a[i];

  int ans = 1e9+1;
  for(int i=-100;i<=100;++i){
    int tmp=0;
    for(int j=0;j<n;++j){
      tmp += (a[j]-i) * (a[j]-i);
    }
    ans = min(tmp,ans);
  }
  cout<<ans<<endl;
}

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

int main(){
    int N,M,X;
    cin>>N>>M>>X;
    
    int C[N],A[N][M];
    rep(i,N){
        cin>>C[i];
        rep(j,M){
            cin>>A[i][j];
        }
    }
    int ans=100000000;
    rep(bit,(1<<N)){
        int Csum=0;
        vector<int> Asum(M,0);
        bool ok=true;
        rep(j,N){
            if((bit>>j)&1){
                Csum+=C[j];
                rep(k,M){
                    Asum[k]+=A[j][k];
                }
            }
        }
        rep(i,M){
            if(Asum[i]<X){
                ok=false;
                break;
            }
        }
        if(ok==true){
            ans=min(ans,Csum);
        }
    }
    if(ans==100000000){
        ans=-1;
    }

    cout<<ans<<endl;
    }
    
    
    
    
    
  
 
 




Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#define N 10
int main(int argc, const char * argv[])
{
    for(int i=1; i<N; i++){
        for(int j=1; j<N; j++){
            printf("%dx%d=%d\n",i,j,i*j);
        }
    }

}

Measured memory_bytes: 1096
N = int(input())
list_1 = [[0,0,0]]
for i in range(N):
    list_1.append([int(i) for i in input().split()])

flag = True
for i in range(N):
    delta_t = list_1[i+1][0]-list_1[i][0]
    delta_x = list_1[i+1][1]-list_1[i][1]
    delta_y = list_1[i+1][2]-list_1[i][2]
    delta_move = delta_x + delta_y
    if delta_t < delta_move or delta_t%2 != delta_move%2:
        flag = False
        break
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 998244353
#define MOD 1000000007
signed main()
{
    SPEED;
    double pi=6.28318530717958623200;
    int n;
    cin>>n;
    cout<<fixed<<setprecision(10)<<n*pi;
}

Measured memory_bytes: 3800
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll ans;

void dfs(string s){
    ll sum = 0;
    ll d = 1;
    REP(i,0,s.size()){
        sum += (s[s.size()-1-i] - '0') * d;
        d *= 10;
    }

    if(sum > N){
        return;
    }

    set<char> st;
    REP(i,0,s.size()){
        st.insert(s[i]);
    }
    if(st.size() == 3){
        ans++;
    }

    dfs(s + "7");
    dfs(s + "5");
    dfs(s + "3");
}

int main() {
    cin>>N;

    dfs("");

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int  d[100000];
    for(int i=0; i<N; i++)
    {
        cin >> d[i];
    }
    sort(d, d+N);
    cout << d[N/2] - d[N/2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
vl A,B;
ll gyaku(ll a) {
	ll bb = 1;
	ll beki[40];
	beki[0] = a;
	ll kk = MOD - 2;
	rep(i, 35) {
		beki[i + 1] = (beki[i] * beki[i]) % MOD;
	}
	for (ll i = 0; kk > 0; i++) {
		if (kk % 2 == 1)bb = (bb * beki[i]) % MOD;
		kk = kk / 2;
	}

	return bb;
}
ll nck(ll m, ll n) {
	vl kaijo(2000000);
	kaijo[0] = 1;
	rep(i, 1000010) {
		kaijo[i + 1] = (kaijo[i] * (i + 1)) % MOD;
	}
	return (kaijo[m] * gyaku((kaijo[m - n] * kaijo[n])%MOD)) % MOD;
}

int main() {
	cin >> a >> b;
	if ((a + b) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	t = (a + b) / 3;
	x = a - t;
	y = b - t;
	if (x < 0 || y < 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << nck(x + y, x) << endl;
}

Measured memory_bytes: 15872
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(min((double)1.0, max((double)-1.0, cosine)));
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		double now_length = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa - now_min >= eps || (abs(goa - now_min) <= eps && (abs(a[i] - a[starter]) - now_length) >= eps)) {
					now_min = goa;
					now_go = i;
					now_length = abs(a[i] - a[starter]);
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	int a, b;
	cin >> a >> b;
	int now = 1;
	int cnt = 0;
	while (now < b) {
		now += a - 1;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod;    }
ll add(ll a, ll b)  { return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;
	ll a,b,k;
	cin>>a>>b>>k;

	ll x = min(k,a);
	ll ans1 = a-x;
	ll ans2 = b-min(k-x,b);

	cout<<ans1<<" "<<ans2;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

map<int, string> mp;
long long f[110][5][5][5];
const long long mod = 1e9 + 7;

bool check(int a, int b, int c, int d) {
    if (mp[a] + mp[b] + mp[c] == "AGC") return 0;
    if (mp[a] + mp[c] + mp[b] == "AGC") return 0;
    if (mp[a] + mp[b] + mp[d] == "AGC") return 0;
    if (mp[a] + mp[c] + mp[d] == "AGC") return 0;
    if (mp[b] + mp[a] + mp[c] == "AGC") return 0;
    if (mp[b] + mp[c] + mp[d] == "AGC") return 0;
    if (mp[b] + mp[d] + mp[c] == "AGC") return 0;
    if (mp[c] + mp[b] + mp[d] == "AGC") return 0;
    return 1;
}

int main() {
    int n;
    scanf("%d", &n);
    f[0][0][0][0] = 1;
    mp[0] = 'E', mp[1] = 'A', mp[2] = 'C', mp[3] = 'G', mp[4] = 'T';
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= 4; j++) 
            for (int a = 0; a <= 4; a++)
                for (int b = 0; b <= 4; b++)
                    for (int l = 0; l <= 4; l++)
                        if (check(l, b, a, j)) 
                            f[i][j][a][b] = (f[i][j][a][b] + f[i-1][a][b][l]) % mod;
    long long ans = 0;
    for (int i = 1; i <= 4; i++) 
        for (int j = 1; j <= 4; j++)
            for (int k = 1; k <= 4; k++)
                ans = (ans + f[n][i][j][k]) % mod;
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

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

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

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

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

#if 1


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

  int N;
  cin >> N;
  vector<int> as(N+1);
  FOR(i, 1, N+1) {
    cin >> as[i];
  }
  vector<int> rs(N+1);
  int cnt = 0;
  RFO(i, 1, N+1) {
    int n = 0;
    for (int j = i * 2; j <= N; j += i) {
      n += rs[j];
    }
    if ((n ^ as[i]) & 1) {
      rs[i] = 1;
      cnt++;
    }
  }

  cout << cnt << newl;
  FOR(i, 1, N + 1) {
    if (rs[i]) cout << i << ' ';
  }
}
#endif


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

using namespace std;

#define ull unsigned long long int
#define ll long long int 

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")


int vec[900006];

int main(){

   ios::sync_with_stdio(0);
   cin.tie(0);

   int a,b;
   cin >> a >> b;
   int ans = 9999999;
   bool tag = false;
   for(int i = 100000; i>=0; i--){
       if(int (i*.08) == a){
           if( int(i*.1) == b){
              ans = min(ans,i);
              tag = true;
           }
       }
       if(int (i*.08) == b){
           if( int(i*.1) == a){
              ans = min(ans,i);
              tag = true;
           }
       }
   }
   if(!tag) cout << "-1" << endl;
   else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())


def ball(b):
    global A
    for c in range(3):
        for co in range(3):
            if A[c][co] == b:
                A[c][co] = "ok"


for c in range(N):
    b = int(input())
    ball(b)


if A[0].count("ok") == 3 or A[1].count("ok") == 3 or A[2].count("ok") == 3:
    print("Yes")
elif A[0][0] == "ok" and A[1][0] == "ok" and A[2][0] == "ok":
    print("Yes")
elif A[0][1] == "ok" and A[1][1] == "ok" and A[2][1] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][2] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][0] == "ok" and A[1][1] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][1] == "ok" and A[2][0] == "ok":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9156
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;

class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                int a,b;
                a = sc.nextInt();
                b = sc.nextInt();
               
                if((a*b)%2==0){
                       System.out.print("Even");
                }else{
                        System.out.print("Odd");
                }
        }
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> num(n, -1);
    for(int i = 0; i < m; ++i)
    {
        int s,c;
        cin >> s >> c;
        s = n-s;
        if(num[s] == -1
        || num[s] == c)
        {
            num[s] = c;
        }
        else
        {
            num[s] = -2;
        }
    }
    if(num[n-1] == -1 && n>1)
    {
        num[n-1] = 1;
    }
    int ans = 0;
    for(int i = n-1; i >= 0; --i)
    {
        if(n > 1
        && i == n-1
        && num[i] == 0)
        {
            ans = -1;
            break;
        }
        if(num[i] == -1)
        {
            num[i] = 0;
        }
        else if(num[i] == -2)
        {
            ans = -1;
            break;
        }
        ans = (ans*10)+num[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,n,count;
	char a[21],b[21];
	scanf("%s",b);
	scanf("%d",&n);
	for(i=0,count=0;i<n;i++){
		scanf("%s",a);
		for(j=0;j<10;j++) {
			a[j+10]=a[j];
		}
		a[j+10]='\0'; 
		if(strstr(a,b)!=0) count++;   }
	printf("%d\n",count);
	scanf("%d",&i);
	return 0; 
} 

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

int main()
{
    string s;
    //cout<<"please enter a string \n";
    cin >> s;
    for (int i = 0; i < s.size() ; i++)
    {
        if (s[i] == ',')
            s[i] = ' ';
    }



    cout << s;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int cnt[4];
int main(){
	REP(i,3){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		cnt[a]++;
		cnt[b]++;
	}
	bool flg=true;
	REP(i,4){
		if(cnt[i]>=3){
			flg=false;
		}
	}
	cout<<(flg ? "YES" : "NO")<<endl;
}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
l = [0,0,W,0,H]
for i in range(N):
  x,y,a = map(int,input().split())
  if a%2 == 1:
    l[a] = max(l[a],[x,y][(a-1)//2])
  else:
    l[a] = min(l[a],[x,y][(a-2)//2])
ans = (l[2]-l[1])*(l[4]-l[3])    
if (l[2]-l[1]) <= 0 or (l[4]-l[3]) <= 0:
  print(0)
else:  
  print(ans)    

Measured memory_bytes: 3192
// 

// g++ -std=c++11 abc145_c.cc && ./a.out 
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string S;
    cin >> S;
    int i;

    if (S.length() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    bool is_hitachi = true;
    for (i = 0; i < S.length(); i += 2) {
        if (S[i] != 'h') {
            is_hitachi = false;
            break;
        }
    }
    for (i = 1; i < S.length(); i += 2) {
        if (S[i] != 'i') {
            is_hitachi = false;
            break;
        }
    }
    if (is_hitachi) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    

    return 0;
}


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

int main() {
  int A,B,C,D;

  cin >> A >> B >> C >> D;
  if (A+B < C+D ){
  cout << "Right" << endl;
  }
  else if(A+B > C+D){
    cout << "Left" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll inf = 1000000001;

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

    int n; cin>>n;
    vector<double>d;
    rep(i,n){
        double a; cin>>a;
        d.push_back(a);
    }
    sort(all(d));
    
    cout << d[n/2] - d[n/2-1] << ln;
}

Measured memory_bytes: 1400
def main():
    N = int(input())
    C = list(map(int, input().split()))
    C.sort()
    mod = 10 ** 9 + 7
    r = 0
    n = N
    i = 0
    for c in C:
        if n == 1:
            r = (r + c * pow(2, N - 1, mod)) % mod
        else:
            r = (r + c * (n + 1)* pow(2, n - 2, mod) * pow(2, N - n, mod)) % mod
        n -= 1
    return 2**N * r % mod

print(main())


Measured memory_bytes: 26024
H, W = map(int, input().split())
S = [list(map(str, input().split())) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == 'snuke':
            res1 = i + 1
            res2 = j
            break
            
print(chr(ord('A') + res2) + str(res1))

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


int main(){
  int64_t N,K,ans=0;
  cin >> N >> K;
  vector<int64_t> H(N);
  for(int64_t i=0;i<N;i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  for(int64_t i=0;i<N-K;i++){
    ans+=H.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const vector<int> AccumulateACNums(const string &S)
{
    vector<int> ACNums{ 0 };
    int ACNum = 0;
    for (int i = 1, n = static_cast<int>(S.size()); i < n; ++i)
    {
        if (S[i - 1] == 'A' && S[i] == 'C') ++ACNum;
        ACNums.push_back(ACNum);
    }
    return ACNums;
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> Ls(Q), Rs(Q);
    for (int i = 0; i < Q; ++i)
    {
        cin >> Ls[i] >> Rs[i];
    }

    const auto ACNums = AccumulateACNums(S);
    for (int i = 0; i < Q; ++i)
    {
        cout << ACNums[Rs[i] - 1] - ACNums[Ls[i] - 1] << endl;
    }
}

Measured memory_bytes: 2296