akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

signed compare(const void *a, const void *b){
	int sub = *(int *)a - *(int *)b;
	if(sub < 0){
		return -1;
	}
	else if(sub == 0){
		return 0;
	}
	else{
		return 1;
	}
}

signed main(){
	int N, M, i, j;
	scanf("%lld%lld", &N, &M);
	int *A = (int *)malloc(sizeof(int) * (N + 1));
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		A[i]--;
	}
	A[N] = N * M;
	int *B = (int *)malloc(sizeof(int) * (M + 1));
	for(j = 0; j < M; j++){
		scanf("%lld", &B[j]);
		B[j]--;
	}
	B[M] = N * M;
	qsort(A, N + 1, sizeof(int), compare);
	qsort(B, M + 1, sizeof(int), compare);
	for(i = 1; i <= N; i++){
		if(A[i - 1] == A[i]){
			printf("0\n");
			return 0;
		}
	}
	for(i = 1; i <= M; i++){
		if(B[i - 1] == B[i]){
			printf("0\n");
			return 0;
		}
	}
	int l, h, r, K, L, ans = 1;
	for(i = N * M - 1; i >= 0; i--){
//		printf("i = %lld\n", i);
		l = -1;
		r = N;
		while(r - l > 1){
			h = (l + r) / 2;
			if(A[h] < i){
				l = h;
			}
			else{
				r = h;
			}
		}
		K = r;

		l = -1;
		r = M;
		while(r - l > 1){
			h = (l + r) / 2;
			if(B[h] < i){
				l = h;
			}
			else{
				r = h;
			}
		}
		L = r;
//		printf("(K, L) = (%lld, %lld)\n", K, L);
		if(A[K] == i && B[L] == i){
//			continue;
		}
		else if(A[K] == i && B[L] != i){
			ans = MOD(ans * (M - L));
		}
		else if(A[K] != i && B[L] == i){
			ans = MOD(ans * (N - K));
		}
		else{
			if((N - K) * (M - L) - (N * M - i - 1) <= 0){
				printf("0\n");
				return 0;
			}
			else{
				ans = MOD(ans * ((N - K) * (M - L) - (N * M - i - 1)));
			}
		}
//		printf("ans = %lld\n", ans);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 252
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int sum(vector<int> & a, int p) {
    int value = 0;
    for(auto v : a) {
        value += (p-v)*(p-v);
    }
    return value;
}
int main(void) {
    int n;
    cin >> n;
    vector<int> x(n);
    REP(i,n) cin >> x[i];
    int ansx = 1;
    int ans = sum(x,ansx);

    for(int i = 1; i <= 100; i++) {
        if(ans < sum(x,i)) {
            cout << ans << endl;
            return 0;
        }else{
            ans = sum(x,i);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int save = values[a];
			values[a] = values[b];
			values[b] = save;
		}
		for (int i = 0; i < w; i++) {
			System.out.println(values[i]);
		}

		sc.close();
	}
}

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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll n, x, y;
    cin >> n >> x >> y;
    ll dist[n+1][n+1];
    ll ans[n+1];
    clr(ans, 0);
    for (int i = 1; i <= n; ++i) {
    	for (int j = 1; j <= n; ++j) {
    		dist[i][j] = abs(i - j);
    	}
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
			dist[i][j] = min(dist[i][j], dist[i][x]+1+dist[y][j]);
			dist[i][j] = min(dist[i][j], dist[i][y]+1+dist[x][j]);
        }
    }
    for (int i = 0; i <= n; ++i) {
    	for (int j = 1; j <= i - 1; ++j) {
    		ans[dist[i][j]]++;
    	}
    }

    for (int i = 1; i <= n - 1; i++) {
    	cout << ans[i] << endl;
    }

    return 0;
}

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

int main() {
    int k, n;
    cin >> k >> n;
    int shortest = k;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for (int i=0; i<n; i++) {
        int dist;
        if (i==0) {
            dist = k - (a[0]+k - a[n-1]);
        }
        else {
            dist = k - (a[i] - a[i-1]);
        }
        if (dist < shortest) {
            shortest = dist;
        }
    }
    cout << shortest << endl;
}

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


