akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input};

const M: usize = 1e+9 as usize + 1;
// const M: usize = 99;

#[derive(Debug, Clone)]
struct Node {
    a: usize,
    v: usize,
    ns: Vec<usize>,
}

// 二分探索（配列は昇順にソートされているものとする）
fn bisect<T: PartialOrd>(a: &mut [T], v: T, lo: usize, hi: usize) -> usize {
    if hi - lo < 2 {
        if v > a[lo] {
            return lo + 1;
        } else {
            return lo;
        }
    } else {
        let m = (lo + hi) / 2;

        if v <= a[m] {
            return bisect(a, v, lo, m);
        } else {
            return bisect(a, v, m, hi);
        }
    }
}

fn dfs(nodes: &mut [Node], idx: usize, lines: &mut [usize]) {
    let i = bisect(lines, nodes[idx].a, 0, lines.len());
    let v = lines[i];

    if lines[i - 1] >= nodes[idx].a || lines[i] < nodes[idx].a {
        panic!("panic!");
    }

    lines[i] = nodes[idx].a;
    nodes[idx].v = bisect(lines, M, 0, lines.len()) - 1;

    for n in nodes[idx].ns.clone().iter() {
        if nodes[*n].v != 0 {
            continue;
        }

        dfs(nodes, *n, lines);
    }

    lines[i] = v;
}

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [usize; in_n], in_v: [[usize; 2]; in_n - 1]};
    let mut nodes = Vec::with_capacity(in_n);
    let mut lines = vec![M; in_n + 1];

    for a in in_a.iter() {
        nodes.push(Node {
            a: *a,
            v: 0,
            ns: vec![],
        })
    }

    for v in in_v.iter() {
        nodes[v[0] - 1].ns.push(v[1] - 1);
        nodes[v[1] - 1].ns.push(v[0] - 1);
    }

    lines[0] = 0;

    dfs(&mut nodes, 0, &mut lines);

    for n in nodes.iter() {
        println!("{}", n.v);
    }
}


Measured memory_bytes: 59288
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)

  sc.Scan()
  s := sc.Text()

  a := make([]int, 26)

  for i := 0; i < len(s); i++ {
    a[int(s[i] - 'A')]++
  }

  for i := 0; i < len(a); i++ {
    if a[i] != 0 && a[i] != 2 {
      fmt.Println("No")
      os.Exit(0)
    }
  }
  fmt.Println("Yes")

}



Measured memory_bytes: 640
#include <iostream>
int main()
{
  int N;
  std::cin >> N;
  int a,b,c;
  a = N/100;
  b = N/10%10;
  c = N%10;
  
  if( a==7 || b==7 || c==7 ){ std::cout << "Yes" <<std::endl;}
  else{ std::cout << "No" <<std::endl;}
}

Measured memory_bytes: 3628
import java.util.Scanner;
  
public class Main { 
    public static void main(String[] args) { 
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();                                             
        int h = x/3600;
        int m = (x%3600)/60;
        int s = ((x%3600)%60)%60;
  
        System.out.println(h+":"+m+":"+s);
    }
}

Measured memory_bytes: 26200
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;

    vector<vector<char> > f(t.length()+1);
    vector<vector<char> > g(t.length()+1);
    
    for(int i=0;i<s.length();i++){
	for(int j=0;j<t.length();j++){
	    if(s[i]==t[j]){
		g[j+1]=f[j];
		g[j+1].push_back(s[i]);
	    }
	    else{
		if(f[j+1].size()>g[j].size())
		    g[j+1]=f[j+1];
		else
		    g[j+1]=g[j];
	    }
	}
	g.swap(f);
    }
    for(int i=0;i<f[t.length()].size();i++)
	cout<<f[t.length()][i];
    cout<<endl;

    
    return 0;
}


Measured memory_bytes: 13696
package main

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

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func readLine() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	input := strings.Split(readLine(), " ")
	n, _ := strconv.Atoi(input[0])
	y, _ := strconv.Atoi(input[1])
	z := -1
	result := map[string]int{
		"x": -1,
		"y": -1,
		"z": -1,
	}

	for i := 0; i <= n; i++ {
		for j := 0; j <= (n - i); j++ {
			z = n - i - j
			if (i*10000+j*5000+z*1000) == y && z >= 0 {
				result["x"] = i
				result["y"] = j
				result["z"] = z
				break
			}
		}
	}

	fmt.Fprintf(writer, "%d %d %d", result["x"], result["y"], result["z"])
	writer.Flush()
}


Measured memory_bytes: 640
#include <iostream>

int main() 
{
	typedef long long ll;
	ll H, N, A, sum = 0;
	std::cin >> H >> N;
	for (int i = 0; i < N; ++i)
	{
		std::cin >> A;
		sum += A;
	}

	if (sum < H)
		std::cout << "No" << std::endl;
	else
		std::cout << "Yes" << std::endl;

		return 0;
}

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

