akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    string s;
    cin >> s;

    if (s[sz(s) - 1] == 's')
        s += "es";
    else
        s += "s";
    cout << s << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

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

int main() {

	int a, b, t;

	cin >> a >> b >> t;

	int total = 0;

	for (int i = 1; i < 10000; i++) {
		if (a*i > t) {
			break;
		}
		total += b;
	}

	cout << total << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int area1 = a * b;
        int area2 = c * d;
        int larger = area1 > area2 ? area1 : area2;
        System.out.println(larger);
    }
}

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

int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr+n);
    int res = abs(arr[n-1] - arr[0]);
    cout << res << endl;
}

Measured memory_bytes: 3600
n,*L=map(int,open(0).read().split())
g=[[]for _ in range(n)]
for a,b in zip(*[iter(L)]*2):
	g[a-1].append(b-1)
	g[b-1].append(a-1)
b=[-1]*n
b[0]=0
q=[0]
while q:
	c=q.pop()
	for x in g[c]:
		if b[x]<0:b[x]=1-b[c];q.append(x)
lab=[-1]*n
Z=[i for i,x in enumerate(b) if x==0]
O=[i for i,x in enumerate(b) if x]
z,o=len(Z),len(O)
if z<=n//3 or o<=n//3:
	(L,H)=(Z,O) if z<=n//3 else (O,Z)
	a,b=1,3
	for i in L:lab[i]=b;b+=3
	for i in H:
		if b<=n:lab[i]=b;b+=3
		else:lab[i]=a;a+=1 if a%3==1 else 2
else:
	a,b,c=1,2,3
	for i in Z:
		if a<=n:lab[i]=a;a+=3
		else:lab[i]=c;c+=3
	for i in O:
		if b<=n:lab[i]=b;b+=3
		else:lab[i]=c;c+=3
print(*lab)

Measured memory_bytes: 78536
n = int(input())
a = list(map(int, input().split()))

t = [0] * n
t[0] = a[0]
for i in range(1, n):
    t[i] = a[i] + t[i-1]

h = sum(a) / 2
ans = 0
for i in range(n):
    if t[i] >= h and t[i] - h >= h - t[i-1]:
        print()
        ans = sum(a) - t[i-1] * 2
        break
    elif t[i] >= h and t[i] - h < h - t[i-1]:
        ans = t[i] * 2 - sum(a)
        break
    

print(ans) 



Measured memory_bytes: 89164
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()

print(N-K+1)

Measured memory_bytes: 4204
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
// 桁数、最上位桁
priority_queue<ll, vector<ll>, greater<ll> > que;

void dfs(ll c, ll num) {
  if (c > 10 || num > 3234566667) return;
  que.push(num);

  ll digit = num % 10;
  if (digit - 1 >= 0) dfs(c + 1, num * 10 + digit - 1);
  dfs(c + 1, num * 10 + digit);
  if (digit + 1 <= 9) dfs(c + 1, num * 10 + digit + 1);
}

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

  for (int i = 1; i <= 9; i++) dfs(0, i);
  for (int i = 0; i < K - 1; i++) que.pop();
  cout << que.top() << endl;
}

Measured memory_bytes: 1528
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print(math.factorial(N)%MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10444
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){

    Scanner in = new Scanner(System.in);

    String input = in.nextLine();

    while(!input.equals("-")){
        String tmp = in.nextLine();
        int h_cnt = Integer.parseInt(tmp);
        StringBuffer sb = new StringBuffer(input);
        for(int i=0; i<h_cnt; i++){
            tmp = in.nextLine();
            int h_pos = Integer.parseInt(tmp);
            String del_str = sb.substring(0,h_pos);
            sb = sb.delete(0,h_pos);
            sb.append(del_str);
        }
        System.out.println(sb.toString());
        input = in.nextLine();
    }

  }
}

Measured memory_bytes: 26048
n = int(input())
p = list(map(int , input().split()))

meet_condition = 0

for i in range(n-2):
    X =[]
    for j in range(3):
        X.append(p[i+j])
    if p[i+1] != max(X) and  p[i+1] != min(X):
        meet_condition += 1
        
print(meet_condition)

