akhauriyash/Code-Regression huggingface dataset:
'use strict'

function main(s) {

  const N = Number(s);
  let answer = 11;

  for (let i = 1; i <= Math.sqrt(N); i++) {
    if (Number.isInteger(N / i)) {
      const f = Math.max(String(i).length, String(N / i).length);
      answer = Math.min(answer, f);
    }
  }

  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8652
#include <bits/stdc++.h>
#include <queue>
using namespace std;
using P = pair<int,int>;

int main() {
    int n; cin >> n;
    vector<P> red(n);
    vector<P> blue(n);
    for(int i=0; i<n; i++){
        cin >> red[i].second;
        cin >> red[i].first;
    }
    for(int i=0; i<n; i++){
        cin >> blue[i].first;
        cin >> blue[i].second;
    }
    //blueはx座標で昇順(blueは(x,y))
    sort(blue.begin(),blue.end());
    //redはy座標で降順(redは(y,x))
    sort(red.begin(),red.end(),greater<P>());
    //redをカウントしたかメモ
    vector<bool> used(n,false);

    int cnt = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(blue[i].first > red[j].second && blue[i].second > red[j].first && !used[j]){
                used[j] = true;
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c << endl;
  }
  else if(a==c){
    cout << b  << endl;
  }
  else{
    cout << a << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pencils
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] inputItems = line.Split(' ');
            int N = int.Parse(inputItems[0]);
            int A = int.Parse(inputItems[1]);
            int B = int.Parse(inputItems[2]);
            int C = int.Parse(inputItems[3]);
            int D = int.Parse(inputItems[4]);

            int minSum = 0;

            if(N % A == 0)
            {
                if( N % B == 0)
                {
                    minSum = Math.Min((N / A * B),(N / C * D));
                }
                else
                {
                    minSum = Math.Min((N / A * B), ((N / C + 1) * D));
                }

            }
            else
            {
                if (N % C == 0)
                {
                    minSum = Math.Min(((N / A +1) * B), (N / C * D));
                }
                else
                {
                    minSum = Math.Min(((N / A + 1)* B), ((N / C + 1) * D));
                }
            }

            Console.WriteLine(minSum.ToString());
            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 17924
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var k = int.Parse(spl[0]);
        var t = int.Parse(spl[1]);

        var ary = ToIntArray(input.ReadLine(), t);

        Array.Sort(ary, (x,y)=>y-x);

        int now = ary.First();

        for(int i=1; i<t; i++) {
            var x = ary[i];
            if(now >= x) {
                now -= x;
            }else{
                now = x-now;
            }
        }

        if(now > 0) now--; //last1
        return now;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	vector<int>vec(n);
	rep(i, 0, n)cin >> vec[i];
	map<int, int>even, odd;
	rep(i, 0, n) {
		if (i % 2 == 0)even[vec[i]]++;
		else odd[vec[i]]++;
	}
	int a = 0, b = 0, x = 0, y = 0;
	for (auto p : even) {
		if (chmax(a, p.second))x = p.first;
	}
	for (auto p : odd) {
		if (chmax(b, p.second))y = p.first;
	}
	int ans = 0;
	if (x == y) {
		int c = 0, d = 0;
		for (auto p : even) {
			if (p.first == x)continue;
			chmax(c, p.second);
		}
		for (auto p : odd) {
			if (y == p.first)continue;
			chmax(d, p.second);
		}
		if (c > d) {
			ans = n - c - b;
		}
		else if (c <= d) {
			ans = n - a - d;
		}

	}
	else {
		ans = n - a - b;
	}
	cout << ans << "\n";

	return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        cout << S[i];
        if (i == 3) cout << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;cin>>n>>m;
    int sum=0;
    rep(i,m){
        int tmp;
        cin>>tmp;
        sum+=tmp;
    }
    if(sum > n){
        cout<<-1<<endl;
    }
    else{
        cout<<n-sum<<endl;
    }

}


Measured memory_bytes: 3632
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b, c) = listOfInt()
    println(
        when (a) {
            b -> c
            c -> b
            else -> a
        }
    )
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

if n == 0:
    print(0)
    exit()

