akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
        }

        enum Status
        {
            NotVisited,
            Visited,
        }

        char[][] graph;
        int[,] shortestPath;


        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int h = tmp[0];
            int w = tmp[1];
            graph = new char[h][];
            for (int i = 0; i < h; i++)
            {
                graph[i] = Console.ReadLine().ToCharArray();
            }
            int totalWhite = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < graph[i].Length; j++)
                {
                    if (graph[i][j] == '.')
                        totalWhite++;
                }
            }

            shortestPath = new int[h, w];

            var queue = new Queue<Pos>();
            queue.Enqueue(new Pos(0, 0));
            shortestPath[0, 0] = 1;
            while (queue.Count != 0)
            {
                var current = queue.Dequeue();

                var nextTiles = new Pos[]
                {
                    new Pos(current.X-1,current.Y),
                    new Pos(current.X+1,current.Y),
                    new Pos(current.X,current.Y-1),
                    new Pos(current.X,current.Y+1),
                };
                foreach (var tile in nextTiles)
                {
                    if (CanMove(tile))
                    {
                        if (shortestPath[tile.Y, tile.X] == 0)//通っていないとき
                        {
                            shortestPath[tile.Y, tile.X] = shortestPath[current.Y, current.X] + 1;
                            queue.Enqueue(tile);
                        }
                    }
                }
            }
            int ans = shortestPath[h - 1, w - 1] == 0 ? -1 : totalWhite - shortestPath[h - 1, w - 1];
            Console.WriteLine(ans);

        }

        bool CanMove(Pos pos)
        {
            if (pos.X < 0 || pos.Y < 0 || pos.X >= graph[0].Length || pos.Y >= graph.Length)
                return false;
            if (graph[pos.Y][pos.X] != '.')
                return false;

            return true;
        }

        class Pos
        {
            public int X { get; set; }
            public int Y { get; set; }
            public Pos(int x, int y)
            {
                X = x;
                Y = y;
            }
        }
    }
}


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

using namespace std;

int dp[100001];
int main()
{
    int n,k;
    cin>>n>>k;
    int ankit[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>ankit[i];
    }
    for(int i=0;i<=k;i++)
    {
        dp[i]=0;
    }
    dp[0]=1;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=n;j++)
        {
           if(ankit[j] > i)
           continue;
           if(ankit[j]==i)
           {
               dp[i]=1;
               break;
           }
           if(dp[i-ankit[j]]==0){
           dp[i]=1;
           break;
           }

        }
    }
    /*for(int i=0;i<=k;i++)
    cout<<dp[i]<<" ";*/

    if(dp[k]==1)
    cout<<"First\n";
    else
    cout<<"Second\n";
}


Measured memory_bytes: 640
#define pb push_back
#define MX 1e3
#define mod 1000000009
#define ff first
#define ss second
#define for1(i,n) for(int i=1;i<=n;i++)
#define for0(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned  ll;

int main(int argc, char const *argv[]) {
  string a,c,b;
  cin>>a>>b>>c;
  char x,y,z;
  x = a[0]-32;
  y = b[0]-32;
  z = c[0]-32;
  cout<<x<<y<<z;
  return 0;
}


Measured memory_bytes: 256
#abc176-d
import sys,math,collections,itertools
input = sys.stdin.readline
 
H,W=list(map(int,input().split()))
Ch,Cw=list(map(int,input().split()))
Dh,Dw=list(map(int,input().split()))
s=[ input().rstrip() for _ in range(H)]
 
#DPで遷移が2種類　初期値をinf として、現在値より小さければ遷移可能とする
dp = [ [float('inf') ]*W  for _ in range(H)]
 
q = collections.deque([])
q.append((Ch-1,Cw-1))
dp[Ch-1][Cw-1]=0
while q:#qがある間の遷移 BSF
    visit = [] #徒歩で動いたところをメモする
    while q:#徒歩用のq
        nh,nw = q.popleft()
        visit.append((nh,nw))
        #徒歩での遷移
        move = [(-1,0),(1,0),(0,-1),(0,1)]
        for ih,iw in move:
            if  (0<= nh+ih<=H-1) and (0<=nw+iw<=W-1):
                if s[nh+ih][nw+iw] =='.' and dp[nh+ih][nw+iw]>dp[nh][nw]:
                    q.append((nh+ih,nw+iw))
                    dp[nh+ih][nw+iw] = dp[nh][nw]
    while visit:#徒歩で訪れたところからワープ先を探す
    #ワープで遷移
        nh,nw = visit.pop()
        for ih in range(-2,3,1):
            for iw in range(-2,3,1):
                if (0<= nh+ih<=H-1) and (0<=nw+iw<=W-1):
                    if s[nh+ih][nw+iw] =='.' and dp[nh+ih][nw+iw]>dp[nh][nw]:
                        q.append((nh+ih,nw+iw))
                        dp[nh+ih][nw+iw] = dp[nh][nw]+1
     
 
