akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
    int x,y;
    scanf("%d %d",&x, &y);

    if(x==2 || y==2){
        printf("No\n");
    } else if((x==4 || x==6)||(x==9 || x== 11)){
        if((y==4 || y==6)||(y==9 || y==11)){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    } else {
        if((y!=4 && y!=6)&&(y!=9 && y!=11)){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

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


int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int ans = 0;
	rep(i,n-2) {
		if ((a[i] < a[i+1] && a[i+1] < a[i+2]) || (a[i] > a[i+1] && a[i+1] > a[i+2])) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)

using namespace std;

ll ans, n, k;

int main()
{
	cin >> n >> k;
	
	if (k==0) {
		cout << n*n;
		return 0;
	}
	
	ans += (n-k+1)*(n-k)/2;
//	cout << ans << "\n";
	for (ll i = k+1; i <= n; i++) {
		ll a = i+k;
		
		if (a > n)
			break;
		
		ll h = 0, t = n, m, res = 0;
		
		while (h <= t) {
			m = (h+t)/2;
			
			if (a+m*i > n)
				t = m-1;
			else
				h = m+1, res = max(res, m);
		}
//		cout<<i<<": " << res << "\n";
//		cout << i << ": " << n-(res*i+a)+1 << "\n";
//		if (res!=0)
//			ans+=(res-1)*(i-k);
		ans+=res*(i-k);
		if (res*i+a + (i-k-1) <= n)
			ans+=i-k;
		else
			ans+=n-(res*i+a)+1;
//		cout << i << ": " << res << "\n";
//		ans+=n-(res*i+a)+1;
//		ans+=res;
	}
	cout << ans;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b, c, d) = (line[0], line[1], line[2], line[3]);

    if ((a-b).abs() <= d && (c-b).abs() <= d) || (c-a).abs() <= d{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
import math
from functools import reduce

class abc_162:
    
    def __init__(self):
        pass
        
    def C(self):
        K=int(input())
        sum_gcd=0
        
        for i in range(1,K+1):
            for j in range(1,K+1):
                for k in range(1,K+1):
                    sum_gcd+=self.gcd(i,j,k)
        
        print(sum_gcd) 


    def gcd(self,*numbers):
        return reduce(math.gcd,numbers)


if __name__=='__main__':
    obj=abc_162()
    obj.C()

Measured memory_bytes: 74772
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[1000000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a>>b;
  int r,u,p;
  cin >>r>>u>>p;
  cin >>s;
  lol ans=0;
  for(int n=0;n<a;n++){
    if(s[n]=='r') ans+=p;
    else{
      if(s[n]=='s') ans+=r;
      else ans+=u;
    }
  }
  for(int n=b;n<a;n++){
    if(s[n]==s[n-b]){
      if(s[n]=='r') ans-=p;
      else{
	if(s[n]=='s') ans-=r;
	else ans-=u;
      }
      s[n]='a';
    }
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 512
#n = map(int,input().split())
mlist = list(map(int,input().split()))

i=0
while(True):
    if mlist[i] % 2 == 0:
        mlist.append(mlist[i]/2)
    else:
        mlist.append(3*mlist[i]+1)
    
    breakFlg = False
    for num in range(0,i):
        if int(mlist[num])==int(mlist[i]):
            if num!=i:
                breakFlg = True
    i=i+1
    if(breakFlg):
        break
print(i)


Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    p = LI_()
    x = LI()
    e = collections.defaultdict(list)
    for i in range(n-1):
        e[p[i]].append(i+1)

    def f(i):
        if not e[i]:
            return [0,x[i]]
        a = 0
        xi = x[i]
        xi1 = xi + 1
        tx = [0] * xi1
        tx[0] = 1
        for c in e[i]:
            rc = f(c)
            if not rc:
                return
            a += sum(rc)
            tt = [0] * xi1
            for i in range(xi1):
                if tx[i] == 0:
                    continue
                for c in rc:
                    if i+c < xi1:
                        tt[i+c] = 1
            tx = tt
        for i in range(xi,-1,-1):
            if tx[i] == 1:
                return [xi, a-i]
        return

    if f(0):
        return 'POSSIBLE'

    return 'IMPOSSIBLE'


print(main())






Measured memory_bytes: 78440
#include <iostream>
using namespace std;
int main(){
	int count=0, a=200001, b=0, i, n;
	cin >> n;
	for (i = 0;i < n;i++) {
		cin >> b;
		if (a >= b) {
			a = b;
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 888
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
typedef long long int LL;
const LL MOD = 998244353;
const int MAXN = 2e5+7;
LL n, m, k, fact[MAXN];
LL ksm(LL a, LL b){
    if(b==0) return 1;
    if(a==0) return 0;
    LL ret = 1;
    while(b){
        if(b&1) ret = ret * a % MOD;
        b >>= 1;
        a = a * a % MOD;
    }
    return ret;
}
LL C(LL a, LL b){ return fact[a] * ksm(fact[b],MOD-2) % MOD * ksm(fact[a-b],MOD-2) % MOD; }
int main(){
    cin >> n >> m >> k;
    LL ret = 0;
    fact[0] = 1; for(int i = 1; i < MAXN; i++) fact[i] = fact[i-1] * i % MOD; 
    for(int i = 0; i <= k; i++) ret = (ret + m * ksm(m-1,n-i-1) % MOD * C(n-1,i) % MOD) % MOD;
    cout << ret << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;
const ll N=3e5 + 5;
ll n,arr[N];

int main()
{
    fast();
    string s,t;
    cin>>s>>t;

    ll ans = 0;
    for(ll i=0;i<3;i++)
        if(s[i]==t[i])
            ans++;
    cout<<ans;
}



Measured memory_bytes: 256
from collections import deque
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


DICTIONARY={}
num_query=int(input())

for loop in range(num_query):
    input_str=input().split()
    if input_str[0]=='insert':
        DICTIONARY[input_str[1]]=True
    else:
        if DICTIONARY.__contains__(input_str[1]):
            print("yes")
        else:
            print("no")


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

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

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

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

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

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 
 
int xx[] = {1, -1, 0, 0};
int yy[] = {0, 0, 1, -1};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n = nxt(), m = nxt(), k = nxt();
    int x1 = nxt() - 1, y1 = nxt() - 1;
    int x2 = nxt() - 1, y2 = nxt() - 1;
    vector<vector<char>> matr(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> matr[i][j];
        }
    } 
    auto is_in = [&](int x, int y) {
        return (x >= 0 && x <= n - 1 && 
                y >= 0 && y <= m - 1);
    };

    auto bfs = [&]() {
        queue<pii> q; 
        vector<vector<int>> d(n, vector<int>(m, INT_MAX));
        if (matr[x1][y1] != '@') {
            q.push({x1, y1});
            d[x1][y1] = 0;
        } 
        
        while (!q.empty()) {
            
            pii from = q.front();
            int cur = d[from.first][from.second];
            q.pop();
            
            for (int i = 0; i < 4; i++) {
                int x = from.first;
                int y = from.second;
                for (int j = 0; j < k; j++) {
                    x += xx[i];
                    y += yy[i];
                    if (!is_in(x, y))
                        break;
                    if (matr[x][y] == '@') {
                        break;
                    }
                    if (cur + 1 > d[x][y]) {
                        break;
                    }
                    if (cur + 1 >= d[x][y]) {
                        continue;
                    }
                    d[x][y] = cur + 1;
                    q.push({x, y});
                }
            }
        }
        return d[x2][y2];
    }; 

    int rez = bfs();
    if (rez == INT_MAX) rez = -1;
    cout << rez;
    return 0;
}


Measured memory_bytes: 11996
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>
#define ll long long
#define pb push_back
using namespace std;

int main()
{
int a,b;
cin>>a>>b;
if(a+b==15)
cout<<"+";
else if(a*b==15) cout<<"*";
else cout<<"x";
return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
main()
{
  int a,b;
  scanf("%d %d",&a,&b);

  if(a>b)
    {
     printf("a > b\n");
    }

  if(a<b)
   {
    printf("a < b\n");
   }

  if(a==b)
  {
   printf("a == b\n");
  }

}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> room(n+1);
    vector<int> ans(n+1,-1);
    int a,b;
    REP(i,m){
        cin >> a >> b;
        room[a].push_back(b);
        room[b].push_back(a);
    }
    deque<int> que={1};
    ans[0]=0;ans[1]=0;
    while(!que.empty()){
        int v = que.front();
        que.pop_front();
        for(int w:room[v]){
            if(ans[w]>=0){
                continue;
            }
            else{
                ans[w]=v;
                que.push_back(w);
            }
        }
    }
    bool flag = true;
    for(int i=2;i<n+1;i++){
        if(ans[i]==-1)flag = false;
    }
    if(flag){
        COUT("Yes");
        for(int i=2;i<n+1;i++){
            COUT(ans[i]);
        }
    }
    else{
        COUT("No");
    }
    return 0;
}

Measured memory_bytes: 10168
#include <stdio.h>

int f(int x, int y, int z)
{
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int check(int n)
{
  int A[100][3], m = 0;
  int x = 1, y = 1, z = 1;
  while (n >= f(x, y, z))
  {
    while (n >= f(x, y, z))
    {
      while (n >= f(x, y, z))
      {
        if (n == f(x, y, z))
        {
          A[m][0] = x;
          A[m][1] = y;
          A[m][2] = z;
          m++;
        }
        z++;
      }
      y++;
      z = y;
    }
    x++;
    y = x;
    z = x;
  }

  int res = m;
  for (int i = 0; i < m; i++)
  {
    int l = 0;
    l += A[i][0] == A[i][1] ? 1 : 0;
    l += A[i][1] == A[i][2] ? 1 : 0;
    l += A[i][2] == A[i][0] ? 1 : 0;
    switch (l)
    {
    case 0:
      res = res + 5;
      break;
    case 1:
      res = res + 2;
      break;
    default:
      break;
    }
  }

  return res;
}

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

  for (int i = 1; i <= n; i++)
  {
    printf("%d\n", check(i));
  }

  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


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

ll zyo5(int n){
  ll a = 1 ;
  REP(i,n){
    a *= 5 ;
  }
  return a ;
}




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n ;
  cin >> n ;
  ll ans = 0 ;
  if(n%2==1){
    cout << 0 << endl ;
    return 0 ;
  }
  int cnt = 1 ;
  while(n/zyo5(cnt)!=0){
    ans += n/zyo5(cnt)/2 ;
    cnt++ ;
  }
  
  
  
  
  cout <<ans <<endl ;
    
    
      
    
  
  
  
  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 0.00001
bool vis[10];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;cin>>n>>k;
    rep(i,1,k)
    {
        int d;cin>>d;
        vis[d]=true;
    }
    rep(i,n,100000)
    {
        bool flag=0;
        int temp=i;
        int x;
        while(temp>0)
        {
            x=temp%10;
            temp/=10;
            if(vis[x]==true)
            {
                flag=1;
                continue;
            }
        }
        if(flag==0)
        {
            cout<<i<<"\n";
            break;
        }
    }



    return 0;
    // check for long long or int
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int M,K;
	cin>>M>>K;
	if((1<<M)<=K){
		cout<<-1<<endl;
		return 0;
	}

	if(M==1){
		if(K==0){
			cout<<"0 0 1 1"<<endl;
		}
		else{
			cout<<-1<<endl;
		}
		return 0;
	}

	vint ans;
	for(int i=(1<<M)-1;i>=0;i--){
		if(i==K)continue;
		ans.pb(i);
	}
	ans.pb(K);
	for(int i=0;i<(1<<M);i++){
		if(i==K)continue;
		ans.pb(i);
	}
	ans.pb(K);
	rep(i,ans.size()){
		if(i)cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

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

int main() {
  string str1,str2,str3;
  0 <= str1.size(),str2.size(),str3.size() <= 100;
  cin >> str1 >> str2 >> str3;
  
  char c1,c2,c3;
  c1 = str1.at(0);
  c2 = str2.at(0);
  c3 = str3.at(0);
  
  cout << c1 << c2 << c3 << endl; 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	// eachTest

	string s, t;
	cin >> s >> t;
	int n1 = s.size();
	int n2 = t.size();
	s = " " + s;
	t = " " + t;

	int table[n1+1][n2+1];
	FOR(i,0,n1+1) {
		table[i][0] = 0;
	}
	FOR(i,0,n2+1) {
		table[0][i] = 0;
	}
	FOR(i,1,n1+1) {
		FOR(j,1,n2+1) {
			if (s[i] == t[j]) {
				table[i][j] = 1 + table[i-1][j-1];
			}
			else {
				table[i][j] = max(table[i-1][j], table[i][j-1]);
			}
		}
	}
	ll x = n1;
	ll y = n2;
	string ans = "";
	while(x != 0 && y != 0) {
		if (s[x] == t[y]) {
			ans += s[x];
			x--;
			y--;
			continue;
		}
		if (table[x-1][y] > table[x][y-1]) {
			x--;
		}
		else {
			y--;
		}
	}
	// cout << reverse(ans.begin(), ans.end()) << "\n";
	// cout << ans.reverse() << "\n";
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 35456
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
x, y, z = 0, 0, 0
for i in p:
    if i <= a:
        x += 1
    elif i <= b:
        y += 1
    else:
        z += 1
print(min(x, y, z))

Measured memory_bytes: 3064
<?php
list($n, $l) = explode(" ", fgets(STDIN));
$last_l = 0;
$ans = 0;
$zero_flg = false;
for($i=0; $i<$n; $i++){
	$last_l=$l+$i;
	$ans += $last_l;
	if($last_l==0){
		$zero_flg = true;
	}
}

if($zero_flg===true){
	$minus = 0;
}elseif (abs($l) < abs($last_l)) {
	$minus = $l;
}else{
	$minus = $last_l;
}

echo $ans - $minus . "\n";
?>

Measured memory_bytes: 4728
n = int(input())

N = [int(i) for i in input().split()]
N_max = max(N)
if N_max % 2 == 0:
    N_mid = N_max / 2
else:
    N_mid = (N_max+1) / 2
d = 10000000000
ans = 0

for i in range(n):
    if N[i] == N_max:
        continue
    a = abs(N_mid-N[i])
    if d > a:
        ans = N[i]
        d = a
        
print(N_max,ans)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
int p=0;
int main(void){
    // Your code here!
    while (true){
    int a,b,n=0;
    cin >> a >> b;
    if (a==0 && b==0) break;
    if (p!=0) cout << endl;
    for (int i=a;i<b+1;i++){
        if (i%400==0) {n=1;cout << i << endl;}
        else if (i%100==0) continue;
        else if (i%4==0) {n=1;cout << i << endl;}
    }
    if (n==0) cout << "NA" << endl;
    p++;
    }
}


Measured memory_bytes: 3084
main = do
	raw <- getLine
	let nums = map (\x -> read x :: Int) (words raw)
	let product = (nums !! 0) * (nums !! 1)
	let sum = (nums !! 0) + (nums !! 1)
	let diff = (nums !! 0) - (nums !! 1)
	putStrLn $ show (maximum (product:sum:diff:[]))

Measured memory_bytes: 508
a, b, c, d = gets.split().map(&:to_i)
n = 0
if a < c
  if b < d
    n = b - c
  else
    n = d - c
  end
else
  if b < d
    n = b - a
  else
    n = d - a
  end
end
if n < 0
  puts 0
else
  puts n
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;


int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 vector<int>B(N);
 for(int i=0;i<N;i++){
     cin>>A[i]>>B[i];
 }
 int64_t ans=0;
 for(int i=N-1;i>=0;i--){
  if((A[i]+ans)%B[i]==0){continue;}
  ans+=B[i]-(A[i]+ans)%B[i];
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 1024
n,m,x=list(map(int,input().split()))
book=[]
for i in range(n):
    book.append(list(map(int,input().split())))

bit=[]
for i in range(2**n):
    b=[]
    for j in range(n):
        if (i>>j & 1):
            b.append(1)
        else:
            b.append(0)
    bit.append(b)

ans_list=[]
#bitの各要素
for i in range(len(bit)):
    a=[0 for l in range(m+1)]
    for j in range(n):
        if bit[i][j]==1:
            for k in range(m+1):
                a[k]=a[k]+book[j][k]
    if min(a[1:])>=x:
        ans_list.append(a[0])
    a=[]
    
if len(ans_list)==0:
    print(-1)
else:
    print(min(ans_list))

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

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

const int N = 1<<18;
const ll INF= INT_MAX; 

/*datのサイズはNに固定*/

class RMQ{
public:
  ll n;
  P dat[2*N-1];
  
  //初期化
  RMQ(){
    n=N;
    for(int i=0;i<2*n-1;i++) dat[i]=P(INF,INF);
  }
  
  //k番目の値をaに変更
  void update(int k,P a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  
  //[a,b)の最小値を求める query(a,b,0,0,n)
  P query(int a,int b,int k=0,int l=0,int r=N){
    if(r<=a||b<=l)return P(INF,INF);
    if(a<=l&&r<=b)return dat[k];
    P vl=query(a,b,k*2+1,l,(l+r)/2);
    P vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
};

const int MAX_N = 1<<18;

class BIT{
public:
  int n;
  ll bit0[MAX_N+1],bit1[MAX_N+1];//1オリジン
  BIT(){n = MAX_N;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  BIT(int n){this->n=n;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  
  ll sum(ll *b,int i){
    ll s=0;
    while(i>0){
      s=(s+b[i]);
      i-=i&-i;
    }
    return s;
  }

  void add(ll *b,int i,ll v){
    while(i<=n){
      b[i]=(b[i]+v);
      i+=i&-i;
    }
  }

  //[a,b]にxを加算(1<=a)
  void add (int a,int b,ll x){
    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]のsumを得る(1<=a)
  ll sum(int a,int b){
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return res;
  }
};

string s;
int k;

void solve(){
  
  RMQ rmq = RMQ();
  BIT bit = BIT(s.size());
  
  for(int i=0;i<s.size();i++){
    rmq.update(i, P(s[i],i));
    bit.add(i+1, i+1, 1);
  }
    
  string ans;
  
  while(ans.size()!=s.size()){
    
    int l=0, r=s.size();
    
    while(l<r){
      
      int m=(l+r)/2;
      
      if(bit.sum(1, m+1)<=k+1) l=m+1;
      else r=m;
      
    }
    
    P minp=rmq.query(0, l);
    char minc=minp.first;
    int minidx=minp.second;
    
    k-=bit.sum(1, minidx);
    bit.add(minidx+1, minidx+1, -1);
    rmq.update(minidx, P(INF, INF));
    
    ans+=minc;
  }
  
  cout<<ans<<endl;
}

int main(){
  
  cin>>s;
  cin>>k;
  
  solve();
  
  return 0;
}



Measured memory_bytes: 11792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if(a%10==7 || (a/10)%10 == 7 || (a/100)==7 ){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}


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

class unionfind {
  vector<int> v;

  int size(int n) {
    return -v[root(n)];
  }

  int parent(int n) {
    return v[n] < 0 ? n : v[n];
  }

  int root(int n) {
    return parent(n) == n ? n : v[n] = root(parent(n));
  }

public:
  int component_count;

  unionfind(int n)
    : component_count(n)
  {
    v.resize(n, -1);
  }

  unionfind(int n, vector<pair<int, int>> vp)
    : unionfind(n)
  {
    unite(vp);
  }

  int unite(int a, int b) {
    int ra = root(a);
    int rb = root(b);
    if (ra == rb) return -1;
    component_count--;
    if (size(ra) < size(rb)) swap(ra, rb);
    v[ra] += v[rb];
    v[rb] = ra;
    return size(ra);
  }

  void unite(vector<pair<int, int>> vp) {
    for (auto&& e : vp) {
      unite(e.first, e.second);
    }
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(m);

  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    vp[i].first = x - 1;
    vp[i].second = y - 1;
  }

  auto uf = unionfind(n, vp);
  cout << uf.component_count << endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define rep(i, n) for(LL i = 0;i < n;i++)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int T

/*************** using variables ***************/

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

template <typename T>
struct Edge {
  int from, to;
  T cost;
  Edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
using Edges = vector<Edge<T>>;
template <typename T>
using AdjList = vector<Edges<T>>;

template <typename T>
class Dinic {
 private:
  int V;  // 頂点数
  vector<T> minCost;
  vector<int> iter;
  AdjList<T> graph;
  const T INF = numeric_limits<T>::max() / 10;
  bool Bfs(int s, int t);
  T Dfs(int idx, const int t, T flow);

 public:
  explicit Dinic(int n);
  void AddEdge(int from, int to, T cost);
  T Run(int s, int t);
};

template <typename T>
Dinic<T>::Dinic(int n) : V(n), graph(n) {}

template <typename T>
void Dinic<T>::AddEdge(int from, int to, T cost) {
  graph[from].push_back(Edge<T>(static_cast<int>(graph[to].size()), to, cost));
  graph[to].push_back(
      Edge<T>(static_cast<int>(graph[from].size() - 1), from, 0));
}

template <typename T>
bool Dinic<T>::Bfs(int s, int t) {
  minCost.assign(graph.size(), -1);
  queue<int> que;
  minCost[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int p = que.front();
    que.pop();
    for (auto &e : graph[p]) {
      if (e.cost > 0 && minCost[e.to] < 0) {
        minCost[e.to] = minCost[p] + 1;
        que.push(e.to);
      }
    }
  }
  return (minCost[t] != -1);
}

template <typename T>
T Dinic<T>::Dfs(int idx, const int t, T flow) {
  if (idx == t) return flow;
  for (int &i = iter[idx]; i < graph[idx].size(); ++i) {
    Edge<T> &e = graph[idx][i];
    if (e.cost > 0 && minCost[idx] < minCost[e.to]) {
      T d = Dfs(e.to, t, min(flow, e.cost));
      if (d > 0) {
        e.cost -= d;
        graph[e.to][e.from].cost += d;
        return d;
      }
    }
  }
  return 0;
}

template <typename T>
T Dinic<T>::Run(int s, int t) {
  T flow = 0;
  while (Bfs(s, t)) {
    iter.assign(graph.size(), 0);
    T f = 0;
    while ((f = Dfs(s, t, INF)) > 0) {
      flow += f;
    }
  }
  return flow;
}
signed main(){
    int n;
    vector<P> blue, red;

    cin >> n;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        red.pb(P(a, b));
    }
    rep(i, n){
        int c, d;
        cin >> c >> d;
        blue.pb(P(c, d));
    }

    Dinic<LL> f(n*2 + 2);
    rep(i, n){
        f.AddEdge(0, i+1, 1);
        f.AddEdge(n+1+i, n*2+1, 1);
    }
    rep(i, n){
        rep(j, n){
            if(red[i].first < blue[j].first && red[i].second < blue[j].second){
                f.AddEdge(i+1, j+n+1, 1);
            }
        }
    }

    cout << f.Run(0, n*2+1) << endl;
}


Measured memory_bytes: 384
// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

/*#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	int n,k;
	cin >> n;
	string s;
	cin >> s>>k ;
	
	for (int i = 0; i < n; i++)
	{
		
	}
	return 0;
}*/


// Contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include"iostream"
#include"string"
#include"vector"
#include"algorithm"

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a < c &&c<b|| a > c &&c>b) {
		cout << "Yes" << endl;

	}

	else {
		cout << "No" << endl;
	}



	return 0;
}




Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

H,W,K = MI()
mod = 10**9+7

if W == 1:
    print(1)
    exit()

fib = [1,1,2,3,5,8,13,21]  # fib[i] = i本のあみだくじの、ある列に横線を引く方法の数

dp = [[0]*(W+1) for _ in range(H+1)]  # dp[i][j] = i段横線を引いたときに1からKに至るような横線の引き方
dp[0][1] = 1
for i in range(1,H+1):
    for j in range(1,W+1):
        if j == 1:
            dp[i][j] = dp[i-1][j+1]*fib[W-j-1] + dp[i-1][j]*fib[W-j]
            dp[i][j] %= mod
        elif j == W:
            dp[i][j] = dp[i-1][j-1]*fib[j-2] + dp[i-1][j]*fib[j-1]
            dp[i][j] %= mod
        else:
            dp[i][j] = dp[i-1][j-1]*fib[j-2]*fib[W-j] + dp[i-1][j+1]*fib[j-1]*fib[W-j-1] + dp[i-1][j]*fib[W-j]*fib[j-1]
            dp[i][j] %= mod

print(dp[H][K])


Measured memory_bytes: 62708
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input())for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11704
using System;
using System.Collections.Generic;

//https://beta.atcoder.jp/contests/agc028/tasks/agc028_a

public class Program_AGC028_A // ←Class名変更！！
{
    public static void Main(string[] args)
    {
        var st = Console.ReadLine();
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var l = Lcm(s.Length, t.Length);
        var x = new Dictionary<long, char>();

        for (int i = 0; i < s.Length; i++)
        {
            var pos = i * (l / s.Length) + 1;
            x[pos] = s[i];
        }


        for (int i = 0; i < t.Length; i++)
        {
            var pos = i * (l / t.Length) + 1;
            if (x.ContainsKey(pos))
            {
                if (x[pos] != t[i])
                {
                    Console.WriteLine(-1);
                    return;

                }
            }
        }

        Console.WriteLine(l);
    } // Main



    //最小公倍数 least common multiple
    public static long Lcm(int a, int b)
    {
        //return a * b / Gcd(a, b) ;
        return (long)(a  / Gcd(a, b)) * (long)b;    //桁あふれをさせないために早めに割る。
    }

    //ユークリッドの互除法
    public static long Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a); // 引数を入替えて自分を呼び出す

        while (b != 0)
        {
            var temp = a % b;
            a = b;
            b = temp;
        }

        return a;
    }

}     // Class




Measured memory_bytes: 21984
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    ll ans = 0;
    REP1(i, N)
    {
        ans += (i & 1) and (A[i - 1] & 1);
    }
    OUT(ans);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
// int main() {
//     cin.tie(0);
//     ios::sync_with_stdio(false);
//     cout << fixed << setprecision(10);
//
// }
ll powm(ll a, ll n, ll m) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= a) %= m;
        (a *= a) %= m;
        n >>= 1;
    }
    return ret;
}
ll invm(ll a, ll m) {
    return powm(a, m-2, m);
}
vector<ll> fact;
void init_fact(int n, ll m) {
    fact.assign(n+1, 1);
    for (int i = 2; i <= n; ++i) {
        (fact[i] = fact[i-1] * i) %= m;
    }
}
// require init_fact(GREATER THAN OR EQUAL TO n, m)
ll C(ll n, ll r, ll m) {
    return (fact[n] * invm((fact[r] * fact[n-r]) % m, m)) % m;
}
// Stirling number
// Stirling(n, k) := the number of cases
//            to split n balls(distinguished)
//            into k boxes(not distinguished)
//            s.t. each box contains at least one ball.
//
// require init_fact(GREATER THAN OR EQUAL TO k, m)
ll Stirling(ll n, ll k, ll m) {
    ll ret = 0;
    for (ll l = 0; l <= k; ++l) {
        ll tmp = (C(k, l, m) * powm((k-l) % m, n, m)) % m;
        if (l & 1) tmp = (-tmp + m) % m;
        (ret += tmp) %= m;
    }
    return (ret *= invm(fact[k], m)) %= m;
}
// Bell number
// Bell(n, k) := the number of cases
//            to split n balls(distinguished)
//            into k boxes(not distinguished)
//
// require init_fact(GREATER THAN OR EQUAL TO k, m)
ll Bell(ll n, ll k, ll m) {
    ll ret = 0;
    for (ll l = 0; l <= k; ++l) {
        (ret += Stirling(n, l, m)) %= m;
    }
    return ret;
}
// Partition function
// Partition[k][n] := the number of cases
//            to split n balls(not distinguished)
//            into k boxes(not distinguished)
vector<vector<ll>> Part;
void init_partition(ll k, ll n, ll m) {
    Part.assign(k+1, vector<ll>(n+1, 0));
    Part[0][0] = 1;
    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (j-i >= 0) {
                Part[i][j] = (Part[i-1][j] + Part[i][j-i]) % m;
            } else {
                Part[i][j] = Part[i-1][j];
            }
        }
    }
}
int main() {
    ll n, k; cin >> n >> k;
    const ll mod = 1e9+7;
    init_partition(k, n, mod);
    cout << (Part[k][n] - Part[k-1][n] + mod) % mod << endl;
}



Measured memory_bytes: 10796
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(auto& v: a) scanf("%lld", &v);

	i64 ans = 0;
	const int MOD = 1e9 + 7;
	for(auto v: a) (ans += v) %= MOD;
	(ans *= ans) %= MOD;
	for(auto v: a) ans = (ans - v * v % MOD + MOD) % MOD;
	
	printf("%lld\n", ans * (MOD + 1) / 2 % MOD);
	return 0;
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int ans=0;
  for(int i=1; i<10; i++){
    if(n%i == 0 && n/i < 10){
      ans++;
    }
  }
  
  if(ans==0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
  
  return 0;
}

Measured memory_bytes: 3228
#include<cstdio>
#include<iostream>
using namespace std;
const int N=200010;
int n,K,a[N];
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=n-K;++i)puts(a[i]<a[i+K]?"Yes":"No");
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll arith(ll n, ll a, ll b) {
	return n * a + n*(n-1)/2 * b;
}

ll solve(ll n, ll a, ll b) {
	if (b == 0) {
		if (a == 0) return 1;
		return n+1;
	}
	
	if (b < 0) {
		b = -b;
		a -= (n-1)*b;
	}

	ll step = 2*b;
	map<ll,vector<pll>> intervals;
	
	FOR(k,0,n+1) {
		ll lo = 2 * arith(k,a,b) - arith(n,a,b);
		ll hi = lo + k*(n-k)*step;
		if (lo > hi) swap(lo,hi);
		ll rem = lo%step;
		if (rem < 0) rem += step;
		intervals[rem].eb(lo,hi);
	}
	
	ll res = 0;
	for (auto pr: intervals) {
		ll lo = LLONG_MAX;
		for (auto q: pr.yy) lo = min(lo,q.xx);

		vector<pll> events;
		for (auto q: pr.yy) {
			ll L = (q.xx-lo)/step;
			ll R = (q.yy-lo)/step;
			events.eb(L,1);
			events.eb(R+1,-1);
		}
		sort(all(events));
//		for (auto [a,b]: events) cout << "(" << a << "," << b << ") ";
//		cout << endl;
		
		ll lastx = 0, dep = 0;
		for (auto ev: events) {
			ll x = ev.xx;
			if (dep) res += x-lastx;
			lastx = x, dep += ev.yy;
		}
	}
	return res;
}

ll solve_naive(ll n, ll a, ll b) {
	vl v(n);
	FOR(i,0,n) v[i] = a + i*b;

	set<ll> res;
	FOR(mask,0,1 << n) {
		ll cur = 0;
		FOR(i,0,n) {
			if (mask & (1 << i)) cur += v[i];
			else cur -= v[i];
		}
		res.insert(cur);
	}
	return sz(res);
}

void test() {
	FOR(i,0,10000) {
		ll n = 1 + rand() % 3;
		ll a = -3 + rand() % 7;
		ll b = -3 + rand() % 7;

		if (solve(n,a,b) != solve_naive(n,a,b)) {
			cout << n << " " << a << " " << b << endl;
			cout << solve(n,a,b) << endl;
			cout << solve_naive(n,a,b) << endl;
			return;
		}
	}
}

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

	ll n, x, d;
	cin >> n >> x >> d;
	cout << solve(n,x,d) << endl;

}



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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (auto& e : h) cin >> e;

  bool r = true;
  for (int i = 0, b = true; i + 1 < n; i++) {
    if (h[i] < h[i + 1]) {
      b = true;
    } else if (h[i] > h[i + 1]) {
      if (b && h[i] - 1 == h[i + 1]) {
        b = false;
      } else {
        r = false;
        break;
      }
    }
  }
  cout << (r ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
  int n,c,s;
  while(cin>>n){
    if(n==0) break;
    int a[n];
    for(c=0;c<n;c++) cin>>a[c];
    c=0;
    for(int i=0; i<n; i++)
      for(int j=0; j<n-i-1; j++)
	if(a[j] > a[j+1])s=a[j+1],a[j+1]=a[j],a[j]=s,c++;
    cout<<c<<"\n";
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    ll n,k;
    cin>>n>>k;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    int che=0,en;
    vector<int> wan, want;
    bool ok=true;
    map<int,int> mp;
    while(ok){
        mp[che]++;
        if(mp[che]>1) ok=false;
        if(ok){
            wan.push_back(che);
        }
        else en=che;
        che=p[che];
    }
    ok=true;
    ll pre=-1;
    for(auto&v :wan){
        if(ok){
            pre++;
            if(v==en){
                ok=false;
                want.push_back(en);
            }
        }
        else{
            want.push_back(v);
        }
    }
    ll len=want.size();
    if(k<=pre){
        cout<<wan[k]+1<<endl;
        return 0;
    }
    k-=pre;
    k%=len;
    cout<<want[k]+1<<endl;    
    return 0;
}

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

const int mxN=100;
int n, m, mt[mxN];
array<int, 2> a[mxN][mxN];
vector<array<int, 2>> adj[mxN];
bool vis[mxN];

bool dfs(int u1) {
	if(!vis[u1]) {
		vis[u1]=1;
		for(array<int, 2> u2 : adj[u1]) {
			if(mt[u2[0]]<0||dfs(a[u2[0]][mt[u2[0]]][0])) {
				mt[u2[0]]=u2[1];
				return 1;
			}
		}
	}
	return 0;
}

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

	cin >> n >> m;
	for(int i=0; i<n; ++i)
		for(int j=0; j<m; ++j)
			cin >> a[i][j][1], a[i][j][0]=(a[i][j][1]-1)/m;
	for(int i=0; i<m; ++i) {
		for(int j=i; j<m; ++j)
			for(int k=0; k<n; ++k)
				adj[a[k][j][0]].push_back({k, j});
		memset(mt, -1, 4*n);
		for(int j=0; j<n; ++j) {
			memset(vis, 0, n);
			dfs(j);
		}
		for(int j=0; j<n; ++j) {
			swap(a[j][mt[j]], a[j][i]);
			adj[j].clear();
		}
	}
	for(int k : {0, 1}) {
		for(int i=0; i<n; ++i) {
			for(int j=0; j<m; ++j)
				cout << a[i][j][1] << " ";
			cout << "\n";
		}
		for(int i=0; i<m; ++i)
			for(int j=0; j<n-1; ++j)
				for(int k=0; k<n-1; ++k)
					if(a[k][i][0]>a[k+1][i][0])
						swap(a[k][i], a[k+1][i]);
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	ll H, W;
	cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0) {
		cout << 0 << endl;
	}
	else {
		ll ans = min(H, W);
		for (int k = 0; k < 2; ++k) {
			for (int i = 0; i <= 1; ++i) {
				for (int j = 0; j <= 1; ++j) {
					int a = H / 3 + i;
					int b = W / 2 + j;
					ll X = a * W;
					ll Y = b * (H-a);
					ll Z = (W - b)*(H - a);
					ll key1 = max(X, max(Y, Z));
					ll key2 = min(X, min(Y, Z));
					ans = min(ans, key1 - key2);
				}
			}
			swap(H, W);
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = 1;
    while(true){
        if(e % 2 == 0){
            a -= d;
        }else{
            c -= b;
        }
        e += 1;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
    } 
    
}

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

constexpr int mod = 1e9 + 7;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    if(w == 1) {
        cout << 1 << endl;
        return 0;
    }
    k--;
    vector<int> dp(w);
    dp[k] = 1;
    for(int i = 0; i < h; ++i) {
        vector<int> nxt(w);
        for(int j = 0; j < w; ++j) {
            if(dp[j] == 0) continue;
            for(int S = 0; S < (1 << (w - 1)); ++S) {
                bool check = true;
                for(int l = 0; l < w - 2; ++l) {
                    if((S & (1 << l)) && (S & (1 << (l + 1)))) check = false;
                }
                if(!check) continue;
                if(j != 0 && (S & (1 << (j - 1)))) (nxt[j - 1] += dp[j]) %= mod;
                else if(S & (1 << j))  (nxt[j + 1] += dp[j]) %= mod;
                else  (nxt[j] += dp[j]) %= mod;
            }
        }
        dp = move(nxt);
    }

    cout << dp[0] << endl;
}


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

const int inf = 0x3f3f3f3f, N = 3e5;

struct RMQ {
        vector <int> t;
        int n;
        RMQ(int n) : n(n) {
                t.resize(n << 1);
        }
        void build(int a[]) {
                for(int i = 0; i < n; i++) t[n + i] = a[i];
                for(int i = n - 1; i > 0; --i) t[i] = min(t[i << 1], t[i << 1 | 1]);
        }
        void modify(int p, int v) {
                for(t[p += n] = v; p > 1; p >>= 1) t[p >> 1] = t[p] | t[p ^ 1];
        }
        int query(int l, int r) { int res = 0;
                for(l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
                        if(l & 1) res = (res | t[l++]);
                        if(r & 1) res = (res | t[--r]);
                }
                return res;
        }
};

int main() {
    int n; string str; cin >> n >> str;
    RMQ X(n + 1);
    for(int i = 1; i <= n; i++) {
        X.modify(i, 1 << (str[i - 1] - 'a'));
    }
    int q; cin >> q;
    while(q--) {
        int typ; cin >> typ;
        if(typ == 1) {
            int idx; string xx; cin >> idx >> xx;
            X.modify(idx, 1 << (xx[0] - 'a'));
        } else {
            int l, r; cin >> l >> r;
            int ans = X.query(l, r);
            cout << __builtin_popcount(ans) << endl;
        }
    }
}


Measured memory_bytes: 4868
<?php

define('MAX', 1000000);
$table = new SplFixedArray(MAX);
$table[0] = 0;
$table[1] = 0;
$i = 2;
while ($i < MAX) {
    $table[$i] = $table[$i - 1] + 1;
    for ($j = $i * 2; $j < MAX; $j += $i) {
        $table[$j] = -1;
    }
    $i++;
    while ($i < MAX && $table[$i] === -1) {
        $table[$i] = $table[$i - 1];
        $i++;
    }
}

while (true) {
    fscanf(STDIN, '%d', $n);
    if (feof(STDIN)) {
        break;
    }

    echo $table[$n];
    echo PHP_EOL;
}

Measured memory_bytes: 57492