Measured memory_bytes: 3060
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc.read::<String>();
    if s.contains('A') && s.contains('B') {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int mat[9] = {2,5,5,4,5,6,3,7,6};
int cos[9] = {3000,3000,3000,3000,3000,3000,3000,3000,3000};
int res[9] = {0,0,0,0,0,0,0,0,0};
int main() {
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    cos[a-1] = mat[a-1];
  }
  int* dp = new int[10000];
  for(int i=0;i<n;i++) dp[i] = -100;
  dp[0] = 0;
  for(int i=2;i<=n;i++){
    int maxi = 0;
    int maxv = -100;
    for(int j=0;j<9;j++){
      int ind = i - cos[j];
      if(ind < 0) continue;
      maxv = max(maxv,dp[ind]+1);
    }
    dp[i] = maxv;
  }
  //for(int i=0;i<n;i++) cout << dp[i] << ",";
  //cout << endl;
  //for(int i=0;i<9;i++) cout << cos[i] << ",";
  //cout << endl;
  while(n>0){
    int cand = 0;
    for(int i=1;i<10;i++){
      int id = n - cos[i-1];
      if(id < 0) continue;
      if(dp[id]==dp[n]-1) cand = i;
    }
    cout << cand;
    if(cand == 0) return 0;
    n -= mat[cand-1];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    float a[n];
    for(int j=0;j<n;j++)
    {
        cin>>a[j];
    }
    sort(a,a+n);
    float ans=(a[0]+a[1])/2;
  for(int i=2; i<n; ++i)
  {
    ans = (ans+a[i])/2;
  }
  cout<<ans;

}
  
  




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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;

	vl a(n);
	FOR(i,0,n) cin >> a[i];
	
	map<ll,ll> next_occ;
	FORD(i,0,n) next_occ[a[i]] = n+i;
	
	ll S = 1;
	vvl step(S,vl(n));
	FORD(i,0,n) {
		ll j = next_occ[a[i]] + 1;
		step[0][i] = j-i;
		next_occ[a[i]] = i;
	}
	
	while (step[S-1][0] < 1e18) {
		step.pb(vl(n));
		FOR(i,0,n) {
			ll j = (i + step[S-1][i]) % n;
			step[S][i] = step[S-1][i] + step[S-1][j];
		}
		S++;
	}
	
	ll i = 0, rem = k*n;
	FORD(s,0,S) {
		if (step[s][i] < rem) {
			rem -= step[s][i];
			i = (i + step[s][i]) % n;
		}
	}
	assert(rem == n-i);
	
	set<ll> have;
	vl res;
	FOR(j,i,n) {
		if (have.count(a[j])) {
			while (res.back() != a[j]) {
				have.erase(res.back());
				res.pop_back();
			}
			have.erase(res.back());
			res.pop_back();
		} else {
			res.push_back(a[j]);
			have.insert(a[j]);
		}
	}

	for (ll x: res) cout << x << " ";
	cout << endl;

}



Measured memory_bytes: 101860
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,k,ans;
signed main(){
	n=read();m=read();k=read();
	ans=n*min(m-1,k)/m;
	printf("%d",ans);
}

Measured memory_bytes: 3764
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var foo = Console.ReadLine().Trim().Split();
            var A = Int32.Parse(foo[0]);
            var B = Int32.Parse(foo[1]);
            var H = Int32.Parse(foo[2]);
            var M = Int32.Parse(foo[3]);

            var mDeg = 6 * M;
            var hDeg = (30) * H + (0.5 * M);
            double deg = Math.Abs(mDeg - hDeg);
            var cosin = Math.Cos(deg * Math.PI / 180.0);
            var res = Math.Pow(A,2) + Math.Pow(B,2) - 2.0 * A * B * cosin;
            Console.WriteLine(Math.Sqrt(res));
        }
    }
}


Measured memory_bytes: 18716
#include<iostream>
#include<algorithm>
#define MAX 2000000
using namespace std;

int n;

int parent(int i);
int left(int i);
int right(int i);
void maxHeap(int node[], int i);
void buildMaxHeap(int node[]);
void insert(int node[], int k);
int extractMax(int node[]);

int main() {
	int k, node[MAX];
	char com[10];

	n = 0;

	while (1) {
		cin >> com;
		if (com[2] == 'd')break;
		else if (com[0] == 'e')cout << extractMax(node) << endl;
		else {
			cin >> k;
			insert(node, k);
		}
	}
	return 0;
}

int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

int right(int i) {
	return 2 * i + 1;
}

void maxHeap(int node[], int i) {
	int r, l, largest;

	if (left(i) <= n)l = left(i);
	else l = i;
	if (right(i) <= n)r = right(i);
	else r = i;
	
	if (node[l] < node[r])largest = r;
	else largest = l;

	if (node[largest] < node[i])largest = i;
	
	if (largest != i) {
		swap(node[i], node[largest]);
		maxHeap(node, largest);
	}
}

void buildMaxHeap(int node[]) {
	int i;
	for (i = n / 2; i > 0; i--)maxHeap(node, i);
}

