akhauriyash/Code-Regression huggingface dataset:
S = input()
count = 0
count_max = 0

for k in range(len(S)):
    if S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T":
        count += 1
        if count > count_max:
             count_max = count
    else:
        count=0
print(count_max)


Measured memory_bytes: 2940
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ans := n
	m := make([]int, n)
	for i := range m {
		fmt.Scan(&m[i])
	}
	sort.Sort(sort.IntSlice(m))
	// fmt.Println(m)
	for j := 0; j < n; j++ {
		x -= m[j]
	}
	// fmt.Println(x)
	ans += int(x / m[0])
	fmt.Println(ans)
}


Measured memory_bytes: 512
def insertionSort(a: list, n: int):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        a_str = map(str, a)
        print(" ".join(a_str))

n = int(input())
a = list(map(int, input().split()))
a_str = map(str, a)
print(" ".join(a_str))
insertionSort(a, n)




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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define MAX_N 100000

int n;


int main(){
  cin >> n;
  int ame[2][n];

  REP(i,n)cin >> ame[0][i];
  REP(i,n)cin >> ame[1][i];

  int memo[2][n];
  memo[0][n-1] = 0;
  memo[1][n-1] = 0;
  for(int i = n-1; i>0; i--){
    memo[0][i-1] = memo[0][i] + ame[0][i];
    memo[1][i-1] = memo[1][i] + ame[1][i-1];
  }
  int ans = memo[1][0];
  REP(i,n-1){
    int tmpans= memo[0][0] - memo[0][i+1] + memo[1][i+1];
    ans = max(ans,tmpans);
  }


  cout << ans + ame[0][0] + ame[1][n-1] << endl;

  return 0;
}


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

int N,M;
vector<vector<char> > A,B;

bool Matching(int i, int j){
    rep(k,0,M){
        rep(l,0,M){
            int x = i+k;
            int y = j+l;
            if(A[x][y] != B[k][l]){
                return false;
            } 
        }
    }
    return true;
}

int main(){
    cin >> N >> M;
    A.resize(N+1,vector<char>(N+1));
    B.resize(M+1,vector<char>(M+1));
    rep(i,0,N){
        rep(j,0,N){
            cin >> A[i][j];
        }
    }
    rep(i,0,M){
        rep(j,0,M){
            cin >> B[i][j];
        }
    }

    bool ok = false;
    rep(i,0,N-M+1){
        rep(j,0,N-M+1){
            if(Matching(i,j)) ok = true;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_mod_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_mod_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value);
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0 || n < r) return 0;
		if (n == r || r == 0) return 1;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_mod_combination<long long> fmc(N, MOD);
//long long result = fmc.process(n, r);

const int MOD = 1e9 + 7;

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

	int H, W, A, B;
	cin >> H >> W >> A >> B;

	fast_mod_combination<long long> fmc(H + W, MOD);

	long long result = 0;
	for (int i = B; i < W; i++)
	{
		result += fmc.process(H - A - 1 + i, i) * fmc.process(A - 1 + W - i - 1, A - 1);
		result %= MOD;
	}

	cout << result;
	
	return 0;
}

Measured memory_bytes: 4992
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val nList = mutableListOf<Pair<Int,Int>>()
    val mList = mutableListOf<Pair<Int,Int>>()
    for (i in 0 until n) nList.add(Pair(scanner.nextInt(),scanner.nextInt()))
    for (i in 0 until m) mList.add(Pair(scanner.nextInt(),scanner.nextInt()))
    val resultList= mutableListOf<Int>()

    nList.forEach {spos ->
        var distlist = mutableListOf<Int>()
        mList.forEach {cpos ->
            val dist = Math.abs((spos.first - cpos.first)) + Math.abs((spos.second - cpos.second))
            distlist.add(dist)
        }
        resultList.add(distlist.indexOf(distlist.min())+1)
    }
    resultList.forEach {
        println(it)
    }
}

Measured memory_bytes: 31524
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=(0);(i)<(n);++i)
#define ll long long
#define PB push_back
#define INF 1000000000