int main(){
	/*input*/
	int n;
	cin >> n;
	char s[11];
	cin >> s;
	int k;
	cin >> k;
	/*calc*/
//    int  ans = 0;
    char key = s[k-1];
    for(int i = 0; i < n; i++){
    	if(s[i] == key) continue;
    	s[i] = '*';
    }
    /*output*/
	   	cout<< s <<endl;
//	   	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  string S;
  cin>>S;
  cout<<S[0]<<S[1]<<S[2]<<endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

using namespace std;

const int INF = 200000000;

int dp[2][2][10000];
int n;
int cost[10000];

main(){
  cin >> n;
    for(int i=0;i<n-1;++i){
      cin >> cost[i];
    }
    fill(dp[0][0], dp[2][0], INF);
    dp[0][0][1] = 0;
    dp[0][1][0] = 0;
    for(int i=0;i<n-1;++i){
      int now = i%2;
      int next = (i+1)%2;
      for(int j=0;j<n;++j) dp[next][0][j] = dp[next][1][j] = INF;
      for(int j=0;j<n;++j){
        dp[next][0][j+1] = min(dp[next][0][j+1], dp[now][0][j]);
        dp[next][0][j+1] = min(dp[next][0][j+1], dp[now][1][j] + cost[i]);
        dp[next][1][j] = min(dp[next][1][j], dp[now][1][j]);
        dp[next][1][j] = min(dp[next][1][j], dp[now][0][j] + cost[i]);
      }
    }
    cout << min(dp[1][0][n/2], dp[1][1][n/2]) << endl;
//  }
  return 0;
}

Measured memory_bytes: 1020
import java.util.*
import kotlin.comparisons.compareValuesBy

fun main(arg: Array<String>) {
    val k = readLine()!!.toInt()
    val edge = PriorityQueue<IntPair>()
    val score = Array<Int?>(k) { null }
    edge.add(IntPair(1, 1))
    while (edge.isNotEmpty()) {
        val pair = edge.poll()
        val next1 = (pair.second * 10) % k
        val next2 = (pair.second + 1) % k
        score[pair.second] = pair.first
        if (pair.second == 0) break
        if (score[next1] == null) edge.add(IntPair(pair.first, next1))
        if (score[next2] == null) edge.add(IntPair(pair.first + 1, next2))
    }
    println(score[0])
}

class IntPair(val first: Int, val second: Int) : Comparable<IntPair> {
    override fun compareTo(other: IntPair): Int = compareValuesBy(this, other, { it.first })
}


Measured memory_bytes: 40744
e=input
a=[]
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[z]
print(*map(len,a),sep='\n')


Measured memory_bytes: 5652
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(map(int, input().split()))
acc = [0]

for Ai in A:
    acc.append(acc[-1]+Ai)
    
ans = 0
r = 0
xor = 0

for l in range(N):
    while r<N and xor^A[r]==acc[r+1]-acc[l]:
        xor ^= A[r]
        r += 1
    
    ans += r-l
    
    if l==r:
        r += 1
    else:
        xor ^= A[l]

print(ans)

Measured memory_bytes: 81356
s=input()

if s.count("N")>0 and s.count("S")==0:
    print("No")
    exit()
if s.count("S")>0 and s.count("N")==0:
    print("No")
    exit()
if s.count("W")>0 and s.count("E")==0:
    print("No")
    exit()
if s.count("E")>0 and s.count("W")==0:
    print("No")
    exit()
else:
    print("Yes") 

Measured memory_bytes: 61780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long int;

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

    bool ok = false;
    for (size_t i = 0; i < 3; i++)
    {
        if (n[i] == '7') {
            ok = true;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;

    Graph G(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<ll> color(n, -1);
    queue<int> que;
    que.push(0);
    color[0] = k;

    COMinit();

    while(!que.empty()) {
        int v = que.front();
        que.pop();
        int m = G[v].size();
        int i = 1;
        for (auto nv : G[v]) {
            if (color[nv] != -1) continue;
            if (v == 0) color[nv] = k - i;
            else color[nv] = k - 1 - i;
            ++i;
            que.push(nv);
        }
    }

    ll res = 1;
    rep(i, n) {
        if (color[i] == -1) continue;
        res = res * color[i] % MOD;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 19320
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	ll count = 0, ans = 0;
	int n; CI n;
	vector<long long> v(n); CI v;
	REP(i, n) {
		if (v[i] < 0) {
			v[i] = v[i] * -1;
			count++;
		}
		ans += v[i];
	}
	sort(all(v));
	if (count % 2) {
		ans -= v[0]*2;
	}
	CO ans EN;
}

Measured memory_bytes: 1024
def C_GreenBin():
    from collections import Counter
    N = int(input())
    s = []
    for x in range(N):
        list_tmp = sorted(input())
        s.append("".join(list_tmp))
    result = 0
    s_tmp = Counter(s)
    for x in s_tmp.values():
        if x > 1:
            result += ((x - 1) * x) // 2
    print(result)
    
if __name__ == "__main__":
    C_GreenBin()

Measured memory_bytes: 19760
#二分探索...ソートした配列を二つに分けて、どちらに入るか調べることで高速化
import bisect

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

#リストを整列する
a.sort()
b.sort()
c.sort()

#二分探索で、それぞれのbについて、a<bになるaの個数を調べる
#二分探索で、それぞれのbについて、c>bになるcの個数を調べる
ans = 0
for i in range(n):
	ab = bisect.bisect_left(a,b[i])	#a==bの場合を除外する
	tmpbc = bisect.bisect_right(c,b[i])#b==cの場合を一度含んでおく
	bc = n-tmpbc
	
	ans += ab*bc
	
print(ans)


Measured memory_bytes: 23328
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
  int a,b,count=1;
  cin >> a >> b;
  for(int i=2; i<=999; i++){
    if(count-a == count+i-b){
      cout << count-a << endl;
      return 0;
    }
    count+=i;
  }
}

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

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main() {
    int n;
    cin >> n;
    int d1 = -1, d2 = -1;
    map<int, int> C;
    for(int i=0; i<=n; ++i) {
        int a;
        cin >> a;
        if(C.find(a) != C.end()) {
            d1 = C[a];
            d2 = i;
        } else {
            C[a] = i;
        }
    }

    COMinit();
    for(int k=1; k<=n+1; ++k) {
        cout << ( COM(n + 1, k) - COM(d1 + n - d2, k - 1) + MOD ) % MOD << endl;
    }
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  map<char,ll> count;
  ll mx=inf;
  for(ll i=0;i<'z'-'a'+1;i++) {
    ll temp=-1;
    ll tx=0;
    for(ll j=0;j<s.size();j++) {
      if(s[j]=='a'+i) {
        tx=max(tx,j-temp-1);
        temp=j;
      }
    }
    tx=max(tx,(ll)s.size()-temp-1);
    mx=min(tx,mx);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	char c; cin >> c; c++;
	cout << c << '\n';
	return 0;
}


Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));

  for($i=0; $i<strlen($s); $i++){
    $enc = hexdec(bin2hex($s[$i]));
    if($enc+$n > 90){
      $step = 65+($enc+$n-91);
    }else{
      $step = $enc+$n;
    }
    echo hex2bin(dechex($step));
  }
  echo "\n";

Measured memory_bytes: 4604
const Main = (input) => {
  input = input.split('\n');
  var arr = input[1].split(' ');
  var newArr = arr.map(function(x) { return x / 2 });
  var count = 0;
  while (true) {
    if(newArr.every(item => Number.isInteger(item))) {
      count++;
      newArr = newArr.map(function(x) { return x / 2 });
    } else {
      break;
    }
  }
  console.log(count);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>

using namespace std;

int main() {
   int a ,b,c,i;
  for(i=0;i<3000;i++)
  {
      cin>>a >>b;
      if(a>b)
  {
   c=a;
   a=b;
   b=c;
  }
  if (a==0 && b==0)
  break;
   cout<<a<<" "<<b<<endl;
}
}


Measured memory_bytes: 3000
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True, end="")

N = _I()
X=LI()
ans=0

lowest=X[0]
for x in X:
	if x <= lowest:
		ans+=1
		lowest=x
print(ans)
	


Measured memory_bytes: 26036
#include <iostream>
using namespace std;
int
main ()
{
  int W, H, x, y, r, a, b, c, d;
  cin >> W >> H >> x >> y >> r;
 a = x + r;
  b = y + r;
c= x-r;
d=y-r;
  if (c < 0 ||a > W|| d < 0 || b > H)
    {
      cout << "No" << endl;
    }
  else
    {
      cout << "Yes" << endl;
    }


  return 0;
}




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

int main(){
    int N;
    cin >> N;
    int K[N];
    int P[N];
    for(int i=0; i<N;i++){
        cin >> K[i];
        P[i]=K[i]%2;
    }

    sort(P,P+N,greater<int>());

    for(int i=0;i<N;i++){

        if(P[i]!=1&& i%2==1){
            cout <<"NO"<<endl;
            break;
        }else if(P[i]!=1&& i%2==0){
            cout <<"YES";
            break;
        } 
        if(P[N-1]==1){
            cout<<"YES";
            break;
        }
    }
}

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

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

int solve(int i, int j, string s, string t)
{
	if (i == s.length()) return 0;
	if (j == t.length()) return 0;

	if (s[i] == t[j]) return 1 + solve(i + 1, j + 1, s, t);

	return max(solve(i + 1, j, s, t), solve(i, j + 1, s, t));
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
#endif
	FASTIO;

	string s, t;
	cin >> s >> t;

	// Recursive - will return max_length subsequence
	// cout<<solve(0,0,s,t);

	int n = s.length();
	int m = t.length();

	vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = m - 1; j >= 0; j--)
		{
			if (s[i] == t[j])
			{
				dp[i][j] = 1 + dp[i + 1][j + 1];
			}
			else dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}

	// for(auto vec : dp)
	// {
	//     for(auto ele : vec) cout<<ele<<" ";
	//     cout<<endl;
	// }

	string ans = "";
	int i = 0, j = 0;

	while (i < n && j < m)
	{
		// only include when it is coming from i+1,j+1
		if (s[i] == t[j])
		{
			ans += s[i];
			i++;
			j++;
		}
		else {

			if (dp[i + 1][j] >= dp[i][j + 1])
			{
				i++;
			}
			else j++;

		}
	}

	cout << ans;


}

Measured memory_bytes: 38496
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    SCIN(str);
    LCIN(K);
    for(int a = 0;a < str.size();a++){
        if(a == K-1){
            COUT(str.at(a));
            return 0;
        }
        if(str.at(a) != '1'){
            COUT(str.at(a));
            return 0;
        }

    }
    return 0;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())

