akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static int n;
	static int[] A;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    n=gi();
	    A=new int[n];
	    for(int i=0; i<n;i++) {
	    	A[i]=gi();
	    }

	    int a=g(0, n-1, 0);
//	    if (s>x) {
//	    	System.out.println(n-1);
//	    } else {
//	    	Arrays.parallelSort(a);
//
//	    	System.out.println(c);
//	    }
	    System.out.println(a);
	}

	public static int g(int l, int r, int m) {
        if(r-l<1) return m;
		int l1=l;
		int r1=Math.floorDiv((l+r),2);
		int l2=r1+1;
		int r2=r;
		int u1=f(l1, r1, m);
		int u2=f(l2, r2, m);
		if(u1>u2) {
			return g(l2, r2, u1);
		} else if(u1<u2) {
			return g(l1, r1, u2);
		} else {
			return u1;
		}
	}

	public static int f(int l, int r, int m) {
		int u=A[l];
		for(int i=l+1; i<=r;i++) {
			u=uclid(u,A[i]);
		}
		if(m!=0) {
			u=uclid(u,m);
		}

		return u;
	}

	// ユークリッドの互除法
    public static int uclid(int m, int n) {
    	if (m<n) {
			m^=n;
			n^=m;
			m^=n;
		}

		while(true) {
			int t=m%n;
			if (t==0) {
				return n;
			} else {
				m=n;
				n=t;
			}
		}
    }


	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 59116
import java.util.Arrays;
import java.util.Scanner;

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

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			dif[i] = a[i] - i - 1;
		}
		Arrays.sort(dif);
		long median = 0;

		if (N == 1) {
			System.out.println(0);
			return;
		}

		if (N%2 != 0) {
			median = dif[(N-1)/2];
		} else {
			median = (dif[N/2 - 1] + dif[N/2])/2;
		}

		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += Math.abs(dif[i] - median);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 85444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x;
    cin>>n>>x;
    
        long long t=x,sum=n;
        x=min(t,n-t);
        long long y=max(t,n-t);
        while(x>=1)
        {
            if(y%x==0)
            {
                sum+=(y/x)*2*x;
                sum-=x;
                break;
            }
            else{             
               sum+=(y/x)*2*x;
               long long te=x;
               x=y%x;
               y=te;
            }
        }
        cout<<sum<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define sit set<int>::iterator
using namespace std;
const int N=1e6+6;
int a[N],d[N],ans[N];
bool vis[N];
set<int> s;
int main(){
    int n; cin>>n;
    rep(i,1,n) scanf("%d",&a[i]),++d[a[i]];
    rep(i,1,n) s.insert(i);
    rep(i,1,n-3){
        for (sit it=s.begin();it!=s.end();++it)
            if (*it!=a[ans[i-1]]&&(vis[a[*it]]||d[a[*it]]!=n-i)){
                ans[i]=*it; break;
            }
        if (!ans[i]){ cout<<-1<<endl; return 0; }
        vis[ans[i]]=true,--d[a[ans[i]]],s.erase(ans[i]);
    }
    int t=0,b[10];
    rep(i,1,n) if (!vis[i]) b[++t]=i;
    do{
        rep(i,1,t) ans[max(n-3,0)+i]=b[i];
        bool f=false;
        rep(i,max(n-3,0)+1,n)
            if (ans[i]==a[ans[i-1]]){ f=true; break; }
        if (!f){
            rep(i,1,n) printf("%d ",ans[i]);
            return 0;
        }
    }while (next_permutation(b+1,b+1+t));
    cout<<-1<<endl;
    return 0;
}
/*
4
1
*/


