akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=305,M=1e9+7;
char s[N];
int n,K,ans,a[N],fac[N],inv[N];
int C(int x,int y){
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
void Check(int num,int sum){
	int pos=num+1,res=fac[num],rnum=0,leftr=0,nxt=0,left=0;
	for (int i=1;i<=K;i++)
		if (s[i]=='r'){
			if (rnum<num)leftr+=a[++rnum]>1;
			else if (left)left--;
		}
		else {
			if (leftr)leftr--,left+=a[++nxt]-2;
			else if (left)left--;
		}
	if (left||rnum<num||leftr) return;
	for (int i=1,j=1;i<=num;i=j){
		while (j<=num&&a[j]==a[i])j++;
		(res*=inv[j-i])%=M;
		pos+=(j-i)*(a[i]*2-1);
	}
	(ans+=res*C(n-sum+pos-1,pos-1))%=M;
}
void dfs(int x,int num,int sum){
	if (sum>n)return;
	Check(num,sum);
	for (int i=x;i;i--){
		a[num+1]=i;
		dfs(i,num+1,sum+(i>1?i*2-3:1)+(num>0));
	}
}
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
signed main(){
	scanf("%lld%lld%s",&n,&K,s+1);
	fac[0]=inv[0]=1;
	for (int i=1;i<N;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	dfs(70,0,0); 
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize t:i64){n;list:(i64,i64)});
    list.into_iter()
        .filter(|&(_, x)| x <= t)
        .map(|(x, _)| x)
        .min()
        .map(|x| x.to_string())
        .unwrap_or("TLE".to_string())
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 70\n7 60\n1 80\n4 50" => "4",
    test2: "4 3\n1 1000\n2 4\n3 1000\n4 500" => "TLE",
    test3: "5 9\n25 8\n5 9\n4 10\n1000 1000\n6 1" => "5",
}


Measured memory_bytes: 4352
A, B, K = map(int, input().split())
flag = 0

if K >= A:
        K -= A
        A = 0
        flag = 1

if flag == 1 and K >= B:
        K -= B
        B = 0

if A == 0 and B == 0:
                print('0 0')
                exit(0)
        
if A > 0:
        print(A-K, B)
        exit(0)
        
if B > 0:
        print(A, B-K)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A+B)==(C+D))
    cout << "Balanced" << endl;
  if ((A+B)<(C+D))
    cout << "Right" << endl;
  if ((A+B)>(C+D))
    cout << "Left" << endl;
}

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

N, M = MAP()
A = LIST()

A = [-x for x in A]
heapify(A)

