akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let dp = vec![vec![0; 51]; 51];
    let ss = read_line();
    let ts =   ["KIHBR",
                "KIHBRA",
                "KIHBAR",
                "KIHBARA",
                "KIHABR",
                "KIHABRA",
                "KIHABAR",
                "KIHABARA",
                "AKIHBR",
                "AKIHBRA",
                "AKIHBAR",
                "AKIHBARA",
                "AKIHABR",
                "AKIHABRA",
                "AKIHABAR",
                "AKIHABARA",
                ];
    for &t in &ts {
        if t == ss {
            println!("YES");
            return;
        }
    }
    println!("NO");
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
class Dice

  attr_accessor :dice, :ptn

  @_ptn_list = []

  def initialize(_input_square)
    @dice = _input_square
    @ptn = []
  end

  def ptn_save
    ptn << dice.join.to_i
  end

  def ptn_join
    @ptn = ptn.sort.join.to_i
  end

  def roll(str, num = 1, save = false)
    num.times do
      case str
      when "n"
        dice[0], dice[1], dice[4], dice[5] = dice[1], dice[5], dice[0], dice[4]
      when "s"
        dice[0], dice[1], dice[4], dice[5] = dice[4], dice[0], dice[5], dice[1]
      when "w"
        dice[0], dice[2], dice[3], dice[5] = dice[2], dice[5], dice[0], dice[3]
      when "e"
        dice[0], dice[2], dice[3], dice[5] = dice[3], dice[0], dice[5], dice[2]
      end
      ptn << dice.join.to_i if save
    end
  end

  def self.ptn_list
    @_ptn_list
  end

  def self.add_list(_list)
    @_ptn_list << _list
  end

  def self.cmp_dice(_dice_a, _dice_b)
    if _dice_a == _dice_b
      puts "No"
      exit
    end
  end

  def self.f_check
    puts @_ptn_list.size == @_ptn_list.uniq.size ? "Yes" : "No"
  end
end

_n = gets(chomp:true).to_i
_dice_a = Dice.new(gets.split.map(&:to_i))

4.times do
  _dice_a.roll("w", 4, true)
  _dice_a.roll("n", 1)
end
_dice_a.roll("e", 1)
_dice_a.roll("n", 1)
_dice_a.roll("w", 4, true)
_dice_a.roll("s", 2)
_dice_a.roll("w", 4, true)
_dice_a.ptn_join
Dice.add_list(_dice_a.ptn)


(_n - 1).times do
  _dice_b = Dice.new(gets.split.map(&:to_i))

  4.times do
    _dice_b.roll("w", 4, true)
    _dice_b.roll("n", 1)
  end

  _dice_b.roll("e", 1)
  _dice_b.roll("n", 1)
  _dice_b.roll("w", 4, true)
  _dice_b.roll("s", 2)
  _dice_b.roll("w", 4, true)
  _dice_b.ptn_join
  Dice.add_list(_dice_b.ptn)

  Dice.cmp_dice(_dice_a.ptn, _dice_b.ptn)

  _dice_a = _dice_b
end

Dice.f_check


Measured memory_bytes: 6972
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


S, T = input(), input()

m = {}
ok = True
for s, t in zip(S, T):
    if s in m and m[s] != t:
        ok = False
        break
    m[s] = t
print('Yes' if ok and len(m.values()) == len(set(m.values())) else 'No')


Measured memory_bytes: 41968
#include<iostream>;
using namespace std;
int main(){
    int n,m,l;
    long long A[100][100],B[100][100],C[100][100];
    cin>>n>>m>>l;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>B[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            C[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j>0) cout<<" "<<C[i][j];
            else{
                cout<<C[i][j];
            }
        }cout<<endl;
    }return 0;
}