ans = ''

flag = True

while n != 0:
    if abs(n % 2) == 1:
        ans += '1'
        if flag:
            n -= 1
        else:
            n += 1
    else:
        ans += '0'

    n = n // 2
    flag = not flag

print(ans[::-1])

Measured memory_bytes: 61776
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)



//小文字=大文字+32
int main() {
	int n, k, q;
	cin >> n>> k >> q;
	map<int, int>m;
	vector<int>a(q);
	rep(i, q) {
		cin >> a[i];
		m[a[i]-1]++;
	}
	int ans = 0;
	rep(i, n) {
		if (k - q + m[i] > 0) {
			cout << "Yes"<<endl;
		}
		else {
			cout << "No" << endl;
		}

	}
	
}
	



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

int main() {
  string s;
  int q;
  cin >> s >> q;
  for (int i = 0; i < q; ++i) {
    string command;
    int a, b;
    cin >> command >> a >> b;
    if (command == "print") {
      cout << s.substr(a, b - a + 1) << endl;
    } else if (command == "reverse") {
      string tmp = s.substr(a, b - a + 1);
      reverse(tmp.begin(), tmp.end());
      s = s.substr(0, a) + tmp + s.substr(b + 1, s.size() - b + 1);
    } else if (command == "replace") {
      string p;
      cin >> p;
      s = s.substr(0, a) + p + s.substr(b + 1, s.size() - b + 1);
    }
  }

  return 0;
}


Measured memory_bytes: 3240
n=input()
dc=dict()
for j in input().split():
    i=int(j)
    if i in dc:
        dc[i]+=1
    else:
        dc[i]=1
ans=0
for i in dc:
    if dc[i]>i:
        ans+=dc[i]-i
    elif dc[i]<i:
        ans+=dc[i]
print(ans)
    


Measured memory_bytes: 65832
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();
const unsigned long long int ULLINF = numeric_limits<unsigned long long int>::max();
const long long mod = 1000000007;

int main() {
    
    LL s;
    cin >> s;

    VLL v(2001,0);
    v[0] = 1;   // 空なる数列も許容するとする
    v[1] = 0;
    v[2] = 0;
    v[3] = 1;

    for (LL i=4; i<=2000; i++) {
        v[i] = (v[i-1] + v[i-3])%mod;
    }

    cout << v[s] << endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=2000100;
const int M=1e9+7;
int fac[N],n,ans,inv[N],f[N];
int fp(int x,int y){
	int ret=1;
	for (; y; y>>=1,x=(long long)x*x%M) if (y&1) ret=(long long)ret*x%M;
	return ret;
}
int c(int x,int y){
	if (x>y) return 0;
	return (long long)fac[y]*inv[x]%M*inv[y-x]%M;
}
int calcg(int deep,int x){
	return c(x,deep-x+1);
}
int main(){
	fac[0]=1; for (int i=1; i<=2000000; ++i) fac[i]=(long long)fac[i-1]*i%M;
	inv[2000000]=fp(fac[2000000],M-2); for (int i=1999999; i>=0; --i) inv[i]=(long long)inv[i+1]*(i+1)%M;
	scanf("%d",&n);
	for (int i=1; i<n; ++i){
		f[i]=(long long)calcg(n-3,n-1-i)*fac[n-1-i]%M*fac[i]%M;
		(ans+=(long long)((f[i]-f[i-1]+M)%M)*i%M)%=M;
	}
	cout<<ans;
}

Measured memory_bytes: 21632
from math import ceil


def A(n, x, t):
  return ceil(n / x) * t


def B(n_str):
  s = 0
  for c in n_str:
    s += int(c)
  if s % 9 == 0:
    return 'Yes'
  return 'No'


def C(n, a):
  ans = 0
  for i in range(1, n):
    if a[i - 1] > a[i]:
      ans += a[i - 1] - a[i]
      a[i] = a[i - 1]
  return ans


def main():
  # n, x, t = map(int, input().split())
  # print(A(n, x, t))
  # n_str = input()
  # print(B(n_str))
  n = int(input())
  a = list(map(int, input().split()))
  print(C(n, a))


if __name__ == '__main__':
  main()


Measured memory_bytes: 33060
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
typedef  long long int lli;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inf (1000*1000*1000+5)
const int NODE =1e4+9;

const int mod=1e9+7;
const lli num=2000000;

void init(){

}


int main()
{
   boost;
   int t=1;
   //cin>>t;
   init();
   while(t--){
      int n,k;
      cin>>n>>k;
      int a[n];
      for(int i=0;i<n;i++)cin>>a[i];
      int dp[n+1][k+2];
      memset(dp,0,sizeof(dp));
      dp[0][0]=1;
      for(int i=1;i<=n;i++){
         vector<int>sum(k+1);
         sum[0]=dp[i-1][0];
         for(int j=1;j<=k;j++)sum[j]=(sum[j-1]+dp[i-1][j])%mod;
         for(int j=0;j<=k;j++){
            int not_ex=j-a[i-1]-1;
            if(j<=a[i-1])dp[i][j]=sum[j];
            else dp[i][j]=(sum[j]-sum[not_ex]+mod)%mod;
         }
         sum.clear();
      }
      cout<<dp[n][k]<<endl;
   }
   return 0;
}


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

int main()
{
    int i,j,k,n,F[100][10],P[100][11],d[10],bodays[100],t=0,sum=0,max=-1e+9;
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        for (j=0;j<10;j++)
        {
            scanf("%d",&F[i][j]);
        }
    }
    for (i=0;i<n;i++)
    {
        for (j=0;j<11;j++)
        {
            scanf("%d",&P[i][j]);
        }
    }
    for (i=1;i<1024;i++)
    {
        for (j=0;j<10;j++)
            d[j]=(i>>j)%2;
        for (k=0;k<n;k++)
        {
            for (t=0,j=0;j<10;j++)
            {
                if (F[k][j]&&d[j]) t++;
            }
            bodays[k]=t;
        }
        for (sum=0,k=0;k<n;k++)
            sum+=P[k][bodays[k]];
        if (sum>max) max=sum;
    }
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
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 mid = a + b;
		if (mid % 2 == 1) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println(mid / 2);
		}
	}
}