int main()
{
	string s;
	cin >> s;
	int crt=0,ans=INF;

	REP(i,s.size()-2){
		crt = (s[i]-48)*100 + (s[i+1]-48)*10 + (s[i+2]-48);
		if(abs(crt-753)<ans)ans = abs(crt-753);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
ll a[200006];
ll n;
int main(){
    string s; cin>>s;
    ll k; cin>>k;
    set<string> v;
    for(ll i=0;i<s.length();i++){
        for(ll j=1;j<=k;j++)
            v.in(s.substr(i,j));
    }
    ll count=1;
    for(auto it=v.begin();it!=v.end();it++){
        if(count==k){
            cout<<*it;
            break;
        }
        count++;
        
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int max(int a,int b){
  if(a > b) return a;
  else return b;
}

int main(){
  int w,h,n;
  scanf("%d%d%d",&w,&h,&n);
  int white[4] = {0,w,0,h};
  int x,y,a;
  int bin;
  for(int i = 0; i < n; ++i){
    scanf("%d%d%d\n",&x,&y,&a);
    if(a <= 2) bin = x;
    else bin = y;
    if(a % 2 == 1){
      if(white[a-1] < bin) white[a-1] = bin;
    }
    else{
      if(white[a-1] > bin) white[a-1] = bin;
    }
  }
  int area = max(white[1] - white[0], 0)*max(white[3] - white[2], 0);
  printf("%d\n",area);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int N, a, max = 0, min = 1001, i;
  
  scanf("%d", &N);
  
  for (i = 0; i < N; i++){
    scanf("%d", &a);
    if(a > max){
      max = a;
    }
    if(a < min){
      min = a;
    }
  }
  
  printf("%d\n", max - min);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define ll long long
using namespace std;


int main() {
	ll n;
	cin>>n;
	ll h[100005]={0};
	ll s=0;
	for(ll i=0;i<n;i++)
	{
       ll x;
       cin>>x;
       s+=x;
       h[x]++;
	}
	ll q;
	cin>>q;
	while(q--)
	{
		ll l,r;
		cin>>l>>r;
		s+=((r-l)*h[l]);
		h[r]+=h[l];
		h[l]=0;
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 4348
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n;
int d[100010];
int res=1e9;
int main()
{
	cin >>n;
	fill(d,d+n+1,1e9);
	d[n]=0;
	for (int i=n;i>0;i--)
	{
		for (int j=6;j<=i;j*=6)
		    d[i-j]=min(d[i-j],d[i]+1); 
		for (int j=9;j<=i;j*=9)
		    d[i-j]=min(d[i-j],d[i]+1); 
	}
	for (int i=0;i<=n;i++) res=min(res,d[i]+i);
	cout <<res;
	return 0;
} 

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	private static String[] card = new String[]{
			"S 1", "S 2", "S 3", "S 4", "S 5", "S 6", "S 7", "S 8", "S 9", "S 10", "S 11", "S 12", "S 13",
			"H 1", "H 2", "H 3", "H 4", "H 5", "H 6", "H 7", "H 8", "H 9", "H 10", "H 11", "H 12", "H 13",
			"C 1", "C 2", "C 3", "C 4", "C 5", "C 6", "C 7", "C 8", "C 9", "C 10", "C 11", "C 12", "C 13",
			"D 1", "D 2", "D 3", "D 4", "D 5", "D 6", "D 7", "D 8", "D 9", "D 10", "D 11", "D 12", "D 13"
	};

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		List<String> list = new ArrayList<String>();

		for (String str : card) {
			list.add(str);
		}

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			list.remove(br.readLine());
		}

		for (String string : list) {
			sb.append(string).append("\n");
		}

		System.out.print(sb);
	}
}

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

using namespace std;

string s; bool a,b;

int main(){

 cin>>s;

 for(int i=0; i<s.size(); i++){

  if(s[i]=='C') a=1;
  if(a&&s[i]=='F') b=1;
  
 }

 if(a&&b) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;

 return 0;
  
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a;
    cin >> a;
    
    cout << a*800 - a/15 * 200 << endl;
    
    return 0;
}

Measured memory_bytes: 256
let rec h x i = if x mod i = 0 then h (x/i) i else if x = 1 then true else false
let rec g x i = if x = i then false else if x mod i = 0 && h x i then true else g x (i+1)
let rec f x = if x = 1 then 1 else if g x 2 then x else f (x-1)
let () =
let x = Scanf.scanf "%d\n" (fun x -> x) in
Printf.printf "%d\n" (f x)

Measured memory_bytes: 384
table[9999][9999],j;main(p,W,a,b,c){for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,table[0][W],j)){for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);c--)for(j=0;j<=W;j++)table[c-1][j]=(j<a)?table[c][j]:(table[c][j]>table[c][j-a]+b)?table[c][j]:(table[c][j-a]+b);for(j=0;table[0][j]!=table[0][W];j++);}}