week_value = A * 7 + B

weeks = C // week_value
rest = C % week_value

day = 0
if rest != 0 and A * 7 < rest:
    day = 7
else:
    day = rest // A
    if rest % A != 0:
        day += 1

print(weeks * 7 + day)



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

using namespace std;

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

	int ans = 0;

	if (s[0] == '1')++ans;
	if (s[1] == '1')++ans;
	if (s[2] == '1')++ans;

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
IronMan = sorted(p)
CaptainAmerica = sorted(q)
for i in range(X):
    r.append(IronMan.pop())
for i in range(Y):
    r.append(CaptainAmerica.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))


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

using namespace std;

int x[111111];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%d", x + i);
	int z = lower_bound(x, x + n, 0) - x;
	x[n] = 1e9;
	int m;
	if (x[z]) m = z < k ? 1e9 : -x[z - k];
	else m = z < k + 1 ? 1e9 : -x[z - k - 1];
	m = min(m, z + k - 1 < n ? x[z + k - 1] : (int)1e9);
	for (int i = max(0, z - k + 1); i < z&&i + k - 1 < n; i++) {
		m = min(m, x[i + k - 1] - 2 * x[i]);
		m = min(m, 2 * x[i + k - 1] - x[i]);
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

const int Q = (int)1e9 + 7;
int fact[1010101];
int revf[1010101];

int comb(int n, int r)
{
    if(n < r) return 0;
    return (long long)fact[n] * revf[n - r] % Q * revf[r] % Q;
}

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

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

    fact[0] = fact[1] = 1;
    for(int i = 2; i < 1010101; ++i) fact[i] = (long long)i * fact[i - 1] % Q;
    revf[0] = revf[1] = 1;
    for(int i = 2; i < 1010101; ++i) revf[i] = Q - (long long)revf[Q % i] * (Q / i) % Q;
    for(int i = 2; i < 1010101; ++i) revf[i] = (long long)revf[i] * revf[i - 1] % Q;

    cout << comb(a + b, b);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int h[N];
    for(int i=0; i<N; i++) {
        cin >> h[i];
    }
    int v[N];
    v[N-1] = 0;
    v[N-2] = abs(h[N-1]-h[N-2]);
    for(int i=N-3; i>=0; i--) {
        v[i] = min(abs(h[i]-h[i+1]) + v[i+1], abs(h[i]-h[i+2]) + v[i+2]);
    }
    cout << v[0];
    return 0;
}