Measured memory_bytes: 23636
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    print((ii()+1)//2)


main()







Measured memory_bytes: 5172
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;

int main(){
    ll x, y;
    cin >> x >> y;
    if(abs(x)>=abs(y)){
        if(x>=0&&y>0){
            cout<<(abs(x)-abs(y))+2<<endl;
        }else if(x>=0&&y<=0){
            cout<<(abs(x)-abs(y))+1<<endl;
        }else if(x<0&&y>0){
            cout<<(abs(x)-abs(y))+1<<endl;
        }else{
            cout<<(abs(x)-abs(y))<<endl;
        }
    }else{
        if(x>=0&&y>=0){
            cout<<(abs(y)-abs(x))<<endl;
        }else if(x>=0&&y<0){
            cout<<(abs(y)-abs(x))+1<<endl;
        }else if(x<0&&y>=0){
            cout<<(abs(y)-abs(x))+1<<endl;
        }else{
            cout<<(abs(y)-abs(x))+2<<endl;
        }
    }




}


Measured memory_bytes: 256
from collections import Counter
from itertools import product
N = int(input())
V = list(map(int, input().split()))

c0mc = Counter(V[::2]).most_common(2)
c1mc = Counter(V[1::2]).most_common(2)
# [0] is error avoidance
if len(c0mc) == 1:
    c0mc.append((0, 0))
if len(c1mc) == 1:
    c1mc.append((0, 0))

print(N - max(a[1] + b[1] for (a, b) in product(c0mc, c1mc) if a[0] != b[0]))


Measured memory_bytes: 15588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;

string solve(int n) {
    vector<int> c(n);
    vector<int> dp(2001, 10000);
    dp[0] = 0;
    rep(i,n) cin >> c[i];
    if (c[0] != 1)return "Cannot pay some amount";
    for (int i = 1; i < 2001; i++) {
        rep(j, n) {
            int m = i - c[j];
            if (m < 0)continue;
            dp[i] = min(dp[i], dp[m] + 1);
        }
        int amount = i;
        int greed = 0;
        for (int j = n - 1; j >= 0; j--) {
            while(amount >= c[j]) {
                amount -= c[j];
                greed++;
            }
        }
        if (greed != dp[i])return "Cannot use greedy algorithm";
    }
    return "OK";
}

int main() {
    int n;
    int cases = 1;
    while(cin >> n, n) {
        cout << "Case #" << cases << ": " << solve(n) << endl;
        cases++;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
#include <random>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << '\n';
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){

	int N;
	cin >> N;
	debug(N);
	if (N&1)
	{
		N *= 2;
	}
	cout << N << endl;
	debug(N);
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int H,W;
    string instr;
    int temp;

    cin >> H >> W;

    for(int i=0; i<H; ++i) {
        cin >> instr;
        temp=(instr[0]=='.'?-1:0);
        cout << temp;
        for(int j=1; j<W; ++j) {
            if(instr[j]=='c') {
                temp=0;
            } else if(temp==-1) {
                temp=-1;
            } else {
                temp=temp+1;
            }
            cout << " " << temp;
        }
        cout << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

int n, m;
vector<vector<int>> g, h;
vector<bool> used;
map<pair<int, int>, int> e; // 頂点aと頂点bを結ぶ辺

void dijkstra(int b) {
  vector<int> dist = vector<int>(n + 1, 1e9);
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  dist[b] = 0;
  q.push(make_pair(0, b));
  while (!q.empty()) {
    auto p = q.top();
    int u = p.second, c = p.first;
    q.pop();
    for (int v = 1; v <= n; v++) {
      if (u == v || g[u][v] == 1e9) {
        continue;
      }
      if (dist[v] >= c + g[u][v]) {
        dist[v] = c + g[u][v];
        if (dist[v] == h[u][v]) {
          int wu = u, wv = v;
          if (wu > wv) swap(wu, wv);
          used[e[make_pair(wu, wv)]] = true;
        }
        q.push(make_pair(dist[v], v));
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  g = vector<vector<int>>(n + 1, vector<int>(n + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        g[i][j] = 0;
      } else {
        g[i][j] = 1e9;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = c;
    g[b][a] = c;
    if (a > b) swap(a, b);
    e[make_pair(a, b)] = i + 1;
  }
  h = g;
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        h[i][j] = min(h[i][j], h[i][k] + h[k][j]);
      }
    }
  }
  used = vector<bool>(m + 1, false);
  for (int i = 1; i <= n; i++) {
    dijkstra(i);
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (!used[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
const int M=1e9+7;



int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);

  int a,b,c,k;
  cin>>a>>b>>c>>k;
  ll sum=0;
  while(k--)
  {
  	if(a)
  	{
  	sum+=1;
	--a;
	continue;	
	}
	else if(b)
	{
		--b;
		continue;
	}
	else if(c)
	{
		sum+=-1;
	}
	else
	break;
  }
 cout<<sum <<'\n';

   return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			//var In=Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));
			var s=Console.ReadLine().Split(' ');
			int[] In=new int[7];
			for(int i=0;i<7;i++)In[i]=int.Parse(s[i]);
			if(In[0]==0)break;
			Sol mySol=new Sol(In);
			Console.WriteLine(mySol.Ans);
		}
	}
}

class Sol{
	int ans;
	public int Ans{
		get{return ans;}
	}
	
	int P;
	int[] Coin;
	int[] Val;
	public Sol(int[] In){
		P=In[0];
		Coin=new int[6];
		for(int i=0;i<6;i++)Coin[i]=In[i+1];
		Val=new int[6]{1,5,10,50,100,500};

		int[] GRDY=new int[501];
		for(int i=0;i<GRDY.Length;i++)GRDY[i]=0;

		for(int i=0;i<501;i++){
			int trgt=P+i;
			//trgt 円ぴったり払えるかgreedily-searchする。ダメなら0。
			GRDY[i]=greedy(trgt);

		}
//for(int kk=0;kk<GRDY.Length;kk++){Console.Write("{0} ",GRDY[kk]);}Console.WriteLine("");


		
		int min=9999;
		for(int i=0;i<GRDY.Length;i++){
			if(GRDY[i]>0){
				if(min>GRDY[i]+count_change(i))min=GRDY[i]+count_change(i);
			}
		}
		
		ans=min;
	}
	
	int greedy(int trgt){
		int cnt=0;
		int[] Rest=new int[6];
		for(int i=0;i<6;i++)Rest[i]=Coin[i];
		
		for(int i=5;i>=0;i--){
			bool chk=true;
			while(chk){
				chk=false;
				if(Rest[i]>0 && trgt>=Val[i]){
					cnt++;
					Rest[i]--;
					trgt-=Val[i];
					chk=true;
				}
			}
		}
		
		if(trgt==0)return cnt;
		return 0;
	}

	int count_change(int pay){
		int cnt=0;
		cnt+=pay/500;
		pay-=(pay/500)*500;
		cnt+=pay/100;
		pay-=(pay/100)*100;
		cnt+=pay/50;
		pay-=(pay/50)*50;
		cnt+=pay/10;
		pay-=(pay/10)*10;
		cnt+=pay/5;
		pay-=(pay/5)*5;
		cnt+=pay;
		
		return cnt;
	}
}

Measured memory_bytes: 5816
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  for (int i = 1; i <= 5; ++i) {
    int x; cin >> x;
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3524
N, M = map(int, input().split())
pS = [list(input().split()) for _ in range(M)]

memo = [[0] * 2 for _ in range(N)]
memo_WA = [0] * N

answer_AC = 0
answer_WA = 0

for i in range(M):
    if memo[int(pS[i][0]) - 1][0] == 1:
        continue
    elif pS[i][1] == "AC":
        answer_AC += 1
        memo[int(pS[i][0]) - 1][0] = 1
    else:
        memo_WA[int(pS[i][0]) - 1] += 1

for i in range(N):
    if memo[i][0] == 1:
        answer_WA += memo_WA[i]

print(answer_AC)
print(answer_WA)

Measured memory_bytes: 36936
#include<stdio.h>
#include<stdlib.h>
int linearSearch(int n,int *s, int q, int *t){
    int i,j;
    for(i=0;i<n;i++){
        if(*(s+i)==*t) return 1;
    }
    return 0;
}
int main(void){
    int n,q,j,B,count=0;
    int *s,*t;
    scanf("%d\n",&n);
    s=malloc(sizeof(int)*(n));
    for(j=0;j<n;j++){
        scanf("%d",(s+j));
    }
    scanf("%d\n",&q);
    t=malloc(sizeof(int)*(q));
    for(j=0;j<q;j++){
        scanf("%d",(t+j));
    }

    for(j=0;j<q;j++){
        B=linearSearch(n,s,q,t+j);
        if(B==1) count++;
    }
   printf("%d\n",count);

    free(s);
    free(t);
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    rep(i, 7) {
        if (day[i] == s) {
            cout << 7 - i << endl;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A[2000000],i,n,maxv,minv;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  maxv=A[1]-A[0];
  minv=A[0];
  for(i=1;i<n;i++){
    if(maxv<A[i]-minv)
      maxv=A[i]-minv;
    if(minv>A[i])minv=A[i];
  }
  printf("%d\n",maxv);
  return 0;
}



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

const int N = 1e5 + 7;

long long a[N], b[N], n, c[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i], c[i] = i;
	sort (c + 1, c + n + 1, [](int x, int y) {
		return 	a[x] + b[x] > a[y] + b[y];
	});
	long long res = 0;
	for (int i = 1; i <= n; i++)
		if (i % 2)
			res += a[c[i]];
		else
			res -= b[c[i]];
	cout << res;

}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<char> vec(N);
  for(int i=0; i<N; i++){
    vec.at(i) = S.at(i);
  }
  sort(vec.begin(), vec.end());
  long long ans = 1;
  long long count = 1;
  for(int j=0; j<N-1; j++){
    if(vec.at(j) == vec.at(j+1)){
      count++;
    }
    else{
      ans = ans *(count+1) %1000000007;
      count = 1;
    }
  }
  if(N == 1){
    ans = 2;
  }
  else if(vec.at(N-2) == vec.at(N-1)){
    ans = ans * (count+1) %1000000007;
  }
  else{
    ans *= 2;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 512
str1 = gets.split
N,M = str1[0].to_i, str1[1].to_i

l = 1
r = N

for x in 1..M
  str1 = gets.split
  li,ri = str1[0].to_i, str1[1].to_i
  if li > l
    l = li
  end
  if ri < r
    r = ri
  end
end

answer = r-l+1
if answer < 0
  answer = 0
end

puts answer

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

using namespace std;


int main()
{
    //freopen("in.txt","r",stdin);
    int n,a=1;
    cin>>n;

    map<string,int> mp;
    vector<string> vs,vf;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(mp[s] > 0)
        {
            mp[s]++;
        }
        else
        {
            mp[s]=1;
            vs.push_back(s);
        }
    }
    int mx=0;
    for(int i=0;i<vs.size();i++)
    {
        string s=vs[i];
        if(mp[s]> mx)
        {
            mx=mp[s];
            vf.clear();
            vf.push_back(s);
        }
        else if(mp[s]== mx)
            vf.push_back(s);
    }
    sort(vf.begin(),vf.end());
    for(int i=0;i<vf.size();i++)
        cout<<vf[i]<<endl;



    return 0;
}


Measured memory_bytes: 29040
#include <iostream>
#include <algorithm>
using namespace std;
int l[205];
int n,i,sum;
int main()
{
    cin>>n;
    for(i=1;i<=2*n;i++)
        cin>>l[i];
    sort(l+1,l+2*n+1);
    for(i=1;i<=2*n;i+=2)
        sum+=l[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 


    ll n, k; cin >> n >> k;

    if (n == 1)
    	 cout << 1 << endl;
   else   
      cout << ceil(log(n) / log(k)) << endl;   
 
    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<pair<int,int>> A(N);
    REP1(i,N){
        int a;cin>>a;
        A[i-1]=mp(a,i);
    }
    sort(all(A));
    cout<<A[0].second;
    REP1(i,N-1){
        cout<<" ";
        cout<<A[i].second;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4992
import math
A, B, H, M = map(int, input().split())

# while M >= 60:
#     M -= 60
# if H >= 12:
#     H -= 12

time = H*60 +M

cho = 6*M
tan = 0.5*time

if cho > tan:
    kakudo = cho - tan
else:
    kakudo = tan - cho

if kakudo > 180:
    kakudo = 360 - kakudo

ans = math.sqrt((A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo))))

print(ans)


Measured memory_bytes: 9532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123;
int n, k, p[N], f[2][N], inv[N];
multiset <int> st;

int sorted(int l, int r) {
	return ((r > 0) ? inv[r - 1] : 0) - ((l > 0) ? inv[l - 1] : 0) == 0;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n - 1; i++)
		inv[i] = ((i > 0) ? inv[i - 1] : 0) + (p[i] > p[i + 1]);
	for (int i = 0; i < n; i++) {
		st.insert(p[i]);
		if (i >= k)
			st.erase(st.find(p[i - k]));
		if (i >= k - 1)
			f[0][i - k + 1] = *st.begin(), f[1][i - k + 1] = *(--st.end());
	}
	int res = 0, flag = 0;
	for (int i = 0; i < n - k + 1; i++) {
		if (sorted(i, i + k - 1)) flag = 1;
		else res++;
	}
	res += flag;
	for (int i = 0; i < n - k; i++) {
		if (sorted(i, i + k - 1) || sorted(i + 1, i + k)) continue;
		if (f[1][i] < p[i + k] && p[i] < f[0][i + 1])
			res--;
	}
	cout << res;
}


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

int main() {
    string s,t;cin>>s>>t;
    int n=s.size();
    int ans=0;
    for(int i=0;i<n;++i){
        if(s[i]!=t[i])ans=1;
    }
    if(ans==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3596
// https://atcoder.jp/contests/abc159/tasks/abc159_d

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)

#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;

int N;
vector<int> A;

map<int, int> mp;

int main() {
  cin >> N;
  A = vector<int>(N);
  REP(i, N) {
    cin >> A[i];
    mp[A[i]]++;
  }

  ll sum = 0LL;
  ITR(mp, it) {
    ll c = it-> second;
    sum += c * (c - 1) / 2;
  }

  REP(k, N) {
    int c = mp[A[k]];
    ll ans = sum - c + 1;
    cout << ans << endl;
  }
}


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

using ll = long long;

int main() {
    ll K;
    cin >> K;
    ll x = K / 50, y = K % 50;
    cout << 50 << endl;
    rep(i, 50) {
        if (i < y) cout << x + 50 + i - y + 1;
        else cout << x + i - y;
        if (i < 49) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  const ll Mod = 1e9 + 7;
  ll n, k;
  cin >> n >> k;
  ll a = 0, b = n, c = 0, d = 0;
  ll sum = 0;
  rep(i,n+1)
  {
    c += a++;
    d += b--;
    if (i >= k - 1) {
      sum += d - c + 1;
      if (sum >= Mod) {
        sum %= Mod;
      }
    }
  }
  cout << sum;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int crs(double x1, double y1, double x2, double y2) {
    double z = x1*y2-y1*x2;
    return (0 < z ? 1 : (z < 0 ? -1 : 0));
}

bool intersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
    if (0 <= crs(x2-x1, y2-y1, x3-x1, y3-y1) * crs(x2-x1, y2-y1, x4-x1, y4-y1)) return false;
    if (0 <= crs(x4-x3, y4-y3, x1-x3, y1-y3) * crs(x4-x3, y4-y3, x2-x3, y2-y3)) return false;
    return true;
}

pair<double,double> intersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
    if (x3 == x4) {
        swap(x1, x3); swap(y1, y3); swap(x2, x4); swap(y2, y4);
    }
    double x, y, a, b, c, d;
    if (x1 == x2) {
        c = (y4-y3)/(x4-x3);
        d = y3-c*x3;
        x = x1;
        y = c*x+d;
    } else {
        a = (y2-y1)/(x2-x1);
        b = y1-a*x1;
        c = (y4-y3)/(x4-x3);
        d = y3-c*x3;
        x = (d-b)/(a-c);
        y = a*x+b;
    }
    return make_pair(x,y);
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    while (N--) {
        double xa, ya, xb, yb;
        int n;
        cin >> xa >> ya >> xb >> yb >> n;
        bool vertical = abs(xa-xb) < abs(ya-yb);

        double xs, ys, xt, yt;
        int o, l;
        vector<pair<double,int> > levels;
        for (int i=0; i<n; ++i) {
            cin >> xs >> ys >> xt >> yt >> o >> l;
            if (intersect(xa, ya, xb, yb, xs, ys, xt, yt)) {
                if (vertical) {
                    double y = intersection(xa, ya, xb, yb, xs, ys, xt, yt).second;
                    levels.push_back(make_pair(y, o==1 ? l : 1-l));
                } else {
                    double x = intersection(xa, ya, xb, yb, xs, ys, xt, yt).first;
                    levels.push_back(make_pair(x, o==1 ? l : 1-l));
                }
            }
        }

        sort(levels.begin(), levels.end());
        int res = 0;
        for (int i=1; i<(int)levels.size(); ++i) {
            if (levels[i].second != levels[i-1].second) {
                res ++;
            }
        }

        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>
#include <sstream>
#include <iomanip>

using namespace std;




int main()
{
	int N;

	cin >> N;

	for(int a = 1; a < 10; a++){
		for(int b = 1; b < 10; b++){
			if (a * b == N){
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";


	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <complex>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()

template <typename T, typename E>
ostream &operator<<(std::ostream &os, const std::pair<T, E> &p){
  return os << "(" << p.first << ", " << p.second << ")";
}

typedef long long ll;

const int INF = 1e9;

struct edge {
  int to;
  int cost;
  int time;
  int line;
  edge(){}
  edge(int to, int cost, int time, int line) : to(to), cost(cost), time(time), line(line){}
};

int main(){
  ios::sync_with_stdio(false);
  int N, M, H, K;
  while (cin >> N >> M >> H >> K && N){
    vector<vector<edge> > G(N);
    REP(i, M){
      int a, b, c, h, r;
      cin >> a >> b >> c >> h >> r; a--, b--, r--;
      G[a].push_back(edge(b, c, h, r));
      G[b].push_back(edge(a, c, h, r));
    }

    int S, T, P;
    cin >> S >> T >> P; S--, T--;
    vector<int> pass_cost(P);
    vector<int> pass_mask(P);
    REP(i, P){
      int l, k;
      cin >> l >> pass_cost[i];
      REP(j, l){
        cin >> k;
        pass_mask[i] |= 1 << (k - 1);
      }
    }
    vector<int> mask_cost(1 << K, INF);
    mask_cost[0] = 0;
    REP(mask, 1 << K) if (mask_cost[mask] < INF){
      REP(i, P){
        int nmask = mask | pass_mask[i];
        mask_cost[nmask] = min(mask_cost[nmask], mask_cost[mask] +  pass_cost[i]);
      }
    }

    int res = INF;

    vector<vector<int> > cost(H + 1, vector<int>(N, INF));
    REP(mask, 1 << K){
      REP(h, H + 1)REP(v, N) cost[h][v] = INF;

      cost[0][S] = mask_cost[mask];
      
      REP(h, H) REP(v, N) if (cost[h][v] < INF){
        for (const auto &e: G[v]){
          int n_cost = cost[h][v] + (((1 << e.line) & mask) ? 0 : e.cost);
          int n_time = h + e.time;
          if (n_time <= H && cost[n_time][e.to] > n_cost){
            cost[n_time][e.to] = n_cost;
          }
        }
      }
      REP(h, H + 1) res = min(res, cost[h][T]);
    }
    cout << (res == INF ? -1 : res) << endl;
  }
  return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n;
    scanf("%d", &n);
    
    int t=0, x=0, y=0;
    
    for(int i=0; i<n; i++){
        int _t, _x, _y;
        scanf("%d %d %d", &_t, &_x, &_y);
        int dist=abs(x-_x)+abs(y-_y);
        t=_t-t;
        x=_x-x;
        y=_y-y;
        if(t<dist || t%2!=dist%2){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll ar[205];
int main()
{
	_fastio
	ll x,n,a,mn,sv;
	cin>>x>>n;
	for1(i,n)
	{
		cin>>a;
		ar[a]=1;
	}
	for(ll i=-x;i<=x*2;i++)
	{
		if(i==-x)
		{
			sv=i;
			mn=abs(x-i);
		}
		else
		{
			if(i<0)
			{
				if(abs(x-i)<mn)
				{
					sv=i;
					mn=abs(x-i);
				}
			}
			else
			{
				if(ar[i]!=1)
				{
					if(abs(x-i)<mn)
					{
						sv=i;
						mn=abs(x-i);
					}
				}
			}
		}
	}
	cout<<sv<<en;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n;vector<int> p,q;
vector<int> t;
signed main(){
cin>>n;
rep(i,n){
  int pp;cin>>pp;p.push_back(pp);
}
rep(i,n){
  int qq;cin>>qq;q.push_back(qq);
}
rep(i,n){
  t.push_back(i+1);
}
int a, b, i = 0;
do{
  i++;bool pp = true, qq = true;
  rep(j,n){
    if(t[j] != p[j])pp = false;
    if(t[j] != q[j])qq = false;
  }
  if(pp)a = i;
  if(qq)b = i;
}while(next_permutation(t.begin(), t.end()));
cout << abs(a-b) << endl;
}



Measured memory_bytes: 256
N = int(input())
nums = [int(e) for e in input().split()]
for i in range(N):
    if nums[i]%2 == 1:
        pass
    else:
        if nums[i]%3 == 0 or nums[i]%5 == 0:
            pass
        else:
            print("DENIED")
            break
    if i == N-1:
        print("APPROVED")
    else:
        pass
    

Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = sum(a)
for i in range(n):
    if b[i] > a[i]:
        b[i] -= a[i]
        a[i] = 0
        if b[i] > a[i + 1]:
            a[i + 1] = 0
        else:
            a[i + 1] -= b[i]
    else:
        a[i] -= b[i]
ans -= sum(a)
print(ans)


Measured memory_bytes: 24144