ans = dp[Dh-1][Dw-1]
print(-1 if ans==float('inf') else ans)    


Measured memory_bytes: 127548
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
	long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
	long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
  long up = -1;//減少で1、増加で2
  long answer = 1;

    for(long i = 0; i < n; i++)
    {
      if(up == -1) up = 0;
      else if(up == 0)
      {
        if(nums[i] > nums[i-1]) up = 2;
        if(nums[i] < nums[i-1]) up = 1;
      }
      else
      {
        if((nums[i] > nums[i-1] && up == 1) || (nums[i] < nums[i-1] && up == 2))
        {
          up = 0;
          answer++;
        }
      }
    }
  

  
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 18912
<?php
$n = int();
$a = ints();
$B = 0;
for($i = 0; $i < $n; $i++){
  $map[$i] = 0;
}
foreach($a as $b){
  $map[$b]++;
  $B = max($b, $B);
}
//echo $B;
//print_r($map);
$num = 1;
for($i = 1; $i <= $B; $i++){
  for($j = 0; $j < $map[$i]; $j++){
    $num *= $map[$i-1];
    $num %= 998244353;
  }
}
if($map[0] != 1)$num = 0;
if($a[0] != 0)$num = 0;
printf("%d", $num);

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 18932
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

typedef pair<int,int> pii;
pii solve(int a, int b, int d){
    for(int x=0;x<100000;x++){
        int rest=abs(d-a*x);
        if(rest%b)continue;
        int y=rest/b;
        return pii(x,y);
    }
    return pii(-1,-1);
}

int main(){
    int a,b,d;
    while(cin>>a>>b>>d && a){
        auto a1=solve(b,a,d), a2=solve(a,b,d);
        auto& ans=min(a1,a2,[](pii const& a, pii const& b){
                return a.first+a.second < b.second+b.first;
            });

        ll tx,ty;
        tie(tx,ty)=ans;
        ll s=tx+ty;
        for(int x=0;x<=s;x++){
            int y=s-x;
            if(a*x+b*y == a*tx+b*ty){
                tx=x;
                ty=y;
            }
        }
        if(&ans!=&a1) swap(tx,ty);
        cout << ty << " " << tx << endl;
    }
}

Measured memory_bytes: 1156
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(a: Vec<char>, b: Vec<char>) -> &'static str {
    if a.len() > b.len() {
        return "GREATER";
    } else if a.len() < b.len() {
        return "LESS";
    }
    for i in 0..a.len() {
        let x = a[i].to_digit(10).unwrap();
        let y = b[i].to_digit(10).unwrap();
        if x > y {
            return "GREATER";
        } else if x < y {
            return "LESS";
        }
    }

    "EQUAL"
}

fn main() {
    input!{
        a: chars,
        b: chars,
    }
    println!("{}", solve(a, b));
}


Measured memory_bytes: 4352
#include <iostream>