void insert(int node[], int k){
	int i;
	node[++n] = k;
	i = n;
	while (i > 1 && node[i] > node[i / 2]) {
		swap(node[i], node[i / 2]);
		i /= 2;
	}
}

int extractMax(int node[]) {
	int max;
	max = node[1];
	node[1] = node[n--];
	maxHeap(node, 1);
	return max;
}

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

int BIT[1000010];
int bit_size;

void bit_init (int n) {
  fill(BIT+1, BIT+n+1, 0);
  bit_size = n;
}

int bit_sum(int n) {
  int ans = 0;
  while (n > 0) {
    ans += BIT[n];
    n &= n-1;
  }
  return ans;
}

void bit_add(int n, int v) {
  while (n <= bit_size) {
    BIT[n] += v;
    n += n & (-1 * n);
  }
}

int com[100010], x[100010], y[100010];

int main() {
  int n, q;
  cin >> n >> q;
  for (int i=0; i<q; i++) {
    cin >> com[i] >> x[i] >> y[i];
  }
  bit_init(n);
  for (int i=0; i<q; i++) {
    if (com[i] == 0) {
      bit_add(x[i], y[i]);
    } else {
      cout << bit_sum(y[i]) - bit_sum(x[i]-1) << endl; 
    }
  }
}

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

using namespace std;

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

    vector <int> a(n);
    vector <double> Pref(n + 1, 0.0);

    for(int& x : a) scanf("%d", &x);

    for(int i = 0; i < n; i++)  Pref[i + 1] = 0.5 * (a[i] + 1) + Pref[i];

    double Ans = 0.0;

    for(int i = k; i <= n; i++) Ans = max(Ans, Pref[i] - Pref[i - k]);

    printf("%.10f\n", Ans);
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next().trim();
        char[] sch = s.toCharArray();
        String t = sc.next().trim();
        char[] tch = t.toCharArray();

        int ans = 0;

        for (int i = 0; i < sch.length; i++) {
            if (sch[i] != tch[i]) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 32972
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
typedef long long ll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vector <int> p(n);rep(i,n)cin>>p[i];

    int minest = inf,  ans = 0;
    rep(i,n){
        if(p[i]<= minest){ ++ans; minest = p[i];}
    }
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] data = in.readLine().split(" ");
        int[] num = new int[6];
        for(int i=0; i<6; i++){
            num[i] = Integer.parseInt(data[i]);
        }
        Dices dice = new Dices(num[0],num[1],num[2],num[3],num[4],num[5]);
        String order = in.readLine();
        char[] chOrder = order.toCharArray();
        for(int j=0; j<order.length(); j++){
            if(chOrder[j]=='N'){
                dice.north();
            } else if(chOrder[j]=='E'){
                dice.east();
            } else if(chOrder[j]=='W'){
                dice.west();
            } else if(chOrder[j]=='S'){
                dice.south();
            }
        }
        System.out.println(dice.on);
    }
}
 
class Dices{
    public int on, tw, th, fo, fi, si;
    public Dices(int on, int tw, int th, int fo, int fi, int si){
        this.on = on;
        this.tw = tw;
        this.th = th;
        this.fo = fo;
        this.fi = fi;
        this.si = si;
    }
    void north(){
        int temp = on;
        on = tw;
        tw = si;
        si = fi;
        fi = temp;
    }
    void east(){
        int temp = on;
        on = fo;
        fo = si;
        si = th;
        th = temp;
    }
    void west(){
        int temp = on;
        on = th;
        th = si;
        si = fo;
        fo = temp;
    }
    void south(){
        int temp = on;
        on = fi;
        fi = si;
        si = tw;
        tw = temp;
    }
}

Measured memory_bytes: 16920
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
   

    rep(i,n){
        cin>>v[i];
      
    }

    int ans=-INF;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

            for(int i=0;i<l;i++){
                sum+=v[i];
                if(v[i]<0) {
                    te.push_back(v[i]);
                }
            }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
            for (int tt = 0; tt <= min(a, b); tt++) {
                if(tt!=0){ sum -= te[tt-1];}
                if (ans < sum) {
                    ans = sum;
                }
              

            }
        }
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        
        if(s[0].equals(s[1]) && s[2].equals(s[3]) && !(s[0].equals(s[2]))) System.out.println("Yes");
        else if(s[0].equals(s[2]) && s[1].equals(s[3]) && !(s[0].equals(s[1]))) System.out.println("Yes");
        else if(s[0].equals(s[3]) && s[1].equals(s[2]) && !(s[0].equals(s[1]))) System.out.println("Yes");
        else System.out.println("No");
        
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	
	vector<vector<char>> ans(H,vector<char>(W,'0'));
	
	for(int i=0;i<B;i++){
		for(int j=0;j<A;j++){
			ans[i][j]='1';
		}
	}
	for(int i=B;i<H;i++){
		for(int j=A;j<W;j++){
			ans[i][j]='1';
		}
	}
	
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

