akhauriyash/Code-Regression huggingface dataset:
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

// output writer
var wtr = bufio.NewWriter(os.Stdout)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func inc(s string, idx int, add int) string {
	a := make([]rune, len(s))
	for i, r := range s {
		if i == idx {
			a[i] = rune(int(r) + add)
		} else {
			a[i] = r
		}
	}
	return string(a)
}

func run(s string, now int) []string {
	prev := 'a'
	for i := 0; i < len(s)-now; i++ {
		p := rune(s[i])
		if p > prev {
			prev = p
		}
	}
	var ans []string
	if now == 1 {
		for i := 0; i <= int(prev)-int('a')+1; i++ {
			ans = append(ans, inc(s, len(s)-now, i))
		}
		return ans
	}
	for i := 0; i <= int(prev)-int('a')+1; i++ {
		ans = append(ans, run(inc(s, len(s)-now, i), now-1)...)
	}
	return ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var a string
	for i := 0; i < n; i++ {
		a = a + "a"
	}
	if n == 1 {
		fmt.Println("a")
		return
	}
	ans := run(a, n-1)
	fmt.Println(strings.Join(ans, "\n"))
}


Measured memory_bytes: 17024
H, W = [int(i) for i in input().split()]

grid = [""]*W

for _ in range(H):
    tmp = input()
    if "."*W != tmp:
        for i, x in enumerate(tmp):
            grid[i] += x
j = len(grid[0])
ans = [""]*j
for row in grid:
    if "."*j != row:
        for i, s in enumerate(row):
            ans[i] += s


for r in ans:
    print(r)


Measured memory_bytes: 9180
N = gets.to_i
ps = N.times.map{gets.to_i}

rev = []
N.times do |i|
    rev[ps[i]] = i
end

max = 0
prev = -1
now = 0
(1..N).each do |i|
    if prev < rev[i]
        now += 1
        max = now if max < now 
    else
        now = 1
    end
    prev = rev[i]
end

puts N - max

Measured memory_bytes: 5428
#include<bits/stdc++.h>
#define ll long long
const int N=200005;
using namespace std;
map<int,int>mp;
int a[N],n;
ll ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++)
		if(i-a[i]>0) mp[i-a[i]]++;
	for(int i=1;i<=n;i++)
		if(mp[i+a[i]]>0) ans+=mp[i+a[i]];
	cout<<ans;
    return 0;
}

Measured memory_bytes: 14728
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;
ll n;

template <class T>
void printVector(const vector<T>& v) {
    for (auto value : v) {
        cout << value << " ";
    }
    cout << endl;
}

void dfs(string alphabets, char mx) {
    if (alphabets.size() == n) {
        cout << alphabets << endl;
        return;
    }

    for (char c = 'a'; c <= mx + 1; c++) {
        string s = alphabets;
        s += c;
        dfs(s, max(c, mx));
    }


}

// https :  // atcoder.jp/contests/panasonic2020/tasks/panasonic2020_d
int main() {
    cin >> n;
    dfs("", 'a' - 1);
    return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
void selectionSort(int[], int);
void swap(int *, int *);
int main()
{
  int N,A[100],i,minj;

  scanf("%d",&N);

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

  selectionSort(A,N);

  return 0;

}

void selectionSort(int A[], int N)
{
  int minj,i,j,count=0;

  for(i=0; i<N; i++)
    {
      minj=i;
      for(j=i; j<N; j++)
	{
	  if(A[j]<A[minj])
	    {
	      minj=j;
	    
	    }
	  
	}
      if(minj!=i)
	{
	  swap(&A[i],&A[minj]);
	  count++;
	}
    }
  for(i=0; i<N; i++)
    {
      if(i!=N-1) printf("%d ",A[i]);
      else printf("%d",A[i]);
    }
  printf("\n");
  printf("%d\n",count);
}



void swap(int *a, int *b)
{
  int temp;

  temp=*a;
  *a=*b;
  *b=temp;
}



Measured memory_bytes: 2104
#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 vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#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 998244353
//priority_queue<int,vector<int>, greater<int> > q2;


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

	
	int N; cin >> N;
	VI A(N), B(N);
	REP(i, N)cin >> A[i] >> B[i];

	SORT(A);
	rSORT(B);
	if (N % 2) {
		cout << B[N / 2] - A[N / 2] + 1 << endl;
	}
	else {
		int a = (A[N / 2] + A[(N - 1) / 2]);
		int b = (B[N / 2] + B[(N - 1) / 2]);
		cout << (b - a) + 1 << endl;
	}



	return 0;
}