int main() {
  std::string U, T, S;
  std::cin >> S >> T;
  int a, b;
  std::cin >> a >> b;
  std::cin >> U;
  if (S == U) {
    --a;
  } else {
    --b;
  }
  std::cout << a << " " << b << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from bisect import bisect

A,B,Q = map(int,input().split())
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
X = [int(input()) for i in range(Q)]

INF = float('inf')
st = []
for s in S:
    i = bisect(T,s)
    x0,x1 = -INF,INF
    if i > 0: x0 = T[i-1]
    if i < B: x1 = T[i]
    st.append(min(s-x0, x1-s))
ts = []
for t in T:
    i = bisect(S,t)
    x0,x1 = -INF,INF
    if i > 0: x0 = S[i-1]
    if i < A: x1 = S[i]
    ts.append(min(t-x0, x1-t))

ans = []
for x in X:
    d0 = d1 = d2 = d3 = INF
    si = bisect(S,x)
    if si > 0:
        d0 = x-S[si-1] + st[si-1]
    if si < A:
        d1 = S[si]-x + st[si]
    ti = bisect(T,x)
    if ti > 0:
        d2 = x-T[ti-1] + ts[ti-1]
    if ti < B:
        d3 = T[ti]-x + ts[ti]
    ans.append(min(d0,d1,d2,d3))
print(*ans, sep='\n')

Measured memory_bytes: 30412
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

short memo[1 << 15][200][5];

short calc(int n, int last, int c){
  if(n == 0) return 1;
  if(c == 4) return 0;
  if(memo[n][last][c] != -1) return memo[n][last][c];

  short &res = memo[n][last][c] = 0;
  for(int i = last; i * i <= n; i++){
    res += calc(n - i * i, i, c + 1);
  }
  return res;
}

int main(){
  memset(memo, -1, sizeof(memo));

  int N;
  while(cin >> N && N){
    cout << calc(N, 1, 0) << endl;
  }
  return 0;
}

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

int main(void) {
  int n;
  long long int p[5]={0};
  cin>>n;  
  for(int i=0; i<n; i++) {
    string s;
    cin>>s;
    if(s[0]=='M')
      p[0]++;
    else if(s[0]=='A')
      p[1]++;
    else if(s[0]=='R')
      p[2]++;
    else if(s[0]=='C')
      p[3]++;
    else if(s[0]=='H')
      p[4]++;
  }
  long long int ans=0;
  for(int i=0; i<5; i++) {
    for(int j=i+1; j<5; j++) {
      for(int k=j+1; k<5; k++) {
	ans+=p[i]*p[j]*p[k];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# セグメント木 最新バージョン
#verify
class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

    def find_max_index(self, L, R, X):
        # [L,R)でX以下の物で最大indexを取得
        return self.fMi(L, R, X, 1, 0, 2**self.K)

    def find_min_index(self, L, R, X):
        # [L,R) でX以下の物で最小のindexを取得する
        return self.fmi(L, R, X, 1, 0, 2**self.K)

    def fMi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vr = self.fMi(a, b, x, (k << 1) | 1, (l + r) // 2, r)
                if vr != -1:
                    return vr
                return self.fMi(a, b, x, k << 1, l, (l + r) // 2)

    def fmi(self, a, b, x, k, l, r):
        if self.seg[k] > x or r <= a or b <= l:
            return -1
        else:
            if k >= 2**self.K:
                return k-2**self.K
            else:
                vl = self.fmi(a, b, x, k << 1, l, (l+r)//2)
                if vl != -1:
                    return vl
                return self.fmi(a, b, x, k << 1 | 1, (l+r)//2, r)
N = int(input())
S = list(input())
Q = int(input())
que = [tuple(input().split()) for i in range(Q)]
alpha = "abcdefghijklmnopqrstuvwxyz"
Data = {alpha[i]: [0]*N for i in range(26)}
for i in range(N):
    Data[S[i]][i] += 1
SEG = {alpha[i]: SegTree(Data[alpha[i]], max, 0) for i in range(26)}
for X, u, v in que:
    if X == "1":
        u = int(u)-1
        NOW = S[u]
        S[u] = v
        SEG[NOW].update(u, 0)
        SEG[v].update(u,1)
    else:
        s, t = int(u)-1, int(v)-1
        res = 0
        for j in range(26):
            res += SEG[alpha[j]].query(s, t+1)
        print(res)


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

using namespace std;

string s;
long long k;

int main (){
    cin >> s >> k;
    if(s.length() == 1){
        cout << k/2;
        return 0;
    }
    long long count = 0;
    for(int i = 0; i < s.length() - 1; i++){
        if(s.at(i) == s.at(i+1)){
            count++;
            i++;
        }
    }
    long long leftcount = 1;
    long long rightcount = 1;
    if(s.at(0) == s.at(s.length() - 1) && k > 1){
        for(int i = 1; i < s.length(); i++){
            if(s.at(i) == s.at(0)){
                leftcount++;
            }
            else break;
        }
        for(int i = s.length() - 2; i >= 0; i--){
            if(s.at(i) == s.at(s.length() - 1)){
                rightcount++;
            }
            else break;
        }
        
        if(leftcount % 2 == 1 && rightcount % 2 == 1){
            count++;
        }
    }
    if(leftcount == s.length() && s.length() % 2 == 1){
        long long kDiv = k / 2;
        if(k % 2 == 1){
            kDiv++;
        }
        cout << count * k - kDiv << endl;
        return 0;
    }
    if((leftcount % 2 == 1 && rightcount % 2 == 1) && s.at(0) == s.at(s.length() - 1) && k > 1){
        cout << count * k - 1 << endl;
        return 0;
    }
    cout << count * k << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
#define pb push_back  

int main()
{
   IOS
   
   ll n,i;
   cin>>n;
   
   ll h[n+1];
   ll dp[n+1];
   memset(dp,0,sizeof(dp));
   for(i=1;i<=n;i++)
   {
   	cin>>h[i];
   }
   dp[1]=0;
   dp[0]=0;
   for(i=2;i<=n;i++)
   {
   	ll op1= abs(h[i]-h[i-1])+dp[i-1];
   	if(i==2)
   	{
   		dp[i] = op1;
   	}
   	else
   	{
   		  ll op2= abs(h[i]-h[i-2])+dp[i-2];
   		 	dp[i] = min(op1,op2);
   		
   	}
   
   }
   cout<<dp[n]<<endl;

}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int n, d, a;
    cin >> n >> d >> a;
    vector<pii> m(n);
    for(auto &x: m) cin >> x.first >> x.second;
    sort(m.begin(), m.end());
    vector<LL> c(n+1);
    LL ans = 0;
    for(int i = 0, j = 0; i < n; ++i) {
        while(j < n && m[j].first <= m[i].first + 2*d) j++;
        LL need = max((m[i].second - c[i]*a+a-1) / a, 0LL);
        c[i] += need;
        c[j] -= need;
        c[i+1] += c[i];
        ans += need;
    }
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>

int main(void) {
	char S[3];
	int count = 0;
	std::cin >> S;
	for(int i=0; i<3; i++) {
		if(strncmp("o",&S[i],1)==0) {
			count++;
		}
	}
	std::cout << 700+100*count << std::endl;
  return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = []
for i in range(H):
  s = str(input())
  S.append(s)
  
ans = [[0]*W for i in range(H)]

cnt = 1
for i in range(H):
  s = S[i]
  if '#' in s:
    flag = False
    for j in range(W):
      if s[j] == '#':
        if flag:
          cnt += 1
        else:
          flag = True
      ans[i][j] = cnt
    cnt += 1
    
def blank(l):
  global H
  global W
  for i in range(H):
    if l[i] == [0]*W:
      if (i<H-1) and (l[i+1]!=[0]*W):
        l[i] = l[i+1]
      elif (i>0) and (l[i-1]!=[0]*W):
        l[i] = l[i-1]
  return l
        
while [0]*W in ans:
  ans = blank(ans)
for i in range(H):
  l = ans[i]
  print(*l)

Measured memory_bytes: 12596
#include <iostream>

using namespace std;

int main()
{
	int x,y;
	while(1)
	{
		cin>>x>>y;
		if(x!=0||y!=0)
		{
		
			if(x<=y)
			{
				cout<<x<<" "<<y<<endl; 
			}
			else
			{
				cout<<y<<" "<<x<<endl; 
			}
		}
		else
		{
			return 0;
		}
	}
}
 


Measured memory_bytes: 3124
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int n = cin.NextInt();
            int a = cin.NextInt();
            int b = cin.NextInt();
            int sum = 0;
            int dam = 0;
            string  vs = cin.Next();
            for(int i = 0; i < n; i++)
            {
                if (vs[i] == 'a' & sum < a + b)
                {
                    Console.WriteLine("Yes");
                    sum++;
                }else if (vs[i] == 'b' & sum < a+b & dam < b)
                {
                    Console.WriteLine("Yes");
                    sum++;
                    dam++;
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 16096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> v(4);

int main()
{
    REP(i,6) {
        int tmp;
        cin>>tmp;
        v[tmp-1]++;
    }
    SORT(v);
    if (v[0] == 1 && v[1] == 1 && v[2] == 2) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main(){
     srand(time(0));
     int n;
     cin >> n;
     vector<P> ps(n);
     for(int i = 0; i < n; ++i){
         ld x,y;
         cin >> x >> y;
         ps[i] = P(x,y);
     }

     printf("%.7lf\n", (double)smallest_enclosing_disc(ps).rad);
     return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner s = new Scanner(System.in);
		int max,min;
		int a,b;
		
	int counter = 0;
		while(s.hasNext()){
			
			a = s.nextInt();
			b = s.nextInt();
			int x = a;
			int y = b;
			while(x!=y){
				if(x>y){
					y += b;
				}else{
					x += a;
				}
			}
			min = x;
			max = (int)((long)a * b / min);
			System.out.println(max+" "+min);

		}
	}
}

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


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   
    //insert();    
  unsigned long long int total;
   cin>>total;


   unsigned long long int allans=101;
   int i;
   for(i=1;;i++)
   {

    long double temp=1.01;
    if(total<=allans)
       break;



    temp*=allans;
    allans=(long long int)temp;
   }

   cout<<i<<endl;
return 0;

}

Measured memory_bytes: 3652
#include <stdio.h>
int main(){
        int A,B,a,b,c,d,i,j,k,l;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        scanf("%d %d %d %d",&i,&j,&k,&l);
        A = a+b+c+d;
        B = i+j+k+l;
        if(A > B){
                printf("%d\n", A);
        }else{
                printf("%d\n", B);
        }
return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> X(N), sX(N);
	for (int i = 0; i < N; i++) cin >> X[i];

	sX = X;
	sort(sX.begin(), sX.end());
	int med = sX[(N - 1) / 2];

	for (int i = 0; i < N; i++) {
		if (X[i] <= med) cout << sX[(N + 1) / 2] << "\n";
		else cout << med << "\n";
	}

	return 0;
}


Measured memory_bytes: 3840
import java.util.*

fun main(args: Array<String>) {
    val read = Scanner(System.`in`)

    val alphabetList = "abcdefghijklmnopqrstuvwxyz".toUpperCase()
    val n = read.nextInt()
    val s = read.next()
    var o :String = ""

    for(i in s.split("").filter { it != "" }) {
        var originIndex = alphabetList.indexOf(i)
        var nextIndex = (originIndex + n) % 26
        o += (alphabetList[nextIndex])
    }

    println(o)
}

Measured memory_bytes: 120412
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

route =[0]*4
for i in range(3):
    a,b=mii()
    route[a-1]+=1
    route[b-1]+=1

cou = Counter(route)

ans1=0
ans2=0
for i in route:
    if i==1:
        ans1+=1
    elif i==2:
        ans2+=1

if ans1==2 and ans2==2:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 63724
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 3005;
const int MAXM = 2e5 + 5;
const int MOD = 1e9 + 7;

int h,w,n;
int fac[MAXM],ifac[MAXM],f[MAXN];
pair<int,int> pos[MAXN];

namespace ModOperation{
	int mul(int x,int y){
		return 1ll * x * y % MOD;
	}
	
	int add(int x,int y){
		x += y;
		if(x >= MOD)
			x -= MOD;
		return x;
	}
	
	int sub(int x,int y){
		x -= y;
		if(x < 0)
			x += MOD;
		return x;
	}
}

using namespace ModOperation;

int power(int x,int y){
	int res = 1;
	while(y){
		if(y & 1)
			res = mul(res,x);
		x = mul(x,x);
		y >>= 1;
	}
	return res;
}

void Init(int N){
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= N;i++)
		fac[i] = mul(fac[i - 1],i);
	ifac[N] = power(fac[N],MOD - 2);
	for(int i = N - 1;i >= 1;i--)
		ifac[i] = mul(ifac[i + 1],i + 1);
}

int C(int x,int y){
	return mul(fac[x],mul(ifac[y],ifac[x - y]));
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	Init(200000);
	scanf("%d%d%d",&w,&h,&n);
	for(int i = 1;i <= n;i++)
		scanf("%d%d",&pos[i].first,&pos[i].second);
	sort(pos + 1,pos + 1 + n);
	pos[++n] = make_pair(w,h);
	for(int i = 1;i <= n;i++){
		int x = pos[i].first,y = pos[i].second;
		f[i] = C(x + y - 2,x - 1);
		for(int j = 1;j < i;j++){
			int nx = pos[j].first,ny = pos[j].second;
			if(nx > x || ny > y)
				continue;
			f[i] = sub(f[i],mul(f[j],C(x - nx + y - ny,x - nx)));
		}
	}
	printf("%d\n",f[n]);
	return 0;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();
    for(int i=1;i<=10;i++){
        x = r*x - d;
        System.out.println(x);
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,y,z;
    cin>>n>>y>>z;
    int a[n+1];rep(i,n)cin>>a[i+1];
    a[0]=a[1];
    cout<<max(abs(a[n]-a[n-1]),abs(z-a[n]));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll           long long
#define pii          pair<int,int>
#define pll          pair<ll,ll>
#define SORT(x)      sort(x.begin(),x.end())
#define isWorking()  cout<<"Wroking"<<endl
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const ll mod=1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {
    Fast_Input


    while(testCase--) {
        char c; cin>>c; c++;
        cout<<c<<endl;

    }
    return 0;
}


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

typedef unsigned long long ull;

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	ull a = 1, b = 1;
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		ull x, y; cin >> x >> y;
		ull l = 1, r = 1e19, s = 1;
		while(l <= r){
			ull m = (l + r) / 2;
			if(x >= (a + m - 1) / m && y >= (b + m - 1) / m){
				s = m;
				r = m - 1;
			} else l = m + 1;
		}
		a = x * s; b = y * s;
	}
	cout << a + b << '\n';
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            List<int> A = new List<int>();
            string[] input2 = Console.ReadLine().Split(' ');
            for (var i = 0; i < N; i++)
            {
                A.Add(int.Parse(input2[i]));
            }
            A.Sort();
            int c = M;
            if (N == 1)
            {
                for (var i = 0; i < M; i++)
                {
                    A[0] /= 2;
                }
            }
            else
            {
                while (c > 0)
                {
                    int max = A[N - 1] / 2;
                    for (var i = N-1; i >= 0; i--)
                    {
                        if (A[i] >= max)
                        {
                            A[i] /= 2;
                            c--;
                            if (c == 0) break;
                        }
                        else
                        {
                            if (A[i] > A[i+1])
                            {
                                A.Sort();
                            }
                            break;
                        }
                    }
                }
            }
            long ans = 0;
            for (var i = 0; i < N; i++)
            {
                ans += A[i];
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main(){
  string S,T,U,V;
  cin>>S;
  
  int N;
  N=S.size();
  
  for(int i=0;i<N;i++){
    T+=S.at(N-i-1);
  }
  for(int i=0;i<(N-1)/2;i++){
    U+=S.at(i);
  }
  for(int i=0;i<(N-1)/2;i++){
    V+=U.at((N-1)/2-i-1);
  }
  
  if(S==T&&U==V){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  
  


Measured memory_bytes: 3668
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */

#include <iostream>
#include <fstream>

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

class DModSum {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        out << n*(n-1)/2 << endl;
	}
};


int main() {
	DModSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

bool v[26];
int main() {
	string s; cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	rep(i, 0, s.size()) {
		v[s[i] - 'a'] = true;
	}
	if (s.size() != 26) {
		char c = 0;
		rep(i, 0, 26) {
			if (!v[i]) {
				c = i + 'a';
				break;
			}
		}
		cout << s << c << endl;
	}
	else {
		for (int i = s.size() - 1; i >= 0; i--) {
			char c = s[i];
			char nextc = 'z';
			bool change = false;
			rep(j, i + 1, s.size()) {
				if (s[j] > c) {
					change = true;
					nextc = min(s[j], nextc);
				}
			}
			if (change) {
				s[i] = nextc;
				repe(k, 0, i) {
					cout << s[k];
				}
				cout << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

int main(){
  bool ad=false;
  int n;
  cin>>n;
  long long d[30000000];
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d,d+n);
  for(int i=0;i<n-1;i++){
    if(d[i]==d[i+1]){
      ad=true;
      break;
    }
  }
  if(ad) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  
}


Measured memory_bytes: 3584
#include<stdio.h>


int main()
{
	int x = 0;
	int y = 0;
	int n,z;
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;
	int e = 0;
	int f = 0;
	int g = 0;
	int h = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &z);
		if (400>z && a == 0) {
			x++;
			a++;
		}
		if (z>=400 &&z < 800 && b ==0) {
			x++;
			b++;
		}
		if ( z>=800 && z < 1200 && c == 0) {
			x++;
			c++;
		}
		if (z>=1200&& z < 1600 && d == 0) {
			x++;
			d++;
		}
		if (z>=1600 && z < 2000 && e == 0) {
			x++;
			e++;
		}
		if (z >= 2000 && z < 2400 && f == 0) {
			x++;
			f++;
		}
		if (z >= 2400 && z < 2800 && g == 0) {
			x++;
			g++;
		}
		if (z >= 2800 && z < 3200 && h == 0) {
			x++;
			h++;
		}
		if (z >= 3200) {
			y++;
		}
	}
if(x==0){
printf("%d %d",1,y);}else{
	printf("%d %d", x, x + y);
}
    return 0;
}



Measured memory_bytes: 128
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -= 1
        temp = a//2
        b += temp
        a -= temp
    else:
        if b % 2 != 0:
            b -= 1
        temp = b//2
        a += temp
        b -= temp

print(a, b)


Measured memory_bytes: 9088
N = gets.to_i
A = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

result = Array.new(60) do |i|
  base = 1 << i
  c = [0, 0]
  A.each do |a|
    c[a[i]] += 1
  end
  c[0] * c[1] * base % MOD
end.inject(&:+)

puts result % MOD


Measured memory_bytes: 36868
#include<stdio.h>
main(){
int x,a,b,c,d;

x: scanf("%d%d%d",&x,&a,&b);
if(x<1||x>1000||a<1||a>1000||b<1||b>1000||a==x||b==x||a==b){goto x;}

if(x-a>0){c=x-a;}
else{c=a-x;}

if(x-b>0){d=x-b;}
else{d=b-x;}

if(c<d){printf("A");}
else{printf("B");}
}

Measured memory_bytes: 128
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long N = scanner.nextLong();
    long[] map = new long[5];

//    int A = scanner.nextInt();
//    int B = scanner.nextInt();
//    int C = scanner.nextInt();
//    int D = scanner.nextInt();
//    int E = scanner.nextInt();

    long min = 99999999999999999L;
    for (int i = 0; i < 5; i++) {

      map[i] = scanner.nextLong();
      if(min > map[i])min = map[i];
    }

    if(min > N){
      System.out.println(5);
    }else{
      System.out.println((N + min - 1)/min + 4);
    }




  }


}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;


int main(){
char a;cin>>a;
if(a>='a'&&a<='z'){
    cout<<'a'<<endl;
    return 0;
}
else if(a>='A'&&a<='Z'){
    cout<<'A'<<endl;
    return 0;

}
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String work[] = new String[4];
		int table[][][] = new int[4][3][10];

		for(int a = 0; a < 4; a++){
			for(int b = 0; b < 3; b++){
				for(int c = 0; c < 10; c++)table[a][b][c] = 0;
			}
		}

		try {
			int N = Integer.parseInt(br.readLine());

			for(int loop = 0; loop < N; loop++){
				work = br.readLine().split("\\s+");
				table[Integer.parseInt(work[0])-1][Integer.parseInt(work[1])-1][Integer.parseInt(work[2])-1] += Integer.parseInt(work[3]);
			}


			print(table[0]);
			for(int i = 1; i <= 3; i++){
				System.out.printf("####################\n");
				print(table[i]);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void print(int house[][]){

		for(int row = 0; row < 3; row++){
			for(int col = 0; col < 10; col++){
				System.out.printf(" %d", house[row][col]);
			}
			System.out.printf("\n");
		}
	}
}




Measured memory_bytes: 25932
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s,t string
	fmt.Scan(&s,&t)

	ans := s
	for i := 0; i < len(s); i++ {
		if ans == t {
			fmt.Println("Yes")
			return
		}
		ss := strings.Split(ans,"")
		ans = ss[len(ans)-1] + string([]rune(ans)[0:len(s)-1])
	}
	fmt.Println("No")
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
int dp[3001][3001][2];
int a[3001];
int solve(int l , int r , int turn) {
   if(l == r) return (turn ? -a[l] : a[l]);
   int &res = dp[l][r][turn];
   if(res != -1)  return res;
   res = 0;
   if(turn == 0) {
      res = max(solve(l+1 , r , 1) + a[l] , solve(l , r-1 , 1) + a[r]);
   }
   else {
      res = min (solve(l+1 , r , 0) - a[l] , solve(l , r-1, 0) - a[r]);
   }
   return res;
}
int32_t main(){
   fast;
   int n;
   cin >> n;
   f(i,1,n+1)  cin >> a[i];
   memset(dp , -1 , sizeof(dp));
   cout << solve(1,n,0);
}

Measured memory_bytes: 141184
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

def solve(hp, count):
	q = hp - b * count
	p = (q - 1) / (a - b) + 1
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 0
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(ll, m):
		r = m
	else:
		l = m

print r

Measured memory_bytes: 18480
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

int main() {
    int h,i,j,k,temp1,temp2,length=0,ans;
    vector<int>n;
    vector<int>x;
    do{
        cin>>temp1>>temp2;
        if(temp1==0&&temp2==0){
            break;
        }
        n.push_back(temp1);
        x.push_back(temp2);
        length++;
    }while(true);
for(h=0;h<length;h++) {
    ans=0;
    for (i = 1; i <= n[h]-2; i++) {
        for (j = i+1; j <= n[h]-1; j++) {
            for (k = j + 1; k <= n[h]; k++) {
                if(i+j+k==x[h])ans++;
            }
        }
    }
cout << ans << endl;
}

    return 0;
}




Measured memory_bytes: 3124
#include <stdio.h>

int main() {
	int n, k, a[200010];
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)scanf("%d", &a[i]);
	for (int i = 0; i < n - k;i++) {
		if (a[i]<a[i+k])printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2404
#include "bits/stdc++.h"
using namespace std;

const long long infinity = 1e18;

int w[100];
int v[100];

long long dp[100][100001];

int main(){
	int n,W;
	cin>>n>>W;
	
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	
	dp[0][0] = 0;
	dp[0][w[0]] = v[0];
	
	for(int id=1;id<n;id++){
		dp[id][0] = 0;
		for(int j=1;j<=W;j++){
			
			// Discard current object
			dp[id][j] = dp[id-1][j];
			
			// Pick current object
			if(j >= w[id])
				dp[id][j] = max(dp[id][j], v[id] + dp[id-1][j-w[id]]);
			
		}
	}
	
	long long answer = -infinity;
	
	for(int j = 0; j <= W;j++){
		answer = max(answer, dp[n-1][j]);
	}
	
	cout<<answer;
	
	return 0;
}


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

int main() {
  string T;
  cin >> T;
  rep(i,T.size()){
    if(T.at(i)=='?'){
      T.at(i)='D';
    }
  }
  cout << T << endl;
}

Measured memory_bytes: 3756
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n+1)
sb = [0] * (m+1)
for i in range(n):
  sa[i+1] = sa[i] + a[i]
for i in range(m):
  sb[i+1] = sb[i] + b[i]
rx = 0
rb = m
for ra in range(0,n+1): 
  while (sb[rb] + sa[ra]) > k and rb>0 :
    rb-=1
  if (sb[rb] + sa[ra]) <= k:
    rx = max(rx,ra+rb)
print(rx)


Measured memory_bytes: 48508
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scanf("%d", &n)
  var s string
  m := make(map[string]bool)
  for i := 0; i < n; i++ {
    fmt.Scanf("%s", &s)
    m[s] = true
  }
  fmt.Println(len(m))
}

Measured memory_bytes: 18908
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
int n;

void dfs(string s, char mx){
  if(s.length()==n){
    cout<<s<<endl;
    
  }else{
    for(char c='a'; c<=mx;c++){
      dfs(s+c, ((c==mx)? (char)(mx+1): mx));
    }
  }
}

int main(){
  cin >>n;
  dfs("",'a');
  return 0;

}

Measured memory_bytes: 1536
// 2-D 長方形の中に円が含まれるかを判定するプログラムを作成してください。
// 次のように、長方形は左下の頂点を原点とし、右上の頂点の座標 (W,H)  が与えられます。
// また、円はその中心の座標 (x,y)  と半径 r  で与えられます。 

import java.util.*;


class Main{
	////プログラムのエントリポイント
	public static void main(String[] args){
		//入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		//数字５つ受け取り
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		//x-r<0 x+y > W 以外のときは縦軸からは出ない
		//y-r<0 y+r > H 以外のときは横軸からは出ない
		//よってこの条件に当てはまらない場合 円は（W.H)内側にある。
	
		if( x - r < 0 || y - r < 0 || x + r > W ||  y + r > H ){
			System.out.println("No");
		}else{
			System.out.println("Yes");      
		}
	}
}

Measured memory_bytes: 17348
#include "bits/stdc++.h"
using namespace std;

int q=0;

struct tranp{
  char gara;
  int atai;
};

int partition(struct tranp CC[],int N,int p,int r){
  int i=0,j=0;
  struct tranp x;
  struct tranp tmp;
  x=CC[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(CC[j].atai<=x.atai){
      i=i+1;
      tmp=CC[i];
      CC[i]=CC[j];
      CC[j]=tmp;
    }
  }
  tmp=CC[i+1];
  CC[i+1]=CC[r];
  CC[r]=tmp;
  return i+1;
}

void quicksort(struct tranp CC[], int N, int p, int r){
  int q;
  if(p<r){
    q=partition(CC,N,p,r);
    quicksort(CC,N,p,q-1);
    quicksort(CC,N,q+1,r);
  }
}
void marge(struct tranp C[],int N, int left, int mid, int right){
  int i,j,k;
  int n1=0,n2=0;
  struct tranp L[500010];
  struct tranp R[500010];
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=C[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=C[mid+i];
  }
  L[n1].atai=2000000000;
  R[n2].atai=2000000000;
  j=0;
  i=0;
  for(k=left;k<right;k++){
    if(L[i].atai<=R[j].atai){
      C[k]=L[i++];
      
    }
    else {
      C[k]=R[j++];
    }
  }
}

void margesort(struct tranp C[],int N, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    margesort(C,N,left,mid);
    margesort(C,N,mid,right);
    marge(C,N,left,mid,right);
  }
}

int main(){
  struct tranp C[100000];
  struct tranp CC[100000];
  int n=0,i=0;
  int N=0;
  int left=0,right=0;
  char gara1[10];
  int atai1;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s %d",gara1,&atai1);
    C[i].gara=CC[i].gara=gara1[0];
    C[i].atai=CC[i].atai=atai1;
  }
  margesort(C,N,0,N);
  quicksort(CC,N,0,N-1);
  for(i=0;i<N;i++){
    if(C[i].gara!=CC[i].gara){
      printf("Not stable\n");
      break;
    }
  }
  if(i==N)printf("Stable\n");
  for(i=0;i<N;i++){
    cout<<CC[i].gara<<" "<<CC[i].atai<<endl;
    
  }
  return 0;
}



Measured memory_bytes: 5404