Measured memory_bytes: 3312
#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 <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int n;
    int a[110][110];
    cin >> n;
    rep(i,1,n+1) rep(j,1,n+1) {
        cin >> a[i][j];
        if(i != 0 && j != 0) a[i][j] += (a[i-1][j] + a[i][j-1] - a[i-1][j-1]);
        else if(i == 0 && j != 0) a[i][j] += a[i][j-1];
        else if(i != 0 && j == 0) a[i][j] += a[i-1][j];
    }

    int ans = -INF;
    rep(i,0,n) rep(j,0,n) rep(k,i+1,n+1) rep(l,j+1,n+1) {
        ans = max(ans, a[k][l] - a[k][j] - a[i][l] + a[i][j]);
    }

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

Measured memory_bytes: 1208
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

first = T[0]
count = 0
res = 0
for i in range(N):
    if count < C and T[i] <= first + K:
        count += 1
    else:
        res += 1
        first = T[i]
        count = 1
print(res + 1)


Measured memory_bytes: 7384
def gost(lis,ky,r,l):
    
    lens=l-r+1
    
    if lens <= 5:
        if ky in lis[r:l+1]:
            return True
        else:
            return False
    
    if ky <= lis[r+(lens//2)-1]:
        return gost(lis,ky,r,r+(lens//2)-1)
    else:
        return gost(lis,ky,r+(lens//2),l)
    

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

q = int(input())
a = input()
t=list(map(int,a.split()))


i = 0
for it in t:
    if gost(s,it,0,n-1):
        i = i+1
print(i)

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

/* constant */

#define MAX_INT	((long)(1 << 30))
#define MAX_N	(5)
#define MAX_BITS	((long)(1 << (MAX_N * MAX_N)))

/* global variables */

static int n;
static unsigned char dists[MAX_BITS];
static long masks[MAX_N][MAX_N][MAX_N][MAX_N];

/* subroutines */

long make_mask(int x0, int x1, int y0, int y1) {
  int y;
  long bits, hbits;

  hbits = ((1 << (x1 - x0 + 1)) - 1) << x0;
  bits = 0;

  for (y = y0; y <= y1; y++)
    bits |= (hbits << (y * n));

  return bits;
}

int min_dist(long bits) {
  int d, id, md, x0, x1, y0, y1;
  long bits0;

  if (dists[bits] < 255) return dists[bits];

  for (id = 0; ((bits >> id) & 1) == 0; id++);

  x0 = id % n;
  y0 = id / n;
  md = MAX_INT;

  for (y1 = n - 1; y1 >= y0; y1--)
    for (x1 = n - 1; x1 >= x0; x1--) {
      bits0 = bits ^ masks[x0][x1][y0][y1];
      d = min_dist(bits0) + 1;
      if (md > d) md = d;
    }

  return (dists[bits] = md);
}

/* main */

int main(int argc, char **argv) {
  int d, i, md, x, x0, x1, y, y0, y1;
  long st;

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    st = 0;

    for (y = 0; y < n; y++)
      for (x = 0; x < n; x++) {
	scanf("%d", &d);
	if (d)
	  st |= (1 << (x + y * n));
      }

    memset(masks, 0, sizeof(masks));

    for (x0 = 0; x0 < n; x0++)
      for (x1 = x0; x1 < n; x1++)
	for (y0 = 0; y0 < n; y0++)
	  for (y1 = y0; y1 < n; y1++)
	    masks[x0][x1][y0][y1] = make_mask(x0, x1, y0, y1);

    memset(dists, 255, sizeof(dists));
    dists[0] = 0;

    md = min_dist(st);

    for (i = 0; i < md; i++) printf("myon");
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 33368
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	vector<vector<long long int>>dis(N, vector<long long int>(N, MOD*MOD));
	for (int i = 0; i < N; i++)dis[i][i] = 0;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> H;
		L--;
		R--;
		dis[L][R] = H;
		dis[R][L] = H;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	vector<vector<int>>step(N, vector<int>(N, MOD));
	for (int i = 0; i < N; i++) {
		queue<int>Q;
		step[i][i] = -1;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (int j = 0; j < N; j++) {
				if (dis[cn][j] <= K && step[i][j] > step[i][cn] + 1) {
					step[i][j] = step[i][cn] + 1;
					Q.push(j);
				}
			}
		}
	}
	cin >> M;
	while (M--) {
		cin >> L >> R;
		L--;
		R--;
		if (step[L][R] == MOD)step[L][R] = -1;
		cout << step[L][R] << endl;
	}
}

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

using namespace std;

int64_t solve(int64_t x) {
  if (x <= 6) {
    return 1;
  }
  if (x <= 11) {
    return 2;
  }
  int64_t ret = (x + 10) / 11 * 2;
  if (x % 11 && x % 11 <= 6) {
    ret--;
  }
  return ret;
}

int main() {
  int64_t x;
  std::cin >> x;
  std::cout << solve(x) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

// dp[i][0]:上位i桁まで一致　dp[i][1]:Kより小さいことが確定
ll dp[61][2];

int main(){
  int N; cin>>N;
  ll K; cin>>K;
  ll A[N]; rep(i,N) cin>>A[i];
  rep(i,61) dp[i][0]=dp[i][1]=-1;
  dp[60][0]=0;
  for(int i=59;i>=0;i--){
    ll mask=1LL<<i;
    int cnt=0;
    rep(j,N) if(A[j]&mask) cnt++;
    if(dp[i+1][1]>=0) dp[i][1]=dp[i+1][1]+mask*max(cnt,N-cnt);
    if(K&mask){
      dp[i][0]=dp[i+1][0]+mask*(N-cnt);
      dp[i][1]=max(dp[i][1],dp[i+1][0]+mask*cnt);
    }else{
      dp[i][0]=dp[i+1][0]+mask*cnt;
    }
  }
  cout<<max(dp[0][0],dp[0][1])<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int f[110][100];
ll p[110][100];

int main() {
	cin >> n;
	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	ll ans = -INF;
	FOR(i, 1, (1 << 10)) {
		ll sum = 0;
		rep(j, n) {
			ll cnt = 0;
			rep(k, 10) {
				if (i&(1 << k) && f[j][k])cnt++;
			}
			sum += p[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << a+b+c+(pow(2,k)-1)*max(a, max(b, c)) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    int sum = 0;

    for (int i = 0; i < N; ++i) {
        int Ai;
        cin >> Ai;
        A.at(i) = Ai;
        sum += Ai;
    }

    int count = 0;

    for (int Ai: A) {
        if (Ai * 4 * M >= sum) {
            count++;
        }
    }

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

    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

int main(){
  int h,a;
  cin >> h >> a;
  cout << (h+a-1)/a << endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        struct Point
        {
            internal double x, y;
        }

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double[] nums = Array.ConvertAll(input.Split(' '), double.Parse);

                Point a, b, c, p;
                a.x = nums[0]; a.y = nums[1];
                b.x = nums[2]; b.y = nums[3];
                c.x = nums[4]; c.y = nums[5];
                p.x = nums[6]; p.y = nums[7];

                sb.AppendLine(IsContain(a, b, c, p) ? "YES" : "NO");
            }
            Console.Write(sb);
        }

        static bool IsContain(Point a, Point b, Point c, Point p)
        {
            Point ab = Sub(b, a), bp = Sub(p, b);
            Point bc = Sub(c, b), cp = Sub(p, c);
            Point ca = Sub(a, c), ap = Sub(p, a);

            double c1 = Cross(ab, bp);
            double c2 = Cross(bc, cp);
            double c3 = Cross(ca, ap);

            if (c1 > 0 && c2 > 0 && c3 > 0) return true;
            if (c1 < 0 && c2 < 0 && c3 < 0) return true;

            return false;
        }

        static Point Sub(Point a, Point b)
        {
            Point ret;
            ret.x = a.x - b.x;
            ret.y = a.y - b.y;
            return ret;
        }

        static double Cross(Point a, Point b)
        {
            return a.x * b.y - a.y * b.x;
        }
    }
}

Measured memory_bytes: 9264
#include <iostream>
#include <vector>

using namespace std;
using vi = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

const int INF = 1e9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(N);
  vi H(N);
  REP(i, N)
    cin >> H[i];

  int dp[N+2]; // dp[i] = 足場iに至るまでの最小コスト
  REP(i, N+2)
    dp[i] = INF;
  dp[0] = 0;

  REP(i, N) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(H[i] - H[i+1]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(H[i] - H[i+2]));
  }
  OUT(dp[N-1]);

  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i<n; i++){
            arr[i] = in.nextInt();
        }
        Arrays.sort(arr);
        int sum = 0;
        for(int i = 0; i<n-1; i++){
            sum+=arr[i];
        }
        out.println(arr[n-1]>=sum?"No":"Yes");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 33008
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer u;
  u=nil->next;
  while(u!=nil){
    if(u->key==key) return u;
    u=u->next;
  }
  return u;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 36120
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    //cout << fixed << setprecision(15);

    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int sum = 0;
    if (A < 0)
    {
        sum += abs(A) * C + D;
        sum += E * B;
    }
    else if (A == 0)
    {
        sum += D;
        sum += E * B;
    }
    else
    {
        sum += (B - A) * E;
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

LL calc(VLL points, LL p) {
	LL ans = 0;
	rep(it, points.begin(), points.end()) {
		ans += ((*it - p)*(*it - p));
	}
	return ans;
}

int main() {
	sll(n);
	VLL points;
	LL sum = 0;
	rep(i, 0, n) {
		sll(num);
		points.push_back(num);
		sum += num;
	}
	LL lo = sum / n, loval = calc(points, lo);
	LL hi = lo + 1, hival = calc(points, hi);
	pll(min(loval, hival)); nl;
} 

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
q1 = q2 = q3 = 0
for i in P:
	if i <= A:
		q1 += 1
	elif i <= B:
		q2 += 1
	else:
		q3 += 1
print(min(q1, q2, q3))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long[] nm = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nm[0];
            long m = nm[1];
            var ls = new List<hoge>();
            for (long i = 0; i < m; i++)
            {
                long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
                long p = s[0];
                long y = s[1];
                ls.Add(new hoge() { id = p, year = y, index = i });
            }
            ls = ls.OrderBy(x => x.id).ThenBy(y => y.year).ToList();

            var ans = new SortedDictionary<long,string>();
            long cnt = 1;long rem = ls[0].id; 
            for (int i = 0; i < m; i++)
            {
                long p = ls[i].id;
                long index = ls[i].index;
                if (rem != p) { cnt = 1; rem = p; }
                ans.Add(index,string.Format("{0:000000}{1:000000}",p,cnt));
                cnt++;
            }
            foreach (var item in ans)
            {
                WriteLine(item.Value);
            }
        }
    }

    class hoge
    {
        public long id { get; set; }
        public long year { get; set; }
        public long index { get; set; }
    }
}


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

using namespace std;
using ll = long long;

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

int dp[1005][10005];
const int INF = 1001001001;

int main() {
  int h, n;
  cin >> h >> n;
  int a[n], b[n];
  rep(i, n) cin >> a[i] >> b[i];

  rep(i, 1005) rep(j, 10005) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, n) rep(j, h + 1) {
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    int nj = min(j + a[i], h);
    dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + b[i]);
    dp[i][nj] = min(dp[i][nj], dp[i][j] + b[i]);
  }

  cout << dp[n][h] << endl;
  return 0;
}


Measured memory_bytes: 42896
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int[] a1 = {1,3,5,7,8,10,12};
        int[] b1 = {4,6,9,11};
        int[] c1 ={2};
        int cnt1=0;
        int cnt2=0;
        int cnt3=0;

        for(int i = 0;i<a1.length;i++){
            if(x==a1[i]){
                cnt1++;
            }
            if(y==a1[i]){
                cnt1++;
            }
        }

        for(int i = 0;i<b1.length;i++){
            if(x==b1[i]){
                cnt2++;
            }
            if(y==b1[i]){
                cnt2++;
            }
        }

        for(int i = 0;i<c1.length;i++){
            if(x==c1[i]){
                cnt3++;
            }
            if(y==c1[i]){
                cnt3++;
            }
        }


        if(cnt1==2 ||cnt2==2||cnt3==2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 23764
import sys

a,b,c,d=map(int,input().split())
count=0

if a>=b:
  if a-b<=d:
    count+=1
elif a<b:
  if b-a<=d:
    count+=1
    
if b>=c:
  if b-c<=d:
    count+=1
elif b<c:
  if c-b<=d:
    count+=1
    
if a>=c:
  if a-c<=d:
    print("Yes")
    sys.exit()
elif a<c:
  if c-a<=d:
    print("Yes")
    sys.exit()
    
print("Yes"if count>=2 else "No")

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (a,b,c) = (0 until 3).map { sc.nextInt() }
    val res = a + b + c
    when {
        res < 22 -> {
            println("win")
        }
        else -> {
            println("bust")
        }
    }
}

Measured memory_bytes: 31384
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    void solve() {
        int n = scanner.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            int p = scanner.nextInt();
            if (p != i + 1) {
                count++;
            }
        }
        out.println(count == 2 || count == 0 ? "YES" : "NO");
    }

    public static void main(String[]$) {
        new Main().solve();
        out.close();
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

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

int main () {
  int N;
  cin >> N;
  
  if (N == 1) {
    cout << "Hello World" << endl;
  }
  
  else {
    int A, B;
    cin >> A; 
    cin >> B;
    
    cout << A + B << endl;
  }
}

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

const int N = 1e5 + 5;

int n, k, dp[N];
set<int> s;
vector<int> rem;

int mex(set<int> &s) {
  for(int i = 0; i <= k; i++) if(!s.count(i)) return i;
  return -1;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  rem.resize(n);
  for(int i = 0; i < n; i++) cin >> rem[i];

  for(int i = 1; i <= k; i++) {
    s.clear();
    for(auto x : rem) if(i - x >= 0) s.insert(dp[i-x]);
    dp[i] = mex(s);
  }

  cout << (dp[k] ? "First\n" : "Second\n");
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int main(){
    int h,w,k;
    scanf("%d%d%d",&h,&w,&k);
    char a[h][w];
    int sx, sy;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            scanf(" %c",&a[i][j]);
            if (a[i][j] == 'S'){
                sx = i, sy = j;
            }
        }
    }
    queue<ii> q;
    int dist[h][w];
    memset(dist,-1,sizeof(dist));
    q.push(ii(sx,sy));
    dist[sx][sy] = 0;
    int ans = h*w;
    while (q.size()){
        ii cur = q.front(); q.pop();
        int x = cur.first, y = cur.second;
        ans = min(ans,min(min(x,h-x-1),min(y,w-y-1)));
        if (dist[x][y] == k) continue;
        for (int k = 0; k < 4; k++){
            int nx = x+dx[k], ny = y+dy[k];
            if (nx >= 0 && nx < h && ny >=0 && ny < w && a[nx][ny] == '.' && dist[nx][ny] == -1){
                dist[nx][ny] = dist[x][y]+1;
                q.push(ii(nx,ny));
            }
        }
    }
    //printf("%d ",ans);
    printf("%d",1+(ans-1)/k+(ans!=0));
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(V) V.begin(),V.end()
#define Mod 1e9+7

using namespace std;

int main()
{
    ll i,j,k,l,m,n,q;
    cin >> n;
    string S;
    vector<ll> Score(n);
    vector<pair<string,ll> >Re(n);

    for(i=0;i<n;i++)
    {
        cin >> S;
        cin >> Score[i];

        Re[i].F = S;
        Re[i].S = i;
    }
    sort(all(Re));

    vector<pair<ll, ll > > Temp;
    for(i=0;i<n-1;i++)
    {
        if(Re[i].F != Re[i+1].F)
        {
            cout << Re[i].S + 1 << endl;
        }
        else
        {

            for(j=i;j<n;j++)
            {
                if(Re[i].F!=Re[j].F)
                    break;
                Temp.pb(make_pair(Score[Re[j].S],Re[j].S));
            }
            sort(all(Temp));

            for(k=Temp.size()-1;k>=0;k--)
            {
                cout << Temp[k].S +1 << endl;
            }
            Temp.clear();
            i = j-1;
        }

    }
    if(n>1)
        if(Re[n-1].F!=Re[n-2].F)
            cout << Re[n-1].S +1<< endl;
    if(n==1)
        cout << 1 << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  long wcnt=0, ret=0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='W'){
      ret += i-wcnt;
      wcnt++;
    }
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int A[1<<20],N, K;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 cin>>N>>K;
 rep(i,N) cin>>A[i+1];

 for(int i = K+1;i <= N;i++) {
   cout << (A[i] > A[i-K] ? "Yes" : "No") << endl;
 }













 return 0;
}


Measured memory_bytes: 4420
N = int(input())
S = list(map(int, input().split()))
flag = 0

for i in range(N):
    if S[i] % 2 == 0:
        if S[i] % 3 != 0 and S[i] % 5 != 0:
            flag += 1
            break

if flag != 0:
    print('DENIED')
else:
    print("APPROVED")


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

using ll = long long;
using ii = pair<int, int>;
const int N = 3000;

int Gold[50], GoldTime[50];

using triple_t = tuple<int, int, int>; // <v, cost, time>
vector<triple_t> g[50];

ll dist[50][N];

void dij(int u, int s) {
    memset(dist, 0x3f, sizeof(dist));
    using something_t = tuple<ll, int, int>;
    priority_queue<something_t, vector<something_t>, greater<something_t>> pq;
    pq.emplace(0, u, s);
    dist[u][s] = 0;

    auto relax = [&](int u, int su, int v, int sv, int time) {
        if (dist[v][sv] > dist[u][su] + time) {
            dist[v][sv] = dist[u][su] + time;
            pq.emplace(dist[v][sv], v, sv);
        }
    };

    ll d;
    while (!pq.empty()) {
        tie(d, u, s) = pq.top(); pq.pop();

        if (d > dist[u][s]) continue;

        for (auto [v, cost, time]: g[u]) {
            if (cost <= s)
                relax(u, s, v, s - cost, time);
        }

        if (s + Gold[u] < N)
            relax(u, s, u, s + Gold[u], GoldTime[u]);
    }
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, m, s;
    cin >> n >> m >> s;

    s = min(s, N-1);

    for (int i = 0; i < m; i++) {
        int u, v, cost, time;
        cin >> u >> v >> cost >> time;
        --u, --v;
        g[u].emplace_back(v, cost, time);
        g[v].emplace_back(u, cost, time);
    }

    for (int i = 0; i < n; i++) {
        cin >> Gold[i] >> GoldTime[i];
    }

    dij(0, s);

    for (int t = 1; t < n; t++) {
        ll ans = numeric_limits<ll>::max();
        for (int g = 0; g < N; g++)
            ans = min(ans, dist[t][g]);

        cout << ans << endl;
    }

    return 0;
%>

Measured memory_bytes: 6436
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()
arg = list(map(int, input().split())) # 1行, 配列

for index,i in enumerate(arg):

  if i == 0:
    print(1+index)


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

int main() {
	int N, T;
	cin >> N >> T;
	int c[110], t[110];
	int i;
	for(i=0; i<N; ++i) cin >> c[i] >>t[i];
	int cmin=0;
	for(i=1; i<N; ++i) if(t[i]<=T && c[i]<c[cmin]) cmin=i;
	if(cmin==0 && t[cmin]>T) cout << "TLE" << endl;
	else cout << c[cmin] <<endl;
	return 0;
}

Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).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;}