for _ in range(M):
	heappush(A, -(-heappop(A)//2))

print(-sum(A))


	


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


int main(){
    int N;
    char S[100];
    int c =0;
    scanf("%d",&N);
    for(int i = 0; i < N ; i++){
       scanf("%s",&S[i]);
       if (i >= 2 && S[i] == 'C' && S[i-1] =='B' && S[i-2] == 'A'){
         c++;
       }
    }
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
c = 0
for i in range(1, N+1):
    if i % K == 0:
        c += 1
ans = c ** 3
if K % 2 == 0:
    c = 0
    for i in range(1, N+1):
        if (i % K) == (K/2):
            c += 1
    ans += c **3
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if (N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13 || N == 17){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string a, s, c; std::cin >> a >> s >> c;
  std::stringstream ss; ss << "A" << (char)std::toupper(s[0]) << "C";
  std::cout << ss.str() << std::endl;
  return 0;
}


Measured memory_bytes: 384
from collections import deque
INF = 10 ** 10
dxdy = ((0, 1), (0, -1), (1, 0), (-1, 0))
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
s = ['#' * (w + 2)] + ['#' + input() + '#' for _ in range(h)] + ['#' * (w + 2)]
d = [[INF] * (w + 1) for _ in range(h + 1)]
d[ch][cw] = 0
q = deque([(ch, cw)])
while q:
    y, x = q.pop()
    for dx, dy in dxdy:
        if s[y + dy][x + dx] == '.' and d[y + dy][x + dx] > d[y][x]:
            d[y + dy][x + dx] = d[y][x]
            q.append((y + dy, x + dx))
    for i in range(-2, 3):
        for j in range(-2, 3):
            if i == j == 0:
                continue
            elif 1 <= y + i <= h and 1 <= x + j <= w and s[y + i][x + j] == '.' and d[y + i][x + j] > d[y][x] + 1:
                d[y + i][x + j] = d[y][x] + 1
                q.appendleft((y + i, x + j))
ans = d[dh][dw]
if ans == INF:
    print(-1)
else:
    print(ans)


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;

int main() {
    fastio;
    //fileio;
        
    string s;
    cin >> s;
    if (s[s.size()-1] == 's') {
        s += "es";
    } else {
        s += "s";
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let x1: f64 = sc.next();
    let y1: f64 = sc.next();
    let x2: f64 = sc.next();
    let y2: f64 = sc.next();

    println!("{:.8}", ((x2 - x1).powi(2) + (y2 - y1).powi(2)).sqrt());
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



Measured memory_bytes: 5076
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		long[] w = new long[N];
		int[] v = new int[N];
		int sum = 0;
		for(int i = 0; i < N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			sum += v[i];
		}
		long[][] dp = new long[N+1][sum+1];
		for(int i = 0; i <= N; i++)
			Arrays.fill(dp[i], 1_000_000_000_000L);
		dp[0][0] = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j <= sum; j++)
				dp[i][j] = Math.min(dp[i][j], dp[i-1][j]);
			for(int j = 0; j <= sum; j++) {
				if(j+v[i-1] <= sum)
					dp[i][j+v[i-1]] = Math.min(dp[i-1][j+v[i-1]], dp[i-1][j] + w[i-1]);
			}
		}
		long ans = 0;
		for(int i = 0; i <= sum; i++)
			if(dp[N][i] <= W)
				ans = i;
		System.out.println(ans);

	}

}


Measured memory_bytes: 129492
from functools import reduce

x,y=list(map(int,input().split()))
mod = 10 ** 9 + 7

if (2 * y - x) % 3 != 0 or (2 * x - y) % 3 != 0:
  print("0")
  exit()
  
a,b = (2 * y - x) // 3, (2 * x - y) // 3 

r = max(a,b)

if min(a,b) < 0:
  print("0")
else:
  numerator = reduce(lambda x, y: x * y % mod, range(a + b - r + 1, a + b + 1))
  denominator = reduce(lambda x, y: x * y % mod, range(1 , r + 1))
  print(numerator * pow(denominator, mod - 2, mod) % mod)

Measured memory_bytes: 9624
#include<stdio.h>
#define N 25
typedef struct{
  int left;
  int right;
  int parent;
}Tree;
Tree n[N];
void preParse(int u){
  printf(" %d",u);
  if(n[u].left!=-1) {preParse(n[u].left);}
  if(n[u].right!=-1)   {preParse(n[u].right);}
}

void inParse(int u){

  if(n[u].left!=-1)  {inParse(n[u].left);}
  printf(" %d",u);
  if(n[u].right!=-1) {inParse(n[u].right);}
}

void postParse(int u){
  if(n[u].left!=-1) {postParse(n[u].left);}
  if(n[u].right!=-1)  {postParse(n[u].right);}
  printf(" %d",u);
}

int main(){
  int i,a,id;
  scanf("%d",&a);
  for(i=0;i<a;i++) {n[i].left=n[i].right=n[i].parent=-1;}

  for(i=0;i<a;i++){
    scanf("%d",&id);
    scanf("%d",&n[id].left);
    scanf("%d",&n[id].right);
   
    n[n[id].right].parent=id;
    n[n[id].left].parent=id;
  }
  

  printf("Preorder\n");

  for(i=0;i<a;i++){

    if(n[i].parent==-1) {preParse(i);}

  }

  printf("\n");

  printf("Inorder\n");

  for(i=0;i<a;i++){

    if(n[i].parent==-1) {inParse(i);}

  }

  printf("\n");


  printf("Postorder\n");

  for(i=0;i<a;i++){

    if(n[i].parent==-1) {postParse(i);}

  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 616
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::fixed;
using std::setprecision;
using std::setw;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 314;

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

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

    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());

    cout << d.size() << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char s[N][N];
int a[5],c[27];
bool vis[N][N];
int main() {
    memset(a,0,sizeof(a));
    memset(c,0,sizeof(c));
    memset(vis,false,sizeof(vis));
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) scanf("%s",s[i]);
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) c[(int)(s[i][j]-'a')]++;
    int top=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) {
            int cnt=0;
            if(!vis[i][j]) {
                vis[i][j]=true;
                cnt++;
                if(!vis[n-1-i][j]) {
                    vis[n-1-i][j]=true;
                    cnt++;
                }
                if(!vis[i][m-1-j]) {
                    vis[i][m-1-j]=true;
                    cnt++;
                }
                if(!vis[n-1-i][m-1-j]) {
                    vis[n-1-i][m-1-j]=true;
                    cnt++;
                }
                a[cnt]++;
            }
        }