Measured memory_bytes: 1024
use proconio::{fastout, input};

use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut g = vec![vec![]; n];
    for _ in 0..n - 1 {
        input! { u: Usize1, v: Usize1 }
        g[u].push(v);
        g[v].push(u);
    }
    let mut ans: Vec<usize> = vec![0; n];
    let mut lis: Vec<u64> = vec![a[0]];
    fn f(
        s: usize,
        p: usize,
        n: usize,
        a: &Vec<u64>,
        g: &Vec<Vec<usize>>,
        ans: &mut Vec<usize>,
        lis: &mut Vec<u64>,
    ) {
        ans[s] = lis.len();
        for t in g[s].iter() {
            if *t == p {
                continue;
            }
            let i = lis.lower_bound(&a[*t]);
            if i < lis.len() {
                let prev = lis[i];
                lis[i] = a[*t];
                f(*t, s, n, a, g, ans, lis);
                lis[i] = prev;
            } else {
                lis.push(a[*t]);
                f(*t, s, n, a, g, ans, lis);
                lis.pop();
            }
        }
    };
    f(0, n, n, &a, &g, &mut ans, &mut lis);
    for x in ans.iter() {
        println!("{}", *x);
    }
}

use std::cmp::Ordering;
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
    fn partition_point<F>(&self, f: F) -> usize
    where
        F: FnMut(&T) -> bool;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        self.partition_point(|y| match y.cmp(x) {
            Ordering::Less => true,
            Ordering::Equal | Ordering::Greater => false,
        })
    }
    fn upper_bound(&self, x: &T) -> usize {
        self.partition_point(|y| match y.cmp(x) {
            Ordering::Less | Ordering::Equal => true,
            Ordering::Greater => false,
        })
    }
    fn partition_point<F>(&self, mut f: F) -> usize
    where
        F: FnMut(&T) -> bool,
    {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            if f(&self[mid]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        low
    }
}