ll N;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    solve();
}

// N は整数
// 1 <= N <= 1000000000000001

// ll N
// ロジャーの問題に対する答えを、英小文字のみからなる文字列として出力せよ。
void solve(){
    N--;
    ll digit=1;
    ll base=26;
    while(N>=base){
        N-=base;
        base*=26;
        digit++;
    }
    
    string ans;
    rep(i,digit){
        ans+=(char)('a'+N%26);
        N/=26;
    }
    reverse(all(ans));
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1234567891234567891;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	long long score = -inf; vector<int> v;
	for (int i = 0; i <= 1; ++i) {
		vector<long long> dp(N, -inf);
		for (int j = i; j < N; j += 2) {
			dp[j] = A[j];
			for (int k = j - 2; k >= 0; k -= 2) {
				dp[j] = max(dp[j], dp[k] + A[j]);
			}
		}
		vector<int> path;
		int ptr = N;
		while (true) {
			ptr = max_element(dp.begin(), dp.begin() + ptr) - dp.begin();
			path.push_back(ptr);
			if (dp[ptr] == A[ptr]) break;
		}
		if (score < *max_element(dp.begin(), dp.end())) {
			score = *max_element(dp.begin(), dp.end());
			reverse(path.begin(), path.end());
			v = path;
		}
	}
	vector<int> ops;
	for (int i = N - 1; i > v.back(); --i) {
		ops.push_back(i);
	}
	for (int i = int(v.size()) - 2; i >= 0; --i) {
		for (int j = v[i] + 2; j < v[i + 1]; j += 2) {
			ops.push_back(v[i] + 2);
		}
		ops.push_back(v[i] + 1);
	}
	for (int i = 0; i < v.front(); ++i) {
		ops.push_back(0);
	}
	cout << score << endl;
	cout << ops.size() << endl;
	for (int i : ops) {
		cout << i + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h1,m1,h2,m2,k;
int main() {
    scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k),m1+=h1*60,m2+=h2*60,
            printf("%d\n",max(m2-m1-k,0)),exit(0);
}

Measured memory_bytes: 3824
#include <iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
using namespace std;
int x[1100];
int main()
{
    int n; int m;
    cin >> n >> m;
    if (n < m) {
        swap(n, m);
   }
    int amari = n % m;
    while (amari != 0) {
        n = m;
        m = amari;
        amari = n % m;
    }
    cout << m << endl;
}


Measured memory_bytes: 3092
#include<cstring>
#include<cstdio>
#include<cctype>
#include<algorithm>
#define ll long long
#define INF 100000000
#define clr(x) memset(x,0,sizeof(x))
using namespace std;

inline int read()
{
	register int ret=0,c=getchar();
	while(!isdigit(c))c=getchar();
	while(isdigit(c))ret=ret*10+c-'0',c=getchar();
	return ret;
}

#define M 2005

int a[M][M],a1[M][M],a2[M][M],a3[M][M];
int n,m,q;

int main()
{
#ifdef anantheparty
	freopen("in.txt","r",stdin);
#endif
	n=read(),m=read(),q=read();
	for(int i=1;i<=n;i++,getchar())
		for(int j=1;j<=m;j++)a[i][j]=getchar()-'0';
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			a1[i][j]=a[i][j]+a1[i-1][j]+a1[i][j-1]-a1[i-1][j-1];
			if(a[i][j])a2[i][j]=a[i-1][j],a3[i][j]=a[i][j-1];
			a2[i][j]+=a2[i-1][j]+a2[i][j-1]-a2[i-1][j-1];
			a3[i][j]+=a3[i-1][j]+a3[i][j-1]-a3[i-1][j-1];
		}
	for(int i=1;i<=q;i++)
	{
		int x1=read(),y1=read(),x3=read(),y3=read();
		int ans=a1[x3][y3]-a1[x1-1][y3]-a1[x3][y1-1]+a1[x1-1][y1-1];
		ans-=a3[x3][y3]-a3[x1-1][y3]-a3[x3][y1]+a3[x1-1][y1];
		ans-=a2[x3][y3]-a2[x1][y3]-a2[x3][y1-1]+a2[x1][y1-1];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 64512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//整数値の入力
char s[100];
cin >> s;

int k;
cin >> k;
char ans='1';
int num1=0;

for(int i=0;i<strlen( s );++i){
    if(s[i]!='1'){ans=s[i];break;}
    num1++;
}

if(num1>k-1){ans='1';}
//回答
cout << ans << endl;
return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a, b, c, d;

  int f=0;

  scanf("%d %d %d %d", &a, &b, &c, &d);

  while(1){
	c = c-b;
	if(c<=0){
	  f=1;
	  break;
	}

	a = a-d;
	if(a<=0){
	  break;
	}

  }

  if(f==0){
	printf("No\n");
  }else{
	printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 1644
#C
N = int(input())
pairdic = {}
s = ''.join(sorted(input()))
pairdic[s] = 1
for i in range(1, N):
    s = ''.join(sorted(input()))
    if s in pairdic:
        pairdic[s] += 1        
    else:
        pairdic[s] = 1
result = 0
for i in pairdic:
    result += (pairdic[i] * (pairdic[i]-1))//2
print(result)

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


using namespace std;

typedef long long ll;

const int MAXN = 2000 + 123, MXLN = 15;






ll n, x, a[MAXN], lst[MAXN], ans = LLONG_MAX;


int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i], lst[i] = a[i];
	for (int k = 0; k < n; k++) {
		ll jav = 0;
		for (int i = 0; i < n; i++)
			jav += lst[i] = min(lst[i], a[((i - k) + n) % n]);
		ans = min(ans, jav + k * x);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
S=input()
K=int(input())
LS=len(S)

if LS==1:
    if K==1:
        print(0)
        exit()
    else:
        print(K//2)
        exit()

cnt=1
ans1=0
c=[]
for i in range(1,LS-1):
    if S[i-1]==S[i]:
        cnt+=1
    elif cnt!=1:
        ans1+=cnt//2
        c.append(cnt)
        cnt=1

if K==1:
    if S[-2]==S[-1]:
        cnt+=1
        ans1+=cnt//2
        print(ans1)
        exit()

if S[-2] == S[-1]:
    cnt += 1
    c.append(cnt)
    if cnt % 2 == 0:
        if ans1 != 0:
            ans1 += cnt // 2
            ans1 = ans1 * K
        else:
            ans1 = (cnt // 2) * K
    elif cnt % 2 == 1 and S[0] == S[-1]:
        if ans1 != 0:
            if c[0] % 2 == 0:
                ans1 += cnt // 2
                ans1 = ans1 * K
            else:
                ans1 += cnt // 2 + 1
                ans1 = ans1 * K - 1
        else:
            if ans1!=0:
                ans1 = (cnt // 2) * K + K - 1
            else:
                ans1=(cnt*K)//2
    elif cnt % 2 == 1 and S[0] != S[-1]:
        ans1 += cnt // 2
        ans1 = ans1 * K
else:
    ans1 += cnt // 2

    if S[0] == S[-1]:
        if ans1!=0 and c[0]%2==0:
            ans1=ans1*K
        else:
            ans1 = ans1*K+K - 1
    else:
        ans1 = ans1 * K


print(ans1)







Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, m;
    cin>>n>>m;
    if(m == n) cout<<"Yes";
    else cout<<"No";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

bool can_make(const vector<int>& A, int i, int m){
    if (m == 0) return true;
    if (m < 0 || i >= A.size()) return false;
    return can_make(A, i + 1, m) || can_make(A, i + 1, m - A[i]);
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto& a : A) cin >> a;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        cout << (can_make(A, 0, m) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 100010

ll dp[M][2];
ll n;
vll g[M];
ll dfs(ll u,ll par,ll col){
	if(dp[u][col]!=-1) return dp[u][col];
	ll ans=1;
	for(auto v:g[u]){
		if(v==par)continue;
		if(col) ans=(ans*(dfs(v,u,0)+dfs(v,u,1)))%md;
		else ans=(ans*dfs(v,u,1))%md;
	}
	return dp[u][col]=ans;
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>n;
	rep(i,0,n-1){
		ll u,v;cin>>u>>v;u--,v--;
		g[u].pb(v);g[v].pb(u);
	}
	ll ans = dfs(0,-1,0)+dfs(0,-1,1);
	ans %=md;
	cout<<ans;

	return 0;
}

Measured memory_bytes: 14208
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,j=0;
  int a[3];
  cin>>n;
  while(j!=n){
    for(int i=0;i<3;i++){
      cin>>a[i];
    }
    sort(a,a+3);
    if(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
    j++;
  }
  return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a,b;
	cin>>a>>b;
	int mx = 1009;
	int res = 1;
	for (; res <= mx; ++res){
		if (int(res*0.08) == a && int(res*0.1) == b){
			break;
		}
	}
	cout<<(res > mx ? -1 : res)<<endl;
}


Measured memory_bytes: 256