Measured memory_bytes: 6328
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  string a;
  cin >> a;

  if(a[0] != 'A'||isupper(a[a.size() - 1])||isupper(a[1])){cout << "WA" << endl;return 0;}
  int Cnum = 0;
  for(int i = 2; i <= a.size() - 2; i ++ ){
    if(a[i] == 'C'){
      Cnum ++;
    }else if(!islower(a[i])){
      cout << "WA" << endl;return 0;
    }
  }
  if(Cnum != 1){
    cout << "WA" << endl;return 0;
  }
  cout << "AC" << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
#define Max1 100000
#define Max2 50000
main(){
  int i;
  int n, q;
  int S[Max1], T[Max2];
  int left, right, mid, count = 0, key;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
  }

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

    left = 0;

    right = n;

    key =  T[i];

    while(left<right){

      if((left + right)%2 == 0) mid = (left + right)/2;

      else  mid = ( left + right -1)/2;

      if(key == S[mid]){count++;
        break;
      }

      else if(key < S[mid])right = mid;

      else if(key > S[mid])left = mid+1;
    }
  }
  printf("%d\n", count);

  return 0;

}

Measured memory_bytes: 1184
package main

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

const mod int = 1000000007

func main() {
	n := getInt()
	k := getInt()

	as := make([]int, n)
	for i := range as {
		as[i] = getInt()
	}

	x := 0
	y := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if as[i] > as[j] {
				y++
				if i < j {
					x++
				}
			}
		}
	}

	ans := 0
	ans = (ans + x*k) % mod
	ans = (ans + y*((k*(k-1)/2)%mod)) % mod

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  int n, k, p;

  scanf("%d", &n);
  while (n--) {
    scanf("%d %d", &k, &p);

    if (k % p)
      printf("%d\n", k % p);
    else
      printf("%d\n", p);
  }

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll x;
void input(){
    fast_io();
    cin >> x;
}

int solve(){
    ll ans = 0;
    ans += 2*(x/11);
    x%=11;
    ans += (x+5)/6;
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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

A, B = MAP()

if(B%A == 0):
	print(A + B)
else:
	print(B - A)


Measured memory_bytes: 60140
import java.util.*;


public class Main {
    static void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = 0;
        int[] ns = new int[n];
        for(int i = 0; i < n; i++){
            ns[i] = sc.nextInt();
        }
        boolean done = false;
        while(!done) {
            for (int i = 0; i < ns.length ; i++) {
                if (ns[i] % 2 == 1) done = true;
                else ns[i] /= 2;
            }
            if(!done) max++;
        }

        System.out.println(max);
    }

    public static void main(String[] args) {
        solve();
    }
}


Measured memory_bytes: 23636
N, Q = map(int, input().split())
S = input()
target = 'AC'
shiftID = len(target) - 1

found_id = []

for i in range(N-shiftID):
    if S[i:i+len(target)] == target:
        found_id.append(i)

found_count = [0 for _ in range(N+1)]

for i in range(shiftID+1, N+1):
    found_count[i] = found_count[i-1] + (1 if S[i-shiftID-1:i]=='AC' else 0)

for _ in range(Q):
    l, r = map(int, input().split())
    print(found_count[r] - found_count[l])


