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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		System.out.println(pow(k-1,n-1)*k);
		sc.close();
	}
	public static long pow(long x, long n) {
	    long sum = 1;
	    while (n > 0) {
	        if ((n & 1) == 1) {
	            sum = sum * x;
	        }
	        x = x*x;
	        n >>= 1;
	    }
	    return sum;
	}
}

Measured memory_bytes: 22868
[X,N] = list(map(int,input().split()))
p = list(map(int,input().split()))

#p = sorted(p)
#ammy=[0]*

for i in range(200):
    if X+i in p:
        continue
    else:
        dammy1=X+i
        kouho1=i
        break

for j in range(200):
    if X-j in p:
        continue
    else:
        dammy2=X-j
        kouho2=j
        break

#print(dammy1,dammy2)

if kouho1<kouho2:
    print(dammy1)
else:
    print(dammy2)

Measured memory_bytes: 61632
#include<stdio.h>

int main() {
	int N[31] = { 0 };
	int i, j;
	for (i = 0; i < 29; i++) {
		scanf("%d", &j);
		N[j] = 1;
	}
	for (i = 1; i < 31; i++) {
		if (N[i] == 0)
			printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int result;
  if (a + b > c * 2) {
    result = c * min(x, y) * 2;
  } else {
    result = (a + b) * min(x, y);
  }
  int temp = min(x, y);
  y -= temp;
  x -= temp;
  if (a > c * 2) {
    result += c * x * 2;
  } else {
    result += a * x;
  }
  if (b > c * 2) {
    result += c * y * 2;
  } else {
    result += b * y;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let A = read::<i32>();
    let B = read::<i32>();
    let C = read::<i32>();

    let mut v: Vec<i32> = vec![];
    v.push(A);
    v.push(B);
    v.push(C);
    v.sort();

    if v[0] == 5 && v[1] == 5 && v[2] == 7 {
        println!("YES");
    } else {
        println!("NO");
    }

}


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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// Let's get AC!
int main(){
    
    long double n, m, d;
    cin >> n >> m >> d;

    if(d > 0)cout << 2 * (n - d) * (m - 1) / (n * n) << '\n';
    else cout << (n - d) * (m - 1) / (n * n) << '\n';
    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main (){
  string s;
  cin >> s;
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ) {
    cout << "Yes"; } else 
  if (s[1] == s[2] && s[0] == s[3] && s[1] != s[0] ) {
    cout << "Yes"; } else 
  if (s[0] == s[2] && s[1] == s[3] && s[0] != s[3] ) {
    cout << "Yes" ; } 
  else {
    cout << "No" ; } }

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

using namespace std;

int main()
{
    int n;
    long long X = 0, x = 0, ans = 1000000000000000000LL;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        X += a[i];
    }

    for (int i = 0; i < n; i++)
    {
        x += a[i];
        if (i + 1 < n)
            ans = min(ans, abs(X - 2 * x));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	LL h,w;
	cin>>h>>w;
	if(h==1 || w==1)cout<<1<<"\n";
	else cout<<(h*w+1)/2<<"\n";	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
X = int(input())

if X >= 30:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 27132
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
	double x1, x2, y1, y2,a,b;
	cin >> x1 >> y1 >> x2 >> y2;
	a = pow(x2 - x1, 2) + pow(y2 - y1, 2);
	b = sqrt(a);
	printf("%f\n", b);

	return 0;
}


Measured memory_bytes: 3192
n,m=map(int,input().split())
edges=[[]for i in range(n)]


for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

for v in edges[-1]:
  if 0 in edges[v]:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')

Measured memory_bytes: 39960
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(m)]

for a,b in ab:
	res = float('inf')
	for j in range(m-1,-1,-1):
		c,d = cd[j][0],cd[j][1]
		cur = abs(abs(a-c)+abs(b-d))
		# print(cur)
		if res >= cur:
			ans = j+1
			res = cur
	print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int A[1000000],n;

int binarySearch(int);


int main(){
      int i,q,key,s=0;

      scanf("%d",&n);
      for(i=0;i<n;i++){
        scanf("%d",&A[i]);
      }
      scanf("%d",&q);
      for(i=0;i<q;i++){
        scanf("%d",&key);
        if(binarySearch(key)){
          s++;
        }
      }printf("%d\n",s);

      return 0;
    }

int binarySearch(int key){
        int left = 0,right,mid;
        right = n;
        while (left < right){
            mid = (left + right) / 2;
            if (A[mid] == key){
                return 1;
            }else if( key < A[mid]){
                right = mid;
            }else{
                left = mid + 1;
              }
        }return 0;
    }



Measured memory_bytes: 2116
#include <stdio.h>

int rot[5][7] = {
{0,1,2,3,4,5,6},{0,2,6,3,4,1,5},{0,4,2,1,6,5,3},{0,3,2,6,1,5,4},{0,5,1,3,4,6,2}};
int assign[7];		// サイコロの1～6の各面に割り当てる数字
int tr['Z'];

void dice_init(int *a)
{
	int i;
	int t[5] = {0,'N','E','W','S'};
	for (i = 1; i <= 6; i++) assign[i] = a[i];
	for (i = 1; i <= 4; i++) tr[t[i]] = i;
}

char s[102];
int main()
{
	int i, k1, k2;
	int a[7], dice[2][7];
	char *p;

	for (i = 1; i <= 6; i++) scanf("%d", a+i);
	dice_init(a);
	scanf("%s", p=s);
	for (i = 1; i <= 6; i++) dice[0][i] = rot[0][i];
	for (k1 = 0, k2 = 1; *p; k1 = k2, k2 = !k2) {
		for (i = 1; i <= 6; i++) dice[k2][i] = dice[k1][rot[tr[*p]][i]];
		p++;
	}
	printf("%d\n", assign[dice[k1][1]]);
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<char> ans;
  int i;
  for (i=0;i<s.size();i++){
    if (s[i]=='0')  ans.push_back('0');
    if (s[i]=='1')  ans.push_back('1');
    if (s[i]=='B' and ans.size()>0)  ans.pop_back();
  }
  for (i=0;i<ans.size();i++){
    cout<<ans.at(i);
  }
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m, ans = 0;
	cin >> n >> m;
	vector <int> a(n+1);
	vector <bool> h(n+1);
	for (int i=1; i<=n; i++) {
		cin >> a[i];
		h[i] = 1;
	}
	for (int i=1; i<=m; i++) {
		int x, y;
		cin >> x >> y;
		if (a[x] > a[y]) h[y] = 0;
		else if (a[x] < a[y]) h[x] = 0;
		else h[x] = h[y] = 0;
	}
	for (int i=1; i<=n; i++) {
		ans += h[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3724
import math

N, D = [int(x) for x in input().split()]

Z = []
for i in range(N):
  Z.append([int(x) for x in input().split()])


ans = 0
for i in range(N):
    if math.sqrt(Z[i][0]**2 + Z[i][1]**2) <= D:
        ans += 1


print(ans)


Measured memory_bytes: 42368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll x;
  cin >> x;
  if(x % 11 > 6)
    cout << x / 11 * 2 + 2 << endl;
  else if (x % 11 == 0)
    cout << x / 11 * 2 << endl;
  else
    cout << x / 11 * 2 + 1 << endl;
  return 0;
}



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

int compare_int(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int main() {
	int hom[10];
	int i;

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

	qsort(hom, 10, sizeof(int), compare_int);

	for (i = 9; i >= 7; --i) {
		printf("%d\n", hom[i]);
	}

	return 0;
}

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

int main(void){

    int A,B,K; cin>>A>>B>>K;
    int mx;
    if(A>B) mx=A;
    else mx = B;

    int count = 0, ans;
    for (int i = mx; i >= 0; --i) {
        if((A%i==0)&&(B%i==0)) {
            count++;
        }
        if(count==K){
            ans = i;
            break;
        }
    }

    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b,ave,cut;
  int c;
  b=48;
  cin >> a >>b;
  ave=(a+b)/2;
  cut=ave+0.6;
  c=cut;
  //cout << ave << endl;
  //cout << cut << endl;
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int n;
	cin >> n;
	vector<string> s(n);
	for (auto i = s.begin(); i != s.end(); i++)
		cin >> *i;
	sort(s.begin(), s.end());
	int count = 1;
	for (auto i = s.begin() + 1; i!= s.end(); i++)
	{
		if (*i != *(i - 1))
			count++;
	}
	cout << count << endl;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};
// 出力は.xで！！！！

mint choose(int n,int a){
  mint x,y; x=y=1;
  rep(i,a){
    x*=n-i;
    y*=i+1;
  }
  return x/y;
}

mint kk2(int n){
    if(n==0) return 1;
    mint a=kk2(n/2);
    a*=a;
    if(n%2==1) a*=2;
    return a;
}

int main(){
    int n,a,b; cin >> n >> a >> b;
    mint ans=kk2(n);
    ans=ans-choose(n,a)-choose(n,b)-1;
    cout << ans.x << endl;
return 0;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B, C;
	std::cin >> A >> B >> C;
	if (A + B >= C) {
		std::cout << "Yes\n";
	} else {
		std::cout << "No\n";
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on
ll X;

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

  ll sum = 0;
  ll ans = 1;

  while (sum < X) {
    sum += ans;
    ans++;
  }
  ans--;

  cout << ans << endl;

  return 0;
}


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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s.substr(i,3)=="ABC")
      ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

int N;

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

    cin>>N;
    N=25-N;
    cout<<"Christmas";
    FOR(i,1,N)cout<<" Eve";
    cout<<'\n';

    return 0;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    string s,t;
    cin >> t >> s;
    if (s.length() != t.length()+1)
    {
        cout << "No";
        return;
    }
    for (int i = 0; i < t.length(); i++)
    {
        if (s[i]!=t[i])
        {
            cout << "No";
            return;
        }
    }

    cout << "Yes";
}

int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
    solve();
    //}
}


Measured memory_bytes: 3556
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  vi a(5);
  scan(a);
  int ans = 0;
  rep (i, 5) {
    ans += a[i] / 10 * 10;
    a[i] %= 10;
  }
  vi b;
  rep (i, 5) {
    if (a[i] != 0) {
      b.push_back(a[i]);
    }
  }
  int bn = b.size();
  if (bn == 0) {
    print(ans);
    return 0;
  }
  sort(all(b));
  ans += b[0];
  FOR (i, 1, bn) {
    ans += 10;
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;
    
int main()
{
    string s;
    cin >> s;

    int interval = s.size() - 1;
    ll ans = 0;

    // iが+をどこに入れるかを表すフラグ
    // i=0のときは(125)
    // i=1のときは(1+25)
    // i=2のときは(12+5)
    // i=3のときは(1+2+5)
    for (int i = 0; i < (1 << interval); i++) {
        ll num = s[0] - '0';
        // +が入り得る場所の数だけforループを回し、
        // フラグが立っている箇所のみif文が実行される
        for (int j = 0; j < interval; j++) {
            if (i & (1 << j)) {
                ans += num;
                num = 0;
            }
            num = num * 10 + s[j + 1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d;
    ll ans;
    cin>>a>>b>>c>>d;
    ans=b*d;
    ans=max({ans,a*c,a*d,b*c});
    cout<<ans;
    return 0;
}

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

#define fastread std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;

int main()
{
	fastread;
	
	ll n, i;

    cin>>n;

    ll ar[n][3], dp[n][3];

    for(i=0 ; i<n ; ++i)
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    
    dp[0][0] = ar[0][0];
    dp[0][1] = ar[0][1];
    dp[0][2] = ar[0][2];

    for(i=1 ; i<n ; ++i)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + ar[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + ar[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + ar[i][2];
    }

    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    
    return 0;
}

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

//temp
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b<a) { a=b; return 1; } return 0; }
//------------------------------------------


int main() {
  int N, M, X, Y, Z, i, num, xmax=-100, ymin=100, ans;
  cin >> N >> M >> X >> Y;


  REP(i, N) {
    in(num);
    chmax(xmax, num);
  }
  REP(i, M) {
    in(num);
    chmin(ymin, num);
  }
  Z = ymin;
  if(xmax < Z && X < Z && Z <= Y ){
    co("No War");
  }else{
    co("War");
  }

  return 0;
}


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    ll n, k; cin >> n >> k;
    V<ll> sum(k);
    for(int i = 1; i <= n; i++) sum[i % k]++;
    ll ans = 0;
    for(int a = 0; a < k; a++){
        ll b = (k - a) % k;
        ll c = (k - a) % k;
        if((b + c) % k != 0) continue;
        ans += sum[a] * sum[b] * sum[c];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
n,k=map(int, input().split()) 
s=list(input())
s=list('R')+s+list('L')
count1=0
count2=0

for i in range(1,n+2):
    if s[i-1]=='R' and s[i]=='L':
        if i==1 or i==n+1:
            count1+=1
        else:
            count2+=1
            
ans=n-(count1+count2*2)

if k<=count2:
    print(ans+k*2)
else:
    print(n-1)
    
    




            
             

Measured memory_bytes: 5420
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int table[1000][1000];
int dp[1000][1000];
int H,W,N;
int main() {
while(1)
{
	scanf("%d%d%d",&H,&W,&N);
	if(H==0)return 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			scanf("%d",table[i]+j);
			dp[i][j]=0;
		}
	}
	dp[0][0]=N-1;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(i+1<H){
				dp[i+1][j]+=(dp[i][j]+1-table[i][j])/2;
			}
			if(j+1<W){
				dp[i][j+1]+=(dp[i][j]+table[i][j])/2;
			}
			table[i][j]=(table[i][j]+dp[i][j])%2;
			//cout << table[i][j] << " ";
		}
		//cout << endl;
	}
	/*  
	cout << endl;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	int x=0;
	int y=0;
	while(x<H&&y<W){
		if(table[x][y]){
			y++;
		}
		else{
			x++;
		}
	}
	printf("%d %d\n",x+1,y+1);
}
}

Measured memory_bytes: 9000
#include<bits/stdc++.h>
using namespace std;
long long n,a,b; 
int main(){
    cin>>n>>a>>b;
    if(n==1&&a==b||n>1&&a<=b) cout<<(b-a)*(n-2)+1<<endl;
	else cout<<"0"<<endl;
    return 0;
} 

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

int main() {
  int a,b;
  
  cin >> a >> b;
  
  if(a%2 == 0 || b%2 == 0){
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <string.h>
#define m 10000007
using namespace std;

int a,b,c,n,i,d,o[110],l[110][110],e[110][110],dx[10]={0,-1,1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,-1,1,-1,1};
long long x,y,z,k;
stack<int> s;
queue<int> qx,qy,qn;
string r1,r2,r3,iop;
vector<pair<int,int> > v[200010];
//char r1[1010],r2[1010],r3[1010];

int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=b;t++)
    {
        scanf("%d",&o[t]);
        c=max(c,o[t]);
    }
    if(c*2<=a+1)
        printf("0");
    else
        printf("%d",2*c-a-1);
    return 0;
}

Measured memory_bytes: 4992
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;
 
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;
 
const int N = 1e6 + 123;
int n , lim = 64;
#define str Str
string str(int x){
    string t;
    if(x == 0)
        t = "0";
    while(x != 0){
        t += char(x % 10 + '0');
        x /= 10;
    }
    reverse(all(t));
    return t;
}
bool ask(int x){
    lim--;
    if(lim < 0){
		assert(0);    
    }
    //return (x <= n and str(x) <= str(n)) or (x > n and str(x) >  str(n));
    cout << "? " << x << endl;
	char ch ;
	cin >> ch;
	return ch == 'Y';
}
main(){
//	cin >> n;
	int res = 0;
	vector < int > tmp;
	for(int i = 0 ; i < 11 ; i++){
	    int l = 0 , r = 9 , d = -1;
	    if(i == 0)l++;
	    while(l <= r){
	        int m = (l + r) >> 1;
	        if(ask(res * 10 + m))
	            l = m + 1 , d = m;
	        else r = m - 1;
	    }
	    if(d == 9 and !ask(max(res * 100ll , 10ll))){
	        int l = 0 , r = 9 , ls = 0;
	        if(i == 0)l++;
	        while(l <= r){
	            int m = (l + r) >> 1;
	            if(ask(res * 100ll + m*10ll))
	                ls = m , r = m - 1;
	            else l = m + 1;
	        }
	        res = res * 10ll + ls;
	        tmp.pb(ls);
	        break;
	    }res = res * 10ll + d;
	    tmp.pb(d);
	}
	if(res % 10 != 9 or res <= 1e9){
		cout <<"! " << res << endl;
		return 0;
	}
	int p = -1;
	for(int i = 0 ; i < sz(tmp) ; i++){
		if(tmp[i] != 9)
			p = i + 1;				
	}
	//109000
    //109999
    //012
	//1000
	int x = powmod(10 , p + 1 , 1e18);

	if(p != -1){
		for(int i = p ; i < sz(tmp) ; i++){
			if(!ask(x)){
				tmp[i] = 0;
				res = 0 ;
				for(int  j = 0 ; j <= i ; j++)
					res = res * 10ll + tmp[j];
				cout <<"! " << res << endl;
				return 0;
			}			
			x *= 10;
		}
	}
	res = 1;
	if(p != -1){
		res = 0;
		tmp[p] = 0;
 		for(int  j = 0 ; j <= p ; j++)
			res = res * 10ll + tmp[j];
		cout << "! " << res << endl;
		return 0;	
	}
	cout << "! " << res << endl;
	return 0;

}

Measured memory_bytes: 596
#include<cstdio>

int main() {
    int a,b;
    std::scanf("%d %d",&a,&b);
        if(a < b) {
        std::printf("a < b");
    }
    else if(a > b ) {
        std::printf("a > b");
    }
    else if(a == b){
        std::printf("a == b");
    }
    std::printf("\n");
    return 0;
    }


Measured memory_bytes: 2740
N = int(input())
a = [0] + list(map(int, input().split())) + [0]
f, last = [0 for _ in range(N + 1)], 0
for i in range(1, N + 1):
    f[i] += abs(a[i] - last) + f[i - 1]
    last = a[i]
f.append(f[N] + abs(a[N]))
for i in range(1, N + 1):
    print(f[N + 1] - f[i + 1] + f[i - 1] + abs(a[i + 1] - a[i - 1]))

Measured memory_bytes: 14048
#include <stdio.h>

int main(void)
{
  int n;
  long x;
  scanf("%d %ld", &n, &x);
  int i = 0;
  long a[n];
  long sum = 0;
  while (i < n)
  {
    scanf("%ld", &a[i]);
    sum += a[i];
    i++;
  }
  if (sum == x)
  {
    printf("%d", i);
    return 0;
  }
  
  int flg = 1;
  int tmp;
  while (flg == 1)
  {
    i = 0;
    flg = 0;
    while (i + 1 < n)
    {
      if (a[i] > a[i + 1])
      {
        tmp = a[i];
        a[i] = a[i + 1];
        a[i + 1] = tmp;
        flg = 1;
      }
      i++;
    }
  }
  
  i = 0;
  sum = 0;
  while (sum <= x && i < n)
  {
    sum += a[i];
    i++;
  }
  printf("%d", i - 1);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    int fa = 0,fb = 0;
    a == -1 ? fa = 0 : fa = a / c + 1;
    fb = b / c + 1;
    cout << fb - fa << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <math.h>
#include <unordered_set>
using namespace std;

#define endl "\n"
#define pb push_back
#define INF INT_MAX/10
typedef long long ll;
typedef pair<ll,ll> PII;
typedef long long ll;



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    if ( n == 1 )	cout << "Hello World" << endl;
    if ( n == 2 ){
    	int a, b;
    	cin >> a >> b;
    	cout << a+b << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	VI num;
	int now = 1, cnt = 0;

	REP(i, N) {
		if (S[i] == (char)('0' + now))cnt++;
		else {
			num.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if (cnt != 0)num.push_back(cnt);
	
	if (num.size() % 2 == 0) 
		num.push_back(0);
	
	int add = 2 * K + 1;
	int ans = 0;
	for (int i = 0; i < num.size(); i += 2) {
		int tmp = 0;

		int left = i;
		int right = min(i + add, (int)num.size());
		FOR(j, left, right) {
			tmp += num[j];
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1528
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int Q;
  cin >> Q;
  REP(i,Q) {
    int n;
    cin >> n;
    int ans = 0;
    while(n>9) {
      int p = 10;
      int next = 0;
      while(1) {
        if (n/p==0) break;
        int t = (n / p) * (n % p);
        next = max(next, t);
        p *= 10;
      }
      n = next;
      ++ans;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1164
let () = Scanf.scanf "%d"
           (fun n ->
             let rec temp n' =
               match n' with
               | n' when n' < 0 -> "No"
               | 0 -> "Yes"
               | n' when n' >= 28 -> temp (n' - 28)
               | n' when n' mod 7 = 0 -> "Yes"
               | n' when n' mod 4 = 0 -> "Yes"
               | n' -> temp (n' - 7)
             in
             Printf.printf "%s" (temp n))

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int to1[3][10]={0},to2[3][10]={0},to3[3][10]={0},to4[3][10]={0};
  int a,n,b,f,r,v,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    if(b==1)to1[f-1][r-1]+=v;
    if(b==2)to2[f-1][r-1]+=v;
    if(b==3)to3[f-1][r-1]+=v;
    if(b==4)to4[f-1][r-1]+=v;
  }
   for(a=1;a<=4;a++){
    for(i=0;i<3;i++){
      for(j=0;j<10;j++){
	if(a==1)printf(" %d",to1[i][j]);
	if(a==2)printf(" %d",to2[i][j]);
	if(a==3)printf(" %d",to3[i][j]);
	if(a==4)printf(" %d",to4[i][j]);
      }
      printf("\n");
    }
    if(a!=4)printf("####################\n");
  }
  return 0;
}

Measured memory_bytes: 612
/*
4 
0 - 0 0 1 1
1 - cannot construct

8
2 - 0 2 0 1 3 2 3 1
0 - 0 0 1 1 2 2 3 3
1 - 0 1 0 2 3 1 3 2
3 - 0 3 0 1 2 3 2 1

16
7 - 0 7 0 1 2 3 4 5 6 7 6 5 4 3 2 1
6 - 0 6 0 1 2 3 4 5 7 6 7 5 4 3 2 1
1 - 0 1 0 2 3 4 5 6 7 1 7 6 5 4 3 2

*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,k;
    cin>>m>>k;
    if(m==0)
    {
        if(k==0)
        {
            cout<<"0 0"<<endl;
            return 0;
        }else {
            cout<<-1<<endl;
            return 0;
        }
    }
    if(m==1)
    {
        if(k==0)
        {
            cout<<"0 0 1 1"<<endl;
            return 0;
        }else
        {
            cout<<-1<<endl;
            return 0;
        }
    }
    if(k > (1<<m)-1)
    {
        cout<<-1<<endl;
        return 0;
    }
    int p = (1<<m)-1;
    if(k==0)
    {
        for(int i=0;i<=p;++i)
            cout<<i<<" "<<i<<" ";
        return 0;
    }
    cout<<0<<" "<<k<<" "<<0;
    for(int i=1;i<=p;++i)
    {
        if(i == k)continue;
        cout<<" "<<i;
    }
    cout<<" "<<k;
    for(int i=p;i>=1;--i)
    {
        if(i==k)continue;
        cout<<" "<<i;
    }
    cout<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x,y;
  cin >> x >> y;
  if(abs(x)==abs(y)){
    cout << 1 << endl;
  }
  else{
    if(x*y>=0){
      if(x<y){
        cout << y-x << endl;
      }
      else{
        if(x*y==0){
          cout << x-y+1 << endl;
        }
        else{
          cout << x-y+2 << endl;
        }
      }
    }
    else{
      cout << abs(abs(y)-abs(x))+1 << endl;
    }
  }
}

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

using namespace std;

int a,b,c,ans,ans1,ans2;

int main()
{
	cin>>a>>b>>c;
	ans1=a*b;
	ans2=c;
	ans=min(ans1,ans2);
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
	int a,b;
	cin >> a;
	cin >> b;
	if (a==1 || b==1)
	{
		if (a==1&&b==1)
		{
			cout << "Draw"<< endl;
		}
		if (a==1 && b!=1)
		{
			cout << "Alice"<< endl;
		}
		if (a!=1&& b==1 )
		{
			cout << "Bob"<< endl;
		}
	}
	else
	{
		if (a>b)
		{
			cout << "Alice"<< endl;
		}
		if (b>a)
		{
			cout << "Bob"<< endl;
		}
		if (b==a)
		{
			cout << "Draw"<< endl;
		}
	}
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  string s;
  cin >> s;
  if(s.substr(0,4) == "YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,x,t;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>x>>t;
	cout<<(n+x-1)/x*t<<endl;
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <limits.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) cin >> vec[i];
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += vec[i] * vec[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if(A+B >= 10) {
    cout << "error" << endl;
  }else{
    cout << A+B << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
   while(~scanf("%d",&n))
    {
          int a,b;
        if(n>=10&&n<=99)

    {
        a=n%10;
    b=n/10;
    if(a==9||b==9)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    }
    
    }
    return 0;
}


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

int main() {
long double  n,m;
cin >> n >>m;
vector<ll> a(n);
long double  sum=0;
rep(i,n)
{cin>>a.at(i);
 sum+=a.at(i);}

long double kijun = sum/(4*m);
ll count=n;
rep(i,n)
{if(a.at(i)<kijun){count--;}}

if(count>=m)
{cout<< "Yes"<<endl;}
else
{
  cout<< "No"<<endl;
}

 //Mを選ぶには得票数が総投票数の1/4m 以上
return 0;
}
/*vector <ll> a(3);
for (ll i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 256
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);


int main() {
	fast;
  	read(a)
  	ll sum=0;
  	loop(j,1,a+1){
  		loop(i,1,a+1){
  			loop(k,1,a+1){
  				ll p=__gcd(j,i);
  				sum+=__gcd(p,k);
  			}
  		}
  	}
  	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.*;


public class Main{
	static int MOD=(int) (1e9+7);
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
  int k=sc.nextInt();
   ArrayList<Long> al=new ArrayList<>();
    for(int i=0;i<n;i++){
		al.add(sc.nextLong());
      
    }
    ArrayList<Long> b=new ArrayList<>(al);

    List<Long> pos = new ArrayList<>();
    List<Long> neg = new ArrayList<>();
    int zero = 0;
    for (long i : al) {
      if (i > 0) {
        pos.add(i);
      } else if (i < 0) {
        neg.add(i);
      } else {
        zero++;
      }
    }

    Collections.sort(al);
   

    long ans=1; 
    if (pos.size() + neg.size() < k || (n == k && zero > 0)) {
        System.out.println(0);
        return;
      }
    if(k==n) {
    for(long i:al) {
    	ans=mul(ans,i);
    }
	 System.out.println(Math.floorMod(ans, MOD));
    
    }else {
    	 if (al.get(n-1) <= 0 && k % 2 != 0) { 
             for (int i = n - 1; i >= n - k; i--) 
               ans =mul(ans,al.get(i)); 
        	 System.out.println(Math.floorMod(ans, MOD));
         }else {
    
    
    	int i=0;int j=n-1;
    	if(k%2!=0) {
    		ans=mul(ans,al.get(j));
    		j--;
    		k--;
    	}
    	k=k>>1;
    	for( int itr =0;itr<k;itr++) {
    		long lf=Math.multiplyExact(al.get(i), al.get(i+1));
    		long rf=Math.multiplyExact(al.get(j), al.get(j-1));
    		if(lf>rf) {
    			ans=mul(ans,lf);
    			i=i+2;
    		}else {
    			ans=mul(ans,rf);
    			j=j-2;
    		}
    	}
    	System.out.println(ans%MOD);
    }
    }
    
	}
	  static long mul(long a, long b) {
		    return (((a + MOD) % MOD) * ((b + MOD) % MOD)) % MOD;
		  }
	}
	


  
   

Measured memory_bytes: 66268
#include<iostream>

using namespace std;

int main()
{
  int N, M, A[31][31], K[31], cnt[31] = {0}, ans = 0;

  cin >> N >> M;
  for(int i = 0; i < N; i++){
    cin >> K[i];
    for(int j = 0; j < K[i]; j++){
      cin >> A[i][j];
    }
  }

  for(int i = 0; i < N; i++){
    for(int j = 0; j < K[i]; j++){
      cnt[A[i][j]]++;
    }
  }

  for(int i = 1; i <= M; i++){
    if(cnt[i] == N)
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define Abs(_A) (((_A) > 0) ? (_A) : (-(_A)))
#define MAX(_A, _B) (((_A) > (_B)) ? (_A) : (_B))
int n, cnt, x[111], y[111], h[111], xs, ys, hs;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d %d %d", &x[i], &y[i], &h[i]);
		if(h[i] != 0) xs = x[i], ys = y[i], hs = h[i];
	}
	if(hs == 0) return !printf("%d %d %d", x[1], y[1], h[1]); 
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			int hh = hs + Abs(xs - i) + Abs(ys - j);
			for(int k = 1; k <= n; k++){
				if(h[k] != MAX(hh - Abs(x[k] - i) - Abs(y[k] - j), 0)) break;
				if(k == n) return !printf("%d %d %d\n", i, j, hh);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<complex>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define NEXT(i,n) ((i+1)%(n))
const int N = 1000001;
int dp1[N],dp2[N];  
main(){
  vector<int> simen;
  REP(i,1,N+1){
    simen.push_back(i*(i+1)*(i+2)/6);
    if (simen[i-1] > N+1)break;
  }
  
  dp1[0]=0;
  dp2[0]=0;
  REP(i,1,N){
    dp1[i]=10000000;
    dp2[i]=10000000;
    rep(j,simen.size()){
      if (i-simen[j] < 0)break;
      dp1[i]=min(dp1[i],dp1[i-simen[j]]+1);
      if (simen[j]%2 == 1){
	dp2[i]=min(dp2[i],dp2[i-simen[j]]+1);
      }
    }
  }
  
  int n;
  while(cin>>n && n){
    cout << dp1[n] <<" " << dp2[n] << endl;
  }

}

Measured memory_bytes: 8584