/*    for(int i=0;i<26;i++) printf("%d ",c[i]);
    puts("");
    for(int i=0;i<=4;i++) printf("%d ",a[i]);
        puts("");*/
    bool f=true;
    for(int i=4;i>=1;i--) {
        for(int j=0;j<26&&a[i];j++) {
            while(c[j]>=i&&a[i]) {
                c[j]-=i;
                a[i]--;
            }
        }
    }
    for(int i=1;i<=4;i++) if(a[i]>0) f=false;
    puts(f?"Yes":"No");
    return 0;
}

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

using namespace std;

#define ALL(v) v.begin(), v.end()
#define PQREV(T) vector<T>, greater<T>
#define PB push_back
#define EB emplace_back
#define CIN_FAST() cin.sync_with_stdio(false), cin.tie(NULL)

#define forempty(q) while(!q.empty())
#define endl '\n'
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

typedef long long int lint;
const int INF = 1e9;
const lint INFL = 1e18;

int main(void) {
    CIN_FAST();

    int N, K;  cin >> N >> K;
    lint res = 0;

    if (K == 0) {
        cout << (lint)N * N << endl;
        return 0;
    }


    for (int b = K+1; b <= N; b ++)
        res += (lint)(b-K) * (N/b) + (lint)max(0, (N%b-K+1));

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
import sys
from copy import deepcopy
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

H,W,K = map(int,readline().split())

maze = []
for _ in range(H):
    maze += [list(readline().rstrip().decode())]

ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        res = deepcopy(maze)
        for k in range(H):
            if i>>k&1:
                for l in range(W):
                    res[k][l] = "."
        for k in range(W):
            if j>>k&1:
                for l in range(H):
                    res[l][k] = "."

        ct = 0
        for k in range(H):
            for l in range(W):
                if res[k][l] == "#":
                    ct += 1
        
        if ct == K:
            ans += 1
            
print(ans)

Measured memory_bytes: 76552
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <complex>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

typedef long double D;
typedef complex<D> P;
#define X real()
#define Y imag()

int sign(D r){
  return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0;
}
struct C{
  P c; D r;
  C(){}
  C(P c, D r) : c(c), r(r) {}
};
bool cross(C c1, C c2){
  D d = abs(c1.c - c2.c);
  return sign(d - c1.r - c2.r) <= 0;
}

int main(){
  int W, H, N;
  while(cin>>W>>H>>N){
    vector<P> center(N);
    REP(i, N) cin>>center[i].X>>center[i].Y;
    D lb = 0, ub = 1e10;
    REP(iter, 100){
      D mid = (ub + lb) / 2;
      vector<C> cirs(N);
      REP(i, N) cirs[i] = C(center[i], mid);
      vector<bool> used(N, false);
      bool ok = true;
      REP(s, N)if(!used[s]){
        queue<int> que;
        que.push(s);
        used[s] = true;
        D mx = cirs[s].c.X - cirs[s].r;
        D Mx = cirs[s].c.X + cirs[s].r;
        while(!que.empty()){
          int u = que.front(); que.pop();
          REP(i, N) if(!used[i] && cross(cirs[i], cirs[u])){
            used[i] = true;
            que.push(i);
            mx = min(mx, cirs[i].c.X - cirs[i].r);
            Mx = max(Mx, cirs[i].c.X + cirs[i].r);
          }
        }
        if(sign(mx) < 0 && sign(Mx - W) > 0){
          ok = false;
          break;
        }
      }
      if(ok) lb = mid;
      else ub = mid;
    }
    printf("%.3Lf\n", lb);
  }
  return 0;
}

Measured memory_bytes: 1308
#include <stdio.h>

int main(int argc, char *argv[]){
     int n; char c;
     
     while((c=getchar())!=EOF){
	  if(c=='@'){
	       n=getchar()-'0';
	       c=getchar();
	       while(n--) putchar(c);
	  }
	  else putchar(c);
     }

     return 0;
}

Measured memory_bytes: 0
def iSort(A, n, g):
    c = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c

def shellSort(A, n):
    cnt = 0
    G = list()
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3*h + 1
    G.reverse()
    for num in G:
        cnt += iSort(A, n, num)
    return cnt, A, G

if __name__ == '__main__':
    n = int(input())
    hoge = list()
    for _ in range(n):
        hoge.append(int(input()))
    cnt, hoge, G = shellSort(hoge, n)
    print (len(G))
    print (' '.join([str(x) for x in G]))
    print (cnt)
    for e in hoge:
        print (e)


Measured memory_bytes: 45520
def resolve():
    A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K=int(input())-1

    print(A[K])    

if __name__ == "__main__":
    resolve()

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

int main(){
  ll N,A,B;
  
  cin>>N>>A>>B;
  
  ll shou=N/(A+B);
  ll mod=N%(A+B);
  if(mod>A)mod=A;

  ll ans=shou*A+mod;
  cout<<ans<<endl;
  


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int n;
	bool ans = false;
	int a[3][3];
	bool f[3][3] = {};
	rep(i, 3){
		rep(j, 3){
			cin >> a[i][j];
		}
	}
	cin >> n;
	rep(i, n){
		int b; cin >> b;
		rep(i, 3){
			rep(j, 3){
				if(b == a[i][j]) f[i][j] = true;
			}
		}
	}
	rep(i, 3){
		bool flag = true;
		rep(j, 3){
			if(!f[i][j]) flag = false;
		}
		if(flag) ans = true;
	}
	rep(i, 3){
		bool flag = true;
		rep(j, 3){
			if(!f[j][i]) flag = false;
		}
		if(flag) ans = true;
	}
	if(f[0][0] && f[1][1] && f[2][2]) ans = true;
	if(f[0][2] && f[1][1] && f[2][0]) ans = true;
	Yes(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

  int a,b,c;
    cin>>a>>b>>c;
    
    cout<<((a+b)*c)/2;
    
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B == C+D) {
    cout << "Balanced"<< endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3548
#include <stdio.h>

int main(){
  int n1,n2,n3,n4;
  scanf("%d%d%d%d",&n1,&n2,&n3,&n4);
  int ans[4];
  ans[0] = ans[1] = ans[2] = ans[3] = 0;
  if(n1 == 1 || n2 == 1 || n3 == 1 || n4 == 1){
    ans[0] = 1;
  }
  if(n1 == 4 || n2 == 4 || n3 == 4 || n4 == 4){
    ans[1] = 1;
  }
  if(n1 == 7 || n2 == 7 || n3 == 7 || n4 == 7){
    ans[2] = 1;
  }
  if(n1 == 9 || n2 == 9 || n3 == 9 || n4 == 9){
    ans[3] = 1;
  }
  if (ans[0] == 1 && ans[1] == 1 && ans[2] == 1 && ans[3] == 1){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 128
#sequence growing easy
N=int(input())
a=[int(input()) for _ in range(N)]
answer=0
now_value=10**9
for i in range(N-1,-1,-1):
    if a[i]>i:
        answer=-1
        break 
    if a[i]==now_value-1:
        now_value-=1
    else:
        answer+=a[i]
        now_value=a[i]
for i in range(N-1):
    if a[i+1]-a[i]>1:
         answer=-1
         break
print(answer)

Measured memory_bytes: 11048
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    map<pair<int, int>, int> m;
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for(int dx = -2; dx <= 0; dx++) {
            for(int dy = -2; dy <= 0; dy++) {
                int nx = a + dx, ny = b + dy;
                if(1 <= nx and nx + 2 <= h and 1 <= ny and ny + 2 <= w) {
                    m[{nx, ny}]++;
                }
            }
        }
    }
    map<int, ll> counter;
    for(auto p : m) {
        counter[p.second]++;
    }
    counter[0] = ll(h - 2) * (w - 2) - accumulate(counter.begin(), counter.end(), 0, [](int s, auto& p) {
        return s + p.second;
    });
    for(int i = 0; i <= 9; i++) {
        cout << counter[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 56576
'use strict'

function main(s) {

  s = s.split('\n');
  const row1 = s[0];
  const row2 = s[1];
  let ans = (s[0] === s[1].split('').reverse().join(''));

  console.log(ans ? 'YES' : 'NO');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}


vector<vi> dp(3,vi(100000,-1));

int happ(int lstact,int indx,const vector<vi> &v){
    if(indx>=v.size())return 0;
    if(dp[lstact][indx]!=-1)return dp[lstact][indx];
    int ans,a,b,c;
    ans=a=b=c=INT_MIN;
    if(lstact!=0)a=v[indx][0]+happ(0,indx+1,v);
    if(lstact!=1)b=v[indx][1]+happ(1,indx+1,v);
    if(lstact!=2)c=v[indx][2]+happ(2,indx+1,v);
    ans=max({a,b,c});
    dp[lstact][indx]=ans;
    return ans;
}

signed main(){
    FASTER;//ifstream cinn("input.txt");ofstream coutt("output.txt");
    int n;cin>>n;
    vector<vi> v(n,vi(3));cin>>v;
    cout<<max({happ(0,0,v),happ(1,0,v),happ(2,0,v)});
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  double xa, ya;
  cin >> xa >> ya;
  double xb, yb;
  cin >> xb >> yb;
  double xc, yc;
  cin >> xc >> yc;
  xb -= xa, yb -= ya;
  xc -= xa, yc -= ya;
  double a = hypot(xc - xb, yc - yb);
  double b = hypot(xc, yc);
  double c = hypot(xb, yb);
  double h = abs(xb * yc - xc * yb) / (a + b + c);
  double mx = max({a, b, c});
  double res = mx * h / (mx + 2 * h);
  cout << res << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String A = sc.next();
		char c = ' ';

		for(int i=0;i<A.length();i++) {
			c = A.charAt(i);
			for(int k=0;k<N;k++) {
				if(c=='Z'){
					c='A';
					--c;
				}
				++c;
			}

			System.out.print(c);
		}


	}

}


Measured memory_bytes: 25436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll q[25];
ll m[2010];
ll lis[2000000];

void solve(){

    ll n;
    cin >> n;
    rep(i,n){
        cin >> q[i];
    }
    ll a;
    cin >> a;
    rep(i,a){
        cin >> m[i];
    }

    

    for (int bit = 0; bit < (1<<n); ++bit) {
        ll count = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                count += q[i];
            }
            lis[bit]=count;
        }
        
    }
        
    rep(i,a){
        bool b = false;
        rep(bit, 1<<n){
            if(lis[bit]==m[i]) {
                b=true;
                break;
            }
        }
        if(b) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    

    
    

}

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



Measured memory_bytes: 11320
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define MOD 1000000007
using namespace std;
int main()
{
	int n;
	//string s[200000];
	cin >> n;
	map<string, int> m;
	for (size_t i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	vector<pair<string,int>> v;
	for (pair<string,int> i : m) {
		if (v.size() == 0||v[0].second == i.second) {
			v.push_back(i);
		}
		if (v[0].second < i.second) {
			vector<pair<string, int>>().swap(v);
			v.push_back(i);
		}
	}
	for (pair<string, int> i : v) {
		cout << i.first<<endl;
	}
	return 0;
}

Measured memory_bytes: 29424
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

left=0
right=W+1
up=0
down=H+1

ans="YES"
for i,(s,t) in enumerate(zip(reversed(S),reversed(T))):
    if i!=0:
        if t=='R':
            left=max(0,left-1)
        elif t=="L":
            right=min(W+1,right+1)
        elif t=="D":
            up = max(0,up-1)
        else:
            down=min(H+1,down+1)


    if s=="R":
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    if right-left==1 or down-up==1:
        ans="NO"
        break

if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int n;
		cin>>n;
		string s;
		cin>>s;
		int cnt = 0;
		for(int i=0; i<n-2;i++)
		{
			if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
			{
				i+=2;
				cnt++;
			}
		}
		cout<<cnt<<"\n";
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	ll N;
  	cin >> N;
  	if(N%2==1){
    	cout << 0 << endl;
      	return;
    }
  	// N: even のとき N!! の 10 進表記の末尾の 0 の個数を答える
  	// N!! = (N/2)! * 2^(N/2)
  	// (N/2)! が 5 で何回割り切れるか
	N /= 2;
  	ll ans = 0;
  	ll div = 5;
  	while(N/div>0){
  		ans += N/div;
      	div *= 5;
    } 
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char a[105],b[105];
	while(cin>>a>>b){
	int n,m;
	n=strlen(a);
	m=strlen(b);
	sort(a,a+n);
	sort(b,b+m);
	if(a[0]<b[m-1])
		printf("Yes\n");
	else if(strcmp(a,b)<0)
			printf("Yes\n");
	else
		printf("No\n");
	
	}
}


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

//using namespace std;

int main()
{
    uint32_t nn;
    /* nn <= 3 so nn is smaller than 1000 */
    uint32_t mm;
    uint32_t tar;
    uint32_t dig1 = 0;
    uint32_t dig2 = 0;
    uint32_t dig3 = 0;

    std::cin >> nn >> mm;

    std::vector<std::vector<int>> vv(2, std::vector<int>(mm, 0));
    
    for(int i = 0; i < mm; i++){
        for(int j = 0; j < 2; j++){
            std::cin >> vv[j][i];
        }
    }
    
    /* N桁目の数字になるかでプローブ領域を変える */

    if(nn == 1){
        for(int i = 0; i < 10; i++){
        /* s_i桁目の数字 */
            dig3 = i;
            for(int k = 0; k < mm; k++){
                if(vv[0][k] != 1){
                    goto out3;
                }
                if(dig3 != vv[1][k]){
                    goto out3;
                }
            }
            std::cout << i << std::endl;
            return 0;
out3:;
        }

    }else if(nn == 2){
        for(int i = 10; i < 100; i++){
        /* s_i桁目の数字 */
            dig3 = i % 10;
            dig2 = i / 10;
            for(int k = 0; k < mm; k++){
                if(vv[0][k] == 3){
                    goto out2;
                }else if(vv[0][k] == 1){
                    if(dig2 != vv[1][k]){
                        goto out2;
                    }
                }else if(vv[0][k] == 2){
                    if(dig3 != vv[1][k]){
                        goto out2;
                    }
                }
            }
            std::cout << i << std::endl;
            return 0;
out2:;
        }

    }else if(nn == 3){
        for(int i = 100; i < 1000; i++){
            dig3 = (i % 100) % 10;
            dig2 = (i % 100) /10;
            dig1 = i / 100;
            for(int k = 0; k < mm; k++){
                if(vv[0][k] == 1){
                    if(dig1 != vv[1][k]){
                        goto out;
                    }
                }
                if(vv[0][k] == 2){
                    if(dig2 != vv[1][k]){
                        goto out;
                    }
                }
                
                if(vv[0][k] == 3){
                    if(dig3 != vv[1][k]){
                        goto out;
                    }
                }
                
            }
            std::cout << i << std::endl;
            return 0;
out:;
        }
    }

    std::cout << (-1) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

const int Mod = 1000000007;
const int MN = 200005;

int N, x[MN], v[MN], p[MN], L[MN], R[MN], _f[MN], *f = _f + 1;
std::vector<int> W[MN], V[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d%d", &x[i], &v[i]), p[i] = i;
	std::sort(p + 1, p + N + 1, [](int i, int j) { return v[i] < v[j]; });
	for (int i = 1; i <= N; ++i) v[i] = x[p[i]];
	for (int i = 1; i <= N; ++i) x[i] = v[i];
	std::sort(p + 1, p + N + 1, [](int i, int j) { return x[i] < x[j]; });
	for (int i = N, y = N; i >= 1; --i) L[p[i]] = y = std::min(y, p[i]);
	for (int i = 1, y = 1; i <= N; ++i) R[p[i]] = y = std::max(y, p[i]);
	for (int i = 1; i <= N; ++i) W[L[i]].push_back(R[i]);
	for (int i = 1; i <= N; ++i) for (int y : W[i]) V[y].push_back(i);
	f[0] = 1;
	for (int i = 1; i <= N; ++i) {
		f[i] = f[i - 1];
		for (int l : V[i])
			f[i] = (2ll * f[i] - f[l - 2] + Mod) % Mod;
	}
	printf("%d\n", (f[N] - f[N - 1] + Mod) % Mod);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main() {
    int x; cin >> x;
    
    cout << 360/gcd(360, x) << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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


int main(){
    int N;
    cin >> N;
    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if((i+1)*(j+1) == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

K = int(input())
Q = deque()
for i in range(1, 10):
    Q.append(i)
temp = 0
for i in range(K):
    temp = Q.popleft()
    if temp%10 != 0:
        Q.append(temp*10+temp%10-1)
    Q.append(temp*10+temp%10)
    if temp%10 != 9:
        Q.append(temp*10+temp%10+1)
print(temp)

Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define Rapido ios::sync_with_stdio(0); cin.tie(0)
const int maxS = 1e5 + 5;

void code_idhr_h() {
    int N; cin >> N;
    int ans = 0, flg = 0;
    while(N--) {
        int X, Y; cin >> X >> Y;
        if(X == Y) ans++;
        else ans = 0;
        if(ans == 3) flg = 1;
    }
    if(flg) cout << "Yes";
    else cout << "No";
}

int32_t main() {
    Rapido;
    int T = 1; //cin >> T;
    for(int t = 1; t <= T; t++) {
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include <cstdlib>
using namespace std;
struct red{
	int x;
	int y;
};
struct blue{
	int x;
	int y;
};
int rcmp( const void *p, const void *q ) {
    return ((red*)p)->x - ((red*)q)->x;
}
int bcmp( const void *p, const void *q ) {
    return ((blue*)p)->x - ((blue*)q)->x;
}
int rcmpy( const void *p, const void *q ) {
    return ((red*)p)->y - ((red*)q)->y;
}
int main(){
	int N;
	cin >>N;
	red r[100];
	for(int i=0;i<N;i++)
		cin >>r[i].x>>r[i].y;
	qsort(r, N,sizeof(red), rcmp);
	blue b[100];
	for(int i=0;i<N;i++)
		cin>>b[i].x>>b[i].y;
	qsort(b, N,sizeof(blue), bcmp);
	int count=0;
	for(int i=0;i<N;i++){
		for(int j=N-1;j>=0;j--){
			if(b[i].x>r[j].x){
				qsort(r, N,sizeof(red), rcmpy);
				for(int k=N-1;k>=0;k--){
					if(b[i].y>r[k].y && b[i].x>r[k].x){
						count++;
						b[i].x=-1;
						b[i].y=-1;
						r[k].x=10000;
						r[k].y=10000;
						qsort(r, N,sizeof(red), rcmp);
						break;
					}
				}
			}
			if(b[i].y==-1)
					break;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;

int main() {
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		sum += a - 1;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

  vi b(n-1);
  rep(i,n-1) cin >> b[i];
  vi a(n);
  a[0] = b[0];
  for (int i = 1; i <= n-2; i++) {
    a[i] = min(b[i-1],b[i]);
  }
  a[n-1] = b[n-2];

  int ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	string s, t; int f = 1
	                     ;
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
			f = 0;
	}
	if (!f)
		cout << "No";
	else
		cout << "Yes";

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf( "%d %d %d", &a, &b, &c );
	
	if( a < b && b < c )
	{
		printf( "Yes\n" );
	}
	else
	{
		printf( "No\n" );
	}
	
	return 0;
}

Measured memory_bytes: 580
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
    if (p[i + 0] < p[i + 1] and p[i + 1] < p[i + 2]) or (p[i + 0] > p[i + 1] and p[i + 1] > p[i + 2]):
        ans += 1
print(ans)

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

using namespace std;


int main () {


	int n, m;
	scanf("%d %d", &n, &m);

	priority_queue <int> q;

	for (int i = 0; i < n; ++i) {
		int x; scanf("%d", &x);
		q.push (x);
	}

	while (m > 0) {
		int x = q.top();
		if (!x) break;

		q.pop();

		x /= 2;
		q.push (x);

		--m;
		
	}

	long long sum = 0;
	while (!q.empty()) {
		int x = q.top ();
		q.pop();

		sum += x;
	}

	printf ("%lld\n", sum);


	return 0;
}





Measured memory_bytes: 892
program main
    implicit none
    integer(8) N, i
    integer(8), allocatable :: A(:), boss(:)
    read *, N
    allocate(A(N))
    allocate(boss(N - 1))
    read *, boss
    do i = 1, N - 1
        A(boss(i)) = A(boss(i)) + 1
    end do
    do i = 1, N
        print '(I0)', A(i)
    end do
    deallocate(A)
    deallocate(boss)
    stop
contains

end program main

Measured memory_bytes: 6128
N = int(input())
A = list(map(int, input().split()))

# pairs = []

# for i in range(len(A)):
#     if A[A[i] - 1] == i + 1:
#         pairs.append(1)

# print(len(pairs) // 2)

n_pair = 0

for i in range(len(A)):
    if A[i] is not None:
        if A[A[i] - 1] == i + 1:
            n_pair += 1
            A[A[i] - 1] = None

print(n_pair)

Measured memory_bytes: 14008
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
ll dp[100005][13];
void solve(){
string s;
cin>>s;
int n=s.length();
int a[n];
rep(i,n){
if(s[i]=='?')a[i]=-1;
else a[i]=s[i]-'0';
}
if(a[0]==-1){
rep(i,10)dp[0][i]=1;
}
else dp[0][a[0]]=1;
for(int i=1;i<n;i++){
if(a[i]!=-1){
rep(j,13){
mad(dp[i][(j*10+a[i])%13],dp[i-1][j]);
}
}
else{
rep(j,10){
rep(k,13){
mad(dp[i][(k*10+j)%13],dp[i-1][k]);
}
}
}
}
cout<<dp[n-1][5];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--){
solve();
}
}



Measured memory_bytes: 11088
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int n,i;
    cin >> n;
    vi arr(n, 0);
    fo(i, n)
    {
        cin >> arr[i];
    }
    sort(arr.begin(),arr.end());
    if(n % 2 != 0)
        cout << 0 << endl;
    else
    {
        int div = n / 2;
        if((arr[div] - arr[div - 1]) >= 1)
            cout << (arr[div] - arr[div - 1]) <<endl;
        else
            cout << 0 << endl;
    }



    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Optional;

public class Main {

	public static void main(String[] args) {		

		try(BufferedReader br = new BufferedReader(new
		        InputStreamReader(System.in))) {
			String[] input = br.readLine().split("\\s");
			Optional<Integer> N = Optional.ofNullable(Integer.parseInt(input[0]));
			Optional<Integer> K = Optional.ofNullable(input.length > 1 ? Integer.parseInt(input[1]) : null);
			
			if(!K.isPresent()) {
				K = Optional.of(Integer.parseInt(br.readLine()));
			}
			
			if(K.get() < 1) { K = Optional.of(1); }
			if(K.get() > 50) { K = Optional.of(50); }

			if(N.get() < 1) { N = Optional.of(1); }
			if(N.get() > 50) { N = Optional.of(50); }
			
			int output = (N.get() - K.get()) + 1;
			
			System.out.println(output);
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 20820
program main
 implicit none
 integer n,one,two,i
 integer, allocatable::a(:)
 read(*,*) n
 allocate(a(1:n))
 read(*,*) a
 one = 0
 two = 0
 do i=1,n
  if(a(i) > one) then
   two = one
   one = a(i)
  else
   if(a(i) > two) then
    two = a(i)
   end if
  end if
 end do
 
 do i=1,n
  if(a(i) == one) then
   write(*,*) two
  else
   write(*,*) one
  end if
 end do
end program main

Measured memory_bytes: 4096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtC_169
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = int.Parse(AB[0]);
            int B = int.Parse(AB[1]);

            Console.WriteLine(A * B);
        }
    }
}

Measured memory_bytes: 27536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC003SimplifiedMahjong
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = new int[N + 1];
            long numPairs = 0;
            long numCards = 0;

            for (int i=1; i <= N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            for(int i=1; i <= N; i++)
            {
                if(A[i] == 0)
                {
                    numPairs += numCards / 2;
                    numCards = 0;
                }
                else
                {
                    numCards += A[i];
                }
            }

            numPairs += numCards / 2;

            Console.WriteLine(numPairs);
        }
    }
}

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

int main() {
  int N,X;
  cin >> N>>X;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
    h.at(i)=abs(h.at(i)-X);
  }
  if(N==1){
    cout<<h.at(0)<<endl;
  }else{

  int g=__gcd(h.at(0),h.at(1));

  
  for (int i =2 ; i < N; i++) { 
    g=__gcd(g,h.at(i));
   
  }
    cout<<g<<endl;
  }
}




Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	int n, a, b, ma = 0, tb;
	
	cin>>n;
	
	rep(i,n){
		cin>>a>>b;
		if(a  > ma){
			ma = a;
			tb  = b;
		}
	}
	
	cout<<ma+tb<<endl;
	
	
	return 0;
}

Measured memory_bytes: 384