class point{
public:
    int x;
    int y;
};

int main(){
    int n;
    cin >> n;
    vector<point> r(n);
    vector<point> b(n);
    for(int i = 0; i < n; i++){
        cin >> r[i].x >> r[i].y;
    }
    for(int i = 0; i < n; i++){
        cin >> b[i].x >> b[i].y;
    }
    auto r_sort = [](point p1, point p2){return p1.y > p2.y;};
    auto b_sort = [](point p1, point p2){return p1.x < p2.x;};
    sort(r.begin(), r.end(), r_sort);
    sort(b.begin(), b.end(), b_sort);
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(b[i].y > r[j].y && b[i].x > r[j].x){
                r[j].x = 201; r[j].y = 201;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  char x[1001],y[1001];
  int dp[1002][1002];
  


  //load n;
  cin >>n;
  for(int i=0;i<n;i++){
    //initialize
    for(int i=0;i<1002;i++){
      for(int j=0;j<1002;j++){
	dp[i][j]=0; 
      }
    }
    //load string
    scanf("%s",x);
    scanf("%s",y);
    //dp
    for(int j=0;j<strlen(x);j++){
      for(int k=0;k<strlen(y);k++){
	if(x[j]==y[k]){
	  dp[j+1][k+1]=dp[j][k]+1;
	}

	else{
 
	  if(dp[j][k+1]>dp[j+1][k]){
	    dp[j+1][k+1]=dp[j][k+1];
	  }

	  else{
	    dp[j+1][k+1]=dp[j+1][k];
	  }
	}
      }
    }

    //print
    cout <<dp[strlen(x)][strlen(y)]<<endl;
  }



  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N+1), b(N+1), c(N+1), dp1(N+1),dp2(N+1),dp3(N+1);
	for (int i = 1; i <= N; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	dp1[0] = dp2[0] = dp3[0] = 0;
	dp1[1] = a[1];
	dp2[1] = b[1];
	dp3[1] = c[1];
	for (int i = 2; i <= N; i++)
	{
		dp1[i] = max(dp2[i - 1], dp3[i - 1]) + a[i];
		dp2[i] = max(dp1[i - 1], dp3[i - 1]) + b[i];
		dp3[i] = max(dp1[i - 1], dp2[i - 1]) + c[i];
	}
	cout << max({ dp1[N],dp2[N],dp3[N] });
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q,a,b;
vector<ll>v[100001];
ll vis[100001]={0},ans=0;
pair<ll,ll> dfs(ll x,ll lvl){
   vis[x]=1;
   ll mx=0;
   ll d2=1e9;
   if(x==a)d2=0;
   for(int i=0;i<v[x].size();i++){
     if(vis[v[x][i]]==0){
       pair<ll,ll> p=dfs(v[x][i],lvl+1);
       d2=min(d2,p.second);
       mx=max(mx,1+p.first);
     }
   }
   if(d2<lvl) ans=max(ans,mx+lvl);
   return {mx,d2+1};
}
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n>>a>>b;
      for(int i=0;i<n-1;i++){
      	cin>>x>>y;
      	v[x].push_back(y);
      	v[y].push_back(x);
      }
      if(a==b)cout<<0;
      else{
      	dfs(b,0);
      	cout<<ans-1;
      }
}

Measured memory_bytes: 16348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

int main(){
int D;
cin>>D;
int c[26];
rep(i, 26){
    cin>>c[i];
}
int s[D][26];
rep(i, D){
    rep(j, 26){
        cin>>s[i][j];
    }
}
int a[26];
rep(i, 26){
    a[i]=0;
}
int M=0;
int m=0;
rep(i, D){
    M=0;
    rep(j, 26){
        if(s[i][j]+c[j]*(i+1-a[j])>M){
            M=s[i][j]+c[j]*(i+1-a[j]);
            m=j;
        }
    }
    a[m]=i+1;
    cout<<m+1<<endl;
}
}

Measured memory_bytes: 3680
s = input()

def tapDance(s_string):

    for i, word in enumerate(s_string):
        if (i + 1) % 2 == 0 and word == "R":
            return "No"
        elif (i + 1) % 2 == 1 and word == "L":
            return "No"

    return "Yes"

print(tapDance(s))

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll dfs(ll index, ll length) {
//	cout << index << " " << length << endl;
	if (index == 1) {
		return 0;
	} else if (length == 5) {
		if (index == 1) return 0;
		else if (index == 2) return 1;
		else if (index == 3) return 2;
		else if (index == 4) return 3;
		else return 3;
	} else if (index == length / 2 + 1) {
//		cout << "just" << endl;
		return index / 2 + 1;
	} else if (index < length / 2 + 1) {
//		cout << "min" << endl;
		return dfs(index - 1, length / 2 - 1);
	} else {
//		cout << "max" << endl;
		return ((length / 2 + 1) / 2 + 1) + dfs(index - (length / 2 + 1), length / 2 - 1);
	}
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, x;
	cin >> n >> x;
	
	ll cnt = 1;
	rep(i, n) {
		cnt = 2 * cnt + 3;
	}
//	cout << cnt << endl;
//	if (x == cnt / 2 + 1) {
// 	    cout << x / 2 + 1 << endl;
//	} else (x < cnt / 2 + 1){
//
//	}
	
	cout << dfs(x, cnt) << endl;
	
	return 0;
}

Measured memory_bytes: 256
def count(s):
	c=0
	
	for i in range(len(s)-1):
		if s[i+1] == s[i]:
			c += 1
	return c
	
n, k = map(int, input().split())
s = input()
a = [str(c) for c in s]
cmax = n-1
p = count(a)
while 1:
  if p == cmax:
    break
  elif p == cmax +1:
    p -=1
    break
  elif k > 0:
    p += 2
    k -= 1
  else:
    break
		
print(p)




Measured memory_bytes: 9996
/**
 *    author:  lets
 *    created: 2020-06-07 15:30:17 JST
 **/
#include <bits/stdc++.h>

using namespace std;

string i2s(long long n) {
  ostringstream oss;
  oss << n;
  return oss.str().c_str();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }
  vector<vector<string>> ans(h, vector<string>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') {
        int b = 0;
        if (i < h - 1) {
          if (s[i + 1][j] == '#') b++;
          if (j < w - 1)
            if (s[i + 1][j + 1] == '#') b++;
          if (j > 0)
            if (s[i + 1][j - 1] == '#') b++;
        }
        if (j < w - 1)
          if (s[i][j + 1] == '#') b++;
        if (j > 0)
          if (s[i][j - 1] == '#') b++;
        if (i > 0) {
          if (j > 0)
            if (s[i - 1][j - 1] == '#') b++;
          if (s[i - 1][j] == '#') b++;
          if (j < w - 1)
            if (s[i - 1][j + 1] == '#') b++;
        }

        ans[i][j] = i2s(b);
      } else
        ans[i][j] = "#";
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ans[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 384
macro_rules! input {
    ( $( $var:ident : $t:tt ),* ) => {
        use std::io::{stdin, Read};
        let mut bytes = stdin().bytes();
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        $(let $var = read_value!(next, $t);)*
    };

    ( $( $var:ident : $t:tt ),+ ,) => {
        input!{ $($var : $t),* }
    };
}

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

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

fn main() {
    input! {
        n: u32,
        k: u32,
        h: [u32; n]
    };

    let ans = h.iter().filter(|x| **x >= k).collect::<Vec<_>>().len();
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      System.out.println(a*b - (a+b-1));
      
    	  
      
    }
 }

Measured memory_bytes: 22608
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderWorkspace
{
    public static class Class142_3
    {
        private struct Hi
        {
            public int Order;
            public int Number;
        }
        private static List<Hi> _hos = new List<Hi>();
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            int n = 0;
            int.TryParse(inputs[0],out n);
            var orders = Console.ReadLine().Split(' ');
            
            for (int i = 0; i < n; i++)
            {
                int temp;
                int.TryParse(orders[i],out temp);
                var hi = new Hi();
                hi.Number = i+1;
                hi.Order = temp;
                _hos.Add(hi);
            }

            var ordered = _hos.OrderBy(h => h.Order).ToList();
            for (int i = 0; i < ordered.Count; i++)
            {
                var hi = ordered[i];
                Console.Write(hi.Number);
                if (i != ordered.Count - 1)
                {
                    Console.Write(" ");
                }
            }
        }
    }
}