Measured memory_bytes: 10112
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k, m, i, ind, s, j, ans;
    vector<int>data;
    while(cin >> n >> k >> m){
        if(n == 0 && k == 0 && m == 0)break;
        for(i = 1; i <= n; i++)data.push_back(i);
        ind = m - 1;
        if(k == 1){
            if(m == 1)ans = n;
            else{
                ans = m-1;
            }
        }
        else{
            while(n > 1){
                data.erase(data.begin()+ind);
                n--;
                for(j = 1; j < k; j++){
                    ind++;
                    if(ind >= n)ind = ind - n;
                }
            }
            ans = data.at(0);
        }
        cout << ans << endl;
        data.erase(data.begin(), data.end());
    }
    return 0;
}

Measured memory_bytes: 1324
use std::collections::BTreeMap;
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let a: Vec<u32> = parse_line().unwrap();
    let mut map: BTreeMap<u32, usize> = BTreeMap::new();

    for &ai in &a {
        map.entry(ai).and_modify(|x| *x += 1).or_insert(1);
    }

    let ans = map
        .values()
        .filter(|&&x| x >= 2)
        .fold(0, |x, &y| x + y * (y - 1) / 2);

    for &ai in &a {
        let diff;
        match map.get(&ai).unwrap() {
            0 | 1 => diff = 0,
            2 => diff = 1,
            &e @ _ => diff = (e * (e - 1) / 2) - ((e - 1) * (e - 2) / 2),
        }
        println!("{}", ans - diff);
    }
}


Measured memory_bytes: 5640
//https://blog.csdn.net/hesorchen
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
int main()
{
    string a, b;
    int c, d;
    string e;
    cin >> a >> b >> c >> d >> e;
    if (a == e)
    {
        cout << c - 1 << ' ' << d << endl;
    }
    else if (b == e)
        cout << c << " " << d - 1 << endl;
    else
        cout << c << " " << d << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	int X, Y;
	cin >> X >> Y;
	int ans = 0;
	ans += max(0LL, 4 - X) * 100000;
	ans += max(0LL, 4 - Y) * 100000;
	if (X == 1 && Y == 1)
		ans += 400000;
	cout << ans << endl;
	return 0;
}

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


def main():
    n = int(si())
    l = [int(e) for e in si().split()]
    prv, ans = l[0], 0
    for e in l:
        if prv > e:
            ans += prv-e
        else:
            prv = e
    print(ans)


