akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc087.contest.atcoder.jp/tasks/arc087_a>
問題文============================================================
 長さ N の正整数の列 a=(a1,a2,…,aN) が与えられます。
 あなたの目標は、a のうちいくつかの要素を取り除き、a を 良い数列 にすることです。
 
 ここで、数列 b が 良い数列 であるとは、次の条件が成り立つことです。
 
 b の各要素 x について、b に値 x はちょうど x 個含まれる。
 例えば、(3,3,3), (4,2,4,1,4,2,4), () (空の数列) は良い数列です。
 一方、(3,3,3,3), (2,4,1,4,2) は良い数列ではありません。
 
 a を良い数列にするために取り除くべき要素の個数の最小値を求めてください。
=================================================================

解説=============================================================

 連想配列である数値が何個存在するのかを保存しておき、順番に見ていけば良い
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    map<ll,ll> mp;
    for(int i = 0; i < N;i++){
        ll A; cin >> A;
        mp[A]++;
    }
    ll ans = 0;
    for(auto p:mp){
        if(p.first < p.second) ans += p.second - p.first;
        else if(p.first > p.second) ans += p.second;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
using namespace std;
int main(){
	int n,b=100000;
	cin>>n;
	for(int i=0;i<n;i++){
	b*=1.05;
	if(b%1000!=0)b=(b/1000+1)*1000;
	}
	cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++) {
        if(i%d==0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int.Parse(Console.ReadLine());
            long[] tmpa = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            long[] a = new long[tmpa.Length + 1];
            for(int i= 1; i<a.Length;++i)
            {
                a[i] = tmpa[i - 1];
            }
            BuildMaxHeap(a);
            StringBuilder sb = new StringBuilder();
            for(int i=1;i<a.Length;++i)
            {
                sb.Append( " " + a[i]);
            }
            
            Console.WriteLine(sb.ToString());
        }
        static long Parent(long i) { return i / 2; }
        static long Left(long i) { return 2 * i; }
        static long Right(long i) { return 2 * i + 1; }
        static void MaxHeapify(long[] a, long i)
        {
            long l = i * 2;
            long r = i * 2 + 1;
            long largest = 0;
            if( l < a.Length && a[l] > a[i])
            {
                largest = l;
            }else
            {
                largest = i;
            }
            if( r < a.Length && a[r] > a[largest])
            {
                largest = r;
            }

            if( largest != i)
            {
                long tmp = a[i];
                a[i] = a[largest];
                a[largest] = tmp;
                MaxHeapify(a, largest);
            }
        }
        static void BuildMaxHeap(long[] a)
        {
            for(int i=a.Length / 2; i >= 1; --i)
            {
                MaxHeapify(a, i);
            }
        }
    }

}



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

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

const long long MOD = 1000000007;

