akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  ll N, A, B;
  cin >> N >> A >> B;
  vector<int> X(N);
  REP(i, N) cin >> X[i];
  ll ans = 0;
  for (int i = 1; i < N; i++) {
    ll d = X[i] - X[i - 1];
    if (A * d < B) ans += A * d;
    else ans += B;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;


int main() {
  
    int h,w;
    scanf("%d%d",&h,&w);
    char s[h+1][w+1];
    char s1[h+1][w+1];
    int i,j,cnt=0,flag=0;
    for(i=0;i<h;++i)
      {
          for(j=0;j<w;++j)
          {
              cin>>s[i][j];
              s1[i][j]=s[i][j];
          }
      }
 
  
      
    for(i=0;i<h;++i)
    {
        for(j=0;j<w;++j)
         {
             cnt=0;
             flag=0;
             if(s[i][j]=='.')
              {
                  if(s[i+1][j]=='#' && i+1<h)
                     cnt++;
                     
                  if(s[i+1][j-1]=='#' && i+1<h && j-1>=0)
                           cnt++;
                           
                  if(s[i+1][j+1]=='#' && i+1<h)      
                       cnt++;
                       
                  if(s[i][j+1]=='#' && j+1<w && j+1<w)
                        cnt++;
                        
                  if(s[i][j-1]=='#' && j-1>=0)
                        cnt++;   
                        
                  if(s[i-1][j-1]=='#' && j-1>=0 && i-1>=0)
                        cnt++; 
                        
                  if(s[i-1][j+1]=='#' && j+1<w && i-1>=0)
                        cnt++;  
                        
                  if(s[i-1][j]=='#' && i-1>=0)
                        cnt++;        
                   
                   flag=1;
              }
            if(flag==1)
              s1[i][j]=cnt+'0';
         }
    }
    
    for(i=0;i<h;++i)
      {
          for(j=0;j<w;++j)
          {
              cout<<s1[i][j];
          }
          
          cout<<endl;
      }
    
    
    	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if (1<=A && A<=9 && 1<=B && B<=9 ){
    cout<< A*B << endl;
  }
  else{
  cout<< -1 << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, t, a, mi = 100010001, ans = 0;
	cin >> n >> t >> a;

	for(int i=1;i<=n;i++){
		int h;
		cin >> h;
		if(mi>abs(t*1000-h*6-a*1000)){
			mi = abs(t*1000-h*6-a*1000);
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
inline const int Get_Int() {
    int num=0,bj=1;
    char x=getchar();
    while(x<'0'||x>'9') {
        if(x=='-')bj=-1;
        x=getchar();
    }
    while(x>='0'&&x<='9') {
        num=num*10+x-'0';
        x=getchar();
    }
    return num*bj;
}
long long n,C,Q[500005],f[500005],s[500005];
double Slope(long long j,long long k) { //求斜率 
    return double((f[j]+s[j]*s[j])-(f[k]+s[k]*s[k]))/(2*s[j]-2*s[k]);
}
int main() {
    scanf("%lld%lld",&n,&C);
    for(int i=1; i<=n; i++)s[i]=Get_Int();
    int Left=1,Right=1;
    Q[1]=1;
    f[0]=0;
    for(int i=2; i<=n; i++) {
        while(Left!=Right&&Slope(Q[Left],Q[Left+1])<=s[i])Left++; //维护队首（删除非最优决策） 
        int Front=Q[Left];
        f[i]=f[Front]+(s[i]-s[Front])*(s[i]-s[Front])+C; //计算当前f 
        while(Left!=Right&&Slope(Q[Right-1],Q[Right])>=Slope(Q[Right],i))Right--; //维护队尾（维护下凸包性质） 
        Q[++Right]=i; //入队 
    }
    printf("%lld\n",f[n]);
    return 0;
}

Measured memory_bytes: 9984
#include<iostream>
    using namespace std;
    int main()
    {
      char c;
      std::cin >> c;

      if (c == 'a'||c =='e'||c =='i'||c =='u'||c =='o') {
        std::cout << "vowel" << '\n';
        /* code */
      }

      else {
        std::cout << "consonant" << '\n';
      }
        return 0;
      }


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

using namespace std;

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

  unsigned N;

  std::cin >> N;
  vector<vector<vector<double>>> dp(N+2, vector<vector<double>>(N+2, vector<double>(N+2, 0.0)));
  vector<int> vals(4, 0);

  for (int i = 0; i < N; ++i)
  {
    int x;
    std::cin >> x;
    vals[x] += 1;
  }


for (int z = 0; z <= vals[3]; ++z)
  {
    for (int y = 0; y <= vals[2]+vals[3]; ++y)
    {   
      for (int x = 0; x <= vals[1]+vals[2]+vals[3]; ++x)
      {   
        if (x+y+z == 0)
        {   
          dp[0][0][0] = 0.0;
          continue;
        }   
        double sum = N;
        if (x > 0) sum += x * dp[x-1][y][z];
        if (y > 0) sum += y * dp[x+1][y-1][z];
        if (z > 0) sum += z * dp[x][y+1][z-1];
        dp[x][y][z] = sum / (x+y+z);
        if (x == vals[1] && y == vals[2] && z == vals[3])
        {   
          std::cout << std::setprecision(20) << dp[x][y][z];
          return 0;
        }   
      }   
    }   
  }

  return 0;
}

Measured memory_bytes: 219776
n=int(input())
a=[int(i) for i in input().split()]
x=min(a)
for i in range(n):
    a[i]-=x
ans=chk=0
chk=a[0]
for i in range(n):
    if a[i]<chk:
        ans+=chk-a[i]
    else:
        chk=a[i]
print(ans)

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

#define int long long

#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
string s;

signed main() {
    IOS();
    /*シフト演算は(1ll<<x)*/
    
    cin>>s;
    rep(i,0,s.size()){
        if(i==3)cout<<'8';
        else cout<<s[i];
    }
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
vector<int> x[10000];
bool used[10000];
int y[10000];
Bpri<int> q;
void dfs(int z){
	used[z]=true;
	y[z]=q.top();
	q.pop();
	f(i,x[z].size()){
		if(!used[x[z][i]]){
			dfs(x[z][i]);
		}
	}
}
signed main(){
	int n,sum=0,ma=0;
	cin>>n;
	f(i,n-1){
		int a,b;
		cin>>a>>b;
		x[a-1].push_back(b-1);
		x[b-1].push_back(a-1);
	}
	f(i,n){
		int a;
		cin>>a;
		q.push(a);
		sum+=a;
		ma=max(a,ma);
	}
	cout<<sum-ma<<endl;
	dfs(0);
	f(i,n){
		if(i)cout<<" ";
		cout<<y[i];
	}
	cout<<endl;
}


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

int main(){
	string S;
	int w;
	cin>>S>>w;
	rep(i,S.size()){
		if(i%w==0){
			cout<<S.at(i);
		}
	}
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, x;
  long cnt = 0;

  while(1){
    cin >> n >> x;

    if(n == 0 && x == 0){ break; }
    for(int i = 1; i <= n-2; i++){
      for (int j = i+1; j <= n-1; j++){
	for(int k = j+1; k <= n; k++){
	  if(i+j+k == x){
	    cnt++;
	    break;
	  }
	}
      }
    }
    cout << cnt << endl;
    cnt = 0;
  }

  return 0;
}



Measured memory_bytes: 3088
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr


ans = 0

if N == 1:
    ans = 0
else:
    l = factorization(N) 
    for i in range(len(l)):
        tmp = 1
        for j in range(40):
            if l[i] >= tmp:
                l[i] -= tmp
                ans += 1
                tmp += 1
            else:
                break
print(ans)

Measured memory_bytes: 9492
from sys import stdin


def get_result(data):
    N, R = data
    if N < 10:
        return R + 100 * (10 - N)
    
    return R

if __name__ == '__main__':
    data = list(map(int, stdin.readline().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void initialize(){
  head = tail = 0;
}

int isEmpty(){
  if(head == tail) return 0;
  else return 1;
}

int isFull(){
  if(head == (tail + 1) % MAX) return 0;
  else return 1;
}

void enqueue(P x){
  if(isFull() == 0) printf("??¨?????????????????????????????????\n");
  else {
    Q[tail] = x;
    if(tail + 1 == MAX)  tail = 0;
    else   tail++;
  }
}

P dequeue(){
  P x;
  if(isEmpty() == 0) printf("??¨???????????¢?????????????????????\n");
  else {
    x = Q[head];
    if(head + 1 == MAX) head = 0;
    else   head++;
  }
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;

  initialize();
  scanf("%d %d", &n, &q);

  for (i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    if(q > u.t) c = u.t;
    else c = q;
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }    
  return 0;
}

Measured memory_bytes: 10756
if __name__ == "__main__":
    N,K = map(int, input().split())
    deg = [0 for x in range(10 ** 5 + 1)]
    for x in range(N):
        a,b = map(int, input().split())
        deg[a] += b
    res = 0
    for i,val in enumerate(deg):
        res += val
        if (res >= K):
            print (i)
            break


Measured memory_bytes: 5920
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [-1 for _ in range(N)]
 
dp[0] = 0
 
for i in range(1, N):
    dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, K+1) if i-j >= 0])
 
print(dp[N-1])

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

using namespace std;

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; ++i) cin >> L[i];
  sort(L.begin(), L.end());
  ll ans = 0;
  for (int i = 2; i < N; ++i) {
    for (int j = i - 1; j >= 1; --j) {
      auto it = upper_bound(L.begin(), L.end(), L[i] - L[j]);
      if (it < L.begin() + j) ans += L.begin() + j - it;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main() {
  char *line = nullptr;
  size_t buffer_size;
  while (getline(&line, &buffer_size, stdin) > 0) {
    int cards[5];
    sscanf(
        line, "%d,%d,%d,%d,%d",
        cards, cards + 1, cards + 2, cards + 3, cards + 4);
    sort(cards, cards + 5);
    int counts[14] = {};
    for (auto card : cards) { ++counts[card]; }

    int pairs[2] = {};
    int three_card = 0, four_card = 0;
    for (int card = 1; card <= 13; ++card) {
      switch (counts[card]) {
        case 2:
          pairs[pairs[0] ? 1 : 0] = card;
          break;
        case 3:
          three_card = card;
          break;
        case 4:
          four_card = card;
          break;
        default:
          break;
      }
    }

    bool trivial_straight = true;
    for (int i = 0, head = cards[0]; i < 5; ++i) {
      if (cards[i] != head + i) {
        trivial_straight = false;
        break;
      }
    }
    bool straight_with_tailing_ace = cards[0] == 1;
    for (int i = 1; i < 5; ++i) {
      if (cards[i] != 10 - 1 + i) {
        straight_with_tailing_ace = false;
        break;
      }
    }
    bool straight = trivial_straight or straight_with_tailing_ace;

    int num_pairs = (pairs[0] ? 1 : 0) + (pairs[1] ? 1 : 0);

    const char *character = "null";
    if (four_card) { character = "four card"; }
    else if (three_card and num_pairs == 1) { character = "full house"; }
    else if (straight) { character = "straight"; }
    else if (three_card) { character = "three card"; }
    else if (num_pairs == 2) { character = "two pair"; }
    else if (num_pairs == 1) { character = "one pair"; }
    puts(character);
  }
  free(line);

  return 0;
}

Measured memory_bytes: 1024
from sys import stdin

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

left = []
right = []

for i in range(n):
  if(i==0):
    before = an[i]
  else:
    before = gcd(before, an[i])
  left.append(before)

for i in range(n):
  if(i==0):
    before = an[n-1-i]
  else:
    before = gcd(before, an[n-1-i])
  right.append(before)

max = 0
for i in range(n):
  if(i==0):
    before = right[n-2];
  elif(i==(n-1)):
    before = left[n-2];
  else:
    before = gcd(left[i-1],right[n-2-i])
  if(max < before ):
    max = before

print(max)

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

int main()
{
  int n, a , b;
  cin >> n >> a >> b;
  int ans = 0, x, y;
  for(int i = 1; i <= n; i++){
    x = i;
    y = 0;
    while(x > 0){
      y += x % 10;
      x /= 10;
    }
    if(a <= y && y <= b) ans += i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
    
        try{
        while((line = reader.readLine()) != null){
            String[] score = line.split(" ");

            if(score[0].equals("-1")&& score[1].equals("-1")){
                break;
            }
            if(score[0].equals("-1")||score[1].equals("-1")){
                System.out.println("F");
                continue;
            }
            
            int sum = Integer.parseInt(score[0]) + Integer.parseInt(score[1]);

            if(sum <30){
                System.out.println("F");
            }
            else if(sum >= 80){
                System.out.println("A");
            }
            else if(sum < 50){
                if(Integer.parseInt(score[2]) >= 50) System.out.println("C");
                else System.out.println("D");
            }
            else if(sum < 65){
                System.out.println("C");
            }
            else System.out.println("B");
        }
        } catch (IOException e){
            System.out.println(e);
        }
        
    }

}


Measured memory_bytes: 24528
# Nの入力
N = int(input())

# S_array(S1,S2,...Sn)の初期化
S_array = []

# S_arrayの入力
for i in range(N):
    S_array.append(input())

# setで重複を省いて、何種類を表示
print(len(set(S_array)))

Measured memory_bytes: 35640
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
// deprecated because mac doesn't support this...
/* #include <bits/stdc++.h> */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
int P[111];
int main() {
  int N;
  int A, B;
  cin>>N>>A>>B; rep(i,0,N) cin>>P[i];
  int a = 0, b = 0, c = 0;
  rep(i,0,N) {
    if(P[i] <= A) a++;
    else if(A+1 <= P[i] && P[i] <= B) b++;
    else if(P[i] >= B + 1) c++;
  }
  dbg(a); dbg(b); dbg(c);
  cout<<min(a, min(b, c))<<endl;
	return 0;
}
// --USE C++11
// *-USE O2



Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

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

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int a,b;
  cin>>a>>b;

  if(b%a) cout<<b-a<<endl;
  else cout<<b+a<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline lint nxi(){
		lint x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	lint n=nxi();
	printf("%lld\n",n/11*2+(n%11>0)+(n%11>6));
	return 0;
}


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

using namespace std;

int main()
{

	int n;
	
	cin >> n;

	long int *pa = new long int[n+1];
	
	long int *pb = new long int[n];

	long int count = 0;

	for (int i = 0; i <= n; i++) cin >> pa[i];
	
	for (int i = 0; i < n; i++) cin >> pb[i];

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


		if (pa[i] <= pb[i]) {
			count += pa[i];
			pb[i] = pb[i] - pa[i];

		}
		else {
			count += pb[i];
			pb[i] = 0;
		}

		if (pb[i] > 0)
		{
			if (pa[i + 1] <= pb[i]) {
				count += pa[i + 1];
				pb[i] = pb[i] - pa[i];
				pa[i + 1] = 0;
			}
			else
			{
				count += pb[i];
				pa[i + 1] = pa[i + 1] - pb[i];
				pb[i] = 0;

			}

		}

	}

	cout << count;

	
	delete[] pa;
	delete[] pb;

	return 0;
}

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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fr(i,x,n) for(i=x;i>=n;--i)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin>>s>>t;
    deque<char> d;
    for(auto x:t) d.pb(x);
    bool fl=false;
    f(sz(s)){
        char tmp=d.back();
        d.pop_back();
        d.push_front(tmp);
        int j;
        bool found=true;
        fi(j,0,sz(s)){
            if(s[j]!=d[j]){
                found=false;
                break;
            }
        }
        if(found){
            fl=true;
            break;
        }
    }
    if(fl) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 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; }

void solve(long long N, long long X, long long T){
    cout<<(N+X-1)/X * T<<endl;
}
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3252
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		sc.close();

		out.println(Math.min(B, A*N));
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, k; string p;

vector<int> cnt;

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

    cnt.resize(26);
    
    FORN(i, n) {
        cin >> p;
        cnt[p[0] - 'A']++;
    }

    int res = 0;

    while (true) {
        sort(cnt.rbegin(), cnt.rend());

        bool ok = true;

        FORN(i, k) {
            if (cnt[i] > 0) cnt[i]--;
            else ok = false;
        }

        if (ok) res++;
        else break;
    }

    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 256
from collections import deque

n=int(input())
d=deque([])
for i in range(1<<n):
    d.append(int(input()))
for i in range(n):
    for j in range(1<<(n-1-i)):
        x=d.popleft()
        y=d.popleft()
        if x!=y:
            m=abs(x-y)
        else:
            m=x
        d.append(m)
print(d[0])


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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.size();
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) != T.at(i)) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3916
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
//#define MOD 1000000007
#define MOD 100000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

ll calc(ll x,ll y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){

	int R,C,a_row,a_col,b_row,b_col;
	scanf("%d %d %d %d %d %d",&R,&C,&a_row,&a_col,&b_row,&b_col);

	int TATE,YOKO;

	bool T_double = false,Y_double = false;

	if(a_row == b_row){
		TATE = 0;
	}else{
		if(a_row > b_row){
			TATE = min(a_row-b_row,R-a_row+b_row);
			if(a_row-b_row == R-a_row+b_row)T_double = true;	//??????????????£????????????????????£???????????????????????????2?????????
		}else{
			TATE = min(b_row-a_row,R-b_row+a_row);
			if(b_row-a_row == R-b_row+a_row)T_double = true;
		}
	}

	if(a_col == b_col){
		YOKO = 0;
	}else{
		if(a_col > b_col){
			YOKO = min(a_col-b_col,C-a_col+b_col);
			if(a_col-b_col == C-a_col+b_col)Y_double = true;
		}else{
			YOKO = min(b_col-a_col,C-b_col+a_col);
			if(b_col-a_col == C-b_col+a_col)Y_double = true;
		}
	}

	ll bunshi[TATE+YOKO],bunbo[TATE+YOKO];

	//??¢???????????§????????§
	for(int i = 0; i < TATE+YOKO; i++){
		bunshi[i] = i+1;
	}

	for(int i = 0; i < TATE; i++){
		bunbo[i] = i+1;
	}
	for(int i = 0; i < YOKO; i++){
		bunbo[TATE+i] = i+1;
	}

	ll common;

	for(int i = 0; i < TATE+YOKO;i++){
		for(int k = 0; k < TATE+YOKO;k++){
			if(bunshi[i] >= bunbo[k]){
				common = calc(bunshi[i],bunbo[k]);
			}else{
				common = calc(bunbo[k],bunshi[i]);
			}
			bunshi[i] /= common;
			bunbo[k] /= common;
		}
	}

	ll ans = 1;

	for(int i = 0; i < TATE+YOKO;i++){
		ans *= bunshi[i];
		ans %= MOD;
	}

	if(T_double){
		ans *= 2;
		ans %= MOD;
	}

	if(Y_double){
		ans *= 2;
		ans %= MOD;
	}

	//if(ans < 0)ans += MOD;
	printf("%lld\n",ans);

    return 0;
}

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

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int hoge[100000000];        // 195584 KB

int main() {
  ios::sync_with_stdio(false);

  // vector<int> hoge(1e7);        // 39296 KB
  // vector<bool> hoge(1e7);        // 1536 KB KB
  // vector<int> hoge(5*1e7);        // 195584 KB
  // vector<int> hoge(6*1e7);        // 195584 KB

  hoge[999999]= 1;

  char a, b;
  cin >> a >> b;
  if(a==b) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }


  return 0;
}


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