if __name__ == '__main__':
    main()


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define fst first
#define snd second
#define pb push_back
#define mp(x,y) make_pair((x),(y))

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    int X, Y;

    cin >>  X >> Y;


    // vector<int> As(N);
    // vector<int> Bs(N);
    // REP(i, N) {
    //     cin >> As.at(i) >> Bs.at(i);
    // }

    // aつる bかめ
    bool flag = false;
    FORE(a, 0, 100) {
        FORE(b, 0, 100) {
            if ((a + b == X) && (2 * a + 4 * b == Y)) {
                flag = true;
                break;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    string s;cin>>s;
    int n=SIZE(s);

    REP(i,n){
        for(int j=1;j<3 && i+j<n;j++){
            if(s[i] == s[i+j]){
                //dump(s[i])
                //dump(s[i+j])
                cout << i+1 <<" "<<i+j+1<<endl;
                return;
            }
        }
    }
    cout << -1 << " " << -1 << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 512
a,b = map(int,input().split())

if a <= 0 and b >= 0:
    print('Zero')
    exit()

if a > 0 and b > 0:
    print('Positive')
    exit()

d = b - a
if d % 2 == 0:
    print('Negative')
else:
    print('Positive')




Measured memory_bytes: 9068
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readString() -> String {
    return readLine()!
}

func readLines(times: Int) -> [String] {
    var array = [String]()
    for _ in 0..<times {
        array.append(readLine()!)
    }
    return array
}

func readSeparatedStrings() -> [String] {
    return readLine()!.split(separator: " ").map {String($0)}
}

func readStringToStrings() -> [String] {
    return readLine()!.map{String($0)}
}

func readSeparatedInts() -> [Int] {
    return readLine()!.split(separator: " ").map {Int($0)!}
}
func readSeparatedDouble() -> [Double] {
    return readLine()!.split(separator: " ").map {Double($0)!}
}

// 二進数に変換
func convertIntToRadix2(n: Int, radix: Int = 2) -> String {
    return String(n, radix: radix)
}

//配列を逆順にする reverced ソートする　sorted

let days = [Character](readString())

if days[0] == "R" {
    if days[1] == "R" {
        if days[2] == "R" {
            print(3)
        } else {
            print(2)
        }
    } else {
        print(1)
    }
} else {
    if days[1] == "R" {
        if days[2] == "R" {
            print(2)
        } else {
            print(1)
        }
    } else if days[2] == "R" {
        print(1)
    } else {
        print(0)
    }
}



Measured memory_bytes: 13216
/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                                          |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                                          ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll t,data[100000],k,ans=99999999999;
int main()
{
	optimization();
    cin>>t>>k;
  rep(i,t)
       cin >> data[i];
  sort(data,data+t);
  k--;
  rep(i,t)
    {
      if(k+i<t)
      ans=min(ans,data[k+i]-data[i]);
    }
  cout <<ans<<endl;
}


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

int main() {
int N;
cin >> N;
string s;
cin >> s;
char c;
  int ans=0;
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
rep(i, N){
if(i == 0){
c = s.at(i);
continue;
}
else if(i == N-1){
if(c == s.at(i)){}
else{
//cout << c;
//cout << s.at(i) << endl;
ans++;
}
  ans++;
}
else if(c == s.at(i)){
continue;
}
else {
//cout<< c;
c = s.at(i);
ans++;
}
}
  cout <<ans<<endl;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int update_score(const set<int>& last, int day, int prev, int c, int max_d)
{
    int ret = 0;
    auto itr = last.upper_bound(day);
    int l, r;
    if (itr == last.end())
    {
        r = max_d + 1;
        l = *--itr;
    }
    else
    {
        r = *itr;
        l = *--itr;
    }
    ret -= ((day - prev) + (r - 1 - prev)) * (r - day) / 2;
    ret += ((day - l) + (r - 1 - l)) * (r - day) / 2;

    return c * ret;
}

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

    const int DAY = 365;
    const int NUM = 26;
    int d;
    cin >> d;
    int c[NUM];
    rep (i, NUM)
    {
        cin >> c[i];
        c[i] = -c[i];
    }

    int s[DAY][NUM];
    rep (i, d) rep (j, NUM) cin >> s[i][j];

    set<int> last[NUM];
    rep (i, NUM) last[i].insert(0);

    int t[DAY];
    rep (i, d)
    {
        cin >> t[i];
        --t[i];
    }

    int v[DAY + 1];
    v[0] = 0;
    rep (i, d)
    {
        v[i + 1] = v[i] + s[i][t[i]];
        last[t[i]].insert(i + 1);
        rep (j, NUM)
        {
            v[i + 1] += c[j] * ((i + 1) - *last[j].rbegin());
        }
    }

    int m;
    cin >> m;

    int ans[m];
    rep (ii, m)
    {
        int dd, q;
        cin >> dd >> q;
        --q;
        int p = t[dd - 1];
        t[dd - 1] = q;
        v[d] += s[dd - 1][q] - s[dd - 1][p];

        last[p].erase(dd);
        last[q].insert(dd);
        int prevq = *(--last[q].lower_bound(dd));

        v[d] += update_score(last[p], dd, dd, c[p], d);
        v[d] += update_score(last[q], dd, prevq, c[q], d);
        ans[ii] = v[d];
    }

    rep (i, m)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 3996
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll ans = a[0] - 1, p = 2;
    reps(i,1,N){
        if(a[i] == p){
            ++p;
        }else if(a[i] > p){
            ans += (a[i] - 1) / p;
        }
    }
    cout<<ans<<endl;
}

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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    double A, B;
    cin >> A >> B;
    int ans = max(ceil(A / 0.08), ceil(B / 0.10));
    if(floor(ans*0.08)==A && floor(ans*0.10)==B) cout << ans << endl;
    else cout << -1 << endl;
}

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

using namespace std;

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

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

  sort(cur.begin(), cur.end());

  int ans = 0;
  for (int k = 30; k >= 1; k--) {
    int target = 1 << k;

    vector<int> nxtl;
    vector<int> nxtr;
    
    int lptr = 0, rptr = cur.size() - 1;
    while (lptr <= rptr) {
      if (lptr == rptr) {
        nxtl.push_back(cur[lptr]);
        break;
      } else if (cur[lptr] + cur[rptr] == target) {
        ans++;
        lptr++;
        rptr--;
      } else if (cur[lptr] + cur[rptr] < target) {
        nxtl.push_back(cur[lptr]);
        lptr++;
      } else if (cur[lptr] + cur[rptr] > target) {
        nxtr.push_back(cur[rptr]);
        rptr--;
      }
    }

    reverse(nxtr.begin(), nxtr.end());
    for (int u : nxtr) {
      nxtl.push_back(u);
    }

    cur = nxtl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3704
#include <iostream>

using namespace std;

int main(){
  long H, W;
  cin >> H >> W;
  
  long line[2]={(W+1L)/2L, W/2L};
  
  long cnt=0;
  
  if (H==1 || W==1) {
    cout << 1 << endl;
    return 0;
  }
  
  for (int i=0; i<H; i++) {
    cnt += line[i%2];
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;

/*
 * J - Sushi
 */
public class Main
{
double[][][] cache = new double[ 301 ][ 301 ][ 301 ];

public static void main( String[] args ) throws Exception
{
	new Main().run();
}

private void initCache()
{
	for( int i = 0; i < 301; ++i )
	{
		for( int j = 0; j < 301; ++j )
		{
			for( int k = 0; k < 301; ++k )
			{
				cache[ i ][ j ][ k ] = -1;
			}
		}
	}
}

public void run() throws Exception
{
	initCache();
	final Scanner sc = new Scanner( getInputStream() );
	final int N = sc.nextInt();
	int[] data = new int[] { 0, 0, 0, 0 };
	for( int i = 0; i < N; ++i )
	{
		data[ sc.nextInt() ]++;
	}
	p( getE2( N, data ) );
}

/*
 * すばり回数の期待値を返す
 */
public double getE2( double dish_size, int[] data )
{
	double cached = cache[ data[ 0 ] ][ data[ 1 ] ][ data[ 2 ] ];
	if( cached != -1 )
	{
		return cached;
	}

	//0とそれ以外の比率を求める
	double count = 0;
	for( int i = 1; i <= 3; ++i )
	{
		count += data[ i ];
	}
	double p = count / (count + data[ 0 ]);
	if( p == 0 )
	{
		return 0;
	}

	double ex = 1 / p;//この状態で次の1つを消費するまでの回数の期待値

	//消費するそれぞれのパターンについて確率を求める
	for( int i = 3; i > 0; --i )
	{
		if( data[ i ] > 0 )
		{
			double patternRatio = data[ i ] / count;
			int[] data2 = Arrays.copyOf( data, data.length );
			data2[ i ]--;//今回選択されたものが減る
			data2[ i - 1 ]++;//1つ少ない数が増える
			ex += patternRatio * getE2( dish_size, data2 );
		}
	}

	//p( ex );

	cache[ data[ 0 ] ][ data[ 1 ] ][ data[ 2 ] ] = ex;
	return ex;
}

public static void p( Object o )
{
	System.out.println( o );
}

public static InputStream getInputStream() throws IOException
{
	//p( System.getProperties() );
	if( System.getProperty( "test" ) != null )
	{
		return new FileInputStream( "1" );
	}
	else
	{
		return System.in;
	}
}

}


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

int main(){

  int W, H;
  cin>>W>>H;

  int x, y, r;
  cin>>x>>y>>r;

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3116
n = int(input())
nums = list(map(int, input().split()))

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 1000000
bug2 = [0] * 1000000

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - min(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)

Measured memory_bytes: 25088
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = sum(A)

for i in range(N):
    if B[i] > A[i]:
        B[i] -= A[i]
        A[i] = 0
        A[i + 1] = max(0, A[i + 1] - B[i])
    else:
        A[i] = max(0, A[i] - B[i])

ans = sum_A - sum(A)
print(ans)


Measured memory_bytes: 18476
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
constexpr int dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
// verified: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3381829
// moda, modb は桁数増やした方が良いかも.
using namespace std;
class RollingHash {
  using ull = uint64_t;
  int n;
  mt19937 rnd;
  static const ull moda = (ull)1e9 + 7;
  static const ull modb = (ull)1e9 + 9;
  ull b1 = (ull)rnd(), b2 = (ull)rnd();
  std::vector<ull> a, b, p, q;

public:
  RollingHash(const std::string& str) : n((int)str.size()), a(n + 1, 0), b(n + 1, 0), p(n + 1, 1), q(n + 1, 1) {
    for (int i = 0; i < n; i++) {
      a[i + 1] = (a[i] * b1 + ull(str[i])) % moda;
      b[i + 1] = (b[i] * b2 + ull(str[i])) % modb;
      p[i + 1] = p[i] * b1 % moda;
      q[i + 1] = q[i] * b2 % modb;
    }
  }
  // [l, r) のハッシュ値を取得
  std::pair<ull, ull> query(int l, int r) {
    assert(0 <= l && l <= r && r <= n);
    ull h1 = (p[r - l] * a[l] - a[r] + moda) % moda;
    ull h2 = (q[r - l] * b[l] - b[r] + modb) % modb;
    return std::make_pair(h1, h2);
  }
};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string t, p;
  cin >> t >> p;
  RollingHash h(t);
  using ull = uint64_t;
  RollingHash hp(p);
  auto a = hp.query(0, p.size());
  vector<int> ans;
  REP(i, t.size() - p.size() + 1) {
    if (h.query(i, i + p.size()) == a)ans.push_back(i);
  }
  for (auto a : ans)cout << a << endl;
}



Measured memory_bytes: 40500
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 2e5;
int n, a[MAXN + 5], b[MAXN + 5];
struct Node {
	int val, id;
	
	inline friend bool operator<(Node x, Node y) {
		return x.val < y.val;
	}
};
priority_queue<Node> q;
LL ans;

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
	for (int i = 1; i <= n; ++i) {
		read(b[i]);
		if (b[i] < a[i]) {
			puts("-1");
			return 0;
		}
		if (b[i] > a[i]) q.push((Node) { b[i], i });
	}
	for (; !q.empty(); ) {
		int i = q.top().id, l = i == 1 ? n : i - 1, r = i == n ? 1 : i + 1;
		q.pop();
		if (b[i] - b[l] - b[r] < a[i]) {
			puts("-1");
			return 0;
		}
		int t = (b[i] - a[i]) / (b[l] + b[r]);
		ans += t;
		b[i] -= (b[l] + b[r]) * t;
		if (b[i] > a[i]) q.push((Node) { b[i], i });
	}
	write(ans);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
using namespace std;

int main(){
    int n,m;

    cin >> n >> m;

    int k[n];

    int a[m];

    int r[m];

    for(int i=0; i<m; i++){
        r[i] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> k[i];
        for(int j=0; j<k[i]; j++){
            cin >> a[j];
            //cout << a[j];
        }
        for(int j=0; j<k[i]; j++){
            r[a[j]-1]++;
        }
       // for(int i=0;i<m;i++){
            //cout << r[i];
       // }

    }

    int c=0;

    for(int i=0; i<m; i++){
        if(r[i] == n){
            c++;
        }
    }

    cout << c << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
bool p[5001][5001];
bool check(int x,int y){
    if(x>=0&&y>=0&&x<=5000&&y<=5000&&p[x][y]) return true;
    else return false;
}
int main(){
while(1){
    int n,x[3000],y[3000];
    long long max=0;
    scanf("%d",&n);
    if(n==0) return 0;
    memset(p,false,sizeof(p));
    for(int i=0;i<n;i++){
        scanf("%d %d",x+i,y+i);
        p[x[i]][y[i]]=true;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int x1=x[i];
            int x2=x[j];
            int y1=y[i];
            int y2=y[j];
            int dx=x2-x1;
            int dy=y2-y1;
            if(max<dx*dx+dy*dy&&((check(x1+dy,y1-dx)&&check(x2+dy,y2-dx))||(check(x1-dy,y1-dx)&&check(x2-dy,y2-dx))))
                max=dx*dx+dy*dy;
        }
    }
    printf("%lld\n",max);
}
}

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

int main(){
  int a[6];
  for(int i=0;i<6;i++){
    cin >> a[i];
  }
  sort(a,a+6);
  int b[4];
  for(int i=0;i<4;i++){
    b[i]=0;
  }
  for(int i=0;i<6;i++){
    for(int j=1;j<=4;j++){
      if(a[i]==j){
        b[j-1]++;
      }
    }
  }
  sort(b,b+4);
  if(b[3]>2){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}
        

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
signed main(){
	int a,b;
	cin>>a>>b;
	if((double)b>=(double)a){
		cout<<"unsafe"<<endl;
	}
	else{
		cout<<"safe"<<endl;
	}
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll sum = 0, t;
    int n;
    cin >> n;
    vector<ll> a;
    for (int i = 0; i < n; i++) {
        cin >> t;
        sum += t;
        a.push_back(t);
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        sum = sum - a[i];
        res += a[i] * (sum % (ll)(1000000007));
        res = res % (ll)(1000000007);
    }
    cout << res << endl;
}

Measured memory_bytes: 5300
#include <bits/stdc++.h>
using namespace std;
int main(){

    int a,b,c;
    cin >> a >> b >> c;
    
    if(a+b == c || a + c == b || b + c == a) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
//
vector<int> light(vector<int> v){
   int N=v.size();
   vector<int> vv(N,0);
   rep(i,v.size()){
      int a,b;
      a=max(0,(i-v[i]));
      b=i+v[i]+1;
      vv[a]++;
      if(b<N)vv[b]--;
   }
   rep(i,vv.size()-1){
       vv[i+1]=min(vv[i+1]+vv[i],N);
   }
   return vv;
   
}

int main(){
   int N,K;
   cin>>N>>K;
   vector<int> v,check(N,N);
   if(K>2*N){
      vector<int> vv(N,N);
      for(auto e:v) cout<<e<<" ";
      cout<<endl;
      return 0;
   } 
   rep(i,N){
      int a;
      cin>>a;
      v.push_back(a);
   }
   rep(i,K){
      if(v==check) break;
      v=light(v);
      
   }
   for(auto e:v) cout<<e<<" ";
   cout<<endl;
}
    

Measured memory_bytes: 6352
<?php
fscanf(STDIN, "%d %d", $n, $k);

$digit = [];
while(true) {
    array_unshift($digit, $n % $k);
    
    if($n < $k) {
        break;
    }
    
    $n = intdiv($n, $k);
}
echo count($digit);

echo PHP_EOL;
?>


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

int main(){
  int n;
  cin >> n;
  int t = n;
  int s = 0;
  while(t>0){
    s = s + t % 10;
    t = t / 10;
  }
  if(n%s==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

cs ll mod=1000000007;

ll fac[1000001]={1,1},inv[1000001]={1,1},ifac[1000001]={1,1};

inline
ll C(int n,int m){
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int n,m,k,maxn;

signed main(){
	
	for(int re i=2;i<=1000000;++i)
	fac[i]=fac[i-1]*i%mod,
	inv[i]=(mod-mod/i)*inv[mod%i]%mod,
	ifac[i]=ifac[i-1]*inv[i]%mod;
	
	scanf("%d%d%d",&n,&m,&k);
	--n;
	maxn=max(n,m+k);
	ll sum=1,ans=1;
	for(int re i=1;i<=m+k;++i){
		sum=(sum<<1)%mod;
		if(i>m)sum=(sum+mod-C(i-1,m))%mod;
		if(i>k)sum=(sum+mod-C(i-1,k))%mod;
		ans=ans*3%mod;
		ans=(ans+C(n+i,i)*sum%mod)%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m; cin >> n >> m;
  string s; cin >> s;
  
  ll now = n;
  vector<ll> move;
  bool flg = false;
  
  while(1){
    flg = false;
    for(ll dice = m; dice >= 1; dice--){
      if(now - dice < 0) continue;
      else if(s[now-dice] == '0'){
        now = now - dice;
        move.emplace_back(dice);
        flg = true;
        break;
      }
    }
    if(!flg){ cout << "-1"; return 0;}
    if(now == 0) break;
  }
  reverse(all(move));
  for(auto x : move) cout << x << " ";
  return 0;
}


Measured memory_bytes: 1480
h,w=map(int,input().split())
a=[]
for _ in range(h):
    s=input()
    a.append(s)
for i in range(h+2):
    for j in range(w+2):
        if i==0 or i==h+1 or j==0 or j==w+1:
            print('#',end='')
        else:
            print(a[i-1][j-1],end='')
    print()

Measured memory_bytes: 4340
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin>>s;
	int rev = 0;
	int q;
	deque<char> d;
	rep(i,s(s)){
		d.push_back(s[i]);
	}
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		if(t == 1){
			rev = 1-rev;
		}
		else{
			int f;
			char c;
			cin>>f>>c;
			if(f == 1){
				if(rev == 1)d.push_back(c);
				else d.push_front(c);
			}
			else{
				if(rev == 1)d.push_front(c);
				else d.push_back(c);
			}
		}
		// for(auto it:d){
		// 	cout<<it;
		// }
		// cout<<"\n";
	}
	// cout<<rev<<" ";
	string ans;
	for(auto it : d){
		ans.pb(it);
	}
	if(rev){
		reverse(all(ans));
	}
	cout<<ans;
	return 0;
}

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

    if (a>c) {
      System.out.println(a-c);
    }else{
      System.out.println("0");
    }
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll c[51][51];
const int MAX_N = 50;

void COMinit()
{
    for (int i = 0; i < MAX_N + 1; i++)
    {
        c[i][0] = 1;
        c[i][i] = 1;
    }

    for (int i = 2; i < MAX_N + 1; i++)
    {
        for (int j = 1; j < i; j++)
        {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    COMinit();
    sort(RALL(v));
    ll t = 0;
    for (int i = 0; i < a; i++)
    {
        t += v[i];
    }
    double ans = (double)t / a;

    int x = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] == v[a - 1])
        {
            x++;
        }
    }
    ll cnt = 0;
    if (v[0] == v[a - 1])
    {
        for (int i = a; i <= b; i++)
        {
            cnt += c[x][i];
        }
    }
    else
    {
        int y = 0;
        for (int i = 0; i < a; i++)
        {
            if (v[i] == v[a - 1])
            {
                y++;
            }
        }
        cnt += c[x][y];
    }
    cout << fixed << setprecision(10) << ans << endl;
    cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Range
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
            Order.Acscend(data);
        }
    }
    class Order
    {
        static public void Acscend(int[] num)
        {
            string answer;
            if (num[0] < num[1] && num[1] < num[2]) answer = "Yes";
            else answer = "No";
            Console.WriteLine(answer);
        }
    }
}

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

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  int x[n], y[m];
  REP(i, n) cin >> x[i];
  REP(i, m) cin >> y[i];

  for (int z = X + 1; z <= Y; ++z) {
    int c = 0;
    REP(i, n) if (x[i] < z) ++c;
    REP(i, m) if (y[i] >= z) ++c;
    if (c == n + m) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 384
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, i = LI()

    print(N-i+1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10028
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int n = 3;
        vector<int> a(n), b(n);
        vector<int> app(5);

        rep(i, 0, n) {
            cin >> a[i] >> b[i];
            app[a[i]]++;
            app[b[i]]++;
        }

        int ki = 0;
        for(int i = 0; i < 5; ++i){
            if(app[i] % 2) ki++;
        }

        if(ki == 0 || ki == 2){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int h = in.ni();
        int w = in.ni();
        char[][] map = new char[h][w];
        int[][] ans = new int[h][w];
        for(int i = 0; i < h; i++) {
            map[i] = in.ns().toCharArray();
        }
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                for(int x = -1; x <= 1; x++) {
                    for(int y = -1; y <= 1; y++) {
                        if(map[i][j]=='#'){
                            if(i+x>=0&&i+x<h&&j+y>=0&&j+y<w){
                                ans[i+x][j+y]++;
                            }
                        }
                    }
                }
            }
        }
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(map[i][j]=='.') out.print(ans[i][j]);
                else out.print('#');
            }
            out.println();
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22612
n = int(input())
li = list(map(int,input().split()))
error = 0
for i in range(n):
  if li[i]%2 == 0:
    if li[i]%3 == 0 or li[i]%5 == 0:
      pass
    else:
      error = 1
  else:
    pass
if error:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 3060
use proconio::input;
use itertools::Itertools;
use std::cmp::min;

//#[proconio::fastout]
fn main() {
    input! {
    n:usize,
    m:usize,
    x:i64,
    ca:[[i64;m+1];n],
    }

    let mut ans = std::i64::MAX;
    for i in 1..=n {
        for books in ca.iter().combinations(i) {
            let mut ul = vec![0i64; m + 1];
            for book in books {
                for j in 0..=m {
                    ul[j] += book[j];
                }
            }
            ans = if ul[1..].iter().all(|u| u >= &x) {
                min(ans, ul[0])
            } else {
                ans
            };
        }
    }
    println!("{}", if ans == std::i64::MAX { -1 } else { ans });
}


Measured memory_bytes: 2188
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int, input().split())

A = [0] * H
for i in range(H):
    A[i] = list(input())

row = [False] * H
col = [False] * W
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(A[i][j], end="")
        print()

Measured memory_bytes: 9412
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int j, jj, i, a[3][3], aa[4], bb[4], w = 0;
    for(i = 0; i < 3; i ++)
        for(j = 0; j < 3; j ++)
            scanf("%d", &a[i][j]);
    for(j = 0; j < 3; j ++)
        for(i = 0; i <= a[0][j]; i ++)
        {
            aa[0] = i;
            for(jj = 0; jj <= a[0][j]; jj++)
                if((aa[0] + jj) == a[0][j])
                {
                    bb[w ++] = jj;
                    break;
                }
            if((aa[0] + bb[w-1]) == a[0][j])
                break;
        }
    aa[1] = a[1][0] - bb[0];
    if(a[1][1] != (aa[1] + bb[1]))
        {
            printf("No");
            return 0;
        }
    if(a[1][2] != (aa[1] + bb[2]))
        {
            printf("No");
            return 0;
        }

    aa[2] = a[2][0] - bb[0];
    if(a[2][1] != (aa[2] + bb[1]))
        {
            printf("No");
            return 0;
        }
    if(a[2][2] != (aa[2] + bb[2]))
        {
            printf("No");
            return 0;
        }
    printf("Yes");
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
int n,a,b,ans,i;
bool cmp(int x)
{
    int sum=0;
    while(x)
    {
        sum+=x%10;
        x/=10;
    }
    return (sum>=a&&sum<=b);
}
int main()
{
    scanf("%d %d %d\n",&n,&a,&b);
    for(i=1;i<=n;i++)
    {
        if(cmp(i))ans+=i;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main () {
    string s; cin >> s;
    int ans = 0;
    while(s.size()) {
        s.pop_back();
        if(s.size() % 2 != 0) {
            continue;
        } else {
            string t = s.substr(s.size() / 2, s.size() / 2);
            if(t + t == s) ans = max(ans, (int)s.size());
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384