Measured memory_bytes: 9668
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; }
template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<double> p(N);
  cin >> p;
  auto dp = make_v<double>(N+1,N+1);
  dp[0][0] = 1;
  REP(i,N) FOR(j,0,i+1) {
    dp[i+1][j+1] += dp[i][j]*p[i];
    dp[i+1][j] += dp[i][j]*(1-p[i]);
  }
  double ans = 0;
  for (int i = N/2+1; i <= N; i++) ans += dp[N][i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 70784
#include<iostream>
using namespace std;
int up, down;

void clear(){
	up = down = 0;
}

void up_len(int len){
	if(up < len) up=len;
}

void down_len(int len){
	if(down < len) down=len;
}

int main(){
	int n,m,len,prev;
	bool first;
	while(cin >> n){
		for(int i=0; i<n; i++){
			cin >> m;
			clear();
			prev = 0;
			first = true;
			for(int i=0; i<m; i++){
				cin >> len;
				if(!first){
					if(len > prev) up_len(len-prev);
					if(len < prev) down_len(prev-len);
				}
				else first = false;
				prev = len;
			}
			cout << up << " " << down << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
# -*- coding:utf-8 -*-
import sys
H, W = map(int, input().split())
word = { key:chr(key+65) for key in range(W) }
S = [ list(input().split()) for _ in range(H) ]
for h in range(H):
    for w in range(W):
        if S[h][w] == 'snuke':
            print(str(word[w])+str(h+1))
            sys.exit()
        else:
            pass

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;
 
int main() {
  ll N, K;
  cin >> N >> K;
  ll cnt = 0;
  ll sum = 0;
  vector<ll> a(N);
  for(ll i = 0; i < N; i++) {
    cnt = i + 1;
    for(ll j = 0; cnt / 4 < K; j++) {
      if(K <= cnt) {
        a.at(i) = j;
        break;
      }
      else cnt *= 2;
    }
    sum += pow(2, a.at(0) - a.at(i));
  }
  cout << fixed << setprecision(15) << double(sum) / double(N) / double(pow(2, a.at(0))) << endl;
}

Measured memory_bytes: 1024
n = int(input())
t, a = map(int, input().split())
array = list(map(int, input().split()))

sa = 10000
for i in range(n):
    if sa > abs(a - (t - array[i] * 0.006)):
        sa = abs((a - (t - array[i] * 0.006)))
        ans = i + 1

print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var ans float64
	for i := 1; i <= n; i++ {
		d := i
		m := float64(n)
		p := 1.0 / m
		if i >= k {
			ans += p
			continue
		}
		for d < k {
			d *= 2
			p *= 0.5
		}
		ans += p
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)
	{
		cout<<1;
	}
	else if(a==b||b==c||a==c)
	{
		cout<<2;
	}
	else
	{
		cout<<3;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F(i,a,b) for(i = a; i <= b; i ++)
#define RF(i,a,b) for(i = a; i >= b;i --)
#define sz(a) sizeof(a)
ll INFINITE = 1000000001LL;
using namespace std;

typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef unordered_map<int,int> umii;
typedef unordered_map<char,int> umci;

int n , v, max_v = 0;
ll w;
vector<pii> v_items;
ll dp[101][100001];

//dp[i][v] = the minimum weight required to get v value from 0.....i items 

void solve()
{
    int items, val, i;
    cin>>n>>w;       
    F(i,0,n - 1)
    {
        pii item;
        cin>>item.first>>item.second;
        v_items.push_back(item);
    }
    F(items, 0, n)
        F(val, 0, 100000)
        {
            if(val == 0)
                dp[items][val] = 0;
            else
                dp[items][val] = INFINITE;    
        }
    ll max_v;
    F(items,1,n)
    {
        F(val,0,100000)
        {
            if((dp[items - 1][val] + v_items[items - 1].first)<= w)
            {
                dp[items][val + v_items[items - 1].second] = min(dp[items - 1][val] + v_items[items - 1].first, 
                                                                dp[items][val + v_items[items - 1].second]);
            }        
            dp[items][val] = min(dp[items][val], dp[items - 1][val]);
        }
    }
    F(i,0,100000)
    {
        if(dp[n][i] != INFINITE)
            max_v = i;
    }
    cout<<max_v<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#else
    //#endif
    solve();
}


Measured memory_bytes: 79232
import scala.io.StdIn
object Main extends App {
  val input = io.Source.stdin.getLines().mkString("\n")
  val list = input.split("\n").drop(1).map(_.split(" ").map(_.toInt)).map{ case Array(t,x,y) => (t,x,y)}.toList

  if (((0,0,0)::list).zip(list).forall { case ((t,x,y),(nextT,nextX,nextY)) => {
    val dt = nextT - t;
    val dist = (nextX - x).abs + (nextY - y).abs;
    dt >= dist && dist % 2 == dt % 2
  }}) {
    println("Yes")
  } else {
    println("No")
  }
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::pair<int, int> a[n];
	int max_range = 0;
	int l_max = 0, r_min = 1000000001;
	for (int i = 0; i < n; i++) {
		int l = ri() - 1;
		int r = ri();
		max_range = std::max(max_range, r - l);
		l_max = std::max(l_max, l);
		r_min = std::min(r_min, r);
		a[i] = {l, r};
	}
	int res = std::max(0, r_min - l_max) + max_range;
	std::sort(a, a + n);
	int r_sum_min[n];
	r_sum_min[n - 1] = a[n - 1].second;
	for (int i = n - 2; i >= 0; i--) r_sum_min[i] = std::min(r_sum_min[i + 1], a[i].second);
	for (int i = 0; i + 1 < n; i++) {
		res = std::max(res, std::max(0, r_min - a[i].first) + std::max(0, r_sum_min[i + 1] - l_max));
	}
	std::cout << res << std::endl;
	return 0;
}



Measured memory_bytes: 1408
def calc_number_of_coin(sum, coins):
    dp = [999999999]*(sum+1)    #  ??????????????????????????????????????????????????????????????????dp[sum]????????????????±????????????????????´?????????????9999???????????????????????°
    dp[0] = 0                   #  0??????????????????????????¶???????????°???0???
    
    # i??????????????????????????????????¨????, j????????????????¨???????
    # ?????????????????¨??§???????????????????¨???????1?¨?????????????????????????????????????????????°????¨??????????
    # ????????????i???????????§?????¨??§???????????????????¨????????¢??????????????????????????¶???????
    for i in range(len(coins)):
        for j in range(coins[i], sum+1):
            # dp[j]: ??????????????????????????°????¢?????????????????????°?????????????????´???
            # dp[j - coins[i]] + 1:  ??°???????????¨??§????????????????????£??????????????????????????¨??§?????????????????°???????????±?????????
            #                        ?????????+1???????????§??????????¨???????-coins[i]????????????????????????????????°????????????+1???coins[i]???
            dp[j] = min(dp[j], dp[j-coins[i]]+1)
    return dp[sum]


if __name__ == '__main__':
    # ??????????????\???
    # f = open('input.txt')
    # sum, _ = [int(x) for x in f.readline().strip().split(' ')]
    # coins = [int(x) for x in f.readline().strip().split(' ')]

    sum, _ = [int(x) for x in input().strip().split(' ')]
    coins = [int(x) for x in input().strip().split(' ')]

    # ???????????????
    result = calc_number_of_coin(sum, coins)

    # ???????????¨???
    print(result)

Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    if (s.size() % 2) {
        cout << "No\n";
        return 0;
    }

    for (int i = 0; i < s.size(); i++) {
        if (i % 2 && s[i] != 'i' ||
            i % 2 == 0 && s[i] != 'h') {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}   

Measured memory_bytes: 256
x,y,a,b,c = gets.chomp.split.map(&:to_i)
ps = gets.chomp.split.map(&:to_i).sort
qs = gets.chomp.split.map(&:to_i).sort
rs = gets.chomp.split.map(&:to_i).sort
array = (ps.slice(a-x..-1) + qs.slice(b-y..-1) + rs).sort

puts array.slice(array.size-x-y..-1).inject(:+)


Measured memory_bytes: 34316
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n;
    cin >> n;
    int ans = 1000-(n%1000);
    if(ans == 1000) ans = 0;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3648
//VS2015エラー回避用
#define _CRT_SECURE_NO_WARNINGS 0 
//include
#include<stdio.h>
//関数プロトタイプ宣言
void probremA(void);
void probremB(void);
//メイン関数
int main(void) {
	//A問題
	//probremA();
	
	//B問題
	probremB();
	
	//getchar();
	//終了
	return 0;
}
//A問題
void probremA(void) {
	int i;			//入力数値:人数
	int n=0;		//計算結果:個数
	//入力処理
	scanf("%d", &i);

	//個数の計算
	for (int j = 0; j <= i; j++) {
		n += j;
	}
	//出力処理
	printf("%d\n", n);

	return;
}
//B問題
void probremB(void) {
	char s[11];		//入力文字列
	char o[11];		//出力文字列
	int count_s = 0;//インデックス
	int	count_o = 0;//インデックス
	
	//入力処理
	scanf("%s", &s);

	//出力文字列の計算
	while(s[count_s]!='\0'){
		if (s[count_s] == '0') {
			o[count_o] = '0';
			count_o++;
		}else if(s[count_s] == '1') {
			o[count_o] = '1';
			count_o++;
		}else if (s[count_s] == 'B') {
			count_o = count_o == 0 ? 0 : count_o - 1;
		}
		//次の文字を判別
		count_s++;
	}
	//出力処理
	for (int i = 0; i < count_o; i++) {
		printf("%c", o[i]);
	}

	return;
}

Measured memory_bytes: 128
package main

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

func main() {
	N := sc.nextInt()
	S := sc.next()

	SArr := strings.Split(S, "")
	ansArr := make([]string, len(S))
	alphaArr := [...]string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
	mmap := make(map[string]int)
	for i, v := range alphaArr {
		mmap[v] = i
	}
	// alpha := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	for i := 0; i < len(S); i++ {
		var c string
		c = SArr[i]
		index := (mmap[c] + N) % 26

		ansArr[i] = alphaArr[index]
	}
	fmt.Println(strings.Join(ansArr, ""))
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	string s; cin >> s;
	const int p = 26;
	vector<int> num(p, 0);
	for (int i = 0; i < s.size(); i++) {
		num[s[i] - 'a'] = 1;
	}
	int index = -1;
	for (int i = 0; i < p; i++) {
		if (num[i] == 0) {
			index = i;
			break;
		}
	}
	if (index == -1) cout << "None" << endl;
	else cout << (char)(index + 'a') << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n,0);
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i] *= 2LL;
    if(i)a[i] += a[i-1];
  }
  ll half = a[n-1]/2LL;
  ll dist = a[n-1];
  for(int i=0; i<n; i++){
    dist = min(dist, abs( half - a[i] ) );
  }
  cout << dist << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
int mod = 1000000007;

class Solution {
public:

    int c(int n, int m, const vector<int>& t1, const vector<int>& t2, int k) {
       int res = 0;

       vector<ll> s1(n + 1 , 0), s2(m + 1, 0);
       for(int i = 1; i < n + 1; ++i) { s1[i] = s1[i - 1] + t1[i - 1]; }
       for(int i = 1; i < m + 1; ++i) { s2[i] = s2[i - 1] + t2[i - 1]; }

       ll l = 0, r = n + m;
       while(l <= r) {
           ll mid = (l + r) / 2;

           ll tres = INT64_MAX;
           for(int k1 = 0; k1 <= mid; ++k1) {
               if(k1 > n || mid - k1 > m) {continue;}
               tres = min(tres, s1[k1] + s2[mid - k1]);
           }
           if(tres <= k) {
               res = mid;
               l = mid + 1;
           }
           else {
               r = mid - 1;
           }
       }



       return res;
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> t1(n), t2(m);
    for(int i = 0; i < n; ++i) cin >> t1[i];
    for(int i = 0; i < m; ++i) cin >> t2[i];
    Solution zhy;
    cout << zhy.c(n, m, t1, t2, k) << endl;
    return 0;
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, a[101], dp[101][76];

int main() {
	cin >> N;
	for (int i = 1; i != N + 1; ++i) {
		int k = i;
		int j = 2;
		while (k != 1) {
			if (k%j)
				++j;
			else {
				k /= j;
				++a[j];
			}
		}
	}
	dp[0][1] = 1;
	for (int i = 1; i != N + 1; ++i) {
		for (int j = 1; j != 76; ++j) {
			for (int k = 0; k != a[i]+1 && (k + 1)*j <= 75; ++k) {
				dp[i][(k + 1)*j] += dp[i - 1][j];
			}
		}
	}
	cout << dp[N][75] << endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    from collections import defaultdict
    from itertools import combinations
    n = int(input())
    d = defaultdict(int)
    for i in range(n):
        s = input()
        d[s[0]] += 1
    ans = 0
    for x, y, z in combinations(["M", "A", "R", "C", "H"], 3):
        ans += d[x] * d[y] * d[z]
    print(ans)
    return


solve()


Measured memory_bytes: 9416
n,a,b = gets.chomp.split().map(&:to_i)
i = 1
count = []
for i in 1..n
    j = i.to_s
    m = j.split("").map(&:to_i).inject(:+)
    if (a <= m) && (m <= b)
        count.push(i)
    end
end
print count.inject(:+)


Measured memory_bytes: 2172
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7) && a+b+c == 17){
        cout << "YES";
    }  
    else
    {
        cout << "NO";
    }
    
    cout << endl;
}


Measured memory_bytes: 256
def solve(s, i)
  @s = s
  @target = i
  @i = 0
  answer = parse[i]
  return answer ? answer : "0"
end

def parse
  return "" if @i >= @s.size
  result = ""
  case @s[@i]
    when /[0-9]/
      n = number
      case @s[@i]
        when "("
          @i += 1
          word = parse
          @i += 1
        else
          word = @s[@i]
          @i += 1
      end
      n.times do
        result += word
        return result if result.size > @target
      end
    when ")"
      return ""
    else
      result += @s[@i]
      @i += 1
  end
  result + parse
end

def number
  n = 0
  while @s[@i] =~ /[0-9]/ do
    n *= 10
    n += @s[@i].to_i
    @i += 1
  end
  n
end

until (s,i=gets.split).all?{|w|w=="0"} do
  puts solve(s, i.to_i)
end

Measured memory_bytes: 18740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=100010;
int n,x,o1,o2,e1,e2,mo1,mo2,me1,me2,ans;
map<int,int> o,e;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>x;
    if(i&1) o[x]++;
    else e[x]++;
  }
  for(auto i:o) if(i.second>mo1) mo1=i.second,o1=i.first;
  for(auto i:e) if(i.second>me1) me1=i.second,e1=i.first;
  for(auto i:o) if(i.second>mo2 && i.first!=o1) mo2=i.second,o2=i.first;
  for(auto i:e) if(i.second>me2 && i.first!=e1) me2=i.second,e2=i.first;
  // cout<<o1<<" "<<o2<<" "<<e1<<" "<<e2<<endl;
  if(o1!=e1) ans=n-o[o1]-e[e1];
  else ans=n-max(o[o1]+e[e2],e[e1]+o[o2]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
import collections

n = int(input())
lis = list(map(int,input().split()))
 
clis = collections.Counter(lis)

count = 0
for kk in clis.values():
	count += (kk * (kk - 1)) // 2
    
for ll in lis:
	print(count - clis[ll] + 1)

Measured memory_bytes: 26908
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   scanf("%d",&n);
  if(n%2==0)
        printf("%.10lf\n",double(n/2)/n);
  else
       printf("%.10lf\n",double((n/2)+1)/n);
  return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long int n,d;
  cin>>n>>d;
  int x[n],y[n],cnt=0;
  for(int i=0;i<n;i++)
  {
    cin>>x[i];
    cin>>y[i];
    long long int p=x[i];
    long long int q=y[i];
    long long int temp=(p*p)+(q*q);
    if(temp<=d*d)
      cnt++;
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 4716
using System;

namespace abc_049_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            if (a == "a" || a == "u" || a == "i" || a == "e" || a == "o")
            { Console.WriteLine("vowel"); }
            else { Console.WriteLine("consonant"); }
        }
    }
}


Measured memory_bytes: 2648
#include<stdio.h>
int main(void){
  
	int n, i;
	int s = 100000;

	scanf("%d", &n);

	for(i = 0; i< n; i++){
		s = s * 1.05;
		if((s % 1000) != 0){
			s = (s / 1000 + 1) * 1000;
		}
	}

	printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef priority_queue<int,vector<int>,greater<int>> pqmini; //top->mini;
typedef priority_queue<int> pqmaxi;  //push(xx) top->maxi,pop();

ll mod=1e9+7;
ll dp[10004][105][2];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  pqmini p,q;
  pqmaxi r;

  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  rep(i,a){
    int tmp;
    cin>>tmp;
    p.push(tmp);
  }
  rep(i,b){
    int tmp;
    cin>>tmp;
    q.push(tmp);
  }
  rep(i,c){
    int tmp;
    cin>>tmp;
    r.push(tmp);
  }
  rep(i,a-x)p.pop();
  rep(i,b-y)q.pop();
  rep(i,x){
    int tmp=p.top();
    p.pop();
    r.push(tmp);
  }
  rep(i,y){
    int tmp=q.top();
    q.pop();
    r.push(tmp);
  }
  ll cnt=0;
  rep(i,x+y){
    cnt+=r.top();
    r.pop();
  }
  cout<<cnt<<endl;
  return 0;
  }


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	string s,t;
	cin>>s>>t;
	int ans=2*N;
	rep(i,N){
		if(s.substr(i,N-i)==t.substr(0,N-i)){
			ans-=N-i;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <stdio.h>
#include <string>
#include <iostream>

int main(int argc, const char * argv[]) {

   std::string str1;
   std::cin >> str1;
   std::string s2 = str1.substr(0, 5);
   std::string s3 = str1.substr(6, 7);
   std::string s4 = str1.substr(14, 5);
    
    
    std::cout << s2 << " " << s3 << " " << s4;
    
    return 0;
}

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

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, 26) cin >> c[i];
    rep(i, D) {
        rep(j, 26) { cin >> s[i][j]; }
    }
    vector<int> ans(D);
    vector<ll> Cost(26, 0);
    rep(i, 26) Cost[i] = c[i];
    rep(i, D) {
        vector<ll> X(26);
        rep(j, 26) X[j] = s[i][j] + Cost[j];
        auto it = max_element(X.begin(), X.end());
        int index = it - X.begin();
        ans[i] = index + 1;
        Cost[index] = 0;
        rep(j, 26) Cost[j] += c[j];
    }
    rep(i, D - 1) cout << ans[i] << " ";
    cout << ans[D - 1] << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  string s;
  s += char(s1[0] - 32);
  s += char(s2[0] - 32);
  s += char(s3[0] - 32);
  cout << s << endl;
}

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

using namespace std;

const int N = 305;
int n, m, k, idx[N * N], c, b[N], mnr = 1e9, extra;
char a[N][N];

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

    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
            if (a[i][j] == '#')
            {
                b[i] = 1;
                mnr = min(mnr, i);
            }
        }
    }

    for (int i = 1; i <= k; i++)
    {
        idx[i] = i;
    }
    idx[0] = 1;

    extra = mnr;

    vector<int> pre;
    for (int i = mnr; i < n; i++)
    {
        vector<int> ans;

        if (!b[i])
        {
            for (auto x : pre)
            {
                cout << x << " ";
            }
            cout << "\n";
            continue;
        }

        int mn = idx[c + 1];
        for (int j = 0; j < m; j++)
        {
            if (a[i][j] == '#')
            {
                c++;
            }
            ans.push_back(max(mn, idx[c]));
        }

        if (i == mnr)
        {
            for (int k = 0; k < extra; k++)
            {
                for (auto x : ans)
                {
                    cout << x << " ";
                }
                cout << "\n";
            }
        }

        for (auto x : ans)
        {
            cout << x << " ";
        }
        cout << "\n";

        pre = ans;
    }
}