#define MAX 300
typedef long double ld;

ld p[MAX+1][MAX+1][MAX+1];
ld dp[MAX+1][MAX+1][MAX+1];
ld dpF(int i, int j, int k) {
	if (dp[i][j][k] != -1.0) return dp[i][j][k];
	
	dp[i][j][k] = 0;
	if (i >= 1) {
		dp[i][j][k] += dpF(i-1, j, k) * ((double)i / (i+j+k));
	}
	if (j >= 1) {
		dp[i][j][k] += dpF(i+1, j-1, k) * ((double)j / (i+j+k));
	}		
	if (k >= 1) {
		dp[i][j][k] += dpF(i, j+1, k-1) * ((double)k / (i+j+k));
	}
	
	dp[i][j][k] += p[i][j][k];
	//cout << i << " " << j << " " << k << " " << ((double)i / (i+j+k)) << " " << ((double)j / (i+j+k)) << " " << ((double)k / (i+j+k)) << " " << p[i][j][k] << " " << dp[i][j][k];
	//cout << endl;
	return dp[i][j][k];
}

int main(void) {
	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
	
	vector<int> c(4, 0);
	for (int i = 0; i < n; i++) c[a[i]]++;
	
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				p[i][j][k] = n / (double)(i+j+k);
				dp[i][j][k] = -1.0;
			}
		}
	}
	
	dp[0][0][0] = 0.0;
	cout.precision(15);
	cout << dpF(c[1], c[2], c[3]) << endl;
	
	return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    int xf = 0, yf = 0;
    switch (x) {
        case 1: case 3: case 5: case 7: case 8: case 10: case 12:
            xf = 0;
            break;
        case 4: case 6: case 9: case 11:
            xf = 1;
            break;
        case 2:
            xf = 2;
            break;
    }

    
    switch (y) {
        case 1: case 3: case 5: case 7: case 8: case 10: case 12:
            yf = 0;
            break;
        case 4: case 6: case 9: case 11:
            yf = 1;
            break;
        case 2:
            yf = 2;
            break;
    }

    if (xf == yf) {
        puts("Yes");
    } else {
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Integer[] L= new Integer[N];
    for(int i = 0;i<N;i++){
      L[i]=sc.nextInt();
      }
    int r = 0,jj;
    Arrays.sort(L,Collections.reverseOrder());
    for (int i = 0;i<N-2;i++){
      for(int k = i+1;k<N-1;k++){
        int s = L[i]-L[k];
        for(int j=k+1;j<N;j++){
          	jj=(j+N)/2;
          	if(L[jj]>s){
              j=jj;
            }
			if(L[j]<=s){
              r+=j-k-1;
              break;
            }
            if(L[j]>s&&j==N-1){
              r+=N-k-1;
            }
        }
 
      }
    }
    System.out.println(r);
  }
}