Measured memory_bytes: 28892
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=1000005;
const LL INF=1<<30;
const LL p=7+1e9;
const LL NN=50;
LL N,alls;
LL A[NN];
int main(){
	LL K=0;
	cin >> N;
	PQ qu;
	REP(i,N){ 
		cin >> A[i];
		alls+=A[i]/(N+1);
		A[i]%=N+1;
		qu.push(A[i]);		
	}
	K+=alls;
	K+=max<LL>(0,alls-(N-1))*N;
	alls=min(alls,N-1);
	while(qu.top()+alls>=N){
		qu.push(qu.top()-(N+1));
		qu.pop();
		alls++;
		K++;
	}
	cout << K << endl;
	return 0;
}

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

ll x,y,z,Z;
int main(){
  while(1){
    cin>>z;
    if(z==0)break;
    Z=z*z*z;
    ll ans=(1LL<<60);
    for(ll i=1;i<z;i++){
      for(ll j=1;j<z;j++){
	ll sum=i*i*i+j*j*j;
	if(sum>Z)break;
	ans=min(ans,Z-sum);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,m;
int q;
ll a[1000001];
ll cnt[7];
int fie[700001][7];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int bfs(int y,int x){
	queue<P> que;
	que.push(P(y,x));
	while(que.size()){
		P p=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=p.second+dx[i],ny=p.first+dy[i];
			if(nx>=0 && nx<7 && ny>=0){
				if(fie[ny][nx]==0){
					fie[ny][nx]=1;
					que.push(P(ny,nx));
				}
			}
		}
	}
}

int main(void){
	scanf("%lld%lld%d",&n,&m,&q);
	for(int i=0;i<q;i++){
		scanf("%lld",&a[i]);
	}
	ll lm=m;
	int cc=1;
	while(lm%7LL!=0){
		lm+=m;
		cc++;
	}
	ll len=lm/7;
	ll cnt=0;
	memset(fie,-1,sizeof(fie));
	for(int i=0;i<len;i++){
		for(int j=0;j<7;j++){
			fie[i][j]=0;
		}
	}
	for(int i=0;i<q;i++){
		for(int j=0;j<cc;j++){
			fie[(a[i]+m*j)/7LL][(a[i]+m*j)%7LL]=1;
		}
	}
	for(int i=0;i<len;i++){
		for(int j=0;j<7;j++){
			if(fie[i][j]==0){
				cnt++;
				bfs(i,j);
			}
		}
	}
	memset(fie,-1,sizeof(fie));
	for(int i=0;i<len*2;i++){
		for(int j=0;j<7;j++){
			fie[i][j]=0;
		}
	}
	for(int i=0;i<q;i++){
		for(int j=0;j<cc*2;j++){
			fie[(a[i]+m*j)/7][(a[i]+m*j)%7]=1;
		}
	}
	ll cnt2=0;
	for(int i=0;i<len*2;i++){
		for(int j=0;j<7;j++){
			if(fie[i][j]==0){
				cnt2++;
				bfs(i,j);
			}
		}
	}
	ll ad=(ll)7LL*n/lm;
	//printf("%lld %lld %lld %lld\n",cnt,cnt2,ad,lm);
	printf("%lld\n",(ll)cnt+(cnt2-cnt)*(ad-1LL));
	return 0;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

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

    int ans=0;
    for(int i=1; i<=100; i++){
        for(int j=0; j<n; j++){
            bool give=false;
            while(j<n && i<=h[j]){
                j++;
                give=true;
            }
            if(give) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	int x = n % 500;
	
	cout << (x <= a ? "Yes" : "No") << endl;
}

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

int main()
{
    int n,flag=0;
    int ard[200005];
    //int ard;
    int res = 0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>ard[i];
    }
    sort(ard,ard+n);
    for(int i =0; i<n-1; i++)
    {
        if(ard[i] == ard[i+1])
        {
            flag = 1;
            break;

        }

    }
    if(flag)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;


    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	
	REP(i, 50000) {
		int a = i * 1.08;
		if (a == N) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;

	return 0;
}



Measured memory_bytes: 256
function Main(input) {
    tmp = input.split(" ");
    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);
    if(a%b === 0){console.log(-1);return;}else{console.log(a);}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n=int(input())
beki=[1,4,8,9,16,16,25,27,32,36,49,64,64,64,81,81,100,121,125,128,144,169,196,216,225,243,256,256,256,289,324,343,361,400,441,484,512,512,529,576,625,625,676,729,729,729,784,841,900,961,1000]
ans=0
for i in range(len(beki)):
   if beki[i]<=n:
       ans=max(ans, beki[i])

print(ans)

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

int n,x,a,ans,l;

int main(){
	scanf("%d%d",&n,&x);
	a = 0;
	ans =1;
	while(n--){
		scanf("%d",&l);
		a+=l;
		if(a<=x)ans++;
		else break;
	}
	printf("%d\n",ans);
	return 0;
}		

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;
using P = pair<ll, ll>;

bool cp(tuple<string, int, int> p1, tuple<string, int, int> p2) {
    if (get<0>(p1) == get<0>(p2)) {
        return get<1>(p1) > get<1>(p2);
    } else {
        return get<0>(p1) < get<0>(p2);
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V.at(i);
    }

    int ans = 0;
    for (int num = 1; num <= min(K, N); num++) {
        for (int l = 0; l <= num; l++) {
            int r = num - l;
            vector<int> B;
            // 左
            for (int j = 0; j < l; j++) {
                B.push_back(V[j]);
            }
            // 右
            for (int j = N - 1; j > (N - 1) - r; j--) {
                B.push_back(V[j]);
            }
            sort(ALL(B));
            int sum = 0;
            for (int i = 0; i < (int)B.size(); i++) {
                if (i < (K - num) && B[i] < 0) continue;
                sum += B[i];
            }
            // cout << sum << endl;
            chmax(ans, sum);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    n: String,
  }
  
  let n: Vec<char> = n.chars().collect();
  let mut sum = 0;
  
  for c in n {
    sum = (sum + (c.to_string()).parse::<i32>().unwrap()) % 9;
  }
  
  if sum == 0 {
    println!("Yes");
  } else {
    println!("No");
  }
}

Measured memory_bytes: 3188
MOD = 998244353
n, k = map(int, input().split())
seg = [list(map(int, input().split())) for _ in range(k)]

s = [0 for _ in range(n + 1)]
s[1] = 1
for i in range(1, n):
    s[i + 1] = s[i]
    for l, r in seg:
        s[i + 1] += (s[max(0, i - l + 1)] - s[max(0, i - r)]) % MOD
        s[i + 1] %= MOD
print((s[n] - s[n - 1]) % MOD)


Measured memory_bytes: 17024
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

class Card
{
public:
    char simbol;
    int num;

    Card() : simbol('\0'), num(0) {}
    Card(char s, int n) : simbol(s), num(n) {}
};

void merge(vector<Card>& v, int left, int mid, int right)
{
    int size1 = mid - left + 1;
    int size2 = right - mid;
    vector<Card> v1(size1);
    vector<Card> v2(size2);

    for (int i = 0; i < size1; ++i) {
        v1[i].simbol = v[left+i].simbol;
        v1[i].num = v[left+i].num;
    }
    for (int i = 0; i < size2; ++i) {
        v2[i].simbol = v[mid+1+i].simbol;
        v2[i].num = v[mid+1+i].num;
    }

    int idx = left;
    int idx1 = 0;
    int idx2 = 0;
    while (idx1 < size1 && idx2 < size2) {
        if (v1[idx1].num <= v2[idx2].num) {
            v[idx].simbol = v1[idx1].simbol;
            v[idx].num = v1[idx1].num;
            ++idx1;
        } else {
            v[idx].simbol = v2[idx2].simbol;
            v[idx].num = v2[idx2].num;
            ++idx2;
        }
        ++idx;
    }

    while (idx1 < size1) {
        v[idx].simbol = v1[idx1].simbol;
        v[idx].num = v1[idx1].num;
        ++idx1;
        ++idx;
    }
    while (idx2 < size2) {
        v[idx].simbol = v2[idx2].simbol;
        v[idx].num = v2[idx2].num;
        ++idx2;
        ++idx;
    }
}

void merge_sort(vector<Card>& v, int left, int right)
{
    if (left < right) {
        int mid = (left + right) / 2;
        merge_sort(v, left, mid);
        merge_sort(v, mid+1, right);
        merge(v, left, mid, right);
    }
}

int partition(vector<Card>& v, int left, int right)
{
    int pivot = v[right].num;
    int boundary = left - 1;

    for (int i = left; i < right; ++i) {
        if (v[i].num <= pivot) {
            ++boundary;
            swap(v[boundary], v[i]);
        }
    }
    ++boundary;
    swap(v[boundary], v[right]);

    return boundary;
}

void quick_sort(vector<Card>& v, int left, int right)
{
    if (left < right) {
        int pivot = partition(v, left, right);
        quick_sort(v, left, pivot - 1);
        quick_sort(v, pivot + 1, right);
    }
}

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

    vector<Card> cards(n);
    for (int i = 0; i < n; ++i)
        cin >> cards[i].simbol >> cards[i].num;

    vector<Card> stable_cards(n);
    copy(cards.begin(), cards.end(), stable_cards.begin());

    quick_sort(cards, 0, n - 1);
    merge_sort(stable_cards, 0, n - 1);

    bool stable = true;
    for (int i = 0; i < n; ++i) {
        if (cards[i].simbol != stable_cards[i].simbol || cards[i].num != stable_cards[i].num) {
            stable = false;
            break;
        }
    }

    if (stable)
        cout << "Stable\n";
    else
        cout << "Not stable\n";

    cout << cards[0].simbol << ' ' << cards[0].num << '\n';
    for (int i = 1; i < n; ++i)
        cout << cards[i].simbol << ' ' << cards[i].num << '\n';
}



Measured memory_bytes: 5108
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int i=1,n,a,b,c=1,s=0;
	for(cin>>n>>b;i<n;i++)
	{
		cin>>a;
		if(a==b)c++;
		else s+=c/2,c=1;
		b=a;
	}
	cout<<s+c/2<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) = panasonic2020a()

fun panasonic2020a() {
    val k = readLine()!!.toInt()

    val list = listOf(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)

    val answer = list[k - 1]

    println(answer)
}


Measured memory_bytes: 32212
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[20],a[20];
int cnt;
int main()
{
	a[1]='C';a[2]='O';a[3]='D';a[4]='E';a[5]='F';a[6]='E';a[7]='S';a[8]='T';a[9]='I';
	a[10]='V';a[11]='A';a[12]='L';a[13]='2';a[14]='0';a[15]='1';a[16]='6';
	cin>>s+1;
	for(int i=1;i<=16;i++)
		if(s[i]!=a[i]) cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
A, B, C, D = [int(e) for e in input().split()]
E = max(C, D)
F = min(C, D)

mod = 1
while mod > 0:
  mod = E % F
  if mod == 0:
    break
  else:
    E = F
    F = mod
G = C*D // F

A_B = []
for AB in [A-1, B]:
  AB_c = AB // C
  AB_d = AB // D
  AB_g = AB // G
  A_B.append(AB_c + AB_d - AB_g)
can_divide = A_B[1] - A_B[0]
ans = (B - (A-1)) - can_divide
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <numeric>
#include <numeric>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;


lli dp[2005][2005] = {};
int main()
{
    lli n, x, a[2005];
    cin >> n >> x;
    rep(i, n) cin >> a[i];
    lli INF = 1e18;
    rep(i, 2005) rep(j, 2005) dp[i][j] = INF;
    rep(i, 2005) dp[i][0] = a[i];
    rep(i, n) rep(j, n)
    {
        dp[i][j + 1] = min(dp[i][j], a[(i - j - 1 + n) % n]);
    }
    lli ans = 1e18;
    rep(j, n + 1)
    {

        lli sum = 0;
        rep(i, n) sum += dp[i][j];
        ans = min(sum + j * x, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

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

    unsigned long long n, k;
    cin >> n >> k;
    if (n == 1) cout << k << endl;
    else 
    {
        int rst = k * pow(k-1, n-1);
        cout << rst << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import sys
import math
import bisect

def query_value(A, m):
    ans = 0
    for a in A:
        ans += (m - a) ** 2
    return ans

def main():
    n = int(input())
    A = list(map(int, input().split()))
    min_val = 10 ** 18
    for i in range(1, 101):
        val = query_value(A, i)
        min_val = min(min_val, val)
    print(min_val)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <stdlib.h>
#include <string.h>

int S[1000]; // stackとして用いる配列
int top; // stackの先頭を示す変数

void push(int x)
{
    // topを更新し、先頭に要素xを追加する
    S[++top] = x;
}

int pop()
{
    int x = S[top];
    --top; // 要素を取り出すのでtopを更新する
    return x;
}

int main()
{
    top = 0;
    char s[100];
    int a, b;
    while (scanf("%s", s) != EOF)
    {
        if (s[0] == '+')
        {
            b = pop();
            a = pop();
            push(a + b);
        }
        else if (s[0] == '-')
        {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if (s[0] == '*')
        {
            b = pop();
            a = pop();
            push(a * b);
        }
        else
        {
            push(atoi(s));
        }
    }

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

    return 0;
}


Measured memory_bytes: 2736
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int c[4][4], i, j, judge=1, a1, a2, a3, b1, b2, b3;

    for(i=1; i<=3; i++){
        for(j=1; j<=3; j++){
            cin >> c[i][j];
        }
    }

    a1 = 0;
    b1 = c[1][1]-a1;
    b2 = c[1][2]-a1;
    b3 = c[1][3]-a1;
    a2 = c[2][1]-b1;
    a3 = c[3][1]-b1;

    if(a2+b2==c[2][2] && a3+b2==c[3][2] && a2+b3==c[2][3] && a3+b3==c[3][3]){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256