Measured memory_bytes: 1280
N, M = map(int, input().split())
if N ==1 and M == 0:
    print(0)
    exit()
d = dict()
d[1] = 1
for o in range(2,N+1):
    d[o] = 0
S = []
C = []
for i in range(M):
    s, c = map(int,input().split())
    S.append(s)
    C.append(c)
    d[s] = c
if (1, 0) in d.items() and N != 1:
    print(-1)
    exit()
for j in range(0,M-1):
    for k in range(j+1, M):
        if S[j] == S[k] and C[j] != C[k]:
            print(-1)
            exit()
num = 0
for p in range(1,N+1):
    num += d[p]*10**(N-p)
print(num)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
string s;
int main(){
	cin>>s;
	if(s=="AKIHABARA"||s=="AKIHABAR"||s=="AKIHBARA"||s=="KIHABARA"||s=="KIHBARA"||s=="KIHABRA"||s=="KIHABRA"||s=="KIHABAR"){
		puts("YES"); return 0;
	}
	if(s=="AKIHBRA"||s=="AKIHBAR"||s=="AKIHABR"||s=="KIHBRA"||s=="KIHBAR"||s=="KIHABR"||s=="AKIHBR"||s=="KIHBR"){
		puts("YES");
	}else puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) cin >> A[i][j];
  }
  cin >> N;
  for (int i = 0; i < N; i++) cin >> b[i];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      appear[i][j] = false;
      for (int k = 0; k < N; k++) {
        if (A[i][j] == b[k]) appear[i][j] = true;
      }
    }
  }
  string ANS = "No";
  for (int i = 0; i < 3; i++) {
    if (appear[i][0] && appear[i][1] && appear[i][2]) ANS = "Yes";
  }
  for (int i = 0; i < 3; i++) {
    if (appear[0][i] && appear[1][i] && appear[2][i]) ANS = "Yes";
  }
  if (appear[0][0] && appear[1][1] && appear[2][2]) ANS = "Yes";
  if (appear[0][2] && appear[1][1] && appear[2][0]) ANS = "Yes";
  cout << ANS << endl;
  return 0;
}

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

