akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(input()) for _ in range(N)]

ans=0
for i in range(N-1):
  if A[i]%2 ==1 and A[i+1]:
    A[i+1] -= 1
    ans += 1
  ans+= A[i]//2
ans+=A[N-1]//2
print(ans)

Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int existe[100001];
int main()
{

ll n;
cin>>n;

ll arr[n];
ll sum =0;
for(int index =0;index<n;index++)
{
    cin>>arr[index];
    existe[arr[index]]++;
    sum+=arr[index];
}

ll q;
cin>>q;

while(q--)
{
    ll b,c;
    cin>>b>>c;
    
    sum-=(existe[b]*b);
    sum+=(existe[b]*c);
    existe[c]+=existe[b];
    existe[b]=0;
    
    cout<<sum<<endl;
}
    return 0;
}


Measured memory_bytes: 4780
n, m = map(int, input().split())
li = [int(input()) for _ in range(m)]
mod = 10**9 + 7

dp = [-1] * (n+1)
dp[0] = 1

for i in li:
    dp[i] = 0

for i in range(1,n+1):
    if dp[i] == 0:
        continue
    
    if i == 1:
        dp[1] = 1
    else:
        dp[i] = (dp[i-1] + dp[i-2])%mod
        
print(dp[-1])


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

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

  vector<int> a(n, 0);

  for (int i = 0; i < n; i++)
    cin >> a[i];

  int l = 0;
  int r = 0;
  int tmp = 0;
  long long count = 0;

  for (l = 0; l < n; l++)
  {

    if (l < r)
      count += (long long )  r - l;
    // printf("count:%d\n", count);

    for (; (tmp & a[r]) == 0 && r < n; r++)
    {
      // printf("tmp:\t");
      // for (int i = 31; i >= 0; i--)
      // {
      //   putchar('0' + !!(tmp & 1 << i));
      // }
      // putchar('\n');

      // printf("a[%d]:\t", r);
      // for (int i = 31; i >= 0; i--)
      // {
      //   putchar('0' + !!(a[r] & 1 << i));
      // }
      // putchar('\n');

      // cout << "(" << l << "," << r <<  ")" << endl;

      count++;
      // printf("count:%d\n", count);
      tmp |= a[r];
    }

    // printf("tmp:\t");
    // for (int i = 31; i >= 0; i--)
    // {
    //   putchar('0' + !!(tmp & 1 << i));
    // }
    // putchar('\n');

    // printf("a[%d]:\t", r);
    // for (int i = 31; i >= 0; i--)
    // {
    //   putchar('0' + !!(a[r] & 1 << i));
    // }
    // putchar('\n');

    tmp -=a[l];
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
As = [int(i) for i in list(input().split())]

result = []

length = len(As)
before_res = 0
for i in range(length):
	res = 0
	if i == 0:
		for j in range(length):
			if (i+j)%2 == 0:
				res += As[(i+j)%length]
			else:
				res -= As[(i+j)%length]
	else:
		res = 2*As[(i-1)%length] - before_res
	before_res = res
	result.append(str(abs(res)))

print(" ".join(result))

Measured memory_bytes: 17352
N, K = map(int, input().split())
moves = [0] + list(map(int, input().split()))
points = [0] + list(map(int, input().split()))
INF = 10**10

arrived = [0 for _ in range(N+1)]
answer = -INF
for move in range(1, N+1):
  if arrived[move] == 1:
    continue
  else:
    arrived[move] = 1
    komas = [move]
    next = moves[move]
    while(arrived[next] == 0):
      arrived[next] = 1
      komas.append(next)
      next = moves[next]
    len_k = len(komas)
    sum_k = [0 for _ in range(len_k*2)]
    sum_k[0] = points[komas[0]]
    for i in range(1, len_k*2):
      sum_k[i] = sum_k[i-1] + points[komas[i%len_k]]
    scores = [-INF for _ in range(len_k+1)]
    for j in range(len_k):
      for k in range(1, len_k+1):
        scores[k] = max(scores[k], sum_k[j+k] - sum_k[j])
    if K > len_k and scores[len_k] > 0:
      max_s = -INF
      max_k = -INF
      for m in range(1, len_k+1):
        if m <= K%len_k:
          max_k = max(max_k, scores[m])
        max_s = max(max_s, scores[m])
      answer = max(answer, max_k+scores[len_k]*(K//len_k), max_s+scores[len_k]*(K//len_k-1))
    else:
      max_s = -INF
      for m in range(1, min(K, len_k)+1):
        max_s = max(max_s, scores[m])
      answer = max(answer, max_s)
print(answer)

Measured memory_bytes: 75268
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?

		int N = 0, T, E;	//Nテ」ツ?ッテァツ?づヲツ卍づィツィツ暗」ツ?ョテ・ツ?凝ヲツ閉ー Tテ」ツ?ッテヲツクツャテ」ツつ甘」ツ?淌」ツ??ヲツ卍づゥツ鳴?Eテ」ツ?ッティツィツアテ・ツョツケティツェツ、テ・ツキツョ
							//T-Eテァツァツ津」ツ?凝」ツつ欝+Eテァツァツ津、ツサツ・テ・ツ??」ツ?ョテヲツ卍づゥツ鳴禿」ツつ津ヲツクツャテ」ツつ甘」ツ?淌」ツ??
		
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		T = sc.nextInt();
		E = sc.nextInt();
		
		int[] x = new int[N];
		
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		
		//テ」ツ?凖」ツ?ケテ」ツ?ヲテ」ツ?ョx[i]テ」ツ?ォテ・ツッツセテ」ツ?療」ツ?ヲテヲツ篠「テァツエツ「テ」ツ?凖」ツつ?
		boolean found = false;
		for(int i = 0; i < N; i++) {
			if(isCountable(x[i], T, E)) {
				System.out.println(i+1);
				found = true;
				break;
			}
		}
		if(found == false) System.out.println(-1);
		
	}

	/**
	 * xテ」ツ?ョテ・ツ?催ヲツ閉ーテ」ツ?卦-Eテ」ツ?凝」ツつ欝+Eテ」ツ?ョテァツッツ?・ツ崢イテ・ツ??」ツ?ォテ・ツ渉偲」ツ?セテ」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツつ津・ツ按、テ・ツョツ堙」ツ?凖」ツつ?
	 * @param x
	 * @param T
	 * @param E
	 * @return
	 */
	static boolean isCountable(int x, int T, int E) {
		/*
		 * テ」ツ?淌」ツ?ィテ」ツ?暗」ツ?ーx=10, T=100, E=2テ」ツ?ョテ」ツ?ィテ」ツ??
		 * 90, 100, 110テ」ツ??」ツ?妥ヲツ篠「テァツエツ「テ」ツ?凖」ツつ古」ツ?ーテ・ツ債?・ツ按?
		 * 90... (100-2)/10 * 10
		 * 110... ((100+2)/10 + 1) * 10
		 * 90 = 10nテ」ツ?ィテ」ツ?ェテ」ツつ凝」ツつ暗」ツ??」ツ?ォnテ」ツつ津・ツョツ堙」ツつ?」ツつ?
		 */
		
		int n = (T-E) / x;
		int search = n * x;
		do {
			if(T-E <= search && search <= T+E) return true;
			search = (++n) * x;
		}while(search <= T+E);
		
		return false;
	}
	
}

Measured memory_bytes: 18308
a,b=map(int,input().split())
a-=1
b-=1
l=[['#']*100 for _ in range(20)]+[['.']*100 for _ in range(20)]
for i in range(0,a//50*2,2):
    l[i]=['.','#']*50
for i in range(0,a%50*2,2):
    l[a//50*2][i]='.'
for i in range(21,21+b//50*2,2):
    l[i]=['#','.']*50
for i in range(0,b%50*2,2):
    l[21+b//50*2][i]='#'
print(40,100)
for x in l:
    print(''.join(x))

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 1000005
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n,D[MAX],H[MAX];

int getSibling(int u){
  if(T[u].p == NIL){
    return -1;
}
  if(T[T[u].p].l != u && T[T[u].p].l != NIL){
    return T[T[u].p].l;
  }
  if(T[T[u].p].r != u && T[T[u].p].r != NIL){
    return T[T[u].p].r;
  }
  return -1;
}
void print(int u){
  int sub;
  int dgree=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",sub = getSibling(u));
  if(T[u].l!=-1){
    dgree++;
      }
  if(T[u].r!=-1){
    dgree++;
  }
  printf("degree = %d, ",dgree);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL){
    printf("root\n");
  }else if(T[u].l == NIL&&T[u].r == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}



  void setDepth(int u,int d){//depth calcurator
    if(u == NIL){
      return;
    }
    D[u] = d;
    setDepth(T[u].l,d+1);
    setDepth(T[u].r,d+1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].l != NIL){
    h1 = setHeight(T[u].l) + 1 ;
  }
  if(T[u].r != NIL){
    h2 = setHeight(T[u].r) + 1;
    
  }
  if(h1 >= h2){
    H[u] = h1;
    return H[u];
  }else{
    H[u] = h2;
    return H[u];
  }
}

int main(){
  int i,v,l,r,root = 0;
  scanf("%d",&n);

  for(i = 0;i<n;i++){
    T[i].p = NIL;
  }
  for(i = 0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL){
      T[l].p = v;
    }
    if(r != NIL){
      T[r].p = v;
    }
  }

  for(i = 0;i<n;i++){
    if(T[i].p == NIL){
      root = i;
    }
  }
  setDepth(root,0);
  setHeight(root);

  for(i = 0;i<n;i++){
    print(i);
  }
  return 0;
}




Measured memory_bytes: 2036
import numpy as np
from functools import reduce
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def main():
    N,M = map(int, input().split())
    a = [int(i) for i in input().split()]
    A = np.array(a)
    m = A // 2

    while np.all(A % 2 == 0):
        A //= 2
    
    c = np.count_nonzero(A % 2 == 1)
    if c != N:
        print(0)
        exit()

    lcm = reduce(lcm_base, m, 1)
    #print(lcm)

    print(int((M / lcm + 1) // 2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 24936
A,B,C,K= map(int, input().split())
a=0
c=0
if A<=K:
    a=A
if A>K:
    a=K
if K-A-B>0:
    if C<=K-A-B:
        c=C*-1
    if C>K-A-B:
        c=(K-A-B)*-1
print(a+c)

Measured memory_bytes: 61648
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	s := scanInts(n)
	t := scanInts(m)

	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, m+1)
	}
	for i := 0; i < m+1; i++ {
		dp[0][i] = 1
	}

	for i := 0; i < n; i++ {
		dp[i+1][0] = 1
		for j := 0; j < m; j++ {
			dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]
			if s[i] != t[j] {
				dp[i+1][j+1] -= dp[i][j]
			}

			dp[i+1][j+1] = (MOD+dp[i+1][j+1])%MOD
		}
		// debug(dp[i+1])
	}

	fmt.Fprintln(wr, dp[n][m])
}

// MOD constant
const MOD = 1000000007


Measured memory_bytes: 33920
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;


int main(){
    string s;
    cin >> s;

    int count = 0;
    int ret = INT32_MAX;
    int status = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] - '0' != status){
            count++;
        }
        status = 1 - status;
    }
    ret = min(ret, count);

    count = 0;
    status = 1;
    for(int i = 0; i < s.length(); i++){
        if(s[i] - '0' != status){
            count++;
        }
        status = 1 - status;
    }
    ret = min(ret, count);

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;
static const int MAX_N = 1 << 17;
int bit[MAX_N + 1];
int n;