int main(){
  int n,x,l;
  int d=0,ans=1;
  cin >> n>>x;
  rep(i,n){
    cin>>l;
    d+=l;
    if(d<=x) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 101000

int main()
{
	int c5,c7,i,x;
	c5=c7=0;
	for (i=1;i<=3;i++)
	{
		scanf("%d",&x);
		if (x==5) c5++;
		if (x==7) c7++;
	}
	if (c5==2 && c7==1) printf("YES\n");
	else printf("NO\n");
	return 0;
}


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

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	public void run() {
		while (true) {
			int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
			if (n == 0) break;
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			for (int i = 1; i <= n; i++) {
				list.add(i);
			}
			
			int idx = (k - 1) % list.size();
			while (list.size() != 1) {
				list.remove(idx);
				idx = (idx + m - 1) % list.size();
//				System.out.println(Arrays.toString(list.toArray()));
			}
			System.out.println(list.get(0));
		}
		out.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

int main(){
   int a,b,x;
   scanf("%d%d%d",&a,&b,&x);
   
   if(a<=x && x<=a+b){
       printf("YES\n");
   }else{
       printf("NO\n");
   }
   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i=0;i<26;i++){
    char a='a'+i;
    int c=-10;
    for(int j=0;j<s.size();j++){
      if(s[j]==a){
        if(j-c<=2){
          cout<<c+1<<" "<<j+1<<endl;
          return 0;
        }
        else c=j;
      }
    }
  }
  cout<<-1<<" "<<-1<<endl;
}

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

int main(){
  long long int a,b,c;
  cin >> a;
  string s;
  cin >> s;
  b = s.at(0)-'0';
  c = (s.at(2)-'0')*10 + s.at(3)-'0';
  
  b = b*100+c;
  long long int ans = (a*b)/100;
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include<cstdio>
#include<string>
#include <string.h>
#include<stdio.h>
using namespace std;

int main() {
	string Tarou,Hanako;
	int much;
	int Taro_p = 0, Hana_p = 0;

	cin >> much;
	for (int i = 0; i < much; i++) {
		cin >> Tarou >> Hanako;
		if (Tarou == Hanako) {
			Taro_p++;
			Hana_p++;
		}
		else if (Tarou > Hanako) {
			Taro_p += 3;
		}
		else {
			Hana_p += 3;
		}
	}
	
	cout << Taro_p << " " << Hana_p << endl;
	return 0;
}




Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

int main(){
  std::string str;
  std::cin >> str;

  if(str[2] == str[3] && str[4] == str[5]){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
  return 0;
}


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

int main()
{
  ll n,cnt=0;
  cin>>n;
  for(ll i=0;i<n;i++)
  {
    ll a;cin>>a;
    if(i%2==0 && a%2==1)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3640
n=int(input())
A=list(map(int,input().split()))
A.sort()

box=[True]*(A[-1]+1)

for i in range(len(A)):
    if i<n-1 and A[i]==A[i+1]:
        box[A[i]]=False
    k=2
    while A[i]*k<len(box):
        box[A[i]*k]=False
        k+=1

ans=0
for i in A:
    if box[i]:
        ans+=1
print(ans)

Measured memory_bytes: 33188
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int[] b = new int[n-1];
	  
	  for(int i=0;i<n-1;i++)b[i]=sc.nextInt();
	  int ans = b[0];
	  for(int i = 1;i<n-1;i++){
	  	if(b[i-1]<b[i]){
          ans+=b[i-1];
        }else ans+=b[i];
	  }

	  ans += b[n-2];
	  
	  System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define rep(i,n) for(int i=0; i<n; i++)

int main(void) {
  int N;
  int i;
  cin >> N;
  vi B(N-1);
  rep(i,N-1) {
    cin >> B[i];
  }

  vi A(N);
  rep(i,N) {
    if(i == 0) {
      A[i] = B[i];
    } else if(i == N-1) {
      A[i] = B[i-1];
    }
    else {
      A[i] = min(B[i], B[i-1]);
    }
  }
  int cnt = 0;
  rep(i,N) {
    cnt += A[i];
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	float a, b, c, d, e, f;
	float x, y;

	while (1) {
		if (scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) == EOF)break;
		x = (e*c - b * f) / (a*e - b * d);
		y = (-c * d + a * f) / (a*e - b * d);
		if (x == 0)x = 0;
		if (y == 0)y = 0;
		printf("%.3f %.3f\n", x, y);
	}

	return 0;
}



Measured memory_bytes: 1976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>

#define ALL(a) (a).begin(), (a).end()
#define FOR(i, a ,b) for(int i = int(a); i < int(b); ++i)
#define REP(i, a) FOR(i, 0, a)
#define RFOR(i, a, b) for(int i = int(b)-1; i >= int(a); --i)
#define RREP(i,a) RFOR(i, 0, a)
#define IN(a, x , b) (a <= x && x <= b)
template<class T> inline void CHMIN(T& a, T& b){if(a<b)a=b;}
template<class T> inline void CHMAX(T& a, T& b){if(a>b)a=b;}

using ll = long long;

template<class T> using V = std::vector<T>;
using namespace std;

int main(){
  int n;
  cin >> n;
  V<int> x(n);
  REP(i, n) cin >> x[i];
  set<int> st;
  int p = 1;
  bool ng = false;
  REP(_, n) {
    if(ng) {
      cout << "No" << '\n';
      continue;
    }
    int t = x[_];
    if(t < p - 1) {
      cout << "No" << '\n';
    }
    else if(t == p - 1) {
      auto it = st.upper_bound(t);
      if(it == st.end()) {
        cout << "Yes" << '\n';
        ng = true;
      }else {
        cout << "No" << '\n';
      }
    }
    else {
      cout << "Yes" << '\n';
    }
    while(st.count(t)) {
      st.erase(t);
      --t;
    }
    st.insert(t);
    while(st.count(p)) ++p;
  }
  return 0;
}



Measured memory_bytes: 16436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  double n,ans=0;
  cin >> n;

  cout << fixed << setprecision(15) << n/3*n/3*n/3;

}


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

int a[100005], b[100005];
int n,k,q,tmp;

int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k>>q;

	for(int i=1; i<=q; i++)
		{
			cin>>tmp;
			b[tmp]++;
		}

	for(int i=1; i<=n; i++)
		{
			a[i] = k - ( q - b[i] );

			if(a[i] <= 0)
				cout<<"No"<<endl;
			else
				cout<<"Yes"<<endl;
		}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int k,s;
  cin>>k>>s;
  int ans=0;
  rep(a,k+1) rep(b,a+1) rep(c,b+1){
    if(a+b+c==s){
      if(a!=b && b!=c)
        ans+=6;
      else{
        if(a==c) ans++;
        else ans+=3;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i, j, k;
    int N, D;

    scanf("%d %d", &N, &D);
    if(N%(2*D+1)==0){
        printf("%d", N/(2*D+1));
    }else{
        printf("%d", N/(2*D+1)+1);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 105;
const int mod = 1e9 + 7;
int a[N][N], b[N * N];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < k; ++i) {
		scanf("%d", &b[i]);
	}
	int sx = 0, sy = 0, d = 0;
	int now = 0;
	for (int T = 0; T < n * m; ++T) {
		a[sx][sy] = now + 1;
		b[now]--;
		// cout << sx << " " << sy << endl;
		if (b[now] == 0) now++;
		if (sx + dx[d] < 0 || sx + dx[d] == n || sy + dy[d] < 0 ||
		    sy + dy[d] == m || a[sx + dx[d]][sy + dy[d]]) {
			d = (d + 1) & 3;
		}
		sx += dx[d];
		sy += dy[d];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			printf("%d ", a[i][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nk = readDoubles()
    let (n, k) = (nk[0], nk[1])
    var ans = 0.0
    for i in 1...Int(n) {
        var count = 0
        var point = i
        while point < Int(k) {
            count += 1
            point *= 2
        }
        ans += (1 / n) * pow(0.5, Double(count))
    }
    print(ans)
}
main()


Measured memory_bytes: 13192
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a,b,c string
	fmt.Scan(&a,&b,&c)

	as := strings.Split(a,"")
	bs := strings.Split(b,"")
	cs := strings.Split(c,"")

	if as[len(as) -1 ] == bs [0] && bs[len(bs)-1] == cs[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
a = input()
b = list(map(int, input().split()))
min = 100000
 
for i in range(len(b)):
  left = 0
  right = 0
  for j in range(i+1):
    left += b[j]
  for j in range(i+1, len(b)):
    right += b[j]
  if min > abs(left - right):
    min = abs(left - right)
    
print(min)

Measured memory_bytes: 9144
import java.util.Scanner;
import java.util.Arrays;
import java.lang.Integer;

class Main {
  public static void main (String[] args) {
    	Scanner scanner = new Scanner(System.in);
		String tokens[] = scanner.nextLine().split(" ");
        int n = Integer.parseInt(tokens[0]);
        int m = Integer.parseInt(tokens[1]);
        if (n <= m) {
          System.out.println("Yes");
        } else {
          System.out.println("No");
        }
    
  }
}


Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	if (N % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}

	string S1 = "";
	string S2 = "";
	for (int i = 0; i < N; i++)
	{
		if (i < N / 2) {
			S1 += S[i];
		}
		else {
			S2 += S[i];
		}
	}
	if (S1 == S2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
int n;cin>>n;
int b[n-1];
int a[n];
rep(i,n-1){
    cin>>b[i];
}
a[0]=b[0];
a[n-1]=b[n-2];
for(int i=1;i<n-1;i++){
    a[i]=min(b[i-1],b[i]);
}
ll ans=0;
rep(i,n){
ans+=a[i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Int long long
#define pb push_back
#define N 3030


int  dp[N][N];

int T2[N][N];


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    int S=s.length();
    int T=t.length();
    t+="!!!!!";
    for(int i = 0;i<S;i++)for(int j = 0;j<S;j++)dp[i][j]=(1<<12);
    for(int i = 0;i<S;i++)
    {
        for(int j = 0;j<=i;j++)
        {
            int x;
            if(j)x=dp[i-1][j-1]+1;
            else x=0;
            while(x<T){if(t[x]==s[i])break;x++;}
            //if(x>=T)x=(1<<12);
            if(i&&dp[i-1][j]<x)dp[i][j]=dp[i-1][j];
            else {
                    dp[i][j]=x;
                    T2[i][j]=1;
            }
        }
    }
    int u=-1;
    for(int j = 0;j<S;j++)if(dp[S-1][j]<T)u=j;
    if(u==-1){
        cout<<"";return 0;
    }
    int i = S-1;
    string ans="";
    while(i>=0)
    {
        if(T2[i][u]==1)ans+=s[i],u--;
        i--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 70656
#include <iostream>

using namespace std;

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

int main () {
  int k;
  cin >> k;
  long long ans = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      for (int l = 1; l <= k; ++l) {
        ans += gcd (i, gcd (j, l));
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, Q;
  cin>>N>>Q;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll even[N+1], sumA[N+1];
  for(int i=0;i<=N;++i) {
    even[i] = 0;
    sumA[i] = 0;
  }
  for(int i=0;i<N;++i) {
    sumA[i+1] = A[i];
    if(N%2==0 && i%2==1) even[i+1] = A[i];
    if(N%2==1 && i%2==0) even[i+1] = A[i];
  }
  for(int i=1;i<=N;++i) {
    sumA[i] += sumA[i-1];
    even[i] += even[i-1];
  }
  vector<ll> arr;
  ll l, r;
  if(N%2==0) l=1;
  else l=0;
  r = N/2;
  while(l<r) {
    arr.push_back((A[l]+A[r])/2);
    l+=2;
    r++;
  }
  ll ans[Q];
  ll X;
  int index;
  for(int i=0;i<Q;++i) {
    cin>>X;
    index = lower_bound(arr.begin(), arr.end(), X)-arr.begin();
    ans[i] = sumA[N]-sumA[N/2+index]+even[2*index];
  }
  for(int i=0;i<Q;++i) cout<<ans[i]<<endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

bool solve(const string &s, const string &temp) {
    ll index = 0;
    rep(i, s.length()) {
        if (temp[index] == s[i]) {
            index++;
            if (index == 3) {
                return true;
            }
        }
    }
    return false;
}

int main() {
source:
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    rep(i, 1000) {
        string temp = to_string(i);
        while (temp.length() < 3) {
            temp = '0' + temp;
        }
        if (solve(s, temp)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
def resolve():
    H, W = map(int, input().split())
    S = [list(input()) for __ in range(H)]

    dl = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    for i, row in enumerate(S):
        for j, val in enumerate(row):
            if val == '.':
                continue

            can_paint = False
            for dx, dy in dl:
                di, dj = i + dx, j + dy
                if di < 0 or H <= di or dj < 0 or W <= dj:
                    continue
                if S[di][dj] == '#':
                    can_paint = True
                    break
            if not can_paint:
                return 'No'
    return 'Yes'

print(resolve())

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<LL,LL> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%d%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,char middle=' '){
    for(int i=0;i<vec_s.size();i++)printf("%lld%c",vec_s[i],(i!=vec_s.size()-1?middle:'\n'));
}

vector<P> path[305];
vector<LL> path2[305];
bool used[305];
priority_queue<P,vector<P>,greater<P> > q1;
LL num[305][305];
LL dis[305];

void queue_clear(){
    priority_queue<P,vector<P>,greater<P> > q2;
    swap(q1,q2);
}

int main(){
    LL n,m,p;
    LL i,j,k;
    LL a,b,c;
    cin>>n>>m>>p;
    for(i=0;i<m;i++){
        cin>>a>>b>>c;
        a--,b--;
        path[a].push_back(make_pair(b,c));
        path[b].push_back(make_pair(a,c));
    }
    for(i=0;i<n;i++){
        memset(used,false,sizeof(used));
        memset(dis,-1,sizeof(dis));
        if(!q1.empty())queue_clear();
        q1.push(make_pair(0,i));
        while(!q1.empty()){
            a=q1.top().first,b=q1.top().second,q1.pop();
            if(a>p || used[b])continue;
            used[b]=true;
            if(i!=b)path2[i].push_back(b);
            for(auto it:path[b]){
                if(used[it.first])continue;
                if(dis[it.first]!=-1 && dis[it.first]<=a+it.second)continue;
                dis[it.first]=a+it.second;
                q1.push(make_pair(a+it.second,it.first));
            }
        }
    }
    memset(num,-1,sizeof(num));
    
    for(i=0;i<n;i++){
        memset(used,false,sizeof(used));
        memset(dis,-1,sizeof(dis));
        if(!q1.empty())queue_clear();
        q1.push(make_pair(-1,i));
        while(!q1.empty()){
            a=q1.top().first,b=q1.top().second,q1.pop();
            if(used[b])continue;
            used[b]=true;
            num[i][b]=a;
            for(auto it:path2[b]){
                if(used[it])continue;
                if(dis[it]!=-1 && dis[it]<=a+1)continue;
                dis[it]=a+1;
                q1.push(make_pair(a+1,it));
            }
        }
    }
    cin>>m;
    for(i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        cout<<num[a][b]<<endl;
    }
}

Measured memory_bytes: 4864
import math
a,b,h,m = map(int,input().split())
w_zi = 2*math.pi/(12*60)
w_hun = 2*math.pi/60
zi_x = a*math.cos(-w_zi*(h*60+m))
zi_y = a*math.sin(-w_zi*(h*60+m))
hun_x = b*math.cos(-w_hun*(h*60+m))
hun_y = b*math.sin(-w_hun*(h*60+m))

ans = math.sqrt((zi_x - hun_x)**2 + (zi_y - hun_y)**2)
print(ans)

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int a,b;
  string s;
  char c;
  cin>>a>>s>>b;
  c=s[b-1];
  rep(i,a){
    if(s[i]==c){
      cout<<c;
    }else{
      cout<<'*';
    }
  }
  cout<<endl;
}

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

int main() {
    int n;
    cin >> n;
    
    vector<long> luca(n + 1);
    
    luca.at(0) = 2;
    luca.at(1) = 1;
    
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 2; i <= n; i++) {
        luca.at(i) = luca.at(i-1) + luca.at(i-2);
    }
    cout << luca.at(n) << endl;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007


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

int main(){

    string s,t;
    cin >> s >> t;

    int n = (int)s.length();
    int m = (int)t.length();

    vector<vector<int>> dp(n+1,vector<int>(m+1,0));


    REP(i,n){
        REP(j,m){
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            if(s[i] == t[j]){
                chmax(dp[i+1][j+1],dp[i][j]+1);
            }
        }
    }

    string res = "";
    int len = dp[n][m];
    int i = n-1,j = m-1;
    while(len > 0) {
       if(s[i] == t[j]){
           res +=s[i];
           i--;j--;len--;
       }else if(dp[i+1][j+1] == dp[i][j+1]){
           i--;
       }else{
           j--;
       }
    }

    reverse(ALL(res));

    if(res.length() == 0){
        cout << ' ' << endl;
    }else{
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 38584
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    string S;
    ll K;
    cin >> S;
    cin >> K;
    int N = S.length();

    for(int i = 0; i < N; i++){
        char s = S[i]; 
        int dist = (s == 'a') ? 0 : 26 - (s - 'a');
        if(dist <= K){
            S[i] = 'a';
            K -= dist;
        }
        //cout << K << endl;

        if(i == N-1){
            S[i] = 'a' + (((S[i] - 'a') + K%26) % 26);
        }
    }

    cout << S << endl;
    return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int> par(N, -1);
    auto bfs = [&](int s) -> vector<int> {
        vector<int> dist(G.size(), -1);
        queue<int> que;
        dist[s] = 0;
        que.push(s);
        while(!que.empty()) {
            int cur = que.front();
            que.pop();
            for(auto &to : G[cur]) {
                if(dist[to] == -1) {
                    dist[to] = dist[cur] + 1;
                    par[to] = cur;
                    que.push(to);
                }
            }
        }
        return dist;
    };
    bfs(0);
    cout << "Yes" << '\n';
    for(int i = 1; i < N; ++i) cout << par[i] + 1 << '\n';
    return 0;
}


Measured memory_bytes: 10548
N, M = [int(i) for i in input().split(' ')]
H = [-1]
H.extend([int(i) for i in input().split(' ')])

links = [set() for _ in range(N + 1)]

for _ in range(1, M + 1):
    A, B = [int(i) for i in input().split(' ')]
    links[A].add(H[B])
    links[B].add(H[A])

count = 0
for i in range(1, N + 1):
    if len(links[i]) == 0:
        count += 1
        continue
    if H[i] > max(links[i]):
        count += 1

print(count)

Measured memory_bytes: 38972
use std::cmp;
use std::collections::HashMap;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let mut hash: HashMap<String, usize> = HashMap::new();

    for _ in 0..n {
        let s = read_as_string();
        *hash.entry(s).or_insert(0) += 1;
    }

    println!("AC x {}", *hash.entry("AC".to_owned()).or_insert(0));
    println!("WA x {}", *hash.entry("WA".to_owned()).or_insert(0));
    println!("TLE x {}", *hash.entry("TLE".to_owned()).or_insert(0));
    println!("RE x {}", *hash.entry("RE".to_owned()).or_insert(0));
}


Measured memory_bytes: 2196
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef pair<int,int> pi;
const int N=2e5+5;
multiset<int>to[N];map<pi,int>mp;queue<pi>q;int n;
inline void ins(R int u,R int v){
	if(u==v)return;
	if(u>v)swap(u,v);
	++mp[pi(u,v)],to[u].insert(v),to[v].insert(u);
	if(mp[pi(u,v)]==2)q.push(pi(u,v));
}
inline void del(R int u,R int v){
	if(u>v)swap(u,v);
	if(mp.count(pi(u,v)))mp.erase(pi(u,v));
}
inline void merge(R int u,R int v){
	for(auto w:to[v])del(w,v),to[w].erase(to[w].find(v)),ins(w,u);
}
int main(){
	scanf("%d",&n);
	for(R int i=1,u,v;i<=n*2-2;++i)scanf("%d%d",&u,&v),ins(u,v);
	fp(i,1,n-1){
		while(233){
			if(q.empty())return puts("NO"),0;
			R pi t=q.front();q.pop();
			if(mp.count(t)){
				if(to[t.fi].size()<to[t.se].size())swap(t.fi,t.se);
				merge(t.fi,t.se);
				break;
			}
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 43136
//8:10
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define MAXt 16*100000

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vp;

typedef long long ll;

int dp[(1<<16)][16];
int dp2[(1<<16)][16];

vvi D;
int N;

int ftime(int c,int d){
    if(dp2[c][d]!=0) return dp2[c][d];
    int mi = D[d][0];
    c = c<<1;
    REP(j,1,N+1){
        if(j-1==d) continue;
        if(((1<<j)&c)==1<<j){
            mi = min(mi,D[d][j]);
        }
    }
    return dp2[(c>>1)][d] = mi;
}

int rec(int c,int d){
    c|=(1<<d);//????????????
    if(dp[c][d]!=0) return dp[c][d];
    // cout<<"@c :"<<c;
    // cout<<" d :"<<d<<endl;
    if(c==(1<<N)-1) return dp[c][d] = ftime(c, d);
    else{
        int mi=MAXt;
        rep(i,N){
            if(i==d)continue;
            if(((1<<i)&c)==1<<i)continue;
            mi = min(mi,ftime(c, d) + rec(c, i));
        }
        return dp[c][d]=mi;
    }
    return dp[c][d]=MAXt;
}

int main() {
    vvi eD;
    while(1){
        rep(i,(1<<16)){
            rep(j,16){
                dp[i][j]=0;
                dp2[i][j]=0;
            }
        }
        cin>>N;
        if(N==0)break;
        D = eD;
        rep(i,N){
            D.pb(vi());
            rep(j,N+1){
                int t;
                cin>>t;
                D[i].pb(t);
            }
        }
        int mi = MAXt;
        rep(i,N){
            mi = min(mi,rec(0, i));
            // cout<<"@mi: "<<mi<<endl;
        }
        cout<<mi<<endl;
        // rep(i,N){
        //     cout<<"@: ";
        //     rep(j,N+1){
        //         cout<<D[i][j]<<" ";
        //     }
        //     cout<<endl;
        // }
    }


    return 0;
}

Measured memory_bytes: 11252
S = input()
if S == 'SAT':
  print(1)
if S == 'SUN':
  print(7)
if S == 'MON':
  print(6)
if S == 'TUE':
  print(5)
if S == 'WED':
  print(4)
if S == 'THU':
  print(3)
if S == 'FRI':
  print(2)
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1e17;
const ll MOD = 1000000007;
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,n,y,t,q,temp,count=0,f=0,l;
    cin>>n;
    ll a[n+1] = {0},dp[n+1][n+1], pre[n+1]= {0};    
    memset(dp,0,sizeof(dp));
    for(i=1;i<=n;i++){
    	cin>>a[i];    	
    }	
    for(i=0;i<=n;i++){    	
    	dp[i][i] = 0;
    	pre[i] = pre[i-1] + a[i];
    }	

    for(l=2;l<=n;l++){
    	for(i=1;i<=n-l+1;i++){
    		j = i+l-1;
    		dp[i][j] = inf;
    		for(k=i;k<j;k++){    			
    			dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + pre[j] - pre[i-1]);
    		}
    	}
    }
    
    // for(i=0;i<=n;i++){
    // 	for(j=0;j<=n;j++){
    // 		cout<<dp[i][j]<<" ";
    // 	}
    // 	cout<<"\n";
    // }	    
    cout<<dp[1][n];
}    
    

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

/*
条件がややこしい。
あるiの数字と、それより前の数字すべてをみて、
iの数字がそれらより小さいかどうか。

普通にやるとO(N^2)でドボン。
順列っていうのがポイントか？

というより、その都度最小値保存しておいて、それと比べればいいな。
*/

int main() {
    // cout << 2e5 << endl;
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }

    int minv = 2e6;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        minv = min(minv, P[i]);
        if (minv >= P[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

    using namespace std;
    #define ll  long long
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define pb push_back
    #define in insert
    #define test   ll t;cin>>t;while(t--)
    #define bs  binary_search
    #define rep1(x,n) for(ll x=n-1;x>=0;x--) 
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db  double
    #define sc scanf
    #define pf printf
    const ll MAX=1e8;
    //ll d[MAX],h[MAX];
    const double pi=3.14159265358979323846;
    const ll M=2e18 +7;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
   
      bool isPrime(ll n) 
{  
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6){ 
        if (n % i == 0 || n % (i + 2) == 0){ 
            return false; 
        }
    }
    return true; 
} 
bool pdrome(string s){
    ll n = s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            return false;
        }
    }
    return true;
}
ll mindig(ll x){
    ll ans = 9;
    ll t = x;
    while(x){
        ans = min(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll maxdig(ll x){
    ll ans = 0;
    ll t = x;
    while(x){
        ans = max(ans,x%10);
        x/=10;
    }
    x = t;
    return ans;
}
ll modpow(ll x,ll n,ll M){
	if(n==0)return 1%M;
	ll u=modpow(x,n/2,M);
	u=(u*u)%M;
	if(n%2==1)u=(u*x)%M;
	return u;

}
ll sum(ll a) {
    ll result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}


  
  
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
        ll n;cin>>n;
        ll ans1,ans2;
        for(ll x=-118;x<=119;x++){
        	for(ll i=-119;i<=118;i++){
        		if(modpow(x,5,M)-modpow(i,5,M)==n){
        			ans1=x;
        			ans2=i;
        			break;
        		}
        	}
        }
        cout<<ans1<<" "<<ans2;
    return 0;
}
    


Measured memory_bytes: 3616
let h, w, c = Scanf.scanf " %d %d" @@ fun a b -> a, b, ref 0
let a_ss = Array.(init h @@ fun _ -> init w @@ fun _ -> Scanf.scanf " %c" @@ fun a -> if a = '#' then incr c; a)
let rec f i y x = if i >= h + w - 2 then (if y = h - 1 && x = w - 1 then (print_endline "Possible"; exit 0))
  else (if x + 1 < w && a_ss.(y).(x + 1) = '#' then f (i + 1) y (x + 1); if y + 1 < h && a_ss.(y + 1).(x) = '#' then f (i + 1) (y + 1) x)
let _ = if !c = h + w - 1 then f 0 0 0; print_endline "Impossible"

Measured memory_bytes: 2432
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll x, y, z;
struct coins {
	ll sil; ll br; ll person;
};

bool order(coins p, coins q) {
	return p.sil > q.sil;
}
struct ad {
	ll coin; ll person;
	bool operator<(const ad& rhs) const {
		return coin < rhs.coin;
	}
};

ll const MAX = 100005;
ll color[MAX];
coins a[MAX];
priority_queue<ad> pq1, pq2;
ll const INF = 1e18;
int main() {
	ll n;
	cin >> x >> y >> z;
	n = x + y + z;
	ll ttl = 0;
	REP(i, 1, x + y + z) {
		ll s, t, r;
		cin >> s >> t >> r;
		t -= s; r -= s;
		a[i] = { t,r,i };
		ttl += s;
	}
	SORT_O(a, n, order);
	REP(i, 1, y) {
		color[i] = 2;
		ttl += a[i].sil;
		ll t = a[i].br - a[i].sil;
		pq1.push({ t,i });
	}
	REP(i, y + 1, n) { 
		color[i] = 1;
		ll t = a[i].br;
		pq2.push({ t,i });
	}
	ll cur = y + 1;
	ll iii = 0;
	while(iii < z){
		ad s, t;
		if (pq1.empty()) {
			s = { -INF,0 };
		}
		else s = pq1.top();
		if (pq2.empty()) {
			t = { -INF,0 };
		}
		else {
			t = pq2.top();
		}
		while (color[cur] != 1) {
			cur++;
		}
		if (s.coin +  a[cur].sil > t.coin) {
			ttl += s.coin + a[cur].sil;
			pq1.pop();
			iii++;
			color[s.person] = 3;
			color[cur] = 2;
			pq1.push({ a[cur].br - a[cur].sil, cur });
		}
		else {
			pq2.pop();
			if (color[t.person] != 1) {
				continue;
			}
			else {
				color[t.person] = 3;
				iii++;
				ttl += t.coin;
			}
		}
	}
	cout << ttl << endl;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;

    if(x ==3 or x == 5 or x==7)
        YES();
    else
        NO();



    return 0;
}


Measured memory_bytes: 892
s = str(input())
n = len(s)-1
t = 2**n

result = 0
for i in range(t):
  p = str(bin(i))[2:]
  p = '0'*(n-len(p))+p
  exList = []
  for j,k in enumerate(s):
    exList.append(k)
    if j != n and  p[j] == '1':
      exList.append('+')
  result += eval(''.join(exList))

print(result)
    
    


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  int sum = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    while(a % 2 == 0) {
      a /= 2;
      sum++;
    }
  }
  cout << sum << endl;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


class BIT{
private:
  int n;
  VI bit;
public:
  // prepare [0..n), assign to bit[1..n]
  BIT(int n_){
	n = n_;
	bit.assign(n+1, 0);
  }

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

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

  // return minimum i s.t. x <= bit[0..i)
  int lower_bound(int x){
	if(x <= 0) return 0;
	int i = 1;
	for(;i<=n;i<<=1);
	i >>= 1;
	int res = 0;
	for(;i>0;i>>=1){
	  if(res+i <= n && bit[res+i] < x){
		x -= bit[res+i];
		res += i;
	  }
	}
	return res+1;
  }
};

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

  int N, Q;
  cin >> N >> Q;
  BIT bit(N);
  while(Q--){
	int c, x, y;
	cin >> c >> x >> y;
	--x;
	if(c == 0){
	  bit.add(x, y);
	}
	else{
	  cout << bit.sum(y) - bit.sum(x) << endl;
	}
  }

  return 0;
}



Measured memory_bytes: 3380
W=input().lower()
A=[]
B={}
while True:
    T=input().split()
    if T[0]=="END_OF_TEXT":
        for s in A:
            if s in B:
                B[s]+=1
            else:
                B[s]=1
        print(B[W])
        break
    else:
        for i in range(len(T)):
            T[i]=T[i].lower()
        A=A+T
        T=[]



Measured memory_bytes: 5560
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int ball[200001] = { 0 };
	int N, K;
	int start = 0;
	int total = 0;
	int num = 0;
	cin >> N >> K;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		ball[tmp]++;
	}
	/*cout << "�e�X�g" << endl;
	for (int i = 0; i <= 10; i++)
	{
		
		cout << i << ":" << ball[i] << endl;
	}*/

	sort(ball, ball + 200001, greater<int>());

	/*for (int i = 0; i <= 200000; i++)
	{
		if (total + i*ball[i] > K) {
			start = i;
			break;
		}
		else {
			total += i*ball[i];
		}
	}

	if (start != 0) {
		for (int i = start; i <= 200000; i++)
		{
			num += ball[i];
		}
	}*/

	for (int i = K; i <= 200000; i++)
	{
		num += ball[i];
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 1024