Measured memory_bytes: 0
#include "bits/stdc++.h"

using namespace std;

  int main() {
  int64_t Q;
  cin >> Q;

  int64_t B = 0;
  priority_queue<int64_t> smaller;
  priority_queue<int64_t, vector<int64_t>, greater<int64_t>> larger;
  int64_t sum_smaller = 0;
  int64_t sum_larger = 0;

  for (int64_t q = 0; q < Q; q++) {
    int64_t c;
    cin >> c;

    if (c == 1) {
      int64_t a, b;
      cin >> a >> b;

      if (smaller.size() == larger.size()) {
        smaller.push(a);
        sum_smaller += a;
      } else {
        larger.push(a);
        sum_larger += a;
      }

      while (smaller.size() && larger.size() && smaller.top() > larger.top()) {
        int64_t p = smaller.top();
        int64_t q = larger.top();
        smaller.pop();
        larger.pop();
        smaller.push(q);
        larger.push(p);
        sum_smaller += q - p;
        sum_larger += p - q;
      }

      B += b;
    } else {
      int64_t x = smaller.top();
      int64_t y = - sum_smaller + x * smaller.size() + sum_larger - x * larger.size() + B;
      cout << x << ' ' << y << endl;
    }

  }

}


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

int main() {
    string s, t;
    cin >> s >> t;
    
    int n = s.size();
    map<char, char> stmap, tsmap;
    
    for(int i = 0; i < n; ++i) {
        stmap[s[i]] = t[i];
        tsmap[t[i]] = s[i];
    }
    for(int i = 0; i < n; ++i) {
        if(stmap[s[i]] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
        if(tsmap[t[i]] != s[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
    
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define ll int
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()
#define triple pair<pill, ll>
using namespace __gnu_pbds;
using namespace std;
typedef gp_hash_table<int, short, hash<int>, equal_to<int>, direct_mod_range_hashing<int>, linear_probe_fn<>, hash_standard_resize_policy<hash_prime_size_policy, hash_load_check_resize_trigger<true>, true>> gp;

const ll N = 5e3 + 100;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;
ll n, x, t;

int main() {
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t;
}

/*

*/


Measured memory_bytes: 3632
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var N, W int
var weight, value [110]int
var dp [110][10010]int

func main() {
	sc.Split(bufio.ScanWords)
	N, W = nextInt(), nextInt()

	for i := 0; i < N; i++ {
		value[i] = nextInt()
		weight[i] = nextInt()
	}

	//初期条件
	//dp[0][w] = 0
	for w := 0; w <= W; w++ {
		dp[0][w] = 0
	}

	//dpループ
	for i := 0; i < N; i++ {
		for w := 0; w <= W; w++ {
			if w >= weight[i] {
				//i番目の品物を選べる場合
				dp[i+1][w] = maxInt(dp[i][w-weight[i]]+value[i], dp[i][w])
			} else {
				//i番目の品物を選べない場合
				dp[i+1][w] = dp[i][w]
			}
		}
	}

	fmt.Println(dp[N][W])
}



Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	string t="ABC";
	int cnt=0;
	for(int i=0;i<sz(s)-2;i++){
		if(s[i]==t[0] && s[i+1]==t[1] && s[i+2]==t[2])cnt++;
	}
	cout<<cnt;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3660
using System;
public class Test{
  public static void Main(){
    var num = Console.ReadLine().Split(' ');
    int A = int.Parse(num[0]);
    int B = int.Parse(num[1]);
    double H = double.Parse(num[2]);
    double M = double.Parse(num[3]);
    double X=0; 
    double Hrad = (H*60+M)/720;
    double Mrad = M/60;
    if(Hrad >= Mrad){
      X = A*A + B*B - 2*A*B*Math.Cos((Hrad-Mrad)*2*Math.PI);    
    }else{
      X = A*A + B*B - 2*A*B*Math.Cos((Mrad-Hrad)*2*Math.PI);
    }
    Console.Write(Math.Sqrt(X));
  }
}

Measured memory_bytes: 27828
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int> >PQG;

int N, M, Q, imos[1000][1000];

signed main()
{
    cin >> N >> M >> Q;
    for(int i = 0; i < M; i++){
        int l, r;
        cin >> l >> r;
        imos[l][r]++;
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            imos[i][j] += imos[i][j - 1];
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            imos[i][j] += imos[i - 1][j];
        }
    }
    for(int i = 0; i < Q; i++){
        int q, p;
        cin >> q >> p;
        cout << imos[p][p] + imos[q - 1][q - 1] - imos[q - 1][p] - imos[p][q - 1] << endl;
    }


    return 0;
}


Measured memory_bytes: 4992
import numpy as np

#バス、電車の入力

a = int(input())
b = int(input())
c = int(input())
d = int(input())

#1円以下、1000円以上なら　おつかれ
if ((a or b or c or d) < 0 )or ((a or b or c or d) > 1000):
    print("NO")
  
#電車とバス　通常が安い場合
elif a < b and c < d:
    print(a+c)
#電車通常、バス乗り放題の場合
elif a < b and c >= d:
    print(a+d)
#電車乗り放題、バス通常の場合
elif a >= b and c < d:
    print(b+c)
#電車、バス乗り放題
else:
    print(b+d)

Measured memory_bytes: 21684
import java.io.*;
class Main{
    public static void main(String[] args)throws IOException{
	BufferedReader br
	    = new BufferedReader(new InputStreamReader(System.in));
	String buf;
	double[] data=new double[8];
	int n=Integer.parseInt(br.readLine());
	for(int k=0;k<n;k++){
	    if((buf=br.readLine())==null)break;
	    if(buf.length()==0)break;
	    
	    String[] buf2=buf.split(" ");
	    for(int i=0;i<8;i++){
		data[i]=Double.parseDouble(buf2[i]);
	    }
	    double data1=((data[1]-data[3])/(data[0]-data[2]));
	    double data2=((data[5]-data[7])/(data[4]-data[6]));

	    if(data1==data2)
		System.out.println("YES");
	    else
		System.out.println("NO");
	}
    }
}

Measured memory_bytes: 9792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	char b;
	cin>>b;
	if(b=='A')cout<<"T";
	if(b=='T')cout<<"A";
	if(b=='C')cout<<"G";
	if(b=='G')cout<<"C";
	return 0;
	}


Measured memory_bytes: 256
#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 loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll MOD = 1000000007;
ll modpow(ll a, ll n, ll p) {
    ll res = 1;
    while (n) {
        if (n & 1) res = res * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n; cin >> n;
    ll ans = modpow((ll)10, n, MOD);
    ans -= modpow((ll)9, n, MOD) * 2 - MOD * 2;
    ans += modpow((ll)8, n, MOD);
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 3604
N = int(input())
value = list(map(int,input().split()))
tval1 = 0
tval2 = 0


value = sorted(value)

for i in range(N-1):
  tval1 = value.pop(0)
  tval2 = value.pop(0)
  
  value.append((tval1+tval2)/2)
  value = sorted(value)

print(value[0])

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            Map<String, Long> out = new HashMap<>();
            for (int i=1; i <= n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                String e = st.nextToken();
                Long p = Long.parseLong(st.nextToken());
                Long q = Long.parseLong(st.nextToken());
                Long total = data.merge(e, p * q, Long::sum);
                if (total >= 1_000_000L) {
                    if (out.putIfAbsent(e, total) == null) {
                        System.out.println(e);
                    }
                }
            }
            if (out.size() == 0) {
                System.out.println("NA");
            }
        }
    }
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct UnionFind {
  vi parent, rank, count;
  UnionFind(const int nodeSize)
      : parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
    rep(i, nodeSize) parent[i] = i, count[i] = 1;
  }
  int find(int x) {
    if (parent[x] == x) return x;
    return parent[x] = find(parent[x]);
  }
  void unite(int x, int y) {
    int rx = find(x);
    int ry = find(y);
    if (rx == ry) return;
    if (rank[rx] < rank[ry]) swap(rx, ry);
    parent[ry] = rx;
    count[rx] += count[ry];
    if (rank[rx] == rank[ry]) ++rank[rx];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int num(int x) {
    return count[find(x)];
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m, k; std::cin >> n >> m >> k;
  vector<vi> block(n);
  vi cnt(n);
  UnionFind uf(n);
  rep(i, m) {
    int a, b; std::cin >> a >> b; --a, --b;
    cnt[a]++, cnt[b]++;
    uf.unite(a, b);
  }
  rep(i, k) {
    int c, d; std::cin >> c >> d; --c, --d;
    block[c].pb(d), block[d].pb(c);
  }
  vi ans(n);
  rep(i, n) {
    ans[i] = uf.num(i) - cnt[i] - 1;
    for (auto &v : block[i])
      if (uf.same(i, v)) --ans[i];
  }
  rep(i, n) {
    std::cout << ans[i] << (i+1 < n ? " " : "\n");
  }
}


Measured memory_bytes: 7936
S = int(input())
f = 10**9 + 7
dp = [0]*(S+1)
dp[0] = 1
for i in range(1,S+1):
    if i==1 or i==2: dp[i] = 0
    else:
        for j in range(0,i-2):
            dp[i] += dp[j]
            dp[i] %= f
print(dp[-1]%f)

Measured memory_bytes: 9160
#include <cstdio>

using namespace std;

const int mod = 1000000007;
int a[3000];
int b[3001];
int last[3000][3000];
long long dp[3000][3000];

int main() {
    int n, q, i, j;
    long long ans = 0;
    
    scanf("%d %d", &n, &q);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    b[0] = 1;
    for (i = 0; i < q; i++) b[i + 1] = b[i] * 2 % mod;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (a[i] > a[j]) dp[i][j] = 1;
        }
    }
    
    for (i = 0; i < q; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        for (j = 0; j < n; j++) {
            if (j == x || j == y) continue;
            
            dp[j][x] = dp[j][x] * b[i - last[j][x]] % mod;
            dp[j][y] = dp[j][y] * b[i - last[j][y]] % mod;
            
            last[j][x] = last[j][y] = i + 1;
            dp[j][x] = dp[j][y] = (dp[j][x] + dp[j][y]) % mod;
        }
        
        for (j = 0; j < n; j++) {
            if (j == x || j == y) continue;
            
            dp[x][j] = dp[x][j] * b[i - last[x][j]] % mod;
            dp[y][j] = dp[y][j] * b[i - last[y][j]] % mod;
            
            last[x][j] = last[y][j] = i + 1;
            dp[x][j] = dp[y][j] = (dp[x][j] + dp[y][j]) % mod;
        }
        
        dp[x][y] = dp[x][y] * b[i - last[x][y]] % mod;
        dp[y][x] = dp[y][x] * b[i - last[y][x]] % mod;
        
        last[x][y] = last[y][x] = i + 1;
        dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) % mod;
    }
    
    for (i = 0; i < n; i++) {
        for (j = i + 1; j < n; j++) {
            dp[i][j] = dp[i][j] * b[q - last[i][j]] % mod;
            ans += dp[i][j];
        }
    }
    
    printf("%lld\n", ans % mod);
    
    return 0;
}


Measured memory_bytes: 105600
(N, S), As = readlines.map{_1.split.map(&:to_i)}
M = 998244353

dp = Array.new(N + 1){Array.new(S + 1, 0)}
dp[0][0] = 1
(0 ... N).each do |n|
  (0 .. S).each do |s|
    dp[n + 1][s] = (dp[n + 1][s] + 2*dp[n][s])%M
    dp[n + 1][s + As[n]] += (dp[n + 1][s + As[n]] + dp[n][s])%M if s + As[n] <= S
  end
end
puts dp[N][S]

Measured memory_bytes: 84868
def read_ints():
  return [int(w) for w in input().split()]

N, D = read_ints()
X = [read_ints() for _ in range(N)]
perf_sq = set(x * x for x in range(1, 201))

ret = 0
for i in range(N):
  for j in range(i):
    dsq = sum((X[i][k] - X[j][k]) ** 2 for k in range(D))
    if dsq in perf_sq:
      ret += 1
print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define maxn (int)(1e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

bool solve(int n){
    if(n > 81) return false;
    for(int i=1;i<10;i++) {
        if(n%i == 0) {
            int d = n/i;
            //printf("%d %d %d\n", n, i ,d);
            if(d >=1 and d<10) return true;
        }
    }
    return false;
}

int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
    // #ifndef ONLINE_JUDGE
    //     fread();
    // #endif
    
    int n,k; 
    while(scanf("%d",&n)==1){
        printf("%s\n", solve(n) ? "Yes" : "No");     
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[21], b[21], c[21];
int main(){
    int n, i;
    int total=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++){
        scanf("%d", &b[i]);
    }
    for(i=0; i<n-1; i++){
        scanf("%d", &c[i]);
    }
    total+=b[a[0]-1];
    for(i=1; i<n; i++){
        total+=b[a[i]-1];
        if(a[i-1]+1==a[i]){
            total+=c[a[i-1]-1];
        }
    }
    printf("%d\n", total);
}


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll K, A, B;
  cin >> K >> A >> B;
  
  for(int i=A;i<=B;i++){
    if(i%K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG" << endl;
}

Measured memory_bytes: 3636
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 01/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N; cin>>N;
  string S; cin>>S;
  const int B = (int)ceil(sqrt(N));
  bitset<26> alphabets[B] = {};
  auto cid = [](char c) {return c-'a';};
  for (int i = 0; i < N; i++) {
    alphabets[i/B] |= (1<<cid(S[i]));
  }
  auto set = [&](int i, char c) {
    if (S[i] == c)
      return;
    S[i] = c;
    auto b = i/B;
    alphabets[b] = {};
    for (int t = b*B; t < min((b+1)*B, N); t++) {
      alphabets[b] |= (1<<cid(S[t]));
    }
  };
  auto query = [&](int l, int r) {
    auto lb = l/B, rb = r/B;
    bitset<26> mask;
    for (int b = lb+1; b < rb; b++)
      mask |= alphabets[b];
    for (int i = l; i < min((lb+1)*B,r+1); i++) {
      mask[cid(S[i])] = true;
    }
    for (int i = max(rb*B,l); i <= r; i++) {
      mask[cid(S[i])] = true;
    }
    int cnt = 0;
    for (int i = 0; i < 26; i++)
      if (mask[i]) cnt++;
    return cnt;
  };

  int Q; cin>>Q;
  for (int i = 0; i < Q; i++) {
    int t; cin>>t;
    if (t == 1) {
      int i; char c; cin>>i>>c;
      i--;
      set(i,c);
    } else if (t == 2) {
      int l,r; cin>>l>>r;
      l--;r--;
      cout << query(l,r) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1172
#include<iostream>
#include<iomanip>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int n;
	double cash,ans = 0;
	string str;


  cin >> n;
	rep(i,n){
		cin >> cash >> str;
		if("JPY" == str) ans += cash;
		else ans += (cash*380000.0);
	}
	cout << fixed << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int r, D, x;
    cin >> r >> D >> x;

    rep(i, 10) {
        x = r * x - D;
        print(x);
    }
}


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

string S; int N, cnt;

int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			// if (S[j] == ('0' + c[f])) f++;
			if (c[f] == (S[j] - '0')) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define NMAX 100005
#define ll long long int

using namespace std;

ll k, t, nr[NMAX], suma, i;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> k >> t;
    for(i=1; i<=t; ++i)
        cin >> nr[i];
    sort(nr+1, nr+t+1);
    for(i=1; i<=t-1; ++i)
        suma += nr[i];
    if(suma < nr[i])
        cout << nr[i] - suma - 1<< '\n';
        else
        cout << "0\n";
    return 0;
}


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


int main(){
    int n, w;
    cin >> n >> w;
    vector<vector<ll>> table(n+1, vector<ll>(w+1,0));
    vector<pair<int, ll>> wvs(n);
    rep(i,n) cin >> wvs[i].first >> wvs[i].second;

    for(int i = 0; i < n; ++i){
        int wi = wvs[i].first;
        ll vi = wvs[i].second;
        for(int j = 0; j <= w; ++j){
            if(0 <= j-wi)
                table[i+1][j] = max(table[i][j], table[i][j-wi] + vi);
            else table[i+1][j] = table[i][j];
        }
    }
    cout << table[n][w] << endl;
}


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

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

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

  int n,m;cin>>n>>m;
  int imos_w[n+2]={0},imos_e[n+2]={0},wsum=0,esum=0;
  for(int i=0;i<m;i++){
      string s;cin>>s;
      for(int j=1;j<=n;j++){
          if(s[j-1]=='W'){
              imos_w[j]++;
              wsum++;
          }
          else{
              imos_e[j]++;
              esum++;
          }
      }
  }
  for(int i=1;i<=n;i++){
      imos_w[i]+=imos_w[i-1];
      imos_e[i]+=imos_e[i-1];
  }
  int res,dif_min=INF;
  for(int i=0;i<=n;i++){
      int tmp=imos_e[i]+(wsum-imos_w[i]);
      //cout<<tmp<<endl;
      if(dif_min>tmp){
          dif_min=tmp;
          res=i;
      }
  }
  cout<<res<<" "<<res+1<<endl;
}

Measured memory_bytes: 3316
from sys import stdin

def main():

    input = stdin.readline

    S = input()[:-1]

    N = len(S)

    S = S + "R"

    ans_list = []

    r_stock = 0
    l_stock = 0

    for i in range(N):
        if S[i] == "R":
            if S[i + 1] == "R":
                ans_list.append(0)
                r_stock += 1
            elif S[i + 1] == "L":
                r_stock += 1
        if S[i] == "L":
            
            if S[i + 1] == "L":
                l_stock += 1
            elif S[i + 1] == "R":
                l_stock += 1

                sum_stock = r_stock + l_stock
                if sum_stock % 2 == 0:
                    ans_list.append(sum_stock//2)
                    ans_list.append(sum_stock//2)
                else:
                    if r_stock % 2 == 0:
                        ans_list.append(sum_stock//2)
                        ans_list.append(sum_stock//2 + 1)
                    else:
                        ans_list.append(sum_stock//2 + 1)
                        ans_list.append(sum_stock//2)

                for _ in range(l_stock-1):
                    ans_list.append(0)

                r_stock = 0
                l_stock = 0    
                
            

    print(' '.join(map(str,ans_list)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 10612
#include <stdio.h>

int main(){
  double A,B;
  scanf("%lf",&A);
  scanf("%lf",&B);
  if(A>B){
    printf("GREATER\n");
  }else if(A<B){
    printf("LESS\n");
  }else if(A=B){
    printf("EQUAL\n");
  }
}

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

using namespace std;

using int64 = long long;
//const int mod = (int) (1e9 + 7);
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K;
  cin >> N >> K;
  vector< int > P(N);
  cin >> P;
  sort(begin(P), end(P));
  int ret = 0;
  for(int i = 0; i < K; i++) ret += P[i];
  cout << ret << "\n";
}








Measured memory_bytes: 3616
#include <iostream>                                             
using namespace std;                                            
                                                                
int main(void) {                                                
  int r,c;                                                      
  cin >> r >> c;                                                
  int a[101][101]={};                                           
  for (int i=0; i<r; i++) {                                     
    for (int j=0; j<c; j++) {                                   
      cin >> a[i][j];                                           
    }                                                           
  }                                                             
  for (int i=0; i<r; i++) {                                     
    for (int j=0; j<c; j++) {                                   
      a[i][c]+=a[i][j];                                         
      a[r][j]+=a[i][j];                                         
    }                                                           
  }                                                             
  for (int j=0; j<c; j++) {                                     
    a[r][c]+=a[r][j];                                           
  }                                                             
  for (int i=0; i<r+1; i++) {                                   
    for (int j=0; j<c+1; j++) {                                 
      if(j!=c) {                                                
        cout << a[i][j] << " ";                                 
      } else {                                                  
        cout << a[i][j];                                        
      }                                                         
    }                                                           
    cout << endl;                                               
  }                                                             
  return 0;                                                     
}                                                               
                                       

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

using namespace std;

typedef long long ll;


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int a = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] != 'R') continue;
    int j = i;
    while (j + 1 < 3 && s[j + 1] == 'R') j++;
    a = max(a, j - i +1);
  }
  cout << a << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi v(4);
    rep(_,n) {
        string s;
        cin >> s;
        if(s == "AC") v[0]++;
        else if(s == "WA") v[1]++;
        else if(s == "TLE") v[2]++;
        else v[3]++;
    }
    cout << "AC x " << v[0] << endl;
    cout << "WA x " << v[1] << endl;
    cout << "TLE x " << v[2] << endl;
    cout << "RE x " << v[3] << endl;
}

Measured memory_bytes: 3656
# abc164_a.py
# https://atcoder.jp/contests/abc164/tasks/abc164_a

# A - Sheep and Wolves /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 羊が S匹、狼が W匹います。
# 狼の数が羊の数以上のとき、羊は狼に襲われてしまいます。
# 羊が狼に襲われるなら unsafe、襲われないなら safe を出力してください。

# 制約
#     1≤S≤100
#     1≤W≤100

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S W

# 出力
# 羊が狼に襲われるなら unsafe、襲われないなら safe を出力せよ。

# 入力例 1
# 4 5

# 出力例 1
# unsafe

# 羊が 4匹、狼が 5匹います。狼の数が羊の数以上なので、羊は狼に襲われてしまいます。

# 入力例 2
# 100 2

# 出力例 2
# safe

# 多勢に無勢です。

# 入力例 3
# 10 10

# 出力例 3
# unsafe


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    S, W = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = 'safe'
    if S <= W:
        result = 'unsafe'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 5']
        lines_export = ['unsafe']
    if pattern == 2:
        lines_input = ['100 2']
        lines_export = ['safe']
    if pattern == 3:
        lines_input = ['10 10']
        lines_export = ['unsafe']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include "algorithm"
#include "cstdio"
using namespace std;
int s[300005],i,j,n;long long ss;
int A(){
    int a=0,k=1;char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') k=-1;c=getchar();
    }
    while(c>='0'&&c<='9'){
        a=a*10+c-'0';c=getchar();
    }
    return a*k;
}
bool cmp(int a,int b){
	return a>b;
}
int main(){
	n=A();
	for(i=1;i<=n*3;i++)s[i]=A();
	sort(s+1,s+1+3*n,cmp);
	for(i=1,j=3*n;i<=j;i+=2,j--){
		ss+=s[i+1];
	}
	printf("%lld\n",ss);
}

Measured memory_bytes: 1280
#include <stdio.h>

int a[200010];
 int ans[200010];
 int main(){
 int n;
 scanf("%d",&n);
 for(int i=2;i<=n;i++)scanf("%d",&a[i]);
 for(int i=2;i<=n;i++)ans[a[i]]++;
 for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
 }

Measured memory_bytes: 3268
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

int main() {
	long H;
	cin >> H;
	long monsters = 1;
	long steps = 0;

	while (H != 0) {
		steps += monsters;
		H /= 2;
		monsters *= 2;
	}

	cout << steps << endl;
}

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

int main() {
	long long n;
	long long ans = 0;
	cin >> n;
	vector<long long> a(n + 1), b(n);
	for (long long i = 0; i <= n; i++) {
		cin >> a[i];
	}
	for (long long i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (long long i = 0; i < n; i++) {
      	long long tmp = min(b[i], a[i]);
        ans += tmp;
        a[i] -= tmp;
        b[i] -= tmp;
        tmp = min(b[i], a[i + 1]);
        ans += tmp;
        a[i + 1] -= tmp;
        b[i] -= tmp;
	}
	cout << ans << endl;
}

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

#define ll long long

ll i,t,j;
ll n,nt,cnt,ans,x;

ll f(ll x){
	if (x<2) return 1;
	
	return (x*(f(x-2)));
}

int main(){
	scanf("%lld",&n);
	
	if (n%2==1) printf("0\n");
	else {
		t=n;
		while(t>0){
			t/=10;
			++cnt;
		}
		
		for (i=1,x=10; i<=27; ++i,x*=5){
			ans+=n/x;
		}
		
		printf("%lld\n",ans);
	}
		
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b, h;
    cin >> a >> b >> h;
    
    cout << ((a+b)*h)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define maxn 100000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int cnt[maxn+5];

int main()
{
    int n; scanf("%d",&n);
    ll s=0;
    rep(i,1,n)
    {
        int x; scanf("%d",&x);
        cnt[x]++;
        s+=x;
    }
    int Q; scanf("%d",&Q);
    while(Q--)
    {
        int b,c; scanf("%d%d",&b,&c);
        s+=(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b]=0;
        printf("%lld\n",s);
    }
    return 0;
}

Measured memory_bytes: 4200