akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

a,b,h,m = MAP()
theta = abs(360 * m / 60 - 360 * (h + m / 60) / 12) * pi / 180
ans = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theta))
print(ans)

Measured memory_bytes: 74720
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] freq = new int[200001];
    for (int i = 0; i < n; i++) {
      int t = sc.nextInt();
      freq[t]++;
    }
    Arrays.sort(freq);
    int ans = n;
    for (int i = 0; i < k; i++) {
      ans -= freq[200000 - i];
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 60552
#include <iostream>
using namespace std;
int main()
{
	int N,K;
	char S[10];
	cin >> N >> S >> K;
	char diff = S[K - 1];
	for (int i = 0; i < N; i++)
	{
		if (diff != S[i])
		{
			S[i] = '*';
		}
	}
	cout << S << endl;
		
	return 0;
}

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

int count(int x) {
    int ct = 0;
    rep(i,x) {
        if (x % (i+1) == 0) ct++;
    }
    return ct;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 0) continue;
        else if (count(i) == 8) ans++;
    }
    cout << ans << endl;
}

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

int main (){
  string A, B, C;
  cin >> A >> B >> C;
  
  char A1 = A.at(0);
  char B1 = B.at(0);
  char C1 = C.at(0);
  
  cout << A1 << B1 << C1 << endl;
}

Measured memory_bytes: 256
#line 1 "test/aoj/GRL_6_B.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_b"
#line 2 "test/aoj/../../graph/min-cost-flow.hpp"
#include <algorithm>
#include <vector>
#include <queue>

struct min_cost_flow {
  struct edge { int to, cap, cost, rev; };
  using P = std::pair<int, int>;
  const int INF_ = 1<<30;
  int V; // 頂点数
  std::vector<std::vector<edge>> G; // グラフの隣接リスト表現
  std::vector<int> h; // ポテンシャル
  std::vector<int> dist; // 最短距離
  std::vector<int> prevv, preve; // 直前の頂点と辺

  min_cost_flow(int V) : V(V), G(V), h(V), dist(V), prevv(V), preve(V) {}

  void add_edge(int from, int to, int cap, int cost) {
    G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
    G[to].push_back((edge){from, 0, -cost, (int)G[from].size()-1});
  }