int sum(int i)
{
	int s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return(s);
}

void add(int i, int x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

void solve()
{
	int q;
	cin >> n >> q;
	for (int i = 0; i < q; ++i)
	{
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
//		cin >> com >> x >> y;
		if (com == 0)
		{
			add(x, y);
		}
		else
		{
			printf("%d\n", sum(y) - sum(x - 1));
//			cout << sum(y) - sum(x - 1) << endl;
		}
	}
}

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

Measured memory_bytes: 1624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll bit[100010], num;
ll n, par[100010], k, kai[2010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	ll n, p[25];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	ll ans = 0;
	for (int i = 1; i < n - 1; i++)
	{
		if ((p[i] - p[i - 1]) * (p[i] - p[i + 1]) < 0)
		{
			ans++;
		}
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


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

int a, b, c, d;

int main(){
	cin >> a >> b >> c >> d;
	bool turn=1;
	while (a>0 && c>0){
		if (turn) c-=b;
		else a-=d;
		turn=!turn;
	}
	cout << (a<=0 ? "No\n" : "Yes\n");
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<ll> cnt(n,0);
	REP(i,m) {
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		cnt[a]++;
		cnt[b]++;
	}
	REP(i,n) if(cnt[i]%2) {
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

/////////////////////////////////////////////////////////

const int N = 1e5;

int n,m,x;
ll arr[N + 5];
ll solve(){
	ll ret = 0;
	REP(i,1,n-1){
		ll tmp = min(arr[i], arr[i]+arr[i-1]-m);
		if(tmp > 0){
			ret += tmp;
			arr[i] -= tmp;
		}
		if(arr[i] + arr[i-1] - m > 0){
			if(arr[i-1] > 0){
				ret += arr[i-1] - m;
			}
			else{
				ret += arr[i] - m;
				arr[i] -= (arr[i] - m);
			}
		}
	}
	return ret;
}


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> n >> m;
	FOR(i,n){
		cin >> arr[i];
	}
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int l = scan.nextInt();
		String[] s = new String[n];
		for(int i =0;i<n;i++) {
			s[i]=scan.next();
		}

		Arrays.sort(s);
		for(int i =0;i<n;i++) {
			System.out.print(s[i]);
		}
		}
	}




Measured memory_bytes: 21460
#40
import sys
a,b = map(int,input().split())
cou = 0

if a<=0 and b>=0:
    print("Zero")
    sys.exit()
elif a>=0 and b<=0:
    print("Zero")
    sys.exit()
    
if a>0 and b>0:
    print("Positive")
    sys.exit()
else:
    cou = abs(b-a) +1
    if cou %2 == 0:
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 9116
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  std::string T;
  std::cin >> T;
  for (int i=0; i<T.length(); i++){
    if (T[i]=='?'){
      T[i]='D';
    }
  }
  std::cout << T << std::endl;
  return 0;
}

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

    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define tmax(a, b, c) max(max(a, b), c)
    #define fio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
    using namespace std;

    const int INF = 1e9+5;
    const long long LINF = 1e18+5;
    const double eps = 1e-9;
    fstream fin, fout;
    typedef pair<int, int> ii;
    typedef vector<ii> vii;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    typedef vector<char> vc;
    typedef vector<vector<int> > vvi;
    typedef vector<ll> vll;

    int main(){
    fio;
    int x, y;
    cin >> x >> y;
    cout << x + y / 2;
    }


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

int main()
{
    int n,m,k,t;
    while(scanf("%d",&k)!=EOF)
    {
        int x,y,z,f=1;
        x=0;y=0;z=0;
        for (int i=0;i<k;i++)
        {
            scanf("%d%d%d",&t,&n,&m);
            int h,p;
            p=t-z;
            h=abs(n-x)+abs(m-y);
            x=n; y=m; z=t;
            if (!(p%2==h%2&&t>=h)) f=0;
        }
        if (f==1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let s=readStr().ToCharArray()

['a'..'z']
|> List.tryFind (fun c -> not (s|>Array.exists ((=) c)))
|> function
| Some c -> string c
| None -> "None"
|> printfn "%s"

Measured memory_bytes: 12752
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
cin>>n;
ll a;
ll min=infll;
ll max=-infll;
for(int i=0;i<n;i++){
    cin>>a;
    chmin(min,a);
    chmax(max,a);
}
cout<<max-min<<endl;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int l,r;
}a[110000];
bool cmp(node a,node b)
{
    if(a.r==b.r)
        return a.l<b.l;
    return a.r<b.r;
}
int main()
{
    int n,m;
    int cnt=1;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&a[i].l,&a[i].r);
    }
    sort(a+1,a+m+1,cmp);
    int mi=a[1].r;
    for(int i=2;i<=m;i++)
    {
        if(a[i].l>=mi)
        {
            mi=a[i].r;
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i;
    int x;
    
    scanf("%d",&x);
    
    while (x!=0) {
        i++;
        printf("Case %d: %d\n",i,x);
        scanf("%d",&x);
    }
        return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

int main(){
    string S;cin >> S;
    if(S[2] == S[3] && S[4] == S[5])
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from sys import stdin

def sp(G,R,V):
    d = {}
    INF = float('inf')
    for i in range(V):
        d[i] = INF
    d[R] = 0
    for i in range(1,V+1):
        for (u,v) in G.keys():
            if d[v] > d[u] + G[u,v]:
                d[v] = d[u] + G[u,v]
                if i == V:
                    return 'NEGATIVE CYCLE'
    return d


V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict()
for case in range(E):
    s, t, w = [int(x) for x in stdin.readline().split()]
    G[(s,t)] = w
d = sp(G, R, V)
if d == 'NEGATIVE CYCLE':
    print('NEGATIVE CYCLE')
else:
    for k in range(V):
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])

Measured memory_bytes: 8764
N = int(input())
A = list(map(int, input().split()))
lis = [0 for _  in range(N+1)]
lis1 = [0 for _ in range(N+1)]
lis2 = [0 for _ in range(N+1)]
for i in range(N):
    lis[A[i]] += 1

for i in range(N+1):
    num = lis[i]
    if num != 0:
        lis1[i] = int(num*(num-1)/2)
        lis2[i] = int((num-1)*(num-2)/2) - lis1[i]

total = sum(lis1)

for i in range(N):
    val = A[i]
    print(total + lis2[val])


Measured memory_bytes: 90064
#include<iostream>
#include<vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int A, B;
	

	cin >> A >> B;

	bool is = false;
	if (A >= 1 && A <= 9){
		if (B >= 1 && B <= 9){
			cout << A * B << endl;
			is = true;
		}
	}

	if (!is){
		cout << -1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;


int main(){

    fast;

    string str;
    cin>>str;

    string res = "";

    for(int i=0;i<str.size();i++){
        res = res + 'x';
    }

    cout<<res;

    return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
  if a[i] == b[i] == c[i]:
    pass
  elif a[i] == b[i] != c[i]:
    ans+=1
  elif b[i] ==c[i] != a[i]:
    ans += 1
  elif a[i] == c[i] != b[i]:
    ans+=1
  else:
    ans+=2
print(ans)
  

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a;
    string s;
    cin>>s;
    string s1,s2;
    if(a%2==0){
        s1=s.substr(0,(a/2));
        s2=s.substr((a/2),a-1);
        if((s1==s2))  cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
       cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int ans;
void calc(int a,int b,int c){
  if((a-b)%(1+2*c)==0) {
    ans=1;
    return;
  }
  if(b>a) return;
  calc(a,b+4*c+4,c+1);
}
int main(){
  int n,count=0;
  cin>>n;
  lp(i,n){
    int a;
    cin>>a;
    ans=0;
    calc(a,4,1);
    if(ans==0) count++;
  }
  cout<<count<<endl;
  return 0;
    
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
#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, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int A, B;
    cin >> A >> B;

    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

#define N 100005
ll n,m;
vector<ll>to[N],from[N];
ll dpt[N],dpf[N];

void dfst(ll c){
    if(to[c].size()==0){
        dpt[c]=0;
        return;
    }
    ll ma=0;
    for(auto x:to[c]){
        if(dpt[x]==0)dfst(x);
        Max(&ma,dpt[x]);
    }
    dpt[c]=ma+1;
    
}

int main(){
    cin>>n>>m;
    while(m--){
        ll x,y;cin>>x>>y;
        x--;y--;
        to[x].pb(y);from[y].pb(x);
    }
    rep(i,0,n-1){
        if(dpt[i]==0)dfst(i);
    }
    /*rep(i,0,n-1){
        cout<<dpt[i]<<" ";
    }*/
    ll ans=0;rep(i,0,n-1)Max(&ans,dpt[i]);
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 13952
import sys
f = sys.stdin

import operator

while True:
    n = int(f.readline())
    if n == 0:
        break
    pd = [map(int, f.readline().split()) for _ in range(n)]
    pd = [[p, d1 + d2] for p, d1, d2 in pd]
    pd.sort(key=operator.itemgetter(1))
    print(*pd[-1])

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

struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sz[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    for (int i = 0; i < q; i++ ){
        int t, a, b;
        cin >> t >> a >> b;
        if (t) {
            cout << uf.same(a, b) << '\n';
        } else {
            uf.unite(a, b);
        }
    }
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int bubbleSort(vector<int>&a, int n){
    bool flag = true;
    int cnt = 0;
    while(flag){
        flag = false;
        
        for(int i = n-1; i > 0; i--){
            if(a[i] < a[i-1]){
                swap(a[i],a[i-1]);
                cnt++;
                flag = true;
            }
        }


    }
    return cnt;

}



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

    int ans = bubbleSort(a,n);
    
    rep(i,n){
        cout << a[i];
        if(i < n - 1){
            cout << " ";
        }
    }
    cout << endl << ans << endl;





}


Measured memory_bytes: 3112
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	bool is_approved = true;
	rep(i, N)
	{
		cin >> A[i];
		if (A[i] % 2 == 0)
		{
			if (A[i] % 3 == 0 || A[i] % 5 == 0)
			{
				// no problem
			}
			else
			{
				is_approved = false;
				break;
			}
		}
	}

	if (is_approved)
	{
		cout << "APPROVED" << endl;
	}
	else
	{
		cout << "DENIED" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,w;
  cin>>n>>w;
  ll wt[n];
  ll val[n];
  for(ll i=0;i<n;i++)
    cin>>wt[i]>>val[i];
  ll dp[n+1][w+1];
  for(ll i=0;i<=n;i++)
    for(ll j=0;j<=w;j++)
    {
      if(i==0||j==0)
        dp[i][j]=0;
      else if(j>=wt[i-1])
      {
        dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
	  }
	  else
	  dp[i][j]=dp[i-1][j];
  }
  cout<<dp[n][w]<<"\n";
  return 0;
}
  
                                                                                                 


Measured memory_bytes: 79104
#include <cstdio>

using namespace std;

int main() {
    int n, p, c1 = 0, c2 = 0, i;
    
    scanf("%d %d", &n, &p);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        if (x % 2 == 0) {
            c1++;
        } else {
            c2++;
        }
    }
    
    if (c2 == 0) {
        if (p == 0) {
            printf("%lld\n", 1LL << c1);
        } else {
            puts("0");
        }
    } else {
        printf("%lld\n", (1LL << c1) * (1LL << (c2 - 1)));
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
まず大事な視点として、たとえば K=4 のとき

1 回目、5 回目、9 回目、...
2 回目、6 回目、10 回目、...
3 回目、7 回目、11 回目、...
14回目、8 回目、12 回目、...
という各系列は完全に独立に考えて OK！！！よって、基本的には「連続して同じ手を出せない」という問題と同一視できるのだ。
*/

int main(){
    FIN;
    int N,K,R,S,P;
    string T;

    cin >> N >> K >> R >> S >> P;
    cin >> T;

    ll ans = 0;
    for(int k=0;k<K;k++){
        bool last = false;
        for(int i=k;i<N;i+=K){
            if(i>=K && T[i-K]==T[i] && last) last = false;
            else{
                if(T[i] == 'r') ans += P;
                if(T[i] == 's') ans += R;
                if(T[i] == 'p') ans += S;
                last = true;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int MAX = 8000;
const char FORWARD = 'F';
const char TURN = 'T';

int main() {
	string s;
	int x, y;
	cin >> s >> x >> y;
	
	int read = 0;
	for (;s[read] == FORWARD;++ read) -- x; // 最初の文字数だけxを減らす
	x = x < 0 ? -x : x;
	y = y < 0 ? -y : y;
	
	int xGo[MAX], yGo[MAX], xp = 0, yp = 0; // 部分和問題に必要な値
	memset(xGo, 0, sizeof(int) * MAX);
	memset(yGo, 0, sizeof(int) * MAX);
	
	for (++ read;s[read] != '\0';++ read) {
		for (;s[read] == FORWARD;++ read) { // y軸方向
			++ yGo[yp];
		}
		++ yp;
		if (s[read] == '\0') break;
		for (++ read;s[read] == FORWARD;++ read) { // x軸方向
			++ xGo[xp];
		}
		++ xp;
	}
	
	bool dpX[MAX], dpY[MAX]; // 部分和問題はdpで解けるよ
	int xSum = 0, ySum = 0;
	memset(dpX, false, sizeof(bool) * MAX);
	dpX[0] = true;
	for (int i = 0;i < xp;++ i) {
		int add = xGo[i];
		xSum += add;
		for (int j = xSum - add;j >= 0;-- j) {
			dpX[j + add] |= dpX[j];
		}
	}
	memset(dpY, false, sizeof(bool) * MAX);
	dpY[0] = true;
	for (int i = 0;i < yp;++ i) {
		int add = yGo[i];
		ySum += add;
		for (int j = ySum - add;j >= 0;-- j) {
			dpY[j + add] |= dpY[j];
		}
	}
	
	if (xSum >= x && (xSum - x & 1) == 0 && dpX[xSum - x >> 1] && ySum >= y && (ySum - y & 1) == 0 && dpY[ySum - y >> 1]) cout << "Yes"; // 例えば左右に合計100マス動けるとして、目的地が20なら丁度60動けるような部分和があれば移動可能、と考えるよ
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、x方向とy方向はそれぞれ独立に求めることができる
最初に、Tが出てくるまで自分を動かしてしまう
そうすると、残りはどちらの方向にも動けるので、左右か上下ということさえ分かっていれば左と右および上と下の区別をつける必要はない
この時、部分和問題を解けば答えが分かる
*/

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {

	var SA, SB, SC string
	fmt.Scan(&SA)
	fmt.Scan(&SB)
	fmt.Scan(&SC)

	turn := SA[0]
	SA = SA[1:]
	for {
		switch turn {
		case byte('a'):
			if len(SA) == 0 {
				fmt.Println("A")
				return
			}
			turn = SA[0]
			SA = SA[1:]
		case byte('b'):
			if len(SB) == 0 {
				fmt.Println("B")
				return
			}
			turn = SB[0]
			SB = SB[1:]

		case byte('c'):
			if len(SC) == 0 {
				fmt.Println("C")
				return
			}
			turn = SC[0]
			SC = SC[1:]
		}
	}
}


Measured memory_bytes: 512
N,X,Y=map(int,input().split())

C=[0]*N
for i in range(1,N):
  for j in range(i+1,N+1):
    C[min(j-i,abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))]+=1

for i in range(1,N):
  print(C[i])


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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  ull x; cin >> x;
  bitset<32> b(x);
  cout << b << endl;
  cout << ~b << endl;
  cout << (b << 1) << endl;
  cout << (b >> 1) << endl;

  return 0;
}



Measured memory_bytes: 3160
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> a(H);

  for(int i=0;i<H;++i) cin >> a.at(i);

  for(int i=0;i<W+2;++i) cout << '#';
  cout << endl;
  for(int i=0;i<H;++i) cout << '#' << a.at(i) << '#' << endl;
  for(int i=0;i<W+2;++i) cout << '#';
  cout << endl;

  return 0;
}


Measured memory_bytes: 3536
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(min((double)1.0, max((double)-1.0, cosine)));
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		double now_length = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa - now_min >= eps || (abs(goa - now_min) <= eps && (abs(a[i] - a[starter]) - now_length) >= eps)) {
					now_min = goa;
					now_go = i;
					now_length = abs(a[i] - a[starter]);
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 256
n=int(input())
mod=10**9+7
if n==1:
    print(0)
    exit()
if n==2:
    print(2)
    exit()
nine,ei,se=1,1,1
for i in range(n):
    nine*=10
    nine%=mod
    ei*=9
    ei%=mod
    se*=8
    se%=mod
print((nine-2*ei+se)%mod)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<math.h>
using namespace std;
const int maxn=3e2+7;
typedef long long ll;
const ll INF=1e18;
int n,m;
ll l,dis[maxn][maxn];
int main()
{
	scanf("%d%d%lld",&n,&m,&l);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
				dis[i][j]=INF;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		ll z;
		scanf("%d%d%lld",&x,&y,&z);
		dis[x][y]=dis[y][x]=z;
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(dis[i][j]<=l)
				dis[i][j]=1;
			else
				dis[i][j]=INF;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(dis[x][y]<INF)
			printf("%lld\n",dis[x][y]-1);
		else
			printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a-b)) << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  string S, T; cin >> S;
  T = S;
  while (1){
    int n = T.size();
    if (n==0) break;

    bool check = true;
    rep(i,n-1){
      if (T.substr(i,2)=="()"){
        T.erase(i,2);
        check = false;
        break;
      }
    }
    if (check) break;
  }
  int l=0, r=0;
  rep(i,T.size()) {
    if (T[i]=='(') r++;
    else l++;
  }
  cout << string(l,'(') << S << string(r,')') << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X=sc.nextInt();
    if(X<30) {
    	System.out.println("No");
    }else {
    	System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 35684
#include <iostream>
using namespace std;
 
int main(){
  	// ask user for a number
    int N;
    cin >> N;
    
    // make a string
    string word = "No";
  
  	// make a nested for loop. Compare the input to the numbers we make
    int i, j, temp;
	for (i=1; i<=9; i++){
    	for(j=1; j<=9; j++){
          temp = i*j;
          if (N==temp){
            word = "Yes";
          }
    	}
	}
    cout << word;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        n = input()
        mil = 196470
        for i in range(n):
            y, m, d = map(int, raw_input().split())
            elapsed = 0
            elapsed += 590 * ((y - 1) / 3) + 195 * ((y - 1) % 3)
            if y % 3 == 0:
                elapsed += 20 * (m - 1)
            else:
                elapsed += 39 * ((m - 1) / 2) + 20 * ((m - 1) % 2)
            elapsed += d - 1
            # print elapsed
            print mil - elapsed
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4660
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int main(){
      ll n;cin>>n;
      ll res = (n-1)*n/2;
      cout<<res;
    }
    


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

#define mp make_pair
#define pb push_back
#define repm(i, n, m)  for(int i = n; i < m; ++i)
#define Repm(i, n, m)  for(int i = n; i <= m; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) repm(i, 1, n)
#define mod 1000000000+7

int main(){
    int a, b; cin >> a >> b;
    cout << (a-1)*(b-1) << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int big = 0;
		int small = 0;
		for(int i = 0;i<M;i++){
			if(X>sc.nextInt()){
				small++;
			}else{
				big++;
			}
		}
		if(big>small){
			System.out.println(small);
		}else{
			System.out.println(big);
		}
	}

}


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

int main(void) {
  int N, A, B;
  char s[100005] = "";
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> N >> A >> B;
  cin >> s;
  int ab = A + B, nownum = 0, bnum = 0;;
  //cout << "ab " << ab << endl;

  for (int i = 0; i < N; ++i) {
    //cout << "ab, nownum, bnum = " << ab << " " << nownum << " " << bnum << endl;
    if (s[i] == 'a') {
      if(nownum < ab) {
        cout << "Yes\n";
        ++nownum;
      } else {
        cout << "No\n";
      }
    } else if(s[i] == 'b') {
      if (nownum < ab) {
        if (bnum <= B-1) {
          cout << "Yes\n";
          ++nownum;
        } else {
          cout << "No\n";
        }
      } else {
        cout << "No\n";
      }
      ++bnum;
    } else if (s[i] == 'c') {
      cout << "No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 768