akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
   int N; cin>>N;
   vector<int> a(N),b(N);
   for(int i=0;i<N;i++) cin>>a[i];
   for(int i=0;i<N;i++) cin>>b[i];

   int ans=0;
   for(int i=28;i>=0;i--){
      const int mod=1<<(i+1);
      for(int j=0;j<N;j++){
         a[j]%=mod;
         b[j]%=mod;
      }
      sort(b.begin(),b.end());

      int cnt=0;
      for(int j=0;j<N;j++){
         for(int k=0;k<2;k++){
            cnt+=lower_bound(b.begin(),b.end(),mod+k*mod-a[j])
                -lower_bound(b.begin(),b.end(),mod/2+k*mod-a[j]);
         }
      }
      if(cnt&1) ans|=1<<i;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
		if (i % 3 && i % 5) ans += i;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <map>

using namespace std;

int main() {
    string b;
    cin >> b;
    
    map<string, string> mp;
    mp["A"]="T";
    mp["T"]="A";
    mp["G"]="C";
    mp["C"]="G";
    
    cout << mp[b] << endl;



    return 0;
    
}

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

#define ll long long

int main(void)
{
    int a,i;
    for(i=1;;i++)
    {
        scanf("%d",&a);
        if(a==0)
        break;
        printf("Case %d: %d\n",i,a);
    }
    return 0;
}




Measured memory_bytes: 2012
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int s1=a.size();
    int s2=b.size();
    if(s1==s2) for(int i=0;i<s1;i++)cout<<a[i]<<b[i];
    else
    {
        for(int i=0;i<s2;i++)cout<<a[i]<<b[i];
        cout<<a[s1-1];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long l,long long w){
	if(w==0)return l;
	return gcd(w,l%w);
}
long long a,b,c,d,e,f;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	e=c/gcd(c,d)*d;
	f=b/c+b/d-b/e-(a-1)/c-(a-1)/d+(a-1)/e;
	printf("%lld",b-a+1-f);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	arr := make([]string, 2)
	for i, _ := range arr {
		arr[i] = sc.nextStr()
	}
	ans := true
	if arr[0] != reverse(arr[1]) {
		ans = false
	}
	if arr[1] != reverse(arr[0]) {
		ans = false
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = INT()
b = a + a ** 2 + a ** 3
print(b)


Measured memory_bytes: 10584
MOD=10**9+7
H,W,A,B=map(int,input().split())

def invmod(a):
  return pow(a,MOD-2,MOD)
def comb_mod(n,r):
  if 0<=r<=n:
    return fact_dic[n]*fact_inv_dic[r]*fact_inv_dic[n-r]
  else:
    return 0

fact_dic={0:1}
fact_inv_dic={0:1}
fact_mod=1
for i in range(1,H+W-1):
  fact_mod=(fact_mod*i)%MOD
  fact_dic[i]=fact_mod
  fact_inv_dic[i]=invmod(fact_mod)
  
answer=0
for i in range(B,W):
  answer+=comb_mod(H-A+B-1,i)*comb_mod(W+A-B-1,W-1-i)
  answer%=MOD
    
print(answer)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,L,T;
int X[222222],W[222222];
int S[222222];

int ans[222222];

signed main(){
    scanf("%lld%lld%lld",&N,&L,&T);
    T*=2;

    rep(i,N){
        scanf("%lld%lld",&X[i],&W[i]);
        X[i+N]=X[i]+L;
        W[i+N]=W[i];
    }

    rep(i,2*N)S[i+1]=S[i]+(W[i]==1);
    int itr=0,jtr=0;

    for(int i=N;i<2*N;i++){
        while(X[i]-X[jtr]>T%L)jtr++;
        while(X[i]-X[itr]>L||X[i]-X[itr]>T)itr++;
        if(W[i]==1)continue;
        int tmp=(S[i]-S[jtr])*(T/L+1);
        tmp+=(S[jtr]-S[itr])*(T/L);
        ans[(i-tmp%N+N)%N]=(X[i]-T/2%L+L)%L;
    }

    itr=2*N,jtr=2*N;
    for(int i=N-1;i>=0;i--){
        while(X[jtr-1]-X[i]>T%L)jtr--;
        while(X[itr-1]-X[i]>L||X[itr-1]-X[i]>T)itr--;
        if(W[i]==2)continue;
        int tmp=(jtr-i-(S[jtr]-S[i]))*(T/L+1);
        tmp+=(itr-jtr-(S[itr]-S[jtr]))*(T/L);
        ans[(i+tmp)%N]=(X[i]+T/2)%L;
    }
    rep(i,N)printf("%lld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 7040
import bisect
N,M,K=map(int,input().split())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))

sum_alist=[0]
for i in range(N):
  sum_alist.append(sum_alist[-1]+alist[i])
#print(sum_alist)

sum_blist=[0]
for i in range(M):
  sum_blist.append(sum_blist[-1]+blist[i])
#print(sum_blist)

limit_a=bisect.bisect(sum_alist,K)
#print(limit_a)

limit_b=bisect.bisect(sum_blist,K)
#print(limit_b)

answer=0
for i in reversed(range(1,limit_a)):
  a_sum=sum_alist[i]
  b_sum=K-a_sum
  pos_b=bisect.bisect(sum_blist,b_sum)
  #print(i,pos_b-1,a_sum,sum_blist[pos_b-1],b_sum)
  answer=max(answer,i+pos_b-1)

for i in reversed(range(1,limit_b)):
  b_sum=sum_blist[i]
  a_sum=K-b_sum
  pos_a=bisect.bisect(sum_alist,a_sum)
  #print(i,pos_b-1,a_sum,sum_blist[pos_b-1],b_sum)
  answer=max(answer,i+pos_a-1)
  
if limit_a==1:
  pos_b=bisect.bisect(sum_blist,K)
  answer=pos_b-1
elif limit_b==1:
  pos_a=bisect.bisect(sum_alist,K)
  answer=pos_a-1
  
print(answer)

Measured memory_bytes: 130180
function Main(input) {
    input = input.split("\n");
  	var a = input[0].split("");
  	var answer="";
    if(a[2]==a[3]&&a[4]==a[5]){
		answer="Yes";
    }else{
		answer="No";
    }
  	console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int length(char*str){ 
 int a=strlen(str);
 return a;
}

int main(void){
    char s[1005];
    int w;
    cin >> s;
    int sl = length(s);
    cin >> w;
    for (int i = 0; i < sl; i += w) cout << s[i];
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a<b)cout<<"Bob\n";
    else if(a>b)cout<<"Alice\n";
    else cout<<"Draw\n";
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
long long a[100001];
long long b[100001];
long long c[100001];
long long dp[4][100001];
long long dptrck[100001];
int main()
{
	memset(dp,0,sizeof(dp));
	long long n;
	cin>>n;
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(long long i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	for(long long i=1;i<=n;i++)
	{
		cin>>c[i];
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	sort(c+1,c+1+n);
	long long l;long long r;
	long long mid;
	for(long long i=1;i<=n;i++)
	{
		l=0;r=n+1;
		while(l<r-1)
		{
			mid=(l+r)/2;
			if(a[mid]<b[i])
			{
				l=mid;
			}
			else
			{
				r=mid;
			}
		}
		dp[2][i]=l;
	}
	for(long long i=1;i<=n;i++)
	{
		l=0;r=n+1;
		while(l<r-1)
		{
			mid=(l+r)/2;
			if(b[mid]<c[i])
			{
				l=mid;
			}
			else
			{
				r=mid;
			}
		}
		dptrck[i]=l;
		dp[3][i]=dp[3][i-1];
		for(long long j=dptrck[i-1]+1;j<=l;j++)dp[3][i]+=dp[2][j];
	}
	long long s=0;
	for(long long i=1;i<=n;i++)s+=dp[3][i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;


double calc_distance(double x1, double y1, double x2, double y2)
{
	double dx = x1 - x2;
	double dy = y1 - y2;
	return sqrt(dx*dx + dy*dy);
}
double calc_area(double x[3], double y[3])
{
	double e[3];
	for (int i = 0; i < 3; ++i)
		e[i] = calc_distance(x[i], y[i], x[(i+1)%3], y[(i+1)%3]);
	double z = (e[0]+e[1]+e[2]) / 2;
	return sqrt(z*(z-e[0])*(z-e[1])*(z-e[2]));
}

int main()
{
	double x[20];
	double y[20];
	int n;
	for (n = 0; scanf("%lf,%lf", x+n, y+n) != EOF; ++n)
		;

	double area = 0;
	for (int i = 1; i < n-1; ++i)
	{
		double xx[3] = { x[0], x[i], x[i+1] };
		double yy[3] = { y[0], y[i], y[i+1] };
		area += calc_area(xx, yy);
	}
	printf("%.6f\n", area);

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,sum = 0;
    cin>>n;
    int a[n];
    set<int>s;
    map<int,int>mp;
    for(i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int k = 0;
    for(i = 0; i < n; i++)
    {
        if(a[i]==k+1)
            k++;
    }
    if(k==0)
        cout<<-1<<endl;
    else
        cout<<n-k<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
#include<algorithm>
using namespace std;
using ll = long long;

template< typename OperatorMonoid >
struct DuelSegmentTree {
  using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;

  int sz, height;
  vector< OperatorMonoid > lazy;
  const H h;
  const OperatorMonoid OM0;


  DuelSegmentTree(int n, const H h, const OperatorMonoid OM0)
      : h(h), OM0(OM0) {
    sz = 1;
    height = 0;
    while(sz < n) sz <<= 1, height++;
    lazy.assign(2 * sz, OM0);
  }

  inline void propagate(int k) {
    if(lazy[k] != OM0) {
      lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
      lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      lazy[k] = OM0;
    }
  }

  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }

  void update(int a, int b, const OperatorMonoid &x) {
    thrust(a += sz);
    thrust(b += sz - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) lazy[l] = h(lazy[l], x), ++l;
      if(r & 1) --r, lazy[r] = h(lazy[r], x);
    }
  }

  OperatorMonoid operator[](int k) {
    thrust(k += sz);
    return lazy[k];
  }
};

int main() {
  
  lint n, q; cin >> n >> q;
  n--;
  n--;


  // n = 3
  auto f = [](lint a, lint b) {
    return lint(min(a, b));
  };
  DuelSegmentTree<lint> tate(n + 1, f, n);
  DuelSegmentTree<lint> yoko(n + 1, f, n);
  
  lint ans = 0;

  for (int i = 0; i < q; i++) {
    int o, x; cin >> o >> x;
    x -= 2;

    if (o == 1) {
      // 縦に亀裂を入れる
      lint ma = yoko[x];
      ans += ma;

      // [0, ma) を、x と min 更新
      tate.update(0, ma, x);
    } else {
      lint ma = tate[x];
      ans += ma;

      // [0, ma) を、x と min 更新
      yoko.update(0, ma, x);
    }
  }

  cout << n * n - ans << endl;

  return 0;
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

int main(int argc, char ** argv) {
	ios_base::sync_with_stdio(false);
	ll n, m, q;
	cin >> n >> m >> q;
	vvi s(n, vi(m,0));
	for(ll i=0; i<n; i++) {
		string tmp;
		cin >> tmp;
		for(ll k=0; k<tmp.length(); k++) {
			if(tmp[k] == '0') s[i][k] = 0;
			if(tmp[k] == '1') s[i][k] = 1;
		}
	}
	vvi v(n, vi(m,0));
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<m; j++) {
			ll A=0, B=0, C=0;
			if(i > 0) A = v[i-1][j];
			if(j > 0) B = v[i][j-1];
			if(i > 0 && j > 0) C = v[i-1][j-1];
			v[i][j] = s[i][j] + A + B - C;
		}
	}
	vvi ev(n, vi(m,0)), eh(n, vi(m,0));
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<m; j++) {
			ll A=0, B=0, C=0, D=0;
			if(i > 0) D = s[i][j]&s[i-1][j];
			if(i > 0) A = ev[i-1][j];
			if(j > 0) B = ev[i][j-1];
			if(i > 0 && j > 0) C = ev[i-1][j-1];
			ev[i][j] = D + A + B - C;
		}
	}
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<m; j++) {
			ll A=0, B=0, C=0, D=0;
			if(j > 0) D = s[i][j]&s[i][j-1];
			if(i > 0) A = eh[i-1][j];
			if(j > 0) B = eh[i][j-1];
			if(i > 0 && j > 0) C = eh[i-1][j-1];
			eh[i][j] = D + A + B - C;
		}
	}
	/*
	cout << "v" << endl;
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<m; j++) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "ev" << endl;
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<m; j++) {
			cout << ev[i][j] << " ";
		}
		cout << endl;
	}
	cout << "eh" << endl;
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<m; j++) {
			cout << eh[i][j] << " ";
		}
		cout << endl;
	}
	*/
	for(ll i=0; i<q; i++) {
		ll x1, x2, y1, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 --; x2 --;
		y1 --; y2 --;
		ll A_v = v[x2][y2];
		ll A_ev = ev[x2][y2];
		ll A_eh = eh[x2][y2];
		ll B_v = 0, C_v = 0, D_v = 0;
		ll B_ev = 0, C_ev = 0, D_ev = 0;
		ll B_eh = 0, C_eh = 0, D_eh = 0;
		if(x1 > 0 && y1 > 0) {
			B_v = v[x1-1][y1-1];
		}
		if(x1 > 0) {
			B_eh = eh[x1-1][y1];
			C_v = v[x1-1][y2];
			C_eh = eh[x1-1][y2];
		}
		if(y1 > 0) {
			B_ev = ev[x1][y1-1];
			D_v = v[x2][y1-1];
			D_ev = ev[x2][y1-1];
		}
		C_ev = ev[x1][y2];
		D_eh = eh[x2][y1];
		ll num_v = A_v + B_v - C_v - D_v;
		ll num_ev = A_ev + B_ev - C_ev - D_ev;
		ll num_eh = A_eh + B_eh - C_eh - D_eh;
		// cout << "num_v : " << num_v << endl;
		// cout << "num_ev : " << num_ev << endl;
		// cout << "num_eh : " << num_eh << endl;
		ll ans = num_v - num_ev - num_eh;
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 127104
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, A, B, C, L[10];
//---------------------------------------------------------------------------------------------------
int ans = inf;
int flag[8];
void dfs(int cu) {
    if (cu == N) {
        int a = 0, b = 0, c = 0;
        int ca = 0, cb = 0, cc = 0;
        rep(i, 0, N) {
            if (flag[i] == 0) a += L[i], ca++;
            else if (flag[i] == 1) b += L[i], cb++;
            else if (flag[i] == 2) c += L[i], cc++;
        }
        if (0 == ca or 0 == cb or 0 == cc) return;
        int cand = (ca-1) * 10 + (cb-1) * 10 + (cc-1) * 10;
        cand += abs(A - a) + abs(B - b) + abs(C - c);
        chmin(ans, cand);
        return;
    }

    rep(i, 0, 4) {
        flag[cu] = i;
        dfs(cu + 1);
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> A >> B >> C;
    rep(i, 0, N) cin >> L[i];

    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String stations = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		while (true) {
			int n = scanner.nextInt();
			if (n == 0) {
				break;
			}
			Deque<Integer> deque = new ArrayDeque<Integer>();

			for (int i = 0; i < n; i++) {
				deque.addFirst(scanner.nextInt());
			}

			String list = scanner.next();
			for (int i = 0; i < list.length(); i++) {
				int s = stations.indexOf(list.substring(i, i + 1));

				int key = deque.pollLast();
				deque.addFirst(key);

				s -= key;
				if (s < 0) {
					s += 52;
				}

				System.out.print(stations.substring(s, s + 1));
			}
			System.out.print("\n");
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 24384
#include <cstdio>
#include <cstring>
char buf[1024];
int main()
{
	int i = 0;
	fgets(buf, 1024, stdin);
	while (i < strlen(buf)) {
		if (!strncmp(buf + i, "apple", 5)) { printf("peach"); i += 5; }
		else if (!strncmp(buf + i, "peach", 5)) { printf("apple"); i += 5; }
		else { putchar(buf[i]); ++i; }
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <map>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x,n;
int a[110];
map<int,int>h;
int main(){
	cin>>x>>n;
	for(int i=1;i<=n;i++)cin>>a[i],h[a[i]]=1;
	int mn=INF,mnpos;
	for(int i=-300;i<=300;i++){
		if(h[i]==0&&mn>abs(i-x))mn=abs(i-x),mnpos=i;
	}
	cout<<mnpos<<endl;
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int n; cin >>n;
    vector<int> p(n); cin >> p;
    
    int ans = 0;
    for (int i = 1; i <= n-2; i++)
        if ((p[i-1]<p[i]&&p[i]<p[i+1])
         ||(p[i-1]>p[i]&&p[i]>p[i+1]))
            ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
wlst = []
vlst = []
for _ in range(N):
  w, v = map(int, input().split())
  wlst.append(w)
  vlst.append(v)

max_V = sum(vlst)
INF = 10 ** 20
dp = [INF] * (max_V + 1)
dp[0] = 0
for w, v in zip(wlst, vlst):
  for i in range(max_V, v - 1, -1):
    dp[i] = min(dp[i], dp[i - v] + w)

for i in range(max_V, -1, -1):
  if dp[i] <= W:
    print(i)
    break

Measured memory_bytes: 66268
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
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; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

double dist[9][9];

int main() {
  int n; cin >> n;
  vector<double> x(n), y(n);
  rep(i, n){
    cin >> x[i] >> y[i];
  }

  rep(i, n){
    rep(j, n){
      dist[i][j] = sqrt((x[i]-x[j]) * (x[i]-x[j]) + (y[i]- y[j])*(y[i]- y[j]));
    }
  }

  double average = 0;
  vector<int> v(n);
  rep(i, n) v[i] = i;
  do {
    rep(i, n-1){
      average += dist[v[i]][v[i+1]];
    }
  } while(next_permutation(ALL(v)));

  reps(i, n){
    average /= i;
  }
  printf("%.12f\n", average);
}


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

using namespace std;

typedef long long ll;

ll n, m, ans2;
ll a[100005];
ll b[100005];

bool f(ll p)
{
    ll cnt = 0;
    for(ll i = 0; i < n; i++)
    {
        ll t = lower_bound(a, a + n, p - a[i]) - a;
        cnt += n - t;
    }
    return cnt >= m;
}

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    ll lt = 0, rt = 2e18, mid = 0, ans = 0;
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid)) lt = mid + 1, ans = mid;
        else rt = mid - 1;
    }
    for(ll i = n - 1; i >= 0; i--)
    {
        b[i] = b[i + 1];
        b[i] += a[i];
    }
    ll cnt = 0;
    ll mn = 4e18;
    for(ll i = 0; i < n; i++)
    {
        ll t = lower_bound(a, a + n, ans - a[i]) - a;
        ans2 += b[t];
        ans2 += a[i] * (n - t);
        cnt += n - t;
    }
    ans2 -= (cnt - m) * ans;
    printf("%lld\n", ans2);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int n,i,count=0;
   cin>>n;
    string s;
    for(i=1;i<=n;i++)
    {
        s=to_string(i);
        long int l=s.size();
        if(l%2!=0)
        {
            count++;
        }
    }
   cout<<count;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n;
    m=n%10;
    if(m==0 || m==1 || m==6 || m==8)
    {
        cout<<"pon\n";
    }
    else if(m==3)
    {
        cout<<"bon\n";
    }
    else
    {
        cout<<"hon\n";
    }
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int>vec(n);
    for(int i=0;i < n;i++){
        cin >> vec[i];
    }
    reverse(vec.begin(),vec.end());
    for(int j=0;j < n;j++){
        if (j == n-1){
            cout << vec[j] << endl;
        }
        else{
        cout << vec[j] << " ";
            
        }
    }
    return 0;
}


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

int main()
{
	int N, num[128];
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		cin >> num[i];
	}
	
	cout << num[N - 1];
	for(int i = N - 2; i >= 0; --i)
	{
		cout << " " << num[i];
	}
	cout << endl;

    return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iomanip>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int a, b,n;
	cin >> a >> b >> n;

	bool ans = true;
	rep(i, n) {
		int s, f;
		cin >> s >> f;
		if ((s <= a && a < f) || (s < b && f >= b) || 
			(a <= s && f <= b) || (s <= a && b <= f))ans = false;
	}
	if (ans)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

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()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n, m;
	cin >> n >> m;
	vi k(n);
	vector<vector<int>> a(n, vector<int>());
	rep(i, n)
	{
		cin >> k[i];
		a[i].resize(k[i]);
		rep(j, k[i]) cin >> a[i][j];
	}

	vi meal(m, 0);
	rep(i, n) sort(all(a[i]));
	rep(i, n)
	{
		rep(j, k[i]) meal[a[i][j]-1]++;
	}

	int ans = 0;
	rep(i, m) if(meal[i] == n) ans++;

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = int(input()) for _ in range(N) # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']

def main():
    A, B = list(map(int,input().split()))
    print(A-B+1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <cstring>
using namespace std;

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x,min(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;


int n;
int dp[100005];
int h[100005];

int minCost(int i)
{
        if(i==n-1 || i==n) return 0;
        if(i==n-2) return abs(h[n-1]-h[n-2]);
        if(dp[i]!=-1) return dp[i];

        return dp[i] = min((abs(h[i+1]-h[i]) + minCost(i+1)), (abs(h[i+2]-h[i]) + minCost(i+2))); 
}

int32_t main()
{
  IOS;

  cin>>n;

  F(i,0,n)
  {
          int x;
          cin>>x;
          h[i] = x;
  }
        
  memset(dp, -1, sizeof dp);

  cout<<minCost(0)<<endl;

  

  

  



 
  
  

  






























  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    ll s_l = s.length();
    ll ans = 0;

    for (int bit = 0; bit < (1<<(s_l-1)); bit++) {
        vector<int> S;
        for (int i = 0; i < s_l-1; i++) {
            if (bit & (1<<i))
                S.push_back(i);
        }
        S.push_back(s_l-1);
        int k = 0;
        for (int i = 0; i < S.size(); i++) {
            int l = S[i];
            ll tmp = 0;
            for (; k <=S[i]; k++) {
                tmp = tmp*10 + (s[k]-'0');
            }
            ans += tmp;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#define MAX 100
int main()
{
  int n,i,j,k,l,min,q;
  scanf("%d\n",&n);
  int M[MAX+1][MAX+1],p[MAX+1],A[MAX],B[MAX];
  for(i=0;i<n;i++)
    {scanf("%d %d \n",&A[i],&B[i]); }

  p[0]=A[0];
  for(i=1;i<=n;i++)
    p[i]=B[i-1];
  n++;
  for(i=0;i<n;i++)M[i][i]=0;
  
  for(i=2;i<n;i++)
    {for(j=1;j<n-i+1;j++){
	k=i+j-1;
	M[j][k]=10000000;
	for(l=j;l<=k-1;l++){
	  min=M[j][l]+M[l+1][k]+p[j-1]*p[l]*p[k];
	  if(min<M[j][k])M[j][k]=min;
	                    }
                         }
      }
      
  printf("%d\n",M[1][n-1]);
  return 0;
}



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

int main()
{
  int a,b;
  cin >> a >> b;
  int cnt = 0;
  for(int i = a; i <= b;i++){
    vector<int> c(5,0);
    c[4] = i % 10;
    c[3] = (i / 10) % 10;
    c[2] = (i / 100) % 10;
    c[1] = (i / 1000) % 10;
    c[0] = i / 10000;
    if(c[0] == c[4] && c[1] == c[3]) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_V 1500
#define INF 1<<29
using namespace std;
struct edge{int to,cap,rev;};
vector<edge>G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}
void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int>q;
  level[s]=0;
  q.push(s);
  while(!q.empty()){
    int v=q.front();q.pop();
    for(int i=0;i<G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[e.to]<0){
        level[e.to]=level[v]+1;
        q.push(e.to);
      }
    }
  }
}
int dfs(int v,int t,int f){
  if(v==t)return f;
  for(int &i=iter[v];i<G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      int 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;
}
int max_flow(int s,int t){
  int flow=0;
  while(1){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,INF))>0){
      flow+=f;
    }
  }
}
int main(){
  int a,b;
  while(cin>>a>>b,a+b){
    for(int i=0;i<MAX_V;i++)G[i].clear();
    int aa[a],bb[b];
    for(int i=0;i<a;i++)cin>>aa[i];
    for(int i=0;i<b;i++)cin>>bb[i];
    for(int i=101;i<601;i++)add_edge(0,i,1);
    for(int i=701;i<1201;i++)add_edge(i,1499,1);
    for(int i=0;i<a;i++)
     for(int j=0;j<b;j++)
      if((__gcd(aa[i],bb[j]))!=1)add_edge(i+101,j+701,1);
    cout<<max_flow(0,1499)<<endl;
  }
}

Measured memory_bytes: 9464
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll A, B;
	cin >> A >> B;

	ll ans = -1;
	if (A >= 10 || B >= 10) {

	}
	else {
		ans = A * B;
	}

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

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

long long sum_string(string S){
  long long value = 0;
  string calc;
  
  for (int i=0; i<S.size(); i++) {
    if (S.at(i) == '+'){
      value += stoll(calc, NULL, 10);
      calc = {};
    }else{
      calc += S.at(i);
    }
  }
  return(value += stoll(calc, NULL, 10));
}


long long sum_plus(string S, string OTW, int digit){
  if ( digit == S.size() ){
   return sum_string(OTW);
  }
  long long value = 0;
  string LINK = OTW;
  OTW += S.at(digit);
  LINK += '+';
  LINK += S.at(digit);
  
  return sum_plus(S, OTW, digit+1) + sum_plus(S, LINK, digit+1);
  
}


int main(){

  string S;
  cin >> S;
  
  string OTW = {S.at(0)};

  cout << sum_plus(S, OTW, 1) << endl;
  
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans;

string s;
char st[1000000];
int sn;

int main() {
	//freopen("x.in", "r", stdin);
	cin >> s;
	n = SZ(s);
	sn = 0;
	F0(i, n) {
		if (sn > 0 && st[sn - 1] == 'S' && s[i] == 'T') sn--;
		else st[sn++] = s[i];
	}
	cout << sn << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;
std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t 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 A, B; cin >> A >> B;
    ll gcd = GCD(A, B);
    map<int64_t, int> ret = prime_factor(gcd);
    cout << ret.size()+1 << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back

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

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

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

    int n; 
    while(cin>>n,n)
    {
	bitset<100> bset[101];
	int c,p;
	REP(i,n){
	    cin>>c;
	    REP(j,c){
		cin>>p;
		bset[i].set(p-1);
	    }
	}
	cin>>c;
	REP(i,c){
	    cin>>p;
	    bset[100].set(p-1);
	}

	int cnt=0,idx;
	REP(i,n){
	    if((bset[i]|bset[100])==bset[i]){
		cnt++; idx=i+1;
	    }
	}
	if(cnt==1) cout<<idx<<endl;
	else cout<<-1<<endl;
    }

}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
using namespace std;

long long inf = (1 << 30);
long long mod = 1e9;

int main(){

    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    int mod_min = 1e6, index = -1;
    if(mod_min > ((A - 1) % 10)){
        mod_min = (A - 1) % 10;
        index = 1;
    }
    if(mod_min > ((B - 1) % 10)){
        mod_min = (B - 1) % 10;
        index = 2;
    }
    if(mod_min > ((C - 1) % 10)){
        mod_min = (C - 1) % 10;
        index = 3;
    }
    if(mod_min > ((D - 1) % 10)){
        mod_min = (D - 1) % 10;
        index = 4;
    }
    if(mod_min > ((E - 1) % 10)){
        mod_min = (E - 1) % 10;
        index = 5;
    }

    int ans = 0;
    if(index != 1){
        if(A % 10 != 0) ans += ((A / 10) + 1) * 10;
        else ans += A;
    }
    if(index != 2){
        if(B % 10 != 0) ans += ((B / 10) + 1) * 10;
        else ans += B;
    }
    if(index != 3){
        if(C % 10 != 0) ans += ((C / 10) + 1) * 10;
        else ans += C;
    }
    if(index != 4){
        if(D % 10 != 0) ans += ((D / 10) + 1) * 10;
        else ans += D;
    }
    if(index != 5){
        if(E % 10 != 0) ans += ((E / 10) + 1) * 10;
        else ans += E;
    }


    if(index == 1) ans += A;
    if(index == 2) ans += B;
    if(index == 3) ans += C;
    if(index == 4) ans += D;
    if(index == 5) ans += E;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  char a,b;
  cin >>a>>b;
  if (a=='D'&&b=='D') {
    cout <<"H"<<endl;
  }
  if (a=='D'&&b=='H') {
    cout <<"D"<<endl;
  }
  if (a=='H') {
    cout <<b<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i, n) for (int i = 0; i < n; i++)
char upper(char c) { return c + ('A' - 'a'); }
int main()
{
    string a, b, c; cin >> a >> b >> c;
    cout << upper(a[0]) << upper(b[0]) << upper(c[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; ++i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	printf("%d\n", (A + B) % 24);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i=0;i<N;i++){
      a[i] = sc.nextInt();
    }
    int alice = 0;
    int bob = 0;
    for (int i=0;i<a.length;i++){
      int high = 0;
      int idx = -1;
      for (int j=0;j<a.length;j++){
        if (high<a[j]){
          high = a[j];
          idx = j;
        }
      }
      if ((i+1)%2==0){
        bob = bob + high;
      } else {
        alice = alice + high;
      }
      a[idx] = 0;
    }
    System.out.println(alice - bob);
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 char ch;
 cin>>ch;
 if('a'<=ch&&ch<='z')
    cout<<'a'<<endl;
 else
    cout<<'A'<<endl;

return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    int a, b, c;
    cin >> a >> b >> c;

    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
T, A = 0, 0
for i in range(N):
  a1, a2 = map(int, input().split())
  if i == 0:
    T, A = a1, a2
  else:
    if T <= a1 and A <= a2:
      T, A = a1, a2
    elif T > a1 and A <= a2:
      if T % a1 == 0:
        X = T // a1
      else:
        X = T // a1 + 1
      T, A = a1 * X, a2 * X
    elif T <= a1 and A > a2:
      if A % a2 == 0:
        X = A // a2
      else:
        X = A // a2 + 1
      T, A = a1 * X, a2 * X
    elif T > a1 and A > a2:
      X, Y = (T - 1) // a1 + 1, (A - 1) // a2 + 1
      if X <= Y:
        T, A = a1 * Y, a2 * Y
      else:
        T, A = a1 * X, a2 * X
print(T + A)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N;
int t[111111];
int x[111111];
int y[111111];

int main() {
   cin >> N;
   for (int i = 1; i <= N; i++) {
      cin >> t[i] >> x[i] >> y[i];
   }

   for (int i = 1; i <= N; i++) {
      int dist = abs(x[i-1]-x[i]) + abs(y[i-1]-y[i]);
      int tt = abs(t[i-1] - t[i]);
      if (dist <= t[i] && (dist%2 == tt%2)) {

      } else {
         puts("No");
         return 0;
      }
   }

   puts("Yes");

   return 0;
}

Measured memory_bytes: 1408
import numpy as np

a, b = list(map(int, input().split()))
minXa = int(np.ceil(a / 0.08))
minXb = b * 10
maxXa = int(np.ceil((a+1) / 0.08))
maxXb = (b+1) * 10

ansX = 9999
ansY = 9999
for x in range(minXa, maxXa):
    if(int(x*0.1) == b):
        ansX = x
        break

for y in range(minXb, maxXb):
    if(int(y*0.08) == a):
        ansY = y
        break

        
if(ansX == 9999 and ansY == 9999):
    print(-1)
else:
    print(min(ansX, ansY))

Measured memory_bytes: 21548