using namespace std;

const int maxn=700;
double dp[maxn];
vector<int> g[maxn];
double ans;
int n, m;
void check(int block){
    dp[n] = 0;
    for(int i=n-1;i;i--){
        double sum = 0.0;
        double maxi = 0.0;
        int num = g[i].size();
        for(auto to : g[i]) {
            sum += dp[to];
            maxi = max(maxi, dp[to]);
        }
        if(i == block && num >= 2) {
            num--;
            sum -= maxi;
        }
        dp[i] = sum / num + 1;
    }
    ans = min(ans, dp[1]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;i++){
        g[i].clear();
    }
    for(int i=0;i<m;i++){
        int x, y;
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
    }
    ans = 1e8;
    for(int i=0;i<n;i++){
        check(i);
    }
    printf("%.10f\n",ans);

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N, T[100];
    cin >> N;
    for(int i=0;i<N;i++)
        cin >> T[i];
    int M, P[100], X[100];
    cin >> M;
    for(int i=0;i<M;i++)
        cin >> P[i] >> X[i];
    int ans;
    for(int i=0;i<M;i++){   // それぞれのドリンクについて
        ans = 0;
        for(int j=0;j<N;j++){
            if(j == P[i] - 1){
                ans += X[i];
            }else{
                ans += T[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

struct _in
{
	const _in operator , (int&a) const
	{
		a = 0;
		int f = 1;
		char k = getchar ();
		while (k > '9' || k < '0')
		{
			if (k == '-')
				f = -1;
			k = getchar ();
		}
		while (k >= '0' && k <= '9')
		{
			a = a * 10 + k - '0';
			k = getchar ();
		}
		a *= f;
		return*this;
	}
} in;

const int N = 1000 + 5;
int info[N][N], h, w, a, b, x1, x2, cntl[N], cur[N];

int main ()
{
	scanf ("%d%d%d%d", &h, &w, &a, &b);
	x1 = b, x2 = a;
	for (int i = 1; i <= b; ++i)
	{
		for (int j = 1; j <= a; ++j)
		{
			info[i][j] = 1;
			cntl[j]++;
		}
	}
	for (int i = b + 1; i <= h; ++i)
	{
		for (int j = 1; j <= w - a; ++j)
		{
			info[i][j] = 1;
			cntl[j]++;
		}
	}
	for (int i = 1; i <= h; ++i)
		cur[i] = w;
	for (int i = 1; i <= w; ++i)
	{
		int c1 = i > a ? h - b : b, tcnt = 0, curx;
		for (curx = 1; curx <= h; ++curx)
		{
			if (info[curx][i]) tcnt++;
			if (c1 == tcnt) break;
		}
		for (int j = curx + 1; j <= h; ++j)
		{
			if (!info[j][i]) continue;
			swap (info[j][i], info[j][ cur[j] ]);
			cntl[i]--;
			cntl[ cur[j] ]--;
			cur[j]--;
		}
	}
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			printf ("%d", info[i][j]);
		}
		puts ("");
	}
	return 0;
}


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

using namespace std;


void dfs(int cur, int pre, vector<vector<int>> &graph, vector<int> &cnt, vector<int> &ans) {
    ans[cur] += cnt[cur];
    for (int next: graph[cur]) {
        if (next != pre) {
            ans[next] += ans[cur];
            dfs(next, cur, graph, cnt, ans);
        }
    }
}


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

    vector<vector<int>> graph(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> cnt(N);
    for (int j = 0; j < Q; j++) {
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }

    vector<int> ans(N);

    dfs(0, -1, graph, cnt, ans);

    for (int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 30464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans=0;
    for(int i = 1; i <= n; i++){
        ans += i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j,k) for(ll i=(ll)j;i<(ll)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vec<P> v(n);
    rep(i,0,n)v[i].fi=v[i].se=0;
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        if(a==1)v[b-1].fi++;
        if(b==n)v[a-1].se++;
    }
    
    rep(i,0,n){
        if(v[i].fi&&v[i].se){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
li = [int(i) for i in input().split()]
times = 1

if 0 in li:
    times = 0
    print(0)
else:
    for k in range (0, n):
        times = times * li[k]
        if times > 10**18:
            print(-1)
            break
  
if times <= 10**18 and times != 0:
  print(times)

Measured memory_bytes: 21788
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

set<int> x;
int main() {
	int n;
	int a;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		x.insert(a);
	}
	if (x.size() == n) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 9600