Measured memory_bytes: 36580
#include <iostream>
    #include <algorithm>
    #include <string>
     
    using namespace std;
     
    int main(){
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	
    	int ans=0;
    	for(int i=1;i<n;i++){
    		int cnt=0;
    		
    		for(char c='a';c<='z';c++){
    			bool left=false,right=false;
    			
    			for(int j=0;j<i;j++)
    				if(s[j]==c)
    					left=true;
    			
    			for(int j=i;j<n;j++)
    				if(s[j]==c)
    					right=true;
    			
    			if(left&&right)
    				cnt++;
    		}
    		
    		if(ans<cnt)
    			ans=cnt;
    	}
    	
    	cout<<ans<<endl;
    }


Measured memory_bytes: 256
N, M = map(int, input().split())

INF = 10**7
dp = [INF]*2**N
dp[0] = 0
bits = set()
bits.add(0)
for i in range(M):
    a, b = map(int, input().split())
    d = sum((1<< (i - 1)) for i in  map(int, input().split()))
    add_set = set() # i個目の鍵を使ってbitsに新しく追加する分の状態を入れる
    for j in bits:
        jord = j | d
        dp[jord] = min(dp[jord], dp[j] + a)
        add_set.add(jord)
    bits |= add_set
    
if dp[- 1] == INF:
    print(- 1)
else:
    print(dp[- 1])

Measured memory_bytes: 3908
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;
#define N 200005
#define ll long long 
#define fst first
#define snd second
//环：1:2,n n:n-1,1 
int n,a[N],b[N];
ll ans;//记得开ll 
inline int rd()
{
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-f;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
priority_queue<pair<int,int> >Q;
//pair定义优先队列 先按first 再按second 自动排序 
int main()
{
	//freopen("hopeless.in","r",stdin);
	//freopen("hopeless.out","w",stdout);
	n=rd();
	for(int i=1;i<=n;i++)
		a[i]=rd();
	for(int i=1;i<=n;i++)
	{
		b[i]=rd();
		if(a[i]!=b[i]) Q.push(make_pair(b[i],i));
	}
	while(!Q.empty())
	{
		pair<int,int> now=Q.top();Q.pop();
		int i=now.snd;
		/*int pre=i-1,suf=i+1;
		if(pre==0) pre=n;
		if(suf==n+1) suf=1;
		int step=(b[i]-a[i])/(b[pre]+b[suf]);
		*/
		int pre=(i+n-2)%n+1,suf=i%n+1;
		int step=(b[i]-a[i])/(b[pre]+b[suf]);
		if(b[i]-b[pre]-b[suf]<a[i])
		{
			puts("-1");
			return 0;
		}
		ans+=step;
		b[i]-=step*(b[pre]+b[suf]);
		if(a[i]!=b[i]) Q.push(make_pair(b[i],i));
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int l=0,r=0;
  for(int i=0;i<s.size();i++) {
	if(s[i]=='T') {
      if(r) r--;
      else l++;
    }
    else r++;
  }
  cout<<l+r<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a;
	int b,c;
	int k;
	scanf("%d",&a);
	while(a!=0){
			if(a==0)
        
				break;
				k=0;
				a=1000-a;
			
		for(b=0;a!=0;b++){
		


		 if(a>=500){
			k+=1;
		    a=a-500;
		}
		else if(a>=100&&a<500){
			k+=1;
			a=a-100;
		}
		else if(a>=50&&a<100){
			k+=1;
		a=a-50;
		}
		else if(a>=10&&a<50){
			k+=1;
			a=a-10;
		}
		else if(a>=5&&a<10){
			k+=1;
			a=a-5;
		}
		else if(a>=1&&a<5){
			k+=1;
			a=a-1;
		}
		}
		
		
		
		printf("%d\n",k);
		scanf("%d",&a);
	}
	return 0;
}
		

Measured memory_bytes: 600
import math
a,b,h,m = (int(x) for x in input().split())
hour_deg = 2*h*math.pi/12 + m/60*math.pi/6
min_deg = 2*m*math.pi/60
diff_deg = min(hour_deg-min_deg, 2*math.pi-(hour_deg-min_deg))
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(diff_deg)))

