akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;
string exp;
int pos, p;
bool valid;

int expression();
int term();
int factor();

int power(int x, int n){
  if ( n == 0 ) return 1;
  int res = power(x*x%p, n/2);
  if ( n & 1 ) res = res*x%p;
  return res;
}

int expression(){
    int value = term();
    while( exp[pos] == '+' || exp[pos] == '-' ){
	if ( exp[pos] == '+' ) { 
	    pos++; value = (value + term())%p; 
	} else { 
	    pos++; 
	    int m = p - term();
	    value = (value + m)%p;
	}
    }
    return value;
}

int term(){
    int value = factor();
    while( exp[pos] == '*' || exp[pos] == '/' ){
	if ( exp[pos] == '*' ) { 
	    pos++; 
	    value = (value*factor())%p;
	} else { 
	    pos++; 
	    int f = factor();
	    if ( f == 0 ) { valid = false; return 0;}
	    int d = power(f, p-2);
	    value = (value*d)%p;
	}
    }
    return value;
}

int factor(){
    int value = 0;
    if ( exp[pos] == '(' ){
	pos++; value = expression(); pos++;
    } else {
	while( isdigit(exp[pos]) ) { value = value*10 + exp[pos] - '0'; pos++;}
    }
    return value;
}


int main(){
    char ch;
    while(1){
	cin >> p >> ch;
	if ( p == 0 ) break;
	exp = "";
	while(1) { 
	  scanf("%c", &ch);
	  if ( ch == ' ' ) continue;
	  if ( ch == '\n' ) break;
	  exp += ch;
	}
	pos = 0;
	valid = true;
	int ans = expression();
	if ( !valid ) {
	    cout << "NG" << endl;
	} else {
	    cout << exp << " = " << ans << " (mod " << p << ")" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1360
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int h, w, k;
    cin >> h >> w >> k;

    vs m(h);
    REP(i, h) cin >> m[i];

    int ans = 0;
    REP(hb, (1<<h)) {
        vector<bool> hs(h, false);
        REP(i, h) if (hb & (1<<i)) hs[i] = true;

        REP(wb, (1<<w)) {
            vector<bool> ws(w, false);
            REP(i, w) if (wb & (1<<i)) ws[i] = true;

            int cnt = 0;
            REP(hi, h) REP(wi, w) {
                if (hs[hi]) if (ws[wi]) {
                    if (m[hi][wi] == '#') cnt++;
                }
            }

            if (cnt == k) ans++;
        }
    }

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


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

using namespace std;

int const maxk = 1005;
int pref[2][4 * maxk][4 * maxk];
int k, ans = 0;

inline void add(int x, int y, char c) {
    int ok = 0;
    if (c == 'B') ok = 1;
    pref[ok][x][y]++;
    pref[ok][x + 2 * k][y]++;
    pref[ok][x][y + 2 * k]++;
    pref[ok][x + 2 * k][y + 2 * k]++;
}

inline int get_s(int x1, int y1, int x2, int y2, int c) {
    return pref[c][x2][y2] - pref[c][x2][y1 - 1] - pref[c][x1 - 1][y2] + pref[c][x1 - 1][y1 - 1];
}

inline void check(int x, int y, int c) {
    /*if (get_s(x, y, x + k - 1, y + k - 1, (1^c)) == 0 && get_s(x + k, y + k, x + 2 * k - 1, y + 2 * k - 1, (1^c)) == 0) {
        if (get_s(x + k, y, x + 2 * k - 1, y + k - 1, c) == 0 && get_s(x, y + k, x + k - 1, y + 2 * k - 1, c) == 0) ans++;
    }*/
    ans = max(ans, get_s(x, y, x + k - 1, y + k - 1, c) + get_s(x + k, y + k, x + 2 * k - 1, y + 2 * k - 1, c)
    + get_s(x + k, y, x + 2 * k - 1, y + k - 1, (1^c)) + get_s(x, y + k, x + k - 1, y + 2 * k - 1, (1^c)));
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, y;
    cin >> n >> k;
    char c;
    for (int i = 1; i <= n; ++i) {
        cin >> x >> y >> c;
        x %= (2 * k), y %= (2 * k);
        x++, y++;
        add(x, y, c);
    }
    for (int z = 0; z <= 1; ++z) {
        for (int i = 1; i <= 4 * k; ++i) {
            for (int j = 1; j <= 4 * k; ++j) {
                pref[z][i][j] += pref[z][i - 1][j] + pref[z][i][j - 1] - pref[z][i - 1][j - 1];
            }
        }
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            check(i, j, 0);
            check(i, j, 1);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 129272
N, K, Q = [int(x) for x in input().split()]
A_list = []
for i in range(Q):
    A_list.append(int(input()))

k_list = [K-Q]*N
for i in A_list:
    k_list[i-1] += 1

for i in k_list:
    if i > 0:
        print('Yes')
    else:
        print('No')


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

int main() {
  int N, S1, S2, S3, S4;
  cin >> N;

  S1 = N / 1000;
  S2 = N / 100 % 10;
  S3 = N / 10 % 10;
  S4 = N % 10;
  
  if (S2 == S3){
    if (S1 == S2 || S3 == S4)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else
    cout << "No" << endl;
}

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

#include <vector>
#include <algorithm>
#include <limits>
#include <unordered_set>
#include <array>
#include <queue>

using namespace std;


int main() {
    string s;
    string t;
    cin >> s >> t;
    int min_score = numeric_limits<int>::max();
    for (int i =0 ; i <= s.size() - t.size(); ++i) {
        int score = 0;
        for (int j =0 ; j < t.size(); ++j) {
            if (s[i+j] != t[j]) {
                score += 1;
            }
        }
        if (score < min_score) {
            min_score = score;
        }
    }
    cout << min_score << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   int arr[3];
   
   vector<int>vec(10,0);
   
   for(int i=0;i<3;i++)
   {
       cin>>arr[i];
       
       vec[arr[i]]++;
   }
   
   
   for(int i=0;i<10;i++)
   {
       if(vec[i]==2)
       {
           cout<<"Yes"<<endl;
         return 0;
       }
   }
   
   cout<<"No"<<endl;
   
   
}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	if (a > b)
	{
		swap(a, b);
	}

	int sub = b - a;
	if (sub % 2 != 0)
	{
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	cout << sub / 2 + a << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	S := sc.Next()

	fmt.Println(strings.Repeat("x", len(S)))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <iostream>

typedef long long ll;

using namespace std;

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

	if(n % 2 == 0)
	{
		cout << -1 << endl;
		return 0;
	}

	int i = 1;
	ll ini = 7;
	while(ini < n)
	{
		ini = ini * 10 + 7;
		i++;
	}

	ll rem = (ini) % n;
	while(i < 1000001 && rem)
	{
		rem = (rem * 10 + 7) % n;
		i++;
	}

	if(i == 1000001)
		cout << -1 << endl;
	else
		cout << i << endl;
}


Measured memory_bytes: 3624
# coding:utf-8

import math
import re

def main(params):
    n,m = params[0]
    a = params[1]
    tmpA = []
    for i in a:
        i = int(i)
        tmpA.append(i)
    a = tmpA
    a.sort()
    a.reverse()
    r = {}
    for g in params[2:]:
        b = int(g.split()[0])
        c = int(g.split()[1])
        if c not in r:
            r[c] = b
        else:
            r[c] += b
#        t = [c] * b
#        r.extend(t)
#    r.sort()
#    r.reverse()
    rV = r.keys()
    rV.sort()
    rV.reverse()
    cnt = 0
    total = 0L
    while True:
        if len(a) == 0:
            total += rV[0]
            r[rV[0]] -= 1
            if r[rV[0]] == 0:
                rV.pop(0)
        elif len(rV) == 0:
            total += a[0]
            a.pop(0)
        elif a[0] < rV[0]:
            total += rV[0]
            r[rV[0]] -= 1
            if r[rV[0]] == 0:
                rV.pop(0)
        else:
            total += a[0]
            a.pop(0)
        cnt += 1
        if cnt == n:
            break
    print total
#    a = params[1].split()
#    b = list(params[2])

if __name__ == "__main__":
    n,m = raw_input().split()
    n = int(n)
    m = int(m)
    a = raw_input().split()
    cnt = m # TODO: edit here
    params = [[n,m],a]
    for i in range(cnt):
        param = raw_input()
        params.append(param)
    main(params)



Measured memory_bytes: 31876
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(x: usize);
    if x == 1 {
        println!("1");
        return;
    }

    let mut b_v = vec![false; 1001];

    for v in 1..x {
        for i in 2..1000f32.sqrt() as u32 {
            let buff = v.pow(i) as usize;
            if buff > 1000 {
                break;
            }
            b_v[buff] = true;
        }
    }

    for i in (0..x + 1).rev() {
        if b_v[i] {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 2204
#include <stdio.h>
#include <math.h>

int main(void){
	int n;
	int i;
	int array[100];
	i = 0;
	scanf("%d\n", &n);
	scanf("%d", &array[0]);
	i++;
	while(i < n){
		scanf(" %d", &array[i]);
		i++;
	}
	for(i = n ;i > 1;i--){
		printf("%d ", array[i - 1]);
	}
	printf("%d\n", array[i - 1]);
	return 0;
}
	

Measured memory_bytes: 596
/* It's a shot in the dark
 				But I will make it */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >>n;
	int cnt=0;
       for(int i=1;i<n;i++){
       	int op = (n-1)/i;
       	cnt+=op;
       	
       	
	   }
	   cout <<cnt<<"\n";

}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;
 
int x[11][11];

int check(int n){
    int tmp = x[0][n / 1000];
    n %= 1000;
    int tmp2 = x[tmp][n / 100];
    n %= 100;
    int tmp3 = x[tmp2][n / 10];
    n %= 10;
    int tmp4 = x[tmp3][n];
    return tmp4;
}

int change_to_i(string s){
    stringstream ss; int k;
    ss<<s; ss>>k;
    return k;
}

string change_to_s(int n){
    stringstream ss; ss<<n;
    return ss.str();
}

bool test(string s){
    int n = change_to_i(s);
    int res = x[check(n / 10)][n % 10];
    return res == 0; 
}

signed main(){
    rep(i, 0, 10) rep(j, 0, 10) cin >> x[i][j];
    int ans = 0;
    rep(i, 0, 10000){
        string s = change_to_s(i);
        int sz_s = s.size();
        rep(j, 0, 4 - sz_s) s = "0" + s;
        int check_digit = check(i);
        s = s + (char)('0' + check_digit);
        bool f = false;
        rep(j, 0, 5){
            rep(k, 0, 10){
                string t = s;
                t[j] = (char)('0' + k);
                if(s == t) continue;
                if(test(t)){
                    f = true;
                    j = 5;
                    break;
                }
            }
        }
        rep(j, 0, 4){
            string t = s;
            swap(t[j], t[j + 1]);
            if(t == s) continue;
            if(test(t)){
                f = true;
                break;
            }
        }
        if(f) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3192
def C(n, s):
    n = len(s)
    cr = 0
    cl = 0
    for i in range(1, n):
        if s[i] == "E":
            cl += 1
    
    min = cr + cl
    for i in range(1, n):
        if s[i - 1] == "W":
            cr += 1
        
        if s[i] == "E":
            cl -= 1
        
        if cr + cl < min:
            min = cr + cl
    
    return min

n = int(input())
s = input()
print(C(n, s))

Measured memory_bytes: 3672
program main
  implicit none
  integer :: i, n, m, s, c, ans = 0
  integer, allocatable :: x(:)

  read *, n, m
  allocate (x(n))
  x(:) = -1

  do i = 1, m
    read *, s, c
    if (x(s) /= -1 .and. x(s) /= c) ans = -1
    if (s == 1 .and. n /= 1 .and. c == 0) ans = -1
    x(s) = c
  end do
  if (ans == -1) then
    print '(i0)', -1
  else
    if (n == 1) then
      ans = max(0, x(1))
    else
      ans = ans + max(1, x(1)) * (10 ** (n-1))
      do i = 2, n
        ans = ans + max(0, x(i)) * (10 ** (n-i))
      end do
    end if
    print '(i0)', ans
  end if
end program

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	unordered_map<char, char> um1, um2;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (um1.find(s[i]) == um1.end()) {
			um1[s[i]] = t[i];
		} else {
			if (um1[s[i]] != t[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (um2.find(t[i]) == um2.end()) {
			um2[t[i]] = s[i];
		} else {
			if (um2[t[i]] != s[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3920
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
 
Node root;

Node treeSearch(Node u, int k){
  while(u != NIL){
    if(u->key == k) break;

    if(u->key > k) u = u->left;

    else u = u->right;
  }

  return u;
}

Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  
  return x;
}

Node treeSuccessor(Node x){
    Node y;
    if (x->right != NIL) return treeMinimum(x->right);

    y = x->parent;

    while(y != NIL && x == y->right){
      x = y;
      y = y->parent;
    }
    return y;
  }

void treeDelete(Node z){
    Node y;
    Node x;

    if(z->left == NIL || z->right == NIL) y = z;

    else y = treeSuccessor(z);

    if(y->left != NIL) x = y->left;

    else x = y->right;

    if(x != NIL) x->parent = y->parent;


    if(y->parent == NIL) root = x;


    else if(y == y->parent->left) y->parent->left = x;

    else y->parent->right = x;

    if(y != z) z->key = y->key;
  }

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
 
  if(y == NIL){
    root = z;
  }

  else if(z->key < y->key){
    y->left = z;
  }

  else{
    y->right = z;
  }
}
 
void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
 
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(void){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%s", com);
    if (com[0] == 'f') {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if (t != NIL) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }

    else if(com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }

    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

    else if (com[0] == 'd'){
        scanf("%d", &x);
        treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

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

N = int(input())
s = input()[:-1]
ans = [1]*(N+2)


def print_ans(l: list):
    """
    T,Fからなる配列を受け取る
    T->S
    F->Wに変えて出力する
    """
    ret = ""
    for a in l[1:-1]:
        ret += "S" if a else "W"
    print(ret)


def next(ind: int, isSame: bool, isSheep: bool)->bool:
    """
    ind+1の動物を決める
    """
    if isSame:
        if isSheep:
            return ans[ind-1]
        else:
            return not ans[ind-1]
    else:
        if isSheep:
            return not ans[ind-1]
        else:
            return ans[ind-1]


def check(first: bool, last: bool)->list:
    """
    Lは動物の並び
    True;羊
    False:狼
    L=[L[-1],L[0],...]として、sの情報に従って隣を決めていく。
    最後まで行ったときに、最後の値がlastと一致するならok
    番兵的な
    """
    ans[0] = last
    ans[1] = first
    for i in range(1, N+1):
        ans[i+1] = next(i, s[i-1] == "o", ans[i])

    return ans[0] == ans[N] and ans[1] == ans[N+1]


for first in [True, False]:
    for last in [True, False]:
        if check(first, last):
            print_ans(ans)
            exit()
print("-1")


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

using namespace std;

int n, ans, i;
string s;

int main() {
	cin >> n >> s;
	while(i < n) {
		ans++, i++;
		while(i < n && s[i] == s[i-1]) 
			i++;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

/* ????????????????????£?¨? */
int insertionSort(int* A, int n, int g);
int shellSort(int* A, int n);

/* main??¢??° */
int main(void){
	int* A = NULL;
	int n, cnt, i;

	scanf("%d", &n);
	A = (int*)malloc(sizeof(int)*n);
	if(A == NULL)exit(1);

	for(i = 0;i < n;i++)
		scanf("%d", &A[i]);

	cnt = shellSort(A, n);
	if(cnt == -1){
		free(A);
		exit(1);
	}
	printf("%d\n", cnt);

	for(i = 0;i < n;i++)
		printf("%d\n", A[i]);

	free(A);

	return 0;
}

/* g????????¢??????????´?????£???§??????????????°??????????????§?????\????????????????????¢??° */
int insertionSort(int* A, int n, int g){
	int cnt = 0, v, i, j;

	for(i = g;i < n;i++){
		v = A[i];
		j = i - g;
		while(j >= 0 && A[j] > v){
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}

	return cnt;
}

/* ?????§?????????????????????????????¢??° */
int shellSort(int* A, int n){
	int *G = NULL;
	int cnt = 0, m, i;

	for(m = 1;1 << 2*m <= n;m++);
	printf("%d\n", m);

	G = (int*)malloc(sizeof(int)*m);
	if(G == NULL)return -1;

	for(i = 0;i < m;i++)
		G[i] = 1 << 2*((m-1) - i);

	printf("%d", G[0]);
	for(i = 1;i < m;i++)
		printf(" %d", G[i]);
	printf("\n");

	for(i = 0;i < m;i++)
		cnt += insertionSort(A, n, G[i]);

	free(G);

	return cnt;
}

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

int n, ans, t[55];
string x, s[55];
int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) cin >> s[i] >> t[i];
	cin >> x;
	for(i=0; s[i]!=x; i++);
	for(++i; i<n; i++) ans += t[i];
	cout << ans;
	return 0;
}

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

typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <pii, ll> ppi;
#define L first.first
#define R first.second
#define C second

const ll MAX_N = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000;
ll n, m;
ppi Arr[MAX_N];
ll dis[MAX_N];
ll seg[MAX_N << 4];

bool cmp (ppi a, ppi b) {
    return a.R < b.R;
}

void build (ll s = 0, ll e = n, ll id = 1) {
    if (e - s == 1) {
        seg[id] = dis[s];
        return ;
    }

    ll mid = e + s >> 1;
    build(s, mid, id << 1);
    build(mid, e, id << 1 | 1);
    seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
}

ll get (ll l, ll r, ll s = 0, ll e = n, ll id = 1) {
    if (l <= s && e <= r)
        return seg[id];

    if (r <= s || e <= l)
        return inf;

    ll mid = e + s >> 1;
    return min(get(l, r, s, mid, id << 1), get(l, r, mid, e, id << 1 | 1));
}

void upd (ll val, ll tmp, ll s = 0, ll e = n, ll id = 1) {
    if (e - s == 1) {
        seg[id] = val;
        return ;
    }

    ll mid = e + s >> 1;
    if (tmp < mid)
        upd(val, tmp, s, mid, id << 1);
    else
        upd(val, tmp, mid, e, id << 1 | 1);

    seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        cin >> Arr[i].L >> Arr[i].R >> Arr[i].C;
        Arr[i].L--, Arr[i].R--;
    }

    sort(Arr, Arr + m, cmp);

    for (ll i = 0; i < n; i++)
        dis[i] = inf;
    dis[0] = 0;
    build();

    for (ll i = 0; i < m; i++) {
        dis[Arr[i].R] = min(dis[Arr[i].R], Arr[i].C + get(Arr[i].L, Arr[i].R + 1));
        upd(dis[Arr[i].R], Arr[i].R);
    }

    cout << (dis[n - 1] == inf? -1: dis[n - 1]) << "\n";
    return 0;
}

Measured memory_bytes: 7680
using System;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = int.Parse(Console.ReadLine());
            int c = 0;
            var res = "No";
            for (int i = 0; i < n; i++)
            {
                var dp = Console.ReadLine().Split(' ');
                if (dp[0] == dp[1])
                {
                    c++;
                    if (c>=3)
                    {
                        res = "Yes";
                    }
                }
                else
                {
                    c = 0;
                }
            }
            Console.WriteLine(res);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27516
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << "AB" << (char)('C' + n / 1000) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007

int main()
{
	
	ll k,i,a;
	cin>>k;
	if(k%2==0)
	{
		cout<<-1;
		return 0;
	}
	a=7;	i=1;
	a=a%k;

	while(a!=0&&i<10000000)
	{
		++i;
		a = (((a*(10%k))%k) + 7%k)%k;
	}
	if(a==0)
		cout<<i;
	else
		cout<<-1;
}

Measured memory_bytes: 3628
/*
    辞書
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_C
*/
#include <bits/stdc++.h>
using namespace std;

#define M 1046527
#define NIL (-1)
#define ll long long int

string HASH[M];

int getChar(char ch) {
    switch (ch) {
    case 'A':
        return 1;
    case 'C':
        return 2;
    case 'G':
        return 3;
    case 'T':
        return 4;
    default:
        return 0;
    }
}

ll getKey(string str) {
    ll sum = 0, p = 1;
    for (size_t i = 0; i < str.length(); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

ll h1(ll key) {
    return key % M;
}

ll h2(ll key) {
    return 1 + (key % (M - 1));
}

int find(string str) {
    ll key = getKey(str);
    for (ll i = 0;; i++) {
        ll h = (h1(key) + i * h2(key)) % M;
        if (HASH[h] == str)
            return 1;
        else if (HASH[h].length() == 0)
            return 0;
    }
    return 0;
}

int insert(string str) {
    ll key = getKey(str);
    for (ll i = 0;; i++) {
        ll h = (h1(key) + i * h2(key)) % M;
        if (HASH[h] == str)
            return 1;
        else if (HASH[h].length() == 0) {
            HASH[h] = str;
            return 0;
        }
    }
    return 0;
}

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

    int n;
    cin >> n;

    string command, str;
    for (int i = 0; i < n; i++) {
        cin >> command >> str;

        if (command == "insert") {
            insert(str);
        } else {
            if (find(str)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 25012
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int D;
	cin >> D;
	int c[26];
	int s[D][26];
	int t[D];
	int ok[26];
	rep(i,26) ok[i] = -1;
	rep(i,26) cin >> c[i];
	rep(i,D){
		rep(j,26){
			cin >> s[i][j];
		}
	}
	/*
	rep(i,D){
		cin >> t[i];
		--t[i];
	}
	*/
	int cnt = 0;
	int num;
	rep(i,D){
		int maxi = 0;
		rep(k,26){
			int ans = 0;
			ans += s[i][k];
			// ok[t[i]] = i;
			rep(j,26){
				if(j == k) continue;
				ans -= c[j] * (i-ok[j]);
			}
			if(maxi < ans){
				maxi = ans;
				num = k;
			}
		}
		cout << num+1 << endl;
		ok[num] = i;
	}
}

Measured memory_bytes: 3724
def main():
    from itertools import tee, zip_longest

    N, T = map(int, input().split())
    *t, = map(int, input().split())

    iter_t = iter(t)
    next(iter_t)

    ans = sum(min(T, t1 - t0) for t0, t1 in zip_longest(t, iter_t, fillvalue=1 << 31))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25200
seq_len = int(input())
seq_a = [int(x) for x in input().split()]
if seq_len == 1:
    print(1)
    exit()
b = 0; c = 0; ans = 1
for i in range(seq_len-1):
    if seq_a[i] < seq_a[i+1]:
        b = 1
    if seq_a[i] > seq_a[i+1]:
        c = 1
    if b == 1 and c == 1:
        ans += 1
        b = 0 ; c = 0
print(ans)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    try(
      Scanner scanner = new Scanner(System.in);) {
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      if(b/a == (double)b/a){
        System.out.println(b + a);
      } else {
        System.out.println(b - a);
      }
    }
  }
}

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

int main() {
	int64_t A, B, K;
	cin >> A >> B >> K;

	if (A < K) {
		B -= K - A;
		if (B < 0) B = 0;
		A = 0;
	}
	else A -= K;
	cout << A << " " << B << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		sc.close();
		
		int k=10;
		if(a%10 != 0) {k = Math.min(k, a%10);a=(a/10+1)*10;}
		if(b%10 != 0) {k = Math.min(k, b%10);b=(b/10+1)*10;}
		if(c%10 != 0) {k = Math.min(k, c%10);c=(c/10+1)*10;}
		if(d%10 != 0) {k = Math.min(k, d%10);d=(d/10+1)*10;}
		if(e%10 != 0) {k = Math.min(k, e%10);e=(e/10+1)*10;}
		k = 10-k;
		
		System.out.println(a+b+c+d+e-k);
		

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int gcd( int m, int n ) {
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;

    while( m != n ) {
        if ( m > n ) m = m - n;
        else         n = n - m;
    }
    return m;
}

int lcm( int m, int n ) {
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main(){
    int a, b;
    while(cin >> a >> b){
        cout << gcd(a, b) << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint A,B,V,W,T;
  cin>>A>>V>>B>>W>>T;
  cout<<((V>W and max(A-B,B-A)<=T*(V-W))?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 3592
X,N=list(map(int,input().split()))
P=list(map(int,input().split()))

abs_min=10**10
ans = ''
for p in [_ for _ in range(-101,201) if _ not in P]:
    if abs_min > abs(X-p) :
        ans = p
        abs_min = abs(X-p)
print(ans)

Measured memory_bytes: 9192
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N,K = LI()
p = LI()
E_half = np.array(p) + 1

def main():
    Pcum = np.zeros(N + 1, np.int32)
    Pcum[1:] = E_half.cumsum()
    # print(E_half)
    # print(Pcum)
    partial_sums_E_half = np.zeros(N-K+1, np.int32)
    for i in range(N-K+1):
        partial_sums_E_half[i] = Pcum[i+K] - Pcum[i]

    # partial_sums = Pcum[K:] - Pcum[0:-K]
    return (partial_sums_E_half.max())/2
print(main())


Measured memory_bytes: 50396
#include <stdio.h>

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

int x[1000010],check[1010],check2[1000010];

int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	
	int g = x[1];
	for(int i=2;i<=a;i++) g = gcd(g,x[i]);
	if(g>1)
	{
		printf("not coprime");
		return 0;
	}
	
	for(int i=2;i<=1000;i++)
	{
		if(check[i]==0)
		{
			for(int j=i;j<=1000;j+=i) check[j] = 1;
			
			int count = 0;
			for(int j=1;j<=a;j++) if(x[j]%i==0) count++;
			if(count>=2)
			{
				printf("setwise coprime");
				return 0;
			}
			for(int j=1;j<=a;j++) while(x[j]%i==0) x[j]/=i;
		}
	}
	
	for(int i=1;i<=a;i++) check2[x[i]]++;
	for(int i=2;i<=1000000;i++)
	{
		if(check2[i]>=2)
		{
			printf("setwise coprime");
			return 0;
		}
	}
	
	printf("pairwise coprime");
}

Measured memory_bytes: 5948
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = [a,b,c,d,e]
kyori = []

for i in l:
    for j in l:
        kyori.append(abs(i-j))
if max(kyori) <= k:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
# AOJ 0603 Illumination
# Python3 2018.7.2 bal4u

import sys
from sys import stdin
input = stdin.readline

n = int(input())
a = list(map(int, input().split()))
t, k = [], 0
for i in range(n):
	if k > 0:
		if a[i] == a[i-1]:
			t.append(k)
			k = 0
	k += 1
if k > 0: t.append(k)
ans = k = 0
for i in range(len(t)):
	k += t[i]
	if i > 2: k -= t[i-3]
	ans = max(ans, k)
print(ans)



Measured memory_bytes: 7240
#include <iostream>
using namespace std;
 
int P, Q, A, N;

int solve(int a, int n, int sum, int b) {
    int res = 0;
 
    if(P * a == Q * sum)
        return 1;
    if(P * a < Q * sum)
        return 0;
    if(n >= N)
        return res;
 
    for(int i = b; a*i <= A; i++)
        res += solve(a * i, n + 1, sum * i + a, i);
    return res;
}
 
int main() {
    while(cin >> P >> Q >> A >> N, P | Q | A | N) {
        int res = 0;
        for(int i = 1; i <= A; i++) {
            int tmp;
            tmp = solve(i, 1, 1, i);
            if(tmp > 0)
                res += tmp;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MP(x,y) make_pair(x,y)
#define X first
#define Y second
using namespace std;
const int MAX=30000;
typedef pair<int,int> PII;


int main(void){
  int N;
  cin >> N;
  vector<int> p(N);
  vector<int> a(N);
  vector<int> b;
  b.resize(N, -100000000);
  for(auto& pi : p)cin >> pi;
  rep(i,N)p[i]--;
  rep(i,N)a[i] = i+1;
  rep(i,N)b[i] = N-i;

  int bab = a[0] + b[0];
  rep(i,N)
    rep(j,N){
      if(p[i] >= j) b[j] += (i);
      if(p[i] <= j) a[j] += (i);
    }




  rep(i,N){
    if(i != 0)cout << " ";
    cout << a[i];
  }
  cout << endl;

  rep(i,N){
    if(i != 0)cout << " ";
    cout << b[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String []args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String t = br.readLine();
        t=t.substring(0,t.length()-1);
        if(s.equals(t))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 25392
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();

        // X-xnの差分の最大公約数を求めればOK
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = Math.abs(sc.nextInt() - X);
        }

        long ans = Long.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            long tmp_ans = gcd(a[i], a[0]);
            ans = Math.min(ans, tmp_ans);
        }

        out.println(ans);
    }

    //最大公約数 ユークリッドの互除法 O(logN)
    public static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 50668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	FastReader sc = new FastReader();
	String s = sc.next();
	int n = 0;
	int total = 0;
	
	for (char c: s.toCharArray()) {
		int num = c - '0';
		total *= 10;
		total += num;
		n += num;
	}
	
	if (total % n == 0) {
		System.out.println("Yes");
	} else {
		System.out.println("No")
;	}
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 21332
#include <stdio.h>
int h, n;
int a, s;
int main() {
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		s += a;
	}
	if (h <= s)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long double X[200100];
int N;
long long Count(long double len)
{
  long long Ans=0;
  for(int i=0;i<N;i++)
  {
    Ans+=(long long)(X[i]/len);
    //Ans+= (ceil(X[i])-1/len);
  }
  return Ans;
}
int main()
{
  long long K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
{
	cin>>X[i];
	//X[i]-=0.1;
}
  long double l=1,r=1e9;
  //while(l<r-0.1)
	for(int i=0;i<50;i++)
  //while(((long long)(r)-(long long)(l)) > 1)
  //while(!((ceil(r)-ceil(l)) == 0))
  {
    //long double mid=(l+r+0.1)/2;
    long double mid=(l+r)/2;
  //  cout<<l<<" "<<r<<" "<<mid<<endl;
    if(Count(mid)<=K) r=mid;
    else	l=mid;
    //else	l=mid+0.01;
  }
  cout<<(long long)(l+0.999)<<endl;
  return 0;
}

Measured memory_bytes: 6824
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int A0 = stdIn.nextInt();
			int L = stdIn.nextInt();
			if(A0 == 0 && L == 0) break;
			int[] ar = new int[21];
			ar[0] = A0;
			for (int i = 0; i < 20; i++) {
				int pre1 = ar[i];
				String pre2 = String.valueOf(pre1);
				String pre2X = String.valueOf(pre1);
				while (pre2.length() < L) {
					pre2 = "0" + pre2;
				}
				String pre3 = "";
				String pre4 = "";
				IN:for (int j = 0; j < pre2.length(); j++) {
					for (int k = 9; k >= 0; k--) {
						for (int l = 0; l < pre2.length(); l++) {
							if (pre2.charAt(l) == String.valueOf(k).charAt(0)) {
								pre3 += String.valueOf(k);
								String tmp1 = pre2.substring(0, l);
								String tmp2 = pre2.substring(l + 1,
										pre2.length());
								pre2 = tmp1 + "0" + tmp2;
								continue IN;
							}
						}
					}
				}
				
				pre2 = pre2X;
				IN:for (int j = 0; j < pre2.length(); j++) {
					for (int k = 0; k <= 9; k++) {
						for (int l = 0; l < pre2.length(); l++) {
							if (pre2.charAt(l) == String.valueOf(k).charAt(0)) {
								pre4 += String.valueOf(k);
								String tmp1 = pre2.substring(0, l);
								String tmp2 = pre2.substring(l + 1,
										pre2.length());
								pre2 = tmp1 + "9" + tmp2;
								continue IN;
							}
						}
					}
				}
				int p5 = Integer.parseInt(pre3);
				int p6 = Integer.parseInt(pre4);
				ar[i + 1] = p5 - p6;
			}
			int jAns = 0;
			int ajAns = 0;
			int ijAns = 0;
			IN:for(int j = 0; j < 21; j++) {
				for(int i = j+1; i < 21; i++) {
					if(ar[i] == ar[j]) {
						jAns = j;
						ajAns = ar[j];
						ijAns = i - j;
						break IN;
					}
				}
			}
			System.out.println(jAns + " " + ajAns + " " + ijAns);
		}
		
	}
}

Measured memory_bytes: 61736
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {
	ll ans = 0,N = 0;
	ll str1[105][28] = { 0 };
	ll str2[105][28] = { 0 };
	char s[105] = "\0";
	string str = "\0";

	scanf("%lld", &N);
	scanf("%s", s);

	str = s;

	for (int i = 0; i < N; i++) {
		for(int j = i;j < N;j++)
			str1[j][str.at(i) - 'a'] = 1;
		for(int j = N - i - 1;j >= 0;j--)
			str2[j][str.at(N - i - 1) - 'a'] = 1;
	}

	for (int i = 0; i < N; i++) {
		ll a = 0;
		for (int j = 0; j < 26; j++) {
			if (str1[i][j] == 1 && str2[i + 1][j] == 1)
				a++;
		}
		ans = max(ans, a);
	}

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

	return 0;
}

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

const int Maxn = 305;

int n, m, k;
char B[Maxn][Maxn];
int S[Maxn][Maxn];
int pnt = 1;
int res[Maxn][Maxn];

int Get(int r1, int r2, int c1, int c2)
{
    return S[r2][c2] - S[r1 - 1][c2] - S[r2][c1 - 1] + S[r1 - 1][c1 - 1];
}

void Solve(int r1, int r2, int c1, int c2)
{
    if (Get(r1, r2, c1, c2) == 1) {
        for (int i = r1; i <= r2; i++)
            for (int j = c1; j <= c2; j++)
                res[i][j] = pnt;
        pnt++;
    } else {
        for (int i = r1; i < r2; i++)
            if (Get(r1, i, c1, c2) > 0 && Get(i + 1, r2, c1, c2) > 0) {
                Solve(r1, i, c1, c2);
                Solve(i + 1, r2, c1, c2);
                return;
            }
        for (int j = c1; j < c2; j++)
            if (Get(r1, r2, c1, j) > 0 && Get(r1, r2, j + 1, c2) > 0) {
                Solve(r1, r2, c1, j);
                Solve(r1, r2, j + 1, c2);
                return;
            }
    }
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%s", B[i] + 1);
        for (int j = 1; j <= m; j++)
            S[i][j] = int(B[i][j] == '#') + S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1];
    }
    Solve(1, n, 1, m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            printf("%d%c", res[i][j], j + 1 <= m? ' ': '\n');
    return 0;
}


Measured memory_bytes: 1536
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	double N,PI = 3.141592653589793;
	cin >> N;

	cout << showpoint;
	cout << fixed;
	cout << setprecision(20);
	cout << 2.0*PI*N << endl;


    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0;
    } else {
        cout << 10;
    }

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3612
def main():
    k = int(input())
    a = list(map(int, input().split()))
    ret = 1
    if 0 in set(a):
        print(0)
        return
    for _a in a:
        ret *= _a
        if ret > 10**18:
            print(-1)
            return
    print(ret)

if __name__=="__main__":
    main()


Measured memory_bytes: 21640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int a,b;
    cin >> a >> b;
    int ans = max(a+b,a-b);
    cout << max(ans,a*b)<<endl;
    return 0;
}

Measured memory_bytes: 256