Measured memory_bytes: 39832
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.NoSuchElementException;

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}

		ptr = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}

		return buflen > 0;
	}

	private int readByte() {
		return hasNextByte() ? buffer[ptr++] : -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int m = fs.nextInt();

		HashMap<Integer, HashSet<Integer>> conMap = new HashMap<Integer, HashSet<Integer>>();
		for (int i = 0; i < m; ++i) {
			int a = fs.nextInt();
			int b = fs.nextInt();
			conMap.putIfAbsent(a, new HashSet<Integer>());
			conMap.get(a).add(b);
			conMap.putIfAbsent(b, new HashSet<Integer>());
			conMap.get(b).add(a);
		}

		int[] distances = new int[n + 10];
		Arrays.fill(distances, 2, n + 1, 1 << 30);
		int[] traces = new int[n + 10];

		ArrayDeque<Integer> adjacent = new ArrayDeque<Integer>();
		adjacent.add(1);
		while (!adjacent.isEmpty()) {
			int current = adjacent.removeFirst();
			HashSet<Integer> destinations = conMap.get(current);
			for (int node : destinations) {
				if (distances[current] + 1 < distances[node]) {
					adjacent.addLast(node);
					distances[node] = distances[current] + 1;
					traces[node] = current;
				}
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		pw.println("Yes");
		for (int i = 2; i <= n; ++i) {
			pw.println(traces[i]);
		}
		pw.flush();
	}

}


Measured memory_bytes: 99984
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    ll s; cin >> s;
    ll a,b,c,d;
    a = 1e9; b = 1;
    // s = a * d - c
    d = ceil((long double)s/(double)a), c = a * d - s;
    cout << "0 0 " << a << " " << b << " " << c << " " << d << ln;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

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

	vector<tuple<ll, ll, ll>> xyps;
	ll x, y, p;
	REPD(i, 0, n){
		cin >> x >> y >> p;
		xyps.emplace_back(x, y, p);
	}

	vector<vector<ll>> min_xs(n, vector<ll>(1LL << n, MAX_VALUE));
	vector<vector<ll>> min_ys(n, vector<ll>(1LL << n, MAX_VALUE));
	ll xk, yk, pk;
	REPD(i, 0, n) {
		REPD(j, 0, 1LL << n) {
			tie(x, y, p) = xyps[i];
			min_xs[i][j] = min(min_xs[i][j], abs(x));
			min_ys[i][j] = min(min_ys[i][j], abs(y));
			REPD(k, 0, n) {
				if ((j >> k) % 2LL == 1LL) {
					tie(xk, yk, pk) = xyps[k];
					min_xs[i][j] = min(min_xs[i][j], abs(x - xk));
					min_ys[i][j] = min(min_ys[i][j], abs(y - yk));
				}
			}
		}
	}

	ll status_count = 1;
	REPD(i, 0, n) status_count *= 3LL;

	vector<ll> results(n + 1, MAX_VALUE);
	REPD(i, 0, status_count) {
		ll status = i;
		ll status_x = 0, status_y = 0, line_count = 0;
		REPD(j, 0, n) {
			status_x <<= 1LL;
			status_y <<= 1LL;
			if (status % 3LL == 1LL) {
				status_x += 1LL;
				++line_count;
			}
			if (status % 3LL == 2LL) {
				status_y += 1LL;				
				++line_count;
			}
			status /= 3LL;
		}
		ll result = 0;
		REPD(j, 0, n) {
			tie(x, y, p) = xyps[j];
			result += p * min(min_xs[j][status_x], min_ys[j][status_y]);
		}
		results[line_count] = min(results[line_count], result);
	}

	REPD(i, 0, n + 1) cout << results[i] << endl;

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 11140
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
struct edge {
	int to, cost;
};
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; ++i) {
		int L, R, D;
		cin >> L >> R >> D; --L, --R;
		G[L].push_back(edge{ R, D });
		G[R].push_back(edge{ L, -D });
	}
	vector<bool> vis(N); 
	vector<long long> pot(N);
	function<bool(int)> dfs = [&](int pos) {
		vis[pos] = true;
		for (edge e : G[pos]) {
			if (vis[e.to] && e.cost + pot[pos] != pot[e.to]) {
				return false;
			}
			if (!vis[e.to]) {
				pot[e.to] = pot[pos] + e.cost;
				bool res = dfs(e.to);
				if (!res) return false;
			}
		}
		return true;
	};
	bool ans = true;
	for (int i = 0; i < N; ++i) {
		if (!vis[i]) {
			ans = ans && dfs(i);
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 13312
package main

import "fmt"

func main(){
var s1,s2,s3 string
  fmt.Scanf("%s",&s1)
  fmt.Scanf("%s",&s2)
  fmt.Scanf("%s",&s3)
  
  s:=fmt.Sprintf("%s%s%s",string([]rune(s1)[0]),string([]rune(s2)[1]),string([]rune(s3)[2]))
  fmt.Println(s)
}

Measured memory_bytes: 512
N, D = list(map(int,input().split()))
d = list(map(int,input().split()))
Q = int(input())
q = list(map(int,input().split()))

a = [D for i in range(N)]
b = [1 for i in range(N+1)]
for i in range(1,N):
	a[i] = min(abs(a[i-1]-d[i-1]),a[i-1])
for i in range(N)[::-1]:
	if d[i]//2 < b[i+1]:
		b[i] = b[i+1] + d[i]
	else:
		b[i] = b[i+1]

res = ""
for i in q:
	if a[i-1] < b[i]:
		res+="NO"
	else:
		res+="YES"
	res+="\n"

print(res)







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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

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

// template<class T> void chmax(T& a, T b) {
//     if (a < b) {
//         a = b;
//     }
// }

int main(void) {
    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    for(int in=0;in<n;in++) {
        cin >> h.at(in);
    }

    sort(h.begin(), h.end());

    int ans=1e9+5;
    for(int in=k-1;in<n;in++) {
        ans=min(ans, h.at(in)-h.at(in-k+1));
    }

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


Measured memory_bytes: 640
#include<stdio.h>
int main() {
	char S[5];
	int a = 0;
	scanf("%s", S);
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') {
			a++;
		}
		else {
			a--;
		}
	}
	printf("%d\n", a);
}

Measured memory_bytes: 128
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

struct Data{

  int h1,h2;
  int m1,m2;

};

int main(){

  int class_num;
  int student_num;
  int teacher_num;
  Data list[100];
  Data student[100][100];
  int student_num2[100];
  Data teacher[100][100];
  int teacher_num2[100];
  char dum;
  
  cin >>class_num;
  
  for(int i=0 ; i < class_num ; i++){
    cin >>list[i].h1>>dum>>list[i].m1>>dum>>list[i].h2>>dum>>list[i].m2;
  }
  
  cin >>teacher_num;
  
  for(int i=0 ; i < teacher_num ; i++){
    cin >>teacher_num2[i];
    for(int j=0 ; j < teacher_num2[i] ; j++){
      cin >>teacher[i][j].h1>>dum>>teacher[i][j].m1>>dum>>teacher[i][j].h2>>dum>>teacher[i][j].m2;
    }
  }
  
  cin >>student_num;
  
  for(int i=0 ; i < student_num ; i++){
    cin >>student_num2[i];
    for(int j=0 ; j < student_num2[i] ; j++){
      cin >>student[i][j].h1>>dum>>student[i][j].m1>>dum>>student[i][j].h2>>dum>>student[i][j].m2;
    }
  }

  int candt[100],cands[100];

  for(int i=0 ; i < class_num ; i++){
    candt[i]=0;
    cands[i]=0;
  }

  for(int i=0 ; i < student_num ; i++){
    for(int j=0 ; j < student_num2[i] ; j++){
      for(int k=0 ; k < class_num ; k++){
	if(((list[k].h1 > student[i][j].h1) ||
	    (list[k].h1 == student[i][j].h1 && list[k].m1 >= student[i][j].m1))&&((list[k].h2 < student[i][j].h2) || (list[k].h2 == student[i][j].h2 && list[k].m2 <= student[i][j].m2))){
	  cands[k]++;
	}
      }
    }
  }
  
  for(int i=0 ; i < teacher_num ; i++){
    for(int j=0 ; j < teacher_num2[i] ; j++){
      for(int k=0 ; k < class_num ; k++){
	if(((list[k].h1 > teacher[i][j].h1) ||
	    (list[k].h1 == teacher[i][j].h1 && list[k].m1 >= teacher[i][j].m1))&&((list[k].h2 < teacher[i][j].h2) || (list[k].h2 == teacher[i][j].h2 && list[k].m2 <= teacher[i][j].m2))){
	  candt[k]++;
	}
      }
    }
  }
  
  int ans=0;

  
  
  for(int i=0 ; i < class_num ; i++){
    //cout <<cands[i]<<" "<<candt[i]<<endl;
    ans+=min(cands[i],candt[i]);
  }

  cout <<ans<<endl;

  return 0;
  
}

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

int main() {
  int N, K, count = 0;
  cin >> N >> K;
  vector<vector<bool>> A(K, vector<bool>(N, false));
  for (int i = 0; i < K; i++){
    int d;
    cin >> d;
    for (int j = 0; j < d; j++){
      int has;
      cin >> has;
      A.at(i).at(has - 1) = true;
    }
  }
  for (int i = 0; i < N; i++){
    int anything = true;
    for (int j = 0; j < K; j++){
      anything *= !A.at(j).at(i);
    }
    if (anything == true){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3592