Measured memory_bytes: 62392
N, M, C = [int(elem) for elem in input().split()]
B_list = [int(elem) for elem in input().split()]
A_mat = [[int(elem) for elem in input().split()] for _ in range(N)]
assert len(A_mat[0]) == M


num_correct_codes = 0
for A_list in A_mat:
    sum_ = C
    for A, B in zip(A_list, B_list):
        sum_ += A * B
    if sum_ > 0:
        num_correct_codes += 1

print(num_correct_codes)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
bool get(int x, int plc) {
	return ((x >> plc) & 1);
}
vector<int> getAns(int lv, int a, int b) {
	if (lv == 0) {
		vector<int> v;
		v.push_back(a), v.push_back(b);
		return v;
	}
	if (get(a, lv) != get(b, lv)) {
		int c = b ^ (1 << (lv - 1));
		vector<int> fr = getAns(lv - 1, a, c ^ (1 << lv));
		vector<int> sd = getAns(lv - 1, c, b);
		for (auto x : sd)
			fr.push_back(x);
//		cout << "lv = " << lv << " a = " << a << " b = " << b << " : " << endl;
//		for (auto x : fr)
//			cout << x << " ";
//		cout << endl;
		return fr;	
	}
	else {
		vector<int> fr = getAns(lv - 1, a, b), rn;
		for (auto x : fr)
			rn.push_back(x), rn.push_back(x);
		int z = 0;
		for (int i = 1; i < rn.size(); i++) {
			if (i % 2)
				z = 1 - z;
			rn[i] = rn[i] ^ (z << lv);
		}
//		cout << "lv = " << lv << " a = " << a << " b = " << b << endl;
//		for (auto x : fr) 
//			cout << x << " ";
//		cout << endl;
		return rn;
	}
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2) {
		cout << "NO";
		return 0;
	}		
	cout << "YES\n";
	vector<int> ans = getAns(n - 1, a, b);
	for (auto u : ans)
		cout << u << " ";
	return 0;
}



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

int main(){
	int n,cnt=0;
	cin>>n;
	vector<int>a(n);
	vector<int>b(n);
	for(int i= 0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a.begin(),a.end());
	for(int i= 0;i<n;i++){
		if(a[i]!=b[i])
			cnt++;
	}
	
//	cout<<cnt<<"\n";
	if(cnt>2)
		cout<<"NO";
	else
		cout<<"YES";
}

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

int main()
{
    int n, a[201];
    int i, count = 0, judge = 0;
    
    cin >> n;
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    do {
        for(i = 0; i < n; i++) {
            if((a[i] % 2) == 0) {
                a[i] = a[i] / 2;
            } else {
                judge = 1;
                break;
            }
        }
        
        if(judge == 0) {
            count++;
        }
        
    } while(judge == 0);
    
    cout << count << "\n";
    
    return 0;
}

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

void insertInSet(long long x, long long y, set<long long> &S)
{
    S.insert(x), S.insert(y);

    if (x + 1 <= y)
        S.insert(x + 1);
    if (y - 1 >= x)
        S.insert(y - 1);
}

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

    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long ans = - (long long) 1e18;

    set<long long> X, Y;

    insertInSet(a, b, X);
    insertInSet(c, d, Y);

    for (auto x : X)
        for (auto y : Y)
            ans = max(ans, x * y);

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<int> li;
typedef vector<li> vli;