int main() {
  long long n, m, current, f, s;
  map<long long, long long> memo;
  memo[0] = 1;
  long long sum = 0, ans = 0;
  scanf("%lld %lld", &n, &m);
  for (long long i=0; i<n; i++) {
    scanf("%lld", &current);
    sum = (sum + current) % m;
    memo[sum]++;
  }
  for (auto it : memo) {
    f = it.first;
    s = it.second;
    cerr << f << " " << s << endl;
    ans += (s*(s-1)/2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
import java.util.*

//

fun main() {
    abc168d()
}

fun abc168d() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val toSign = IntArray(n + 1) { 0 }
    toSign[0] = -1
    toSign[1] = -1
    val loads = Array<MutableSet<Int>>(n + 1) { mutableSetOf() }
    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        loads[a].add(b)
        loads[b].add(a)
    }
    val queue = ArrayDeque<Int>()
    val reached = mutableSetOf<Int>(1)
    queue.add(1)
    while (queue.isNotEmpty() && reached.size < n) {
        val size = queue.size
        for (i in 0 until size) {
            val base = queue.pollFirst()
            for (l in loads[base]) {
                if (l !in reached) {
                    reached.add(l)
                    queue.add(l)
                    toSign[l] = base
                }
            }
        }
    }
    if (toSign.contains(0)) {
        println("No")
    } else {
        println("Yes")
        for (i in 2..n) {
            println(toSign[i])
        }
    }
}


Measured memory_bytes: 119784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while(x <= y) {
    ans++;
    x *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

ans = list(map(ord, S))
for i in range(len(ans)):
    ans[i] = ans[i] + N
    if ans[i] > ord("Z"):
        ans[i] = ans[i] - 26

for ans in ans:
    print("".join(chr(ans)), end="")

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

int main() {
  int n, m, p;
  while(cin >> n >> m >> p, n) {
    vector<int> v(n);
    int sum = 0;
    for(int i = 0; i < n; i++) {
      cin >> v[i];
      sum += v[i]*100;
    }
    if(v[m-1] == 0) cout << 0 << endl;
    else {
      int ans = (sum - sum*((double)p/100)) / v[m-1];
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1196
n=int(input())
lst=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(lst[0]-lst[1])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(lst[i]-lst[i-1]),dp[i-2]+abs(lst[i]-lst[i-2]))
print(dp[n-1])

Measured memory_bytes: 13900
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-09 17:50:51
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n, -1));

  for (int i = 0; i < n; ++i) {
    int A; cin >> A;
    for (int j = 0; j < A; ++j) {
      int x, y; cin >> x >> y; --x;
      if (y) {
        a[i][x] = 1;
      } else {
        a[i][x] = 0;
      }
    }
  }

  int ans = 0;

  for (int bit = 0; bit < (1 << n); ++bit) {
    bitset<20> bs(bit);
    bool flag = true;
    for (int i = 0; i < n; ++i) {
      if (bs.test(i)) {
        for (int j = 0; j < n; ++j) {
          if (a[i][j] == -1) continue;
          if (a[i][j] == 1 && !bs.test(j) || a[i][j] == 0 && bs.test(j)) {
            flag = false;
            break;
          }
        }
      }
    }
    if (flag) {
      ans = max(ans, static_cast<int>(bs.count()));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main() //input->compute->output
{
        int A, B;
        cin >> A >> B;
        int s, e;
        s = B - A + 1;
        e = B + A - 1;
        cout << s;
        for (int i = s + 1; i < e + 1; i++)
        {
                cout << " " << i;
        }
        cout << endl;

        return 0;
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b = readInts()
    judge = 0
    if a <= 0 <= b:
        pass
    elif a <= b < 0:
        if (abs(a) - abs(b) + 1)%2:
            judge = 2
        else:
            judge = 1
    else:
        judge = 1

    if judge == 0:#0がある
        print('Zero')
    elif judge == 1:#正
        print('Positive')
    else:
        print('Negative')
if __name__ == '__main__':
  main()


Measured memory_bytes: 5272
def main():
    n = input()
    non_zero = int(input())
    length = len(n)
    dp = [[[0, 0] for _ in range(non_zero + 1)] for _ in range(length + 1)]
    dp[0][0][0] = 1
    for i in range(length):
        for j in range(non_zero + 1):
            for k in range(2):
                now_digit = int(n[i])
                for next_d in range(10):
                    new_i = i + 1
                    new_j = j
                    new_k = k
                    if next_d > 0:
                        new_j += 1
                    if new_j > non_zero:
                        continue
                    if k == 0:
                        if next_d > now_digit:
                            continue
                        elif next_d < now_digit:
                            new_k = 1
                    dp[new_i][new_j][new_k] += dp[i][j][k]
    print(sum(dp[length][non_zero]))


if __name__ == '__main__':
    main()



Measured memory_bytes: 8984
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	char s[100][100];
	int i, j;
	int H, W;
	cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			cin >> s[i][j];
		}
	}
	rep(j, W) {
		int f = 1;
		rep(i, H) {
			if (s[i][j] == '#') {
				f = 0;
				break;
			}
		}
		if (f) {
			rep(i, H) {
				s[i][j] = 0;
			}
		}
	}
	rep(i, H) {
		int f = 1;
		rep(j, W) {
			if (s[i][j] == '#') {
				f = 0;
				break;
			}
		}
		if (f) {
			rep(j, W) {
				s[i][j] = 0;
			}
		}
	}
	rep(i, H) {
		int f = 0;
		rep(j, W) {
			if (s[i][j] != 0) {
				cout << s[i][j];
				f = 1;
			}
		}
		if (f) cout << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);

  cout << a[n-1] - a[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

void dfs(const vector<vector<int>>& nodes, map<pair<int, int>, ll>& costs, const int& s, vector<ll>& d) {
  for (auto& t : nodes[s]) {
    if (d[t] != INFL) continue;
    d[t] = d[s] + costs[{min(s, t), max(s, t)}];
    dfs(nodes, costs, t, d);
  }
}

int main(int argc, char* argv[])
{
  int h, w, d;
  cin >> h >> w >> d;

  vector<pair<int, int>> mp(h * w + 1);
  rep(i, h) rep(j, w) {
    int a;
    cin >> a;
    mp[a] = make_pair(i, j);
  }

  vector<vector<int>> costs(d+1, vector<int>());

  for (int i = 1; i <= d; i++) {
    auto s = mp[i];
    for (int j = 0; i + d * j <= h * w; j++) {
      if (j == 0) {
        costs[i].emplace_back(0);
      }
      auto t = mp[i + d * j];
      costs[i].emplace_back(abs(s.first - t.first) + abs(s.second - t.second));
      s = t;
    }
    for (int j = 1; j < costs[i].size(); j++) {
      costs[i][j] += costs[i][j-1];
    }
  }
/*
  cerr << "--" << endl;
  for (auto& v : costs) {
    for (auto& x : v) {
      cerr << x << " ";
    }
    cerr << endl;
  }
  cerr << "--" << endl;
*/
  int q;
  cin >> q;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    int idx = l % d;
    if (idx == 0) idx = d;
    int s = (l+d-1) / d;
    int t = (r+d-1) / d;
//    cerr << s << " " << t << " r: " << r << endl;
    cout << costs[idx][t] - costs[idx][s] << endl;
  }

  return 0;
}


Measured memory_bytes: 6016
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
	int n,m,in,MAX;
	vector<int> P;
	vector<int>::iterator it;
	
	while(scanf("%d%d",&n,&m)&&(n!=0||m!=0)){
		P.clear();
		
		for(int i = 0; i < n; i++){
			scanf("%d",&in);
			P.push_back(in);
		}
		for(int i = 0; i < n; i++){
			for(int j = i; j < n; j++){
				P.push_back(P[i]+P[j]);
			}
		}
	
		P.push_back(0);
		sort( P.begin(),P.end() );
		MAX = 0;
	
		for(int i = 0; i < P.size(); i++){
			if(P[i] > m){
				break;
			}
			it = upper_bound(P.begin(),P.end(),m-P[i]);
			it--;
			MAX = max(MAX,P[i] + *it);
		}
	
		printf("%d\n",MAX);
	}
	
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int D = 365;
V p(D);
V l(D, 0);
VV up(D, V(26));
void calc(ll& now, int x, int d) { // 今のスコア、どれを選んだか、何日目か(0-indexed)
	l[x] = d + 1;
	now += up[d][x];
	rep(j, 26) {
		now -= p[j] * ((d + 1) - l[j]);
	}
}
ll test(ll now, int x, int d) { // その選択をしてみる
	ll tmp = now;
	int old = l[x];
	l[x] = 0;
	tmp += up[d][x];
	rep(j, 26) {
		tmp -= p[j] * ((d + 1) - l[j]);
	}
	l[x] = old;
	return tmp - now;
}
int main() { // とりあえずgreedyにやる
	int d;
	cin >> d;
	ll now = 0;
	queue<int> que;
	rep(i, 26) cin >> p[i];
	rep(i, d) rep(j, 26) cin >> up[i][j];
	rep(i, d) {
		ll diff = UNDER;
		int select = -1;
		rep(j, 26) {
			if (chmax(diff, test(now, j, i))) select = j;
		}
		que.push(select + 1);
		calc(now, select, i);
	}
	while (!que.empty()) {
		cout << que.front() << endl;
		que.pop();
	}
	return 0;
}

Measured memory_bytes: 3688
import sys
h, w = map(int, input().split())
l = [list(input()) for i in range(h)]
for i in range(h):
  l[i] = ["."] + l[i] + ["."]
l = [["." for i in range(w+2)]] + l + [["." for i in range(w+2)]]
for i in range(1, h+1):
  for j in range(1, w+1):
    if l[i][j] == "#":
      if "#" not in [l[i-1][j], l[i][j-1], l[i][j+1], l[i+1][j]]:
        print("No")
        sys.exit()
print("Yes")

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

using namespace std;

int main()
{
    cout << fixed;
    cout << setprecision(10);
    int n;
    cin >> n;
    double p[n];
    double f[n+1][n+1];
    for(int i=0;i<n;i++)
    {
        cin >> p[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            f[i][j]=0;
        }
    }
    f[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            f[i+1][j+1]+=f[i][j]*p[i];
            f[i+1][j]+=f[i][j]*(1-p[i]);
        }
    }
    double rez=0.0;
    for(int j=(n+1)/2;j<=n;j++)
    {
        rez+=f[n][j];
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 70528
import numpy as np

abc = np.array([int(a) for a in input().split()])
abc = abc - np.array([np.min(abc)] * 3)
abc = np.sort(abc)
ans = 0
if abc[1] == 0:
    ans = abc[2]
elif abc[1] % 2 == 0:
    ans += abc[1] // 2
    ans += abc[2] - abc[1]
else:
    ans += 1
    abc[0] += 1
    abc[2] += 1
    ans += (abc[1] - abc[0]) // 2
    ans += abc[2] - abc[1]
print(ans)


Measured memory_bytes: 14436
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int num(int x){
    if(!x) return -1;
    return 1;
}

char sign(int x){
    if(!x) return '-';
    return '+';
}

void solve(){
    char A, B, C, D;
    cin >> A >> B >> C >> D;
    int a = A - '0', b = B - '0', c = C - '0', d = D - '0';
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < 2; ++j){
            for(int k = 0; k < 2; ++k){
                int sum = a + num(i) * b + num(j) * c + num(k) * d;
                if(sum == 7){
                    cout << a << sign(i) << b << sign(j) << c << sign(k) << d << "=7\n";
                    return;
                }
            }
        }
    }
}

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

    solve();
    
    return 0;
}

Measured memory_bytes: 256
# include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == 5&& b == 5&& c == 7)
		printf("YES\n");
	else if (a == 5&& b == 7&& c == 5)
		printf("YES\n");
	else if (a == 7&& b == 5&& c == 5)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

const int INF = 0x3f3f3f3f;
long long B1[100005], B2[100005];
int n, q, t1, t2, t3, t4;

long long qry(long long* ar, int p) {
	long long rt = 0;
	while (p) {
		rt += ar[p];
		p -= (p & -p);
	}
	return rt;
}

void upt(long long* ar, int p, long long val) {
	while (p <= n) {
		ar[p] += val;
		p += (p & -p);
	}
}

void rangeUpt(int l, int r, long long val) {
	upt(B1, l, val);
	upt(B1, r + 1, -val);
	upt(B2, l, val * (l - 1));
	upt(B2, r + 1, -val * r);
}

long long preSum(int p) {
	return qry(B1, p) * p - qry(B2, p);
}

long long rangeQry(int l, int r) {
	return preSum(r) - preSum(l - 1);
}

int main() {
	cin >> n >> q;
//	for (int i = 1; i <= n; i++) B1[i] = -INF, B2[i] = -INF;
	for (int i = 0; i < q; i++) {
		cin >> t1;
		if (t1 == 0) {
			cin >> t2 >> t3 >> t4;
			rangeUpt(t2, t3, t4);
		}
		else {
			cin >> t2 >> t3;
			cout << rangeQry(t2, t3) << endl;
		}
	}
}



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

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

    string S; cin >> S;
    long long K; cin >> K;
    for (int i = 0; i < S.size(); i++) {
        if (i == K - 1 || S[i] != '1') {
            cout << S[i] << "\n";
            return 0;
        }
    }
    cout << 1 << "\n";
}