  // sからtへの流量fの最小費用流を求める
  // 流せない場合は-1を返す
  int run(int s, int t, int f) { 
    int res = 0;
    std::fill(h.begin(), h.end(), 0);
    while (f > 0) { 
      std::priority_queue<P, std::vector<P>, std::greater<P>> q;
      std::fill(dist.begin(), dist.end(), INF_);
      dist[s] = 0;
      q.push({0, s});
      while (!q.empty()) { 
        P p = q.top(); q.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < (int)G[v].size(); ++i) { 
          edge &e = G[v][i];
          int d = dist[v] + e.cost + h[v] - h[e.to];
          if (e.cap > 0 && dist[e.to] > d) { 
            dist[e.to] = d;
            prevv[e.to] = v;
            preve[e.to] = i;
            q.push({dist[e.to], e.to});
          }
        }
      }
      if (dist[t] == INF_) {
        // これ以上流せない
        return -1;
      }
      for (int v = 0; v < V; ++v) h[v] += dist[v];

      // s-t間最短路に沿って目一杯流す
      int d = f;
      for (int v = t; v != s; v = prevv[v]) {
        d = std::min(d, G[prevv[v]][preve[v]].cap);
      }
      f -= d;
      res += d*h[t];
      for (int v = t; v != s; v = prevv[v]) {
        edge &e = G[prevv[v]][preve[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return res;
  }
};
#line 3 "test/aoj/GRL_6_B.test.cpp"

#include <iostream>
using namespace std;

typedef long long ll;

int main() {
  int V, E, F;
  cin >> V >> E >> F;
  min_cost_flow mcf(V);
  for (int i = 0; i < E; ++i) {
    int from, to, cap, cost;
    cin >> from >> to >> cap >> cost;
    mcf.add_edge(from, to, cap, cost);
  }
  cout << mcf.run(0, V-1, F) << endl;
}



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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, x, m;
  cin >> n >> x >> m;
  vector<pair<bool, int>> samefirst(m);
  rep(i,m) samefirst[i].first = false;
  vl a(m);
  a[0] = x;
  samefirst[a[0]].first = true;
  samefirst[a[0]].second = 0;
  int end = -1, aend = -1;
  for(int i=1; i<n; i++){
    a[i] = a[i-1] * a[i-1] % m;
    if(samefirst[a[i]].first){
      end = i;
      aend = a[i];
      break;
    }
    else{
      samefirst[a[i]].first = true;
      samefirst[a[i]].second = i;
    }
  }
  ll ans = 0;
  if(end != -1){
    ll sum = 0;
    ll first = samefirst[aend].second;
    for(int i=first; i<end; i++) sum += a[i];
    rep(i,first) ans += a[i];
    ll rest1 = n - first;
    ans += rest1 / (end - first) * sum;
    ll rest2 = rest1 % (end - first);
    for(int i=first; i<first + rest2; i++) ans += a[i];
  }
  else rep(i,n) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 4708
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, k;
	cin >> n >> k;
	
	map<char, ll> cost;
	map<char, char> rv;
	
	rv['s'] = 'r';
	rv['r'] = 'p';
	rv['p'] = 's';
	
	cin >> cost['r'] >> cost['s'] >> cost['p'];
	
	ll ans = 0;
	
	string a;
	cin >> a;
	
	
	
	for(int i = 0; i < k; i++){
		ll cnt = 1;
		char c = a[i];
		for(int j = i + k; j < n; j += k){
			c = a[j];
			if(a[j] == a[j - k])
				cnt++;
			else{
				cnt = (cnt + 1) / 2;
				ans += cnt * cost[rv[a[j - k]]];
				cnt = 1;
			}
		}
		
		cnt = (cnt + 1) / 2;
		ans += cnt * cost[rv[c]];
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

# Filtering the data if any "#" are existed in the each row or col
# Usage: filter(lambda row: <filtering condition>, grid or zip(*grid)) 
# If true, the row is not be deleted
# (Do not use if statement!)
row_compressed_grid = list(filter(lambda row: any(x == "#" for x in row), grid))
compressed_grid = list(filter(lambda col: any(x == "#" for x in col), zip(*row_compressed_grid)))
# list -> string and out
for row in zip(*compressed_grid):
    print("".join(row))

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 0004：Simultaneous Equation
 * 
 * @author Lyu
 * @version 2015/07/12
 */
public class Main {

    /** 区切り文字：スペース */
    protected static final String DELIMITER_SPACE = " ";

    /**
     * 連立方程式<br>
     * <p>
     * ax + by = c<br>
     * dx + ey = f
     * </p>
     * の解を出力する。
     * 
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        List<String[]> dataSets = getInput();

        for (int i = 0; i < dataSets.size(); ++i) {
            BigDecimal[] dataSet = toBigDecimalArray(dataSets.get(i));

            System.out.println(getX(dataSet).toPlainString() + DELIMITER_SPACE + getY(dataSet).toPlainString());
        }
    }

    private static BigDecimal getX(BigDecimal[] dataSet) {
        return dataSet[1]
                .multiply(dataSet[5])
                .subtract(dataSet[2].multiply(dataSet[4]))
                .divide(dataSet[1].multiply(dataSet[3]).subtract(dataSet[0].multiply(dataSet[4])), 3,
                        BigDecimal.ROUND_HALF_UP);
    }

    private static BigDecimal getY(BigDecimal[] dataSet) {
        return dataSet[2]
                .multiply(dataSet[3])
                .subtract(dataSet[0].multiply(dataSet[5]))
                .divide(dataSet[1].multiply(dataSet[3]).subtract(dataSet[0].multiply(dataSet[4])), 3,
                        BigDecimal.ROUND_HALF_UP);
    }

    /**
     * String型の配列をBigDecimal型の配列に変換する。
     * 
     * @param stringArray
     *            変換対象のString型配列
     */
    private static BigDecimal[] toBigDecimalArray(String[] stringArray) {
        BigDecimal[] bigDecimalArray = new BigDecimal[stringArray.length];
        for (int i = 0; i < stringArray.length; ++i) {
            bigDecimalArray[i] = new BigDecimal(stringArray[i]);
        }
        return bigDecimalArray;
    }

    /**
     * 標準入力を読み取る。<br>
     * データセットの各行は、区切り文字により分割した配列としてリストに格納する。
     * 
     * @return データセットの各行を格納したリスト
     * @throws IOException
     */
    protected static List<String[]> getInput() throws IOException {
        // 入力読取り
        InputStreamReader streamReader = new InputStreamReader(System.in);
        BufferedReader bufferedReader = new BufferedReader(streamReader);

        List<String[]> dataSets = new ArrayList<String[]>();
        String line = null;

        try {
            while ((line = bufferedReader.readLine()) != null) {
                String[] dataSet = line.split(DELIMITER_SPACE);
                dataSets.add(dataSet);
            }
            return dataSets;
        } finally {
            bufferedReader.close();
            streamReader.close();
        }
    }
}

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

public class Main {

	

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int h=sc.nextInt(),w=sc.nextInt();
		int max=Math.max(h, w);
		out.println((sc.nextInt()+max-1)/max);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    string n = "";
    while (cin >> n, n != "0") {
        int sum = 0;
        // 文字化したため、計算するには'0'で引く
        // 文字である数字の整数化テクニック
        rep(i, n.length()) { sum += n[i] - '0'; }
        cout << sum << "\n";
    }

    return 0;
}



Measured memory_bytes: 3148
// Try AtCoder
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
)

func main() {
	var n, p int
	fmt.Scan(&n, &p)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	dp := make([]uint64, n*100+10)
	dp[0] = uint64(1)
	for _, x := range a {
		for i := len(dp) - 1 - x; i >= 0; i-- {
			dp[i+x] += dp[i]
		}
	}
	ans := uint64(0)
	for i, x := range dp {
		if i%2 == p {
			ans += x
		}
	}
	fmt.Println(ans)
}


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

using namespace std;
typedef long long LL;

int main(){
	string S;
	cin >> S;
	int n=S.size();
	if(n%2==1) cout << "No" << endl;
	else{
		rep(i,n/2){
			if(S[i*2]!='h'||S[i*2+1]!='i'){
				cout << "No" <<endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}

	return 0;
}

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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int M[N][N] = {0}, color[N] = {0}, d[N], f[N], tt = 0, n;

void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for (v = 0; v < n; v++) {
    if (M[u][v] == 0) continue;
    if (color[v] == WHITE) {
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs() {
  int u;
  for (u = 0; u < n; u++) {
    if (color[u] == WHITE) {
      dfs_visit(u);
    }
  }

  for (u = 0; u < n; u++) {
    cout << u + 1 << " " << d[u] << " " << f[u] << endl;
  }
}

int main(void) {
  int u, v, k, i, j;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;
}

Measured memory_bytes: 3120
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
    fast ;

    int n;
    cin >> n;

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

    int ans = INT_MAX;
    for(int i = -100; i <= 100; ++i)
    {
        int sum = 0;

        for(int j = 0; j < n; ++j)
        {
            sum += (i - a[j]) * (i - a[j]);
        }

        ans = min(ans, sum);
    }

    cout << ans << endl;
}






Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    ll n, p;
    cin >> n >> p;

    map<ll, ll> map;
    for (ll i = 2; i * i <= p; i++) {
        while (p % i == 0) {
            map[i]++;
            p /= i;
        }
    }
    if (p != 1) map[p] = 1;
    
    ll ans = 1;
    for (auto i : map)ans *= max((ll)pow(i.first, i.second / n), 1LL);
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	cin>>n>>m;
	vvi in;
	int a,b,c;
	while(cin>>a>>b>>c,a+b+c){
		a--;b--;
		vi t(3);t[0]=a;t[1]=b;t[2]=c;
		in.pb(t);
	}
	cin>>c;
	while(c--){
		vi out(n),tmp(m);
		rep(i,m)cin>>tmp[i];
		rep(i,in.size())out[in[i][0]]+=in[i][2]*tmp[in[i][1]];
		rep(i,n){
			if(i)cout<<" ";
			cout<<out[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 4680
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	//static final long MOD = 1000000007L;
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.ni();
		long[][] cnt = new long[40][60];
		int ints = 0;
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			
			int ind = s.indexOf(".");
			if (ind==-1) {
				s += ".0";
				ind = s.indexOf(".");
			}
			int M = s.length();
			String str = s.substring(0,ind);
			if (ind < M)
				str += s.substring(ind+1,M);
			long num = Long.parseLong(str);
			int[] pow = new int[2];
			pow[0] = (ind-M+1);
			pow[1] = (ind-M+1);
			while (num % 2 == 0) {
				pow[0] += 1;
				num /= 2;
			}
			while (num % 5 == 0) {
				pow[1] += 1;
				num /= 5;
			}
			if (pow[0] >= 0 && pow[1] >= 0)
				ints += 1;
			cnt[pow[0]+9][pow[1]+9] += 1;
		}
		
		long ans = 0;

		for (int i = 0; i < cnt.length; i++) {
			for (int j = 0; j < cnt[0].length; j++) {
				for (int a = Math.max(18-i,0); a < cnt.length; a++) {
					for (int b = Math.max(18-j,0); b < cnt[1].length; b++) {
						ans += cnt[i][j]*cnt[a][b];
					}
				}
			}
		}
		ans = (ans-ints)/2;
		pw.println(ans);
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 57348
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    ll n;
    while(sf("%lld",&n)==1)
    {
        ll mn=INF;
        for(ll i=1;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                ll a=n/i;
                ll b=i;

                ll acnt=0;
                while(a)
                {
                    a/=10;
                    acnt++;
                }

                ll bcnt=0;
                while(b)
                {
                    b/=10;
                    bcnt++;
                }
                mn=min(mn,max(acnt,bcnt));
            }
        }
        pf("%lld\n",mn);
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

typedef struct {
	int a, b, c;
} fuku_t;

int d, n;

int t[200];
fuku_t f[200];

int dp[200][200];

int main()
{
	scanf("%d %d", &d, &n);

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

	for (int i = 0; i < n; ++i) scanf("%d %d %d", &f[i].a, &f[i].b, &f[i].c);

	for (int i = 0; i < n; ++i) if (f[i].a <= t[1] && t[1] <= f[i].b) {
		for (int j = 0; j < n; ++j) if (f[j].a <= t[0] && t[0] <= f[j].b) {
			dp[1][i] = max(dp[1][i], abs(f[j].c - f[i].c));
		}
	}

	for (int i = 2; i < d; ++i) {
		for (int j = 0; j < n; ++j) if (f[j].a <= t[i] && t[i] <= f[j].b) {
			for (int k = 0; k < n; ++k) if (f[k].a <= t[i - 1] && t[i - 1] <= f[k].b) {
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(f[k].c - f[j].c));
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < n; ++i) ans = max(ans, dp[d - 1][i]);

	printf("%d\n", ans);
}

Measured memory_bytes: 1184
from itertools import combinations
N, M, X = map(int, input().split())
CA = [tuple(map(int, input().split())) for _ in range(N)]

ans = None
for n in range(1, N + 1):
    for cas in combinations(CA, n):
        atotals = [0] * M
        ctotal = 0
        for ca in cas:
            for i, a in enumerate(ca[1:]):
                atotals[i] += a
            ctotal += ca[0]
        if all(map(lambda atotal: atotal >= X, atotals)):
            if ans is None:
                ans = ctotal
            else:
                ans = min(ans, ctotal)
if ans is None:
    print(-1)
else:
    print(ans)

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

int main(){
	int n,k;

	while(true){
		int max=0,s=0;
		vector<int> a;

		cin>>n>>k;
		if(n==0&&k==0) break;

		for(int i=0;i<n;i++){
			int t;
			cin>>t;
			a.push_back(t);
		}
		
		for(int i=0;i<k;i++){
			s+=a[i];
		}

		max=s;

		for(int i=1;i<=n-k;i++){
			int t=i+k-1;
			s=s-a[i-1]+a[t];
			if(max<s) max=s;
		}

		cout<<max<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr int INF=1e9;
int D, c[30], s[400][30];
int ans[400];
int tans[400];

// 乱数
unsigned int xor32() {
  static unsigned int x = 2463534242;
  x = x ^ (x << 13); x = x ^ (x >> 17);
  return x = x ^ (x << 15);
}

// スコアを全部計算
int val(){
  int last[30];
  REP(i, 26){
    last[i]=0;
  }
  int res=0;
  FOR(i, 1, D+1){
    last[tans[i]]=i;
    res+=s[i-1][tans[i]];
    REP(j, 26){
      res-=c[j]*(i-last[j]);
    }
  }
  return res;
}

// スコアを差分計算
int diff(){
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  time_t start=clock();

  // 入力
  cin>>D;
  REP(i, 26){
    cin>>c[i];
  }
  REP(i, D){
    REP(j, 26){
      cin>>s[i][j];
    }
  }

  // 初期解
  int score=0;
  int last[30];
  REP(i, 26){
    last[i]=0;
  }
  REP(i, D){
    int ma=0, idx=-1;
    REP(j, 26){
      if(ma<s[i][j]+c[j]*(i+1-last[j])){
        ma=s[i][j]+c[j]*(i+1-last[j]);
        idx=j;
      }
      score-=c[j]*(i+1-last[j]);
    }
    ans[i]=idx;
    tans[i]=ans[i];

    score+=s[i][idx]+c[idx]*(i+1-last[idx]);
    last[idx]=i;
  }
  // DEBUG(score);

  // while(true){
  //   time_t end=clock();
  //   if((double)(end-start)/CLOCKS_PER_SEC*1000>1980){
  //     break;
  //   }
  //   int d=xor32()%D, x=xor32()%26;
  //   tans[d]=x;
  //   int tmp=val();
  //   if(tmp>score){
  //     score=tmp;
  //     ans[d]=x;
  //   }
  // }
  // DEBUG(score);
  REP(i, D){
    cout<<ans[i]+1<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3700
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const INF: i32 = 1000000000;

fn main() {
    let n: usize = read();
    let edges: Vec<(usize, usize)> = readn(n-1);
    let mut graph: Vec<Vec<usize>> = vec![vec![]; n];
    for &(u, v) in &edges {
        graph[u-1].push(v-1);
        graph[v-1].push(u-1)
    }

    let k: usize = read();
    let mut dp: Vec<i32> = vec![INF; n];
    let mut q = BinaryHeap::new();
    for i in 0..k {
        let (v, p): (usize, i32) = read();
        dp[v-1] = p;
        q.push((-p, v-1));
    }

    while let Some((mp, now)) = q.pop() {
        let value = -mp;
        let next = value + 1;

        for &to in &graph[now] {
            if dp[to] == INF {
                dp[to] = next;
                q.push((-next, to));
            }
        }
    }

    let mut is_ok = true;
    for u in 0..n {
        for &v in &graph[u] {
            if (dp[u]-dp[v]).abs() != 1 {
                is_ok = false;
            }
        }
    }
    
    if is_ok {
        println!("Yes");
        for i in 0..n {
            println!("{}", dp[i]);
        }
    } else {
        println!("No");
    }
}

Measured memory_bytes: 17276
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = set([1,3,5,7,8,10,12])
    b = set([4,6,9,11])
    c = set([2])
    x,y = LI()
    d = [a,b,c]
    xi = yi = -1
    for i in range(3):
        if x in d[i]:
            xi = i
        if y in d[i]:
            yi = i

    if xi == yi:
        return 'Yes'

    return 'No'



print(main())


Measured memory_bytes: 7720
# coding: utf-8
# Your code here!
N = int(input())
mochi = []
for i in range(N):
    mochi.append(int(input()))
    
mochi = sorted(mochi)
ans = 1
for m,n in zip(mochi[:-1],mochi[1:]):
    if not m == n:
        ans += 1
        
print(ans)
    
    


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

int main() {
	const int MAX_N = 100 + 10;
	const int MAX_W = 10000 + 10;
    int N, W, v[MAX_N], w[MAX_N], dp[MAX_N][MAX_W];
    cin >> N >> W;
    for (int i = 1; i <= N; ++i){
    	cin >> v[i] >> w[i];
    }

    for (int j = 0; j <= W; ++j){
    	dp[0][j] = 0;
    }

    for (int i = 1; i <= N; ++i){
    	for (int j = 0; j <= W; ++j){
    		if (j - w[i] < 0) dp[i][j] = dp[i-1][j]; 
    		else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
    	}
    }

    cout << dp[N][W] << endl;


}


Measured memory_bytes: 7040
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

struct Edge {
    vector<int> to; //{to_where, weight}
};

ll ans = 0;
void recursion(vector<vector<Edge>>& Graph,int cur,vi& isVisited){
    vi myisVisited = isVisited;
    myisVisited[cur] = 1;
    
    int blcnt = 0;
    for(auto bl: myisVisited){
        if(bl == true) blcnt++;
    }
    if(Graph.size() == blcnt){
        ans++;
        return;
    }

    for(auto e: Graph[cur]){
        // e is type Edge
        if(myisVisited[e.to[0]] == 0){
            recursion(Graph,e.to[0],myisVisited);
        }
    }
}
int main(){
    int N,M; cin >> N >> M;
    vector<vector<Edge>> Graph(N);
    for (int i = 0; i < M; i++) {
      int a,b; cin >> a >> b;
      --a; --b;
      Edge e_a; e_a.to = {b,1};
      Edge e_b; e_b.to = {a,1};
      Graph[a].push_back(e_a);
      Graph[b].push_back(e_b);
    }
    vi isVisited(N,false);
    recursion(Graph,0,isVisited);

    cout << ans << endl;
    sysp;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll x,a;cin>>x>>a;
	if(x<a) cout<<0<<endl;
	else cout<<10<<endl;
	return 0;
}

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

using ll=long long;
enum{PAR,RANK,SUM};
struct Log{
    int type;
    int pos;
    ll val;
};
class GodUnion{
    vector<int> par;
    vector<int> rank;
    vector<ll> sum;
    vector<vector<Log>> vec;
    public:
    GodUnion(int n,int m,vector<ll> x):rank(n),par(n),sum(x),vec(m){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x) return x;
        else return find(par[x]);
    }
    void unite(int x,int y,int t){
        x=find(x),y=find(y);
        // cerr<<x<<" "<<y<<endl;
        // cerr<<sum[x]<<" "<<sum[y]<<endl;
        if(rank[x]<rank[y]){
            vec[t].push_back(Log{PAR,x,x});
            vec[t].push_back(Log{SUM,y,sum[y]});
            par[x]=y;
            sum[y]+=sum[x];
        }
        else{
            vec[t].push_back(Log{PAR,y,y});
            vec[t].push_back(Log{SUM,x,sum[x]});
            if(rank[x]==rank[y]){
                vec[t].push_back(Log{RANK,x,rank[x]});
                rank[x]++;
            }
            par[y]=x;
            sum[x]+=sum[y];
        }
    }
    void RollBack(int t){
        for(auto l:vec[t]){
            if(l.type==PAR){
                par[l.pos]=l.val;
            }
            if(l.type==SUM){
                sum[l.pos]=l.val;
            }
            if(l.type==RANK){
                rank[l.pos]=l.val;
            }
        }
    }
    ll getSum(int v){
        return sum[find(v)];
    }
};
struct Edge{
    int a,b;
    ll y;
};
bool operator<(const Edge& lhs,const Edge& rhs){
    return lhs.y<rhs.y;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<ll> x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    GodUnion u(n,m,x);
    vector<Edge> edges(m);
    for(int i=0;i<m;i++){
        int a,b;
        ll y;
        cin>>a>>b>>y;
        a--,b--;
        edges[i]={a,b,y};
    }
    sort(edges.begin(),edges.end());
    for(int i=0;i<m;i++){
        if(u.find(edges[i].a)!=u.find(edges[i].b)){
            u.unite(edges[i].a,edges[i].b,i);
        }
    }
    // cerr<<"#United"<<endl;
    // for(int i=0;i<n;i++){
    //     cerr<<u.getSum(i)<<endl;
    //     cerr<<u.find(i)<<endl;
    // }
    int res=0;
    for(int i=m-1;i>=0;i--){
        // cerr<<i<<endl;
        // cerr<<"#"<<endl;
        if(u.getSum(edges[i].a)<edges[i].y){
            res++;
            u.RollBack(i);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 12400
X,Y,A,B,C=map(int,input().split())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))

P=sorted(P,reverse=True)
Q=sorted(Q,reverse=True)
R=sorted(R,reverse=True)
ans=sum(P[:X])+sum(Q[:Y])
pi=X-1
qi=Y-1
ri=0
for i in range(min(C,X+Y)):
	if pi==-1:
		temp=ans-Q[qi]
		qi-=1
	elif qi==-1:
		temp=ans-P[pi]
		pi-=1
	elif P[pi]<=Q[qi]:
		temp=ans-P[pi]
		pi-=1
	else:
		temp=ans-Q[qi]
		qi-=1

	if ans<temp+R[i]:
		ans=temp+R[i]
	else:
		break

print(ans)

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

void bubblesort(int A[100], int N){
  int cnt=0;

  for(int i=0;i<N;i++){
    for(int j=N-1;j>i;j--){
      if(A[j]<A[j-1]){
        swap(A[j],A[j-1]);
        cnt++;}
    }
}
  for(int k=0;k<N-1;k++)cout <<A[k]<<" ";
  cout <<A[N-1]<<endl;
cout <<cnt<<endl;}

int main(){
  int N,A[100];
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  bubblesort(A,N);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define PUT(a, n) FOR(i, n) cin >> a[i]
#define OUT(a, n) FOR(i, n) cout << a[i] << ' '

using namespace std;


int main() {
	fast;
    int n;// k; cin >> n >> k;
    cin >> n;
    int k = 2;
    int a[n];
    FOR(i, n, 0)cin >> a[i];
    int dp[n + 1] = {};
    FOR(i, min(k + 1, n), 1)
    {
        int minv = 1e9 + 5;
        FOR(j, i, 0)
        {
            minv = min(minv, dp[j] + abs(a[j] - a[i]));
        }
        dp[i] = minv;
    }
    FOR(i, n, k)
    {
        int minv = 1e9 + 5;
        FOR(j, k + 1, 1)
        {
            minv = min(minv, dp[i - j] + abs(a[i - j] - a[i]));
        }
        dp[i] = minv;
    }  
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T,V> &x){cerr<<'{';__print(x.first);cerr<<',';__print(x.second);cerr<<'}';}
template<typename T>
void __print(const T &x){int f=0;cerr<<'{';for(auto &i:x)cerr<<(f++ ? "," : ""),__print(i);cerr<<"}";}
void _print(){cerr<<"]\n";}
template<typename T,typename... V>
void _print(T t, V... v) {__print(t);if(sizeof...(v))cerr<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define sz(x) (int)x.size()                         					
#define all(x) x.begin(), x.end()           		
#define lb lower_bound                  	
#define ub upper_bound             		
                                   	
typedef long long ll;           		
typedef pair<int, int> pii;     	
typedef pair<ll, ll> pll;       	
typedef long double ld;
          						
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;    
template<typename T> void print(T x){cerr<<x<<'\n';}
inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}                 		
																															 
const int maxn = 1e9;
const ll inf = 1e18;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 3e5 + 10;


void solve() {
	int x; cin >> x;

	cout << 8 - (x - 400) / 200;
}   	            
 
int main() {
    SpeedForce;
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
}    

Measured memory_bytes: 3576
s = list(input())
YYMM = False
MMYY = False
 
if s[2] == '1':
    if (s[3] == '0') | (s[3] == '1') | (s[3] == '2'):
        YYMM = True
elif s[2] == '0':
    if s[3] != '0':
        YYMM = True
 
if s[0] == '1':
    if (s[1] == '0') | (s[1] == '1') | (s[1] == '2'):
        MMYY = True
elif s[0] == '0':
    if s[1] != '0':
        MMYY = True
 
if YYMM & MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
// Brute Force Attack!
int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  vector<int> rs;
  double d = 0;
  for(int i = 0; i < n; i++) {
    int r;
    cin >> r;
    rs.push_back(r);
  }
  // locating greedily!
  vector<double> xs;
  double xmax = 0;
  auto touching = [&xs,&rs](int j, int i) {
    double xj = xs[j];
    int rj = rs[j];
    int ri = rs[i];
    // xi^2 + (ri - rj)^2 = (ri + rj)^2
    // xi = \sqrt{ (ri + rj)^2 - (ri - rj)^2 }
    double xi = 2 * sqrt( ri * rj );
    return xi + xj;
  };
  for(int i = 0; i < n; i++) {
    double x = rs[i]; // touching the wall
    for(int j = i - 1; j >= 0; j--) {
      double xx = touching(j, i);
      if(xx > x) x = xx;
    }
    xs.push_back(x);
    xmax = max(xmax, x + rs[i]);
  }
  cout << setprecision(16) << xmax << endl;
  
  return 0;
}



Measured memory_bytes: 3268
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input())
l=[list(map(int,input().split())) for _ in [0]*(n-1)]
q,k=map(int,input().split())
L=[list(map(int,input().split())) for _ in [0]*q]

neighbor=[[] for _ in range(n+1)]
for i in range(n-1):
    neighbor[l[i][0]].append([l[i][1],l[i][2]])
    neighbor[l[i][1]].append([l[i][0],l[i][2]])

cost=[-1]*(n+1)
cost[k]=0
c=0

def sol(i,p,d):
    global cost
    cost[i]=d
    for x in neighbor[i]:
        if x[0]!=p:
            sol(x[0],i,d+x[1])
sol(k,-1,0)

for i in range(q):
    print(cost[L[i][0]]+cost[L[i][1]])

Measured memory_bytes: 171260
#include <bits/stdc++.h>
//#define int long long
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int num = log10(b)+1;
    for (int i = 0; i < num; i++) {
        a *= 10;
    }
    a += b;
    string ans = "No";
    for (int i = 0; i <= sqrt(100100); i++) {
        if(i * i == a) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a,b,c,d,e;
  cin >> a;
  b = a % 10000 / 1000;
  c = a % 1000 / 100;
  d = a % 100 / 10;
  e = a % 10 / 1;
  
  if ( b == c && c == d) {
    cout << "Yes" << endl;
  }
  else if ( c == d && d == e) {
    cout << "Yes" << endl;
  }
    else{
    cout << "No" << endl;
    }
}

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

int main() {
  int x[5];
  for(int i = 0; i < 5; i++) cin >> x[i];
  
  for(int i = 0; i < 5; i++) {
    if(x[i] == 0) cout << (i + 1) << endl;
  }
  
  return 0;
}  

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

int pow(int x, int a) {
    int ret = 1;
    for(int i = 0; i < a; i++) {
        ret *= x;
    }
    return ret;
}


int N, K;
char op[1025][11];

int doop(int i) {
    int ret = 1;
    for(int j = 0; j < N; j++) {
        if(op[i][j] == 0) {
            ret *= 2;
        } else {
            ret += K;
        }
    }
    return ret;
}

int main() {
    int min;
    cin >> N >> K;

    char b;
    int tmp, NN;
    NN = pow(2, N);
    for(int j = 0; j < N; j++) {
        tmp = pow(2, j);
        b = 1;
        for(int i = 0; i < NN; i++) {
            if(i % tmp == 0)
                b = (b == 0)? 1:0;
            op[i][j] = b;
        }
    }
	
	min = 999999;
    for(int i = 0; i < NN; i++) {
        tmp = doop(i);
        if(tmp < min) min = tmp;
    }
    cout << min << endl;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int n,x,l[100];
  cin>>n>>x;
  rep(i,n)cin>>l[i];
  int d = 0, r = 0;

  while(d<=x) {
    d += l[r];
    r++;
  }

  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

int main(void) {
    int n, k, count=0;
    cin >> n >> k;
    vector<int> checked(n, 0);
    for (int i=0; i<k; i++) {
        int di;
        cin >> di;
        vector<int> ai(di);
        for (int j=0; j<di; j++) {
            cin >> ai.at(j);
            checked.at(ai.at(j)-1) = 1;
        }
    }
    for (int i=0; i<n; i++) {
        if (checked.at(i)==0) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.datetime;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

bool test(int[][] m, int x, int y) {
	foreach(i; 0..9) {
		if(i != y && m[x][i] == m[x][y]) {
			return false;
		}
		if(i != x && m[i][y] == m[x][y]) {
			return false;
		}
	}
	int X = (x/3)*3;
	int Y = (y/3)*3;
	foreach(i; 0..3) {
		foreach(j; 0..3) {
			if((X+i != x || Y+j != y) && m[x][y] == m[X+i][Y+j]) {
				return false;
			}
		}
	}
	return true;
}

void main(){
	int N = readInt();
	foreach(t; 0..N) {
		if(t){ 
			writeln();
		}
		int[][] m;
		foreach(i; 0..9) {
			m ~= readInts();
		}
		bool[9][9] g;
		foreach(i; 0..9) {
			foreach(j; 0..9) {
				g[i][j] = test(m, i, j);
			}
		}
		foreach(i; 0..9) {
			foreach(j; 0..9) {
				write(g[i][j] ? " ": "*");
				write(m[i][j]);
			}
			writeln();
		}
	}
}

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

typedef long long ll;
const int N=450;
ll pre[N],f[N][N];

ll dp(int l,int r) {
	if(l==r) return 0;
	if(f[l][r]!=-1) return f[l][r];
	ll ret=0x3f3f3f3f3f3f3f3f;
	for(int i=l;i<r;++i) ret=min(ret,dp(l,i)+dp(i+1,r));
	return f[l][r]=(ret+pre[r]-pre[l-1]);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int n; scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&pre[i]),pre[i]+=pre[i-1];
	memset(f,255,sizeof(f));
	printf("%lld\n",dp(1,n));
	
	return 0;
}


Measured memory_bytes: 1792