int main() {FIN
	
	int n, q, t, s, x, op;
	cin >> n >> q;
	vli ls(n);
	while (q--) {
		cin >> op;
		if (op == 0) {
			cin >> t >> x;
			ls[t].push_back(x);
		} else if (op == 1) {
			cin >> t;
			for (auto it = ls[t].begin(); it != ls[t].end(); it++) {
				if (it != ls[t].begin()) cout << " ";
				cout << *it;
			}
			cout << "\n";
		} else {
			cin >> s >> t;
			ls[t].splice(ls[t].end(), ls[s]);
		}
	}
	
	return 0;
}



Measured memory_bytes: 18732
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;
  vl D(K);
  rep(i, K){
    cin >> D[i];
  }

  vl u;
  ll cnt = 0;
  
  rep(i, 10){
    if(D[cnt] != i){
      u.push_back(i);
    } else{
      cnt++;
    }
  }

  /*
  for(auto itr = u.begin(); itr != u.end(); itr++){
    cout << (*itr) << " ";
  }

  cout << endl;
  */

  ll ans;
  queue<ll> que;
  cnt = 2;
  if(u[0] != 0){
    rep(i, 10 - K){
      que.push(u[i]);
    }
  } else{
    que.push(u[1]);
    que.push(u[0]);
    while(cnt < u.size()){
      que.push(u[cnt]);
      cnt++;
    }
  }

  while(!(que.empty())){
    if(que.front() >= N){
      ans = que.front();
      break;
    } else{
      rep(i, 10 - K){
	que.push(10*que.front() + u[i]);
      }
      que.pop();
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 768
import numpy as np
data = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans = 0
for k in range(29):
    a = np.sort(np.hstack((A%(2**(k+1)),A%(2**(k+1))-2**(k+1))))
    b = B%(2**(k+1))
    ans += (np.sum(np.searchsorted(a,2**(k+1)-b)-np.searchsorted(a,2**k-b)))%2*2**k

print(ans)

Measured memory_bytes: 38812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll calc(ll x){
    if(x==0) return 0;
    if(x==1) return 0^1;
    if(x==2) return 0^1^2;
    if(x==3) return 0^1^2^3;
    if(x%4==1) return 1;
    if(x%4==2) return x^1;
    if(x%4==3) return 0;
    if(x%4==0) return x^0;
}

int main(){
    ll a,b; cin>>a>>b;
    ll res=0;
    ll x=calc(b), y=calc(a-1);
    if(a==0) y=0;
    if(b==0) x=0;
    res=x^y;
    cout<<res<<endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


map<ll, int > prime_factor(ll n) {
  map<ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  int ans=0;
  for(ll i = 1; i <= n; i+=2){
    map<ll,int> mp = prime_factor(i);
    int x=1;
    for(auto &v: mp){
      x *= (v.second+1);
    }
    if(x==8){
      ans++;
    }
  }
  cout << ans << endl;

}



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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct edge {
    int to,rev;
    ll cap;
};

vector<edge> G[102];
bool used[102];

void add_edge(int from,int to,ll cap) {
    G[from].push_back((edge){to,(int)G[to].size(),cap});
    G[to].push_back((edge){from,(int)G[from].size()-1,0});
}

ll dfs(int v,int t,ll f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0;i < G[v].size();++i) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            ll d = dfs(e.to,t,min(f,e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s,int t) {
    ll flow = 0;
    for (;;) {
        memset(used,0,sizeof(used));
        ll f = dfs(s,t,INT64_MAX);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
    int n;
    ll ans = 0;
    cin >> n;
    for (int i = 1;i <= n;++i) {
        int a;
        cin >> a;
        if (a > 0) {
            add_edge(i,101,a);
            ans += a;
        } else add_edge(0,i,-a);
    }
    for (int i = 1;i <= n;++i) for (int j = i*2;j <= n;j += i) add_edge(i,j,INT64_MAX);
    ans -= max_flow(0,101);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);
using ll = long long;
const ll mod = 1'000'000'007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M+1, 0LL);
  rep(i, M) cin >> a[i];

  vector<ll> dp(N+1, 0LL);
  int cntA = 0;
  dp[0] = 1LL;
  if (a[0] == 1) {
    cntA++;
    dp[1] = 0LL;
  }
  else {
    dp[1] = 1LL;
  }

 
  for (int i = 2; i <= N; i++) {
    if (a[cntA] == i) {
      cntA++;
      dp[i] = 0LL;
    }
    else {
      dp[i] = dp[i-1] + dp[i-2];
    }
    dp[i] %= mod;
  }

  cout << dp[N] << endl;
    

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int GCD(int x, int y) {
    if (x % y == 0) return y;
    else return GCD(y, x % y);
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    if (C % GCD(A, B) == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

string s;
int bk,wt;
int dp[200005][2];

int main(){

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

    cin>>s;
    cin>>s;
    dp[0][0]=s[0]!='#';
    dp[0][1]=s[0]!='.';
    for(int i=1;i<s.size();i++){
        dp[i][0]=dp[i][1]=1e9;
        dp[i][0]=min(dp[i][0],dp[i-1][1]+int(s[i]!='#'));
        dp[i][0]=min(dp[i][0],dp[i-1][0]+int(s[i]!='#'));
        dp[i][1]=min(dp[i][1],dp[i-1][1]+int(s[i]!='.'));
    }
    cout<<min(dp[s.size()-1][0],dp[s.size()-1][1])<<endl;

    return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long A, long long B) {
    int c = max({A + B, A - B, A * B});
    cout << c << endl;
}

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

    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    func(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
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);
}


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

ll N;
  cin>>N;
  ll sum=0;
  for(ll i=1;i<N+1;i++){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  cout<<sum<<endl;

}



Measured memory_bytes: 3640
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        scanf("%lld", &a[i]);
    }
    ll all = 0;
    rep(i, n) {
        all ^= a[i];
    }
    rep(i, n) {
        if (i == 0) {
            printf("%lld", a[i] ^ all);
        } else {
            printf(" %lld", a[i] ^ all);
        }
    }
    return 0;
}


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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll left = 4 * a * b;
    ll right = c - a - b;
    string res;
    if (right < 0) res = "No";
    else{
        if (left < right * right) res = "Yes";
        else res = "No";
    }
    cout << res << endl;
}


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

int int_len(long long int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(long long int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a=0,b=0,c=0,d=0,n=0,count=0,ans=1000000;
  string s;
  cin>>n>>a;
  vector<int> t(n);
  rep(i,n) cin>>t[i];
  ans=t[0];
  rep(i,n-1){
    if(a>=t[i+1]-t[i]) ans+=t[i+1]-t[i];
    else ans+=a;
  }
  ans+=a;
  cout<<ans<<endl;
}
///////////////////////////





Measured memory_bytes: 1024
// SeeAlso: 

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <limits>
#include <string>

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

using namespace std;

int N, K;
char S[MAX];

int main() {
    
    cin >> N >> K;
    rep(i, N) {
        cin >> S[i];
    }
    
    for(int i = 0; i < N; i++){
        if (i == (K-1)) {
            S[i] = towlower(S[i]);
        }
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

f([]).
f(['R'|Xs]) :- g(Xs).
f(['U'|Xs]) :- g(Xs).
f(['D'|Xs]) :- g(Xs).

g([]).
g(['L'|Xs]) :- f(Xs).
g(['U'|Xs]) :- f(Xs).
g(['D'|Xs]) :- f(Xs).

main :-
    get_chars(S),
    f(S) -> writeln("Yes") ; writeln("No").

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8016
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;	

int main() {
	int x; cin >> x;
	if (x==0){
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 3592
N = int(input())
B = list(map(int,input().split()))
cnt = 0
for i in range(N):
  if i == 0:
    cnt += B[i]
  elif i == N-1:
    cnt += B[i-1]
  else:
    cnt += min(B[i-1],B[i])
print(cnt)

Measured memory_bytes: 3060
c1=list(map(int,input().split()))
c2=list(map(int,input().split()))
c3=list(map(int,input().split()))


a1=0

t21=[x-y for x,y in zip(c2,c1)]
t32=[x-y for x,y in zip(c3,c2)]
t31=[x-y for x,y in zip(c3,c1)]

tmp1=t21[0]
tmp2=t32[0]
tmp3=t31[0]


for i in range(1,3):
    if tmp1!=t21[i] or tmp2!=t32[i] or tmp3!=t31[i]:
        print("No")
        exit()

print("Yes")
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;
 
int main() {

	int q;
	cin >> q;

	int a;
	int x;

	list<int> l;
	list<int>::iterator itr = l.end();

	rep(i, q) {
		cin >> a;

		switch(a) {
			case 0:
				cin >> x;
				itr = l.insert(itr, x);
				break;

			case 1:
				cin >> x;
				if ( x >= 0)
					rep(i, x) itr++;
				else 
					for (int i = x; i < 0; i++) itr--;
				break;

			case 2:
				itr = l.erase(itr);
				break;
		}
	}

	for (list<int>::iterator i = l.begin(); i != l.end(); i++)
		cout << *i << endl;
}


Measured memory_bytes: 18640