Measured memory_bytes: 256
from sys import stdin

N, M = map(int, stdin.readline().split())
py = [list(map(int, stdin.readline().split())) for _ in range(M)]

for i in range(M):
    py[i].append(i)

py.sort()

px = []

ptmp = 0
xtmp = 1

for p, y, i in py:
    if p == ptmp:
        xtmp += 1
    else:
        ptmp = p
        xtmp = 1
    px.append([str(p).zfill(6) + str(xtmp).zfill(6), i])


px.sort(key=lambda x: x[1])

for out, i in px:
    print(out)


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

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

int main(){
	long double a,b;
	int c;
	while(cin>>a>>b>>c){
		int ans=0;
		if(a==0&&b==0&&c==0) break;
		int n=c+100;
		rep(i,n){
			rep(j,n){
			if(i==0) continue;
			int aa=i;
			int bb=j;
			if(bb==0) continue;
			// if(aa>=c) continue;
			// if(bb>=c) continue;
			// cout<<i<<endl;
			int aaa=aa*(100.0+a)/100.0;
			int bbb=bb*(100.0+a)/100.0;
			// cout<<aaa+bbb<<" "<<c<<endl;
			if(aaa+bbb!=c) continue;
			aaa=aa*(100.0+b)/100.0;
			bbb=bb*(100.0+b)/100.0;
			// cout<<aaa<<" "<<bbb<<endl;
			int tmp=aaa+bbb;
			// tmp+=bbb*(100.0+b)/100.0;
			ans=max(ans,tmp);
		}}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1228
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        bool isCon = true;
        while(isCon){
            string tmp = System.Console.ReadLine();
            string[] ab = tmp.Split(' ');
            int a = Convert.ToInt32(ab[0]);
            int b = Convert.ToInt32(ab[1]);
            
            if(a == 0 && b == 0){
                isCon = false;
            }else{
                for(int i = 0; i<a;i++){
                    for(int j = 0; j < b; j++){
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
                
            }
        }
    }
}

Measured memory_bytes: 8920
#include "bits/stdc++.h"
using namespace std;

int rui[1010];
int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	ans+=n+1;
	fill(rui,rui+1010,0);
	for(int i=0;i<m;i++)
	{
		int c,d;
		cin>>c>>d;
		if(c<d)
		{
			rui[c]++;
			rui[d]--;
		}
	}
	for(int i=1;i<1010;i++)
		rui[i]=rui[i]+rui[i-1];
	
	//累積和が1以上の区間を見る
	int i=0;
	while(i<n+1)
	{
		if(rui[i]>0)
		{
			int l=i;
			while(rui[i]>0)
				i++;
			int r=i;
			ans+=(r-l)*2;
		}
		i++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H;
    cin >> W >> H;
    vector<P> cost(W + H);
    rep(i, 0, W) {
        cin >> cost[i].first;
        cost[i].second = 0;
    }
    rep(i, 0, H) {
        cin >> cost[i + W].first;
        cost[i + W].second = 1;
    }
    sort(all(cost));
    ll ans = 0;
    ll a = W + 1, b = H + 1;
    rep(i, 0, cost.size()) {
        if (cost[i].second == 0) {
            ans += b * cost[i].first;
            a--;
        }
        else {
            ans += a * cost[i].first;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
const int maxn = 50 + 10;
const int inf = 1 << 30;
int n, D[maxn][3], table[13], timeGap[maxn], ans;
int getMin(){
	int minimum = inf;
	for(int i = 0; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			int Gap = abs(timeGap[i] - timeGap[j]);
			Gap = min(Gap, 24 - Gap);
			minimum = min(minimum, Gap);
		}
	}
	// cout << "ans:";
	// for(int i = 0; i <= n; i++){
	// 	cout << timeGap[i] << " ";
	// }
	// cout << endl;
	return minimum;
}
void dfs(int k){
	for(int i = 1; i <= D[k][0]; i++){
		timeGap[k] = D[k][i];
		if(k == n){
			int minimum = 0;
			minimum = getMin();
			ans = max(ans, minimum);
		}
		else dfs(k + 1);
	}
}
int main(){
	//freopen("input.txt", "r", stdin);
	while(scanf("%d", &n) != EOF){
		int flag = 0;
		ans = -inf;
		memset(table, 0, sizeof(table));
		D[0][0] = 1;
		D[0][1] = 0;
		table[0]++;
		for(int i = 1; i <= n; i++){
			int temp = 0;
			scanf("%d", &temp);
			D[i][0] = 2;
			D[i][1] = temp;
			D[i][2] = 24 - temp;
			if(temp == 12) D[i][0] = 1;
			table[temp]++;
			if(table[temp] == 3) flag = 1;
		}
		if(!flag){
			for(int i = 0; i <= 12; i++){
				if(table[i] == 2){
					int p1 = 0, p2 = 0;
					for(int j = 1; j <= n; j++){
						if(D[j][1] == i && !p1) p1 = j;
						else if(D[j][1] == i && p1) {p2 = j; break;}
					}
					D[p1][0] = 1;
					D[p2][0] = 1;
					D[p2][1] = 24 - i;
				}
			}
			// for(int i = 0; i <= n; i++){
			// 	printf("%d %d %d\n", D[i][0], D[i][1], D[i][2]);
			// }
			dfs(0);
			printf("%d\n", ans);
		}
		else{
			printf("0\n");
		}	

	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int memo[2001][2001];
char grid[2001][2001];
int ans=0;
int H,W;
int L[2001][2001];
int R[2001][2001];
int D[2001][2001];
int U[2001][2001];

int dfs(int x,int y){
 
}
int main(){
  int H,W;cin >>H>>W;
  rep(i,2001){
  	rep(j,2001){
    	L[i][j]=0;R[i][j]=0;D[i][j]=0;U[i][j]=0;
    }
  }
   rep(i,H){
  	 string s;
     cin >>s;
     rep(j,W){
    	grid[i][j]=s[j];
     
     }
  }
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
    	if(grid[i][j]=='#'){L[i][j]=0;}
      	else{
          if(j==0){L[i][j]=1;}
          else{L[i][j]=L[i][j-1]+1;}
        }
    }
  }
  for(int i=0;i<H;i++){
  	for(int j=W-1;j>=0;j--){
    	if(grid[i][j]=='#'){R[i][j]=0;}
      	else{
          if(j==W-1){R[i][j]=1;}else{R[i][j]=R[i][j+1]+1;}
        }
    }
  }
  for(int i=0;i<W;i++){
  	for(int j=0;j<H;j++){
    	if(grid[j][i]=='#'){U[j][i]=0;}
      	else{
          if(j==0){U[j][i]=1;}else{U[j][i]=U[j-1][i]+1;}
        }
    }
  }
  for(int i=0;i<W;i++){
  	for(int j=H-1;j>=0;j--){
    	if(grid[j][i]=='#'){D[j][i]=0;}
      	else{
          if(j==H-1){D[j][i]=1;}else{D[j][i]=D[j+1][i]+1;}
        }
    }
  }
  int ans=0;
  rep(i,H){
     rep(j,W){
    	int p=L[i][j]+R[i][j]+D[i][j]+U[i][j]-3;
       ans=max(p,ans);
    }
  }
  cout<<ans;
    
}

Measured memory_bytes: 67840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    //sonomama
    if(A < D && B < C && C < D || A < D && C < B && C < D){
        int c = 0;
        bool flag = 1;
        rep(i,A-1,C){
            if(S[i] == '#'){
                c++;
                if(c == 2){
                    flag = 0;
                    break;
                }
            }else{
                c = 0;
            }
        }
        c = 0;
        rep(i,B-1,D){
            if(S[i] == '#'){
                c++;
                if(c == 2){
                    flag = 0;
                    break;
                }
            }else{
                c = 0;
            }
        }
        if(!flag){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        int c = 0;
        bool flag = 1;
        rep(i,A-1,C){
            if(S[i] == '#'){
                c++;
                if(c == 2){
                    flag = 0;
                    break;
                }
            }else{
                c = 0;
            }
        }
        c = 0;
        bool flag2 = 0;
        rep(i,B-1,D){
            if(S[i] == '.'){
                c++;
                if(c == 3){
                    flag2 = 1;
                    break;
                }
            }else{
                c = 0;
            }
        }
        if(S[B-2] == '.' && S[B-1] == '.' && S[B] == '.' || 
        S[D-2] == '.' && S[D-1] == '.' && S[D] == '.')flag2 = 1;
        //cout << flag << " " << flag2 << endl;
        if(flag && flag2){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = (int) 1e9;
  for (char c = 'a'; c <= 'z'; c++) {
    string w = s;
    for (int it = 0; ; it++) {
      if (w.empty()) {
        break;
      }
      if (w == string(w.length(), c)) {
        ans = min(ans, it);
        break;
      }
      string nw = "";
      for (int i = 0; i < (int) w.size() - 1; i++) {
        if (w[i] == c || w[i + 1] == c) {
          nw += c;
        } else {
          nw += w[i];
        }
      }
      w = nw;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct space{
	int build;
	int floor;
	int room ;
	int pepole;
} A[120];

int FindPos(int build,int floor,int room)
{
	return (build-1)*30+(floor-1)*10+room-1;
}

int main()
{
	int floor,build,room,num,n,pos,k=0;
	for(int i=0 ;i<4;i++){
		for(int j=0;j<3;j++){
			for(n=0;n<10;n++){
				A[k].build=i+1;
				A[k].floor=j+1;
				A[k].room=n+1;
				A[k].pepole=0;
				k++;
			}
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>build>>floor>>room>>num;
		pos=FindPos(build,floor,room);
		A[pos].pepole+=num;
	}
	k=0;
	for(int i=0 ;i<4;i++){
		for(int j=0;j<3;j++){
			for(int n=0;n<10;n++){
				cout<<" "<<A[k].pepole;
				k++;
			}
			cout<<endl;
		}
		if (i!=3){
			for(int s=0;s<20;s++)
			cout<<"#";
			cout<<endl;	
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 3124
#include <algorithm>　　　  
#include <cctype>
#include <cmath>
#include <complex>　　　　
#include <cstdio>
#include <cstring>
#include <deque>　　　　
#include <functional>　　
#include <list>　　　　　　 
#include <map>　　　　　
#include <iomanip>       
#include <iostream>
#include <queue>　　　　　
#include <set>　　　　　　
#include <stack>　　　　　
#include <string>　
#include <vector>
#define INF 0x3f3f3f3f
#define ll long long 
using namespace std; 
const ll N=1e5+100; 
ll n,m,v,p,a[N],sum[N],ans; 
int main(){ 
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p); 
	for (ll i=1; i<=n; i++) 
		scanf("%lld",&a[i]); 
	sort(a+1,a+1+n); 
	for (ll i=1; i<=n; i++) 
		sum[i]=sum[i-1]+a[i]; 
	a[n+1]=INF; 
	for (ll i=n; i>=1; i--) 
		if (i>=v){ 
			ll pos=upper_bound(a+1,a+2+n,a[i]+m)-a; 
			if (n-pos+1<p) ans++; 
		}else{ 
			ll pos=upper_bound(a+1,a+2+n,a[i]+m)-a; 
			if (n-pos+1>=p) continue; 
			if (v-i-p+1<=0){ 
				ans++; 
				continue; 
			} 
			ll cnt=v-i-p+1; 
			ll l=i+1;
			ll r=min(n-p+1,pos-1); 
			if (r-l+1>=cnt&&cnt*m<=(a[i]+m)*(r-l+1)-(sum[r]-sum[l-1])) 
				ans++; 
		}
	printf("%lld\n",ans); 
}

Measured memory_bytes: 4740
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

const ll mod = 1000000;
ll dp[101][5];
void add(ll &a, ll b) {
  a = (a+b) % mod;
}

int main() {
  int mat[5][5] = {
    1,1,1,1,0,
    1,1,1,0,0,
    1,1,1,0,1,
    0,0,1,1,0,
    1,0,0,0,1
  };
  int n,m;
  while(cin >> n >> m) {
    if (m == 1) {
      ll r = 1;
      REP(i,n) r = r * 2 % mod;
      cout << r << endl;
      continue;
    }
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    REP(i,n) {
      REP(j,5) {
        REP(k,5) {
          add(dp[i+1][k], dp[i][j]*mat[j][k]);
        }
      }
    }
    ll ans = 0;
    REP(i,4) add(ans, dp[n][i]);
    cout << ans << endl;
  }
}

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

#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, b, a) for(int i = (b); i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (ll)(1e9+7)
#define inf (ll)(2e9+9)
#define infl (ll)(2e18+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

/* -------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------*/

void A(){
	int n,a,b; cin>>n>>a>>b; 
	vi p(n); 
	int x=0,y=0,z=0; 
	rep(i,0,n-1) { 
		cin>>p[i]; 
		if(p[i]<=a) x++; 
		else if(p[i]>b) z++; 
		else y++; 
	}
	cout<<min(x,min(y,z)); 
}

int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    A(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


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

const int N = 303;

double dp[N][N][N];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi cnt(3);
    for (int i=0; i<n; i++) {
        int x;
        cin >> x;
        cnt[x-1]++;
    }
    for (int c=0; c<=n; c++) {
        for (int b=0; b<=n; b++) {
            for (int a=0; a<=n; a++) {
                int d = n-a-b-c;
                if (d == n) {
                    continue;
                }
                double p = 0.0;
                if (a) p += 1.0*a/n * (1 + dp[a-1][b][c]);
                if (b) p += 1.0*b/n * (1 + dp[a+1][b-1][c]);
                if (c) p += 1.0*c/n * (1 + dp[a][b+1][c-1]);
                if (d) p = (p+1.0*d/n) / (1 - 1.0*d/n);
                dp[a][b][c] = p;
            }
        }
    }
    cout << fixed << setprecision(14) << dp[cnt[0]][cnt[1]][cnt[2]] << '\n';
}


Measured memory_bytes: 217344
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int inverse(int x){
    return binpow(x, MOD - 2, MOD);
}

void solve()
{
    int n, sum = 0;
    cin >> n;
    V a(n);
    for(auto & i : a)   cin >> i , sum += i;
    int ans = 0;
    for(auto i : a){
        sum -= i;
        int te = (sum % MOD) * i;
        ans += te;
        ans = ans % MOD;
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++)
  {
  	for (int j = 0; j < W; j++)
    {
    	cin >> a.at(i).at(j);
    }
  }
  vector<char> row_white(H, '.');
  vector<char> row_black(H, '#');
  vector<char> column_white(W, '.');
  vector<char> column_black(W, '#');
  bool flag = true;
  for (int i = 0; i < H; i++)
  {
    if (a.at(i) == column_white) continue;
  	for (int j = 0; j < W; j++)
    {
      	for (int k = 1; k < H; k++)
        {
        	if (a.at(k).at(j) != a.at(k-1).at(j)) break;
          	if (a.at(k).at(j) == '.' && k == H - 1) flag = false;
        }
      	if (flag) cout << a.at(i).at(j);
      	flag = true;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
S = input()
a = int(S[:2])
b = int(S[2:])
judge = [0,0,0]
# in case of YYMM
if 1<=b<=12:
    judge[0] = 1
# in case of MMYY
if 1<=a<=12:
    judge[1] = 1

if sum(judge) == 2:
    print("AMBIGUOUS")
elif sum(judge) == 0:
    print("NA")
elif judge[0] == 1:
    print("YYMM")
else:
    print("MMYY")


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

using namespace std;

int main() {

	long n,m;
	cin >> n >> m;

	vector<string> a(n);
	vector<string> b(m);

	for (long i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (long i = 0; i < m; i++) {
		cin >> b[i];
	}

	bool fflg = false;
	for (long i = 0; i < n - m+1; i++) {
		for(long j=0;j<n-m+1;j++){
			if (a[i].substr(j, m) == b[0]) {
				for (long k = 0; k < m; k++) {
					if (a[i + k].substr(j, m) != b[k]) {
						break;
					}
					if (k == m-1) {
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}

	cout << "No" << endl;
}

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

int main() {

    int n;
    cin >> n;

    int num = n * 3;

    vector<int> a(num);

    for (int i = 0; i < num; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    long long sum = 0;

    for (int i = n; i < n*3; i+=2) {
        sum += a[i];
    }
    
    cout << sum << endl;

    return 0;

}


Measured memory_bytes: 1408
N,K = map(int,input().split())
A = list(map(int,input().split()))
r = [0]*N
p = 0
q = 1 #現在地
for i in range(K):
    if i == K-1:
        print(A[q-1])
        exit()
    q = A[q-1] #次の町
    if r[q-1] == 0:
        p += 1
        r[q-1] += p       
    else:
        p += 1
        y = r[q-1]
        break
z = (K-y) % (p-y)
for i in range(N):
    if r[i] == y+z:
        print(i+1)

Measured memory_bytes: 32388
def main():
    N = int(input())
    T, A = map(int, input().split())
    H = [int(h) for h in input().split()]
    min_d, min_i = float('inf'), None
    for i in range(N):
        aveT = T - 0.006 * H[i]
        if abs(aveT - A) < min_d:
            min_d = abs(aveT-A)
            min_i = i
    return min_i+1


if __name__ == '__main__':
    print(main())

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

int main(){
  ll A;
  d B;
  cin >> A >> B;
  B = round(B*100);
  A = A*(ll)B/100;
  cout << A << endl;
}

Measured memory_bytes: 3764
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

//change
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//math
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second)
    {
        return a.second < b.second;
    }
    else
    {
        return a.first < b.first;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<PII> ab(N + 1);
    for (int i = 1; i <= N; ++i)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ALL(ab), compare_by_b);
    int now = 0;
    FOR(i, 1, N)
    {
        now += ab[i].first;
        if (now > ab[i].second)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)

int L,l;

int main(){
	scanf("%d",&L);
	while(L>>l) ++l;
	printf("%d %d\n",l,l+l+__builtin_popcount(L)-3);
	F(i,1,l-1) printf("%d %d 0\n",i,i+1), printf("%d %d %d\n",i,i+1,1<<i-1);
	int S=1<<l-1;
	dF(i,l-2,0) if(L>>i&1){
		printf("%d %d %d\n",i+1,l,S);
		S|=1<<i;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define EPS 1e-10
typedef complex<double> P;

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int main() {
  int n;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    P a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
    if (fabs(cross(b - a, d - c)) < EPS) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}



Measured memory_bytes: 3044
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    
    string S, T;
    cin >> S >> T;

    int S_size = S.size();
    int T_size = T.size();

    string T_sub = T.substr(0,T_size-1);

    if ((S_size+1) == T_size){
        if(S == T_sub){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3584
// edpc_i
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<double> P(N);
    REP(i, N) cin >> P[i];


    vector<vector<double>> dp;
    dp.assign(N+1, vector<double>(N, 0));

    dp[0][0] = 1;
    REP(i, N){
        dp[i+1][0] = dp[i][0] * P[i];
        REPN(j, 1, N/2 + 1){
            dp[i+1][j] = dp[i][j] * P[i] + dp[i][j-1] * (1 - P[i]);
        }
    }

//    print2D(N+1, N, dp);

    double ans = 0;
    REP(j, N/2 + 1) ans += dp[N][j];

    print(ans);

    return 0;
}


Measured memory_bytes: 70656
/*
    Print Test Cases
*/

#include <stdio.h>

int main(void)
{
    int index[10000] = {0};
    int i;

    for (i = 0; i < 10000; i++) {
        scanf("%d", &index[i]);
        if (index[i] == 0)
            break;

        printf("Case %d: %d\n", i+1, index[i]);
    }
    return (0);
}

Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int even=0;
  int odd=0;
  for(int i=0;i<s.size();i++){
   if(i%2==0){
     if(s[i]=='1'){
       even++;
     }
     else{
       odd++;
     }
   }
    else{
      if(s[i]=='1'){
        odd++;
      }
      else{
        even++;
      }
    }
  }
  if(odd>=even){
    cout<<even<<endl;
  }
  else{
    cout<<odd<<endl;
  }
}

Measured memory_bytes: 512