akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int T,N,K,X[100000+10],A[100000+10];
int main()
{
    int sum=0;
    int i,j,t;
    cin>>T;//データセットの数を詠みこむ
    for(t=0;t<T;t++)
    {
        sum=0;
        cin>>N>>K;
        for(i=0;i<N;i++)
        {
            cin>>X[i];
        }
        for(i=0;i<N-1;i++)
        {
            A[i]=X[i+1]-X[i];
        }
        sort(A,A+i);
        for(j=0;j<N-K;j++)
        {
            sum+=A[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3932
s = int(input())

memo = {1: 0, 2: 0, 3: 1, 4: 1, 5: 1}
for total in range(6, s + 1):
    memo[total] = (sum(memo[total - n]
                       for n in range(3, total - 2)) + 1) % (1000000007)

print(memo[s])


Measured memory_bytes: 9264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int a,b,max;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a=atoi(p);
  p=strtok(NULL," \n");
  b=atoi(p);
  
  max=a+b;
  if(max<a-b) max=a-b;
  if(max<a*b) max=a*b;
  
  printf("%d\n",max);
  
  
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int count = 0;
    int s = 0;

    if (a > b) {
      s = b;
    } else {
      s = a;
    }

    for (int i = s; i > 0; i--) {
      if (a % i == 0 && b % i == 0) {
        count++;
        if (count == k) {
          System.out.println(i);
        }
      }
    }
  }

}


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

int main() {
	int a,b,i,j,c=0,ans=0,cnt=0;
	while(1){
		cin >> a;
		if(a==0) break;
		for(i=1;i<a;i++){
			for(j=i;;j++){
				if(c<a){
					c+=j;
					cnt++;
				}
				if(c==a && cnt!=0){
					ans++;
					c=0;
					cnt=0;
					break;
				}else if(c>a){
					c=0;
					cnt =0;
					break;
				}
			}
		}
		cout <<ans <<endl;
		c=0;
		cnt=0;
		ans=0;
		
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  vector<vector<int>> vec(n, vector<int>());
  for(int i=0; i<n; ++i){
    if(i != n-1) vec.at(i).push_back(i+1);
    if(i != 0) vec.at(i).push_back(i-1);
  }
  vec.at(x).push_back(y);
  vec.at(y).push_back(x);
  
  queue<int> que;
  vector<int> ans(n,0);
  for(int i=0; i<n; ++i){
    que.push(i);
    vector<int> fin(n,INF);
    fin.at(i) = 0;
    while(!que.empty()){
      int x = que.front();
      que.pop();
      for(a:vec.at(x)){
        if(fin.at(a) == INF) {
          fin.at(a) = fin.at(x)+1;
          que.push(a);
          ++ans.at(fin.at(x)+1);
        }
      }
    }
  }
  for(int i=1; i<n; ++i){
    cout << ans.at(i)/2 << endl;
  }
}

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

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r;
	cin>>r;
	cout << 3 * r * r << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    vector<int> x{1,9,7,4};
    int count = 0;
    REP(i,4) {
        int n; cin >> n;
        REP(j,4) {
            if (x[j] == n) {
                count++;
                x[j] = 0;
                break;
            }
        }
    }

    CFYN(count == 4)

    return 0;
}

Measured memory_bytes: 3540
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    for x in 0..10{
        if x == 3{
            print!("8");
        }else{
            print!("{}", vec[0].to_string().chars().nth(x).unwrap());
        };
    }
    println!("");
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n,x;
    while(true){
    cin >> n>> x;
    if(n == 0 && x == 0) break; 
    int ans = 0;
    for(int i = 1;i<=n;i++) {
        for(int j = i+1;j <=n;j++) {
            for(int k = j+1; k<=n;k++) {
                int sum = i+j+k;
                if(i != j && i != k && j != k && sum == x) {
                    ans += 1;
                } 
            }
        }
    }
    cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3052
import sys
si = sys.stdin.readline
so = sys.stdout.write


def main():
    n = int(si())
    l = [int(e) for e in si().split()]

    bn = 1
    count = 0
    for i in range(n):
        if l[i] == bn:
            bn += 1
        else:
            count += 1

    print(count if count != n else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25328
#include <bits/stdc++.h>
using namespace std;
int x, y, z, n;
const int N = 200000;
#define LL long long
int ai[N], bi[N], ci[N], ord[N];
int comp(int u, int v)
{
    return ai[u] - bi[u] > ai[v] - bi[v];
}
priority_queue <int> H;
LL pre[N], suc[N], preA[N], sucB[N];
LL ans;
int main()
{
    scanf("%d%d%d", &x, &y, &z); n = x + y + z;
    for (int i = 1; i <= n; ++ i)
        scanf("%d%d%d", &ai[i], &bi[i], &ci[i]);
    for (int i = 1; i <= n; ++ i) ord[i] = i;
    sort(ord + 1, ord + n + 1, comp);
    for (int i = 1; i <= x; ++ i) H.push(ci[ord[i]] - ai[ord[i]]);
    for (int i = x + 1; i <= n - y; ++ i)
    {
        H.push(ci[ord[i]] - ai[ord[i]]);
        int v = H.top(); H.pop();
        pre[i] = pre[i - 1] + v;
    }
    while (!H.empty()) H.pop();
    for (int i = n; i > n - y; -- i) H.push(ci[ord[i]] - bi[ord[i]]);
    for (int i = n - y; i > x; -- i)
    {
        H.push(ci[ord[i]] - bi[ord[i]]);
        int v = H.top(); H.pop();
        suc[i] = suc[i + 1] + v;
    }
    for (int i = 1; i <= n; ++ i) preA[i] = preA[i - 1] + ai[ord[i]];
    for (int i = n; i >= 1; -- i) sucB[i] = sucB[i + 1] + bi[ord[i]];
    for (int i = x; i <= n - y; ++ i) ans = max(ans, preA[i] + pre[i] + sucB[i + 1] + suc[i + 1]);
    printf("%lld\n", ans);
}


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

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

Measured memory_bytes: 3624
/*input
3
#.#
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 100001

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
  int ans = 1 % mod;
  while (y) {
    if (y & 1) ans = mul(ans, x);
    x = mul(x, x);
    y >>= 1;
  }
  return ans;
}
inline ll inv(int a) {return pwr(a, mod - 2);}

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

  int n;
  cin >> n;
  string str;
  cin >> str;
  int ans = n + 1;
  int w = count(all(str), '.');
  int cur = 0;
  for (int i = 0; i < n; i++) {
    w -= (str[i] == '.');
    cur += (str[i] == '#');
    ans = min(ans, cur + w);
  }
  cout << min(ans, min((int)count(all(str), '.'), (int)count(all(str), '#'))) << endl;


  return 0;
}


Measured memory_bytes: 720
K,N = map(int,input().split())
A = list(map(int ,input().split()))

B = []
for a in range(len(A)):
  if a != 0:
    B.append(A[a-1] - A[a] + K)
  else:
    B.append(A[len(A)-1] -A[a])

print(min(B))

Measured memory_bytes: 26420
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N, M, K, ans, mi, A, B, C, D;
string s;

LL GCD(LL a, LL b) {
	LL temp;
	while (a%b != 0) {
		temp = b;
		b = a%b;
		a = temp;
	}
	return b;
}

int main() {
	cin >> A >> B >> C >> D;
	LL LCM = (C / GCD(max(C, D), min(C, D)))*D;
	LL a, ac, ad, acd;
	ac = (A-1) / C;
	ad = (A-1) / D;
	acd = (A-1) / LCM;
	a = (A-1) - (ac - acd + ad);

	LL b, bc, bd, bcd;
	bc = B / C;
	bd = B / D;
	bcd = B / LCM;
	b = B - (bc - bcd + bd);

		cout << b - a  << endl;
	return 0;

}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = {}
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))

print(dp[N-1])

Measured memory_bytes: 23200
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    string s;
    cin >> s;
    bool z = true;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        if(i == 0){
            if(s[i] != 'A'){
                z = false;
                break;
            }
        } 
        else if(i >= 2 && i <= s.length()-2 && s[i] == 'C'){
            if(cnt == 1){
                z = false;
                break;
            }else cnt++;
        }else if('A' <= s[i] && s[i] <= 'Z'){
            z = false;
            break;
        }
    }
    if(z && cnt == 1) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int minv = R[0];
  int maxv = R[1] - R[0];

  for ( int i = 1; i < n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}




Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
int main(){
    int a;cin >>a;
    string s[101];
    map<string,int> ma;
    bool ok = true;
    rep(i,a){
        cin >> s[i];
        if(ma.count(s[i]) != 0){
            ok = false;
        }else {
            ma[s[i]] = 1;
        }
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }
    char top;
    char tail;
    Rep(i,a-1){
        top = s[i][0];
        tail = s[i-1][s[i-1].length()-1];
        if(top != tail){
            cout << "No" << endl;
            return 0;
        }
    }
    
    rep(i,a){

    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a;
  cin>>a;
  int b=a/200;
  cout<<10-b;
}   

Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc166/tasks/abc166_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, K;
  cin >> N >> K;

  VL cts(N, 0);

  rep(i, K) {
    ll d;
    cin >> d;

    rep(j, d) {
      ll a;
      cin >> a;
      --a;
      cts[a]++;
    }
  }

  ll res = 0;
  rep(i, N) if (cts[i] == 0)++ res;
  cout << res << "\n";
}


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

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)

int main() {
	string s;
	cin >> s;
	For(i,1,s.length()) For(j,i + 1,s.length()) if (s[i - 1] == 'C' && s[j - 1] == 'F') {
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  int N;
  cin >> N;
  int a[200010];
  rep(i, N) cin >> a[i+1];
  int ball[200010]={};
  int sum;
  int out=0;
  
  for(int i = N; i>0; i--){
    sum = 0;
    for(int j = 2*i; j<=N; j+=i){
      sum += ball[j];
    }
    if(sum%2!=a[i]) ball[i] = 1;
  }
  
  rep(i, N) out += ball[i+1];
  cout << out << endl;
  rep(i, N) if(ball[i+1]==1) cout << i+1 << endl;
  
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	ll ans = 0LL;
	for(int i=1;i<=n;i++){
		if(i%3==0){
			continue;
		}
		else if(i%5==0){
			continue;
		}else{
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
int main(){
    int i, n;
    double ave, date[1001] = {}, sum, r;

    for(;scanf("%d", &n),n != 0;){
        sum = 0;
        ave = 0;
        r = 0;
        for( i = 0; i < n; i++ ){
            scanf("%lf", &date[i]);
            sum += date[i];
        }
        ave = sum / n;
        for( i = 0, sum = 0; i < n; i++ ){
            sum += ( date[i] - ave ) * ( date[i] - ave );
        }
        r = sqrt( sum / n );
        printf("%f\n", r);
    }
   return 0;
}

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

int main(){
    int num[3];
    int res = 0;
//配列に三つの数字を挿入
    cin >> num[0] >> num[1] >> num[2];
//偶奇が全て一致していたらすべて＋２の処理で済ませる
    if (num[0] % 2 == num[1] % 2 && num[1] % 2 == num[2] % 2){}
//偶奇が一致していない場合、揃っている二つに＋１の処理で偶奇を先に合わせる
    else {
        if (num[0] % 2 == num[1] % 2) {
            num[0]++;
            num[1]++;
            res++;
        }
        else if (num[1] % 2 == num[2] % 2) {
            num[1]++;
            num[2]++;
            res++;
        }
        else if (num[2] % 2 == num[0] % 2) {
            num[2]++;
            num[0]++;
            res++;
        }
    }
//数字を小さいもん順に並び替え
    sort(num, num+3);
//後は一番大きい数との差が０になるまで＋２の処理を行う
    while (num[2] - num[0] > 0) {
        num[0] += 2;
        res++;
    }
    while (num[2] - num[1] > 0) {
        num[1] += 2;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input().split()
num_list = [0] * N

def combination(n):
    C = [0]
    for i in range(2,n+1):
        C.append(int(i*(i-1)/2))
    
    return C

com = combination(N)
sum_com = 0

for i in range(N):
    num_list[int(A[i])-1] += 1


for i in range(N):
    if num_list[i] == 0:
        continue
    else:
        sum_com += com[num_list[i]-1]

for i in range(N):
    print(sum_com - num_list[int(A[i])-1] + 1)


Measured memory_bytes: 34820
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 998244353ll;



int main() {
    ll k;
    string s;
    cin >> k >> s;
    string ans = "";
    if(s.length() <= k){
        ans = s;
    }else{
        REP(i, k){
            ans += s[i];
        }
        ans += "...";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  for(int i=1;i<11;i++){
  if(1000*i-N<1000&&0<=1000*i-N){
   cout<<1000*i-N<<endl;
    break;
  }
  }

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
constexpr ll INF = static_cast<ll>(1e18);

int main(){
	int n,e;
	ll p;
	cin>>n>>e>>p;
	vector<tuple<int,int,ll>> h;
	fo(i,e){
		int a,b;ll c;
		ci2(a,b); ci(c);
		a--;
		b--;
		c=(c-p)*(-1);
		h.pb(make_tuple(a,b,c));
	}
	ll dist[n+1];
	fo(i,n){
		dist[i]=INF;
	}
	dist[0]=0;
	fo(i,n){
		for(auto x : h){
			int a,b,w;
			tie(a,b,w)=x;
			if(dist[a]!= INF)
			dist[b]=min(dist[b],dist[a]+w);
		}
	}
	bool bad[n+1];
	memset(bad,false,sizeof(bad));
	fo(i,n){
		for(auto x : h){
			int a,b,w;
			tie(a,b,w)=x;
			if(dist[b]!=INF && dist[b]>dist[a]+w)
				bad[b]=true;
			if(bad[a]) 
				bad[b]=true;
		}
	}
	
	if (!bad[n - 1])
        cout << -1*(min<ll>(0, dist[n - 1])) << endl;
    else
        co(-1);
	
}


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

using namespace std;
#define int long long
#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    a = x % 10;
    b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
}

int n;

void dfs(string s, char mx) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= mx + 1; c++) {
        string t = s;
        t += c;
        dfs(t, max(mx, c));
    }

}

signed main() {
    cin >> n;
    dfs("", 'a' - 1);
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
string x;
int main(void)
{
    cin>>x;
    int cnt=0;
    for(int i=0;i<x.size();++i)
    {
        if(x[i]=='o')
        {
            cnt++;
        }
    }
    cout <<700+100*cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int M;
	cin >> M;
	int ato = 24-M;
	int day31 = 24;
	cout << day31 + ato << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main(void){
    int a,b,t[999];
    cin>>a>>b;
    int cnt=0;
    for(int i=1;i<=999;i++){
        cnt+=i;
        t[i-1]=cnt;
    }

    if(b-a==t[998]-t[997]){
        cout<<t[997]-a<<endl;
        return 0;
    }
    for(int i=1;i<999;i++){
        if(t[i]-t[i-1]==b-a){
            cout<<t[i-1]-a<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong

signed main(){
	int a,b;
	cin >> a >> b;
	if(b%a ==0){
		cout << a + b << endl;
	}
	else{
		cout << b - a << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define    ll  long long int
using namespace std;
int binary_search(ll *a,ll begin,ll end, ll key)
{     bool prime=true;
    while(begin<=end)
    {
          int mid=(begin+end)/2;
          if(a[mid]==key)
          {
              prime=false;
              return 1;
              break;
          }

          else if(a[mid]>key)
          {
              end=mid-1;
          }
          else
          {
              begin=mid+1;
          }
    }
    if(begin>end&&prime)
        return 0;
}
int main()
{
   ll n;
   while(cin>>n)
   {
        ll a[n];
   for(ll i=0;i<n;i++)
       cin>>a[i];
    ll m;
    cin>>m;
    ll b[m];
    for(ll i=0;i<m;i++)
        cin>>b[i];
        ll t=0;
        for(ll j=0;j<m;j++)
               {
                    t+=binary_search(a,0,n-1,b[j]);
                }
    cout<<t<<endl;
   }

    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N, K; cin >> N >> K;
    int ma = (N-1) * (N-2) / 2;
    if (ma < K) cout << -1 << endl;
    else {
        vector<P> res;
        // 頂点Nを中心にスターグラフを作成
        REP(i, 1, N) res.pb({i, N});
        int rem = ma - K;
        int ci = 1, cj = 2;
        rep(_, rem) {
            res.pb({ci, cj});
            cj++;
            if (cj == N) {
                ci++;
                cj = ci + 1;
            }
        }
        cout << res.size() << endl;
        for (auto p : res) cout << p.fi << ' ' << p.se << endl;
    }
    return 0;
}

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

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

    vector<int> d(N);

    for(int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }

    set<int> s;

    for(int i = 0; i < N; i++)
    {
        s.insert(d.at(i));
    }

    cout << s.size() << endl;
}

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

int main(void){

  int i, j, n, num;
  int check[4][13];
  char m, dummy;
  char mark[5] = "SHCD";

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      check[i][j] = j+1;
    }
  }

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%c %c %d", &dummy, &m, &num);

    for(j=0;j<4;j++){
      if(m == mark[j]){
        check[j][num-1] = 0;
        break;
      }
    }
  }

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(check[i][j] != 0){
        printf("%c %d\n", mark[i], check[i][j]);
      }
    }
  }

  return 0;

}



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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n,m;
    cin>>n>>m;
    ll dif=m-n;
    if(dif<2019)
    {
        ll l=INT_MAX;
        for(ll i=n;i<m;i++){
         {
        for(int j=i+1;j<=m;j++)
        {
            ll tmp= (i*j)%2019;
            l=min(tmp,l);
        }
        }
    }
      cout<<l;
    }
    else{
        cout<<"0";
    }
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(){
  int n,m,a,b,c,i,j,k,p[10],d[20][20]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&b);
    for(j=0;j<b;j++){
      scanf("%d",&a);
      d[i][a-1]=1;
    }
  }
  for(i=0;i<m;i++)scanf("%d",&p[i]);
  for(i=b=0;i<(1<<n);i++){
    for(k=a=0;k<m;k++){
      for(j=c=0;j<n;j++){
	if(d[k][j]==0)continue;
	if(i&(1<<j))c++;
      }
      if(c%2==p[k])a++;
    }
    if(a==m)b++;
  }
  printf("%d\n",b);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int x,a,b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;

  return 0;

}

Measured memory_bytes: 256
hw = [int(n) for n in input().split()]

for i in range(hw[0]):
    a = [moji for moji in input().split()]
    a.insert(0, '#')
    a.append('#')
    if i == 0:
        print('#' * (hw[1] + 2))
    print(''.join(a))

print('#' * (hw[1] + 2))


Measured memory_bytes: 3064
n = int(input())
sp = {i+1:input().split() for i in range(n)}

d = []
for i,s in sp.items():
    d.append((i,s[0],int(s[1])))
    
d = sorted(d,key=lambda x:x[2],reverse=True)
d = sorted(d,key=lambda x:x[1])
    
    
for i in d:
    print(i[0])


Measured memory_bytes: 9144
s=input()
a=s[:2]
b=s[2:]
MMYY=0
YYMM=0

#MMYY
MMYY=1 if int(a)<=12 and int(a)>0 else 0
YYMM=1 if int(b)<=12 and int(b)>0 else 0

if MMYY==YYMM==1:
  print("AMBIGUOUS")
elif MMYY==1:
  print("MMYY")
elif YYMM==1:
  print("YYMM")
else:
  print("NA")



Measured memory_bytes: 3060
X = int(input())

a = -1
b = 1
def f(x,y): return x**5-y**5

while f(a, b) != X:
    a += 1
    b = a
    while f(a, b) < X:
        b -= 1
        # print("{}, {}".format(a, b))

print(a, b)


Measured memory_bytes: 9172
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;
int X, Y, S;

int tax(int p, int r){
  return p*(100+r)/100;
}

int solve(){

  int maximum = 0;
  for (int i = 1; i < S; ++i){
    for (int j = 1; j < S; ++j){
      if (tax(i, X) + tax(j, X) == S){
        maximum = max(maximum, tax(i, Y) + tax(j, Y));
      }
    }
  }

  return maximum;

}

int main (){
  while (cin >> X >> Y >> S && X > 0){
    cout << solve() << endl;
  }

}


Measured memory_bytes: 3072
#include <stdio.h>
int main(void)
{
	int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,wa;
	scanf("%d",&s1);
		scanf("%d",&s2);
			scanf("%d",&s3);
				scanf("%d",&s4);
					scanf("%d",&s5);
						scanf("%d",&s6);
							scanf("%d",&s7);
								scanf("%d",&s8);
									scanf("%d",&s9);
										scanf("%d",&s10);
	wa=s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
	printf("%d\n",wa);
									
	return 0;
}


Measured memory_bytes: 2064
n, m, k = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
from itertools import accumulate
AS = [0] + list(accumulate(A))
BS = [0] + list(accumulate(B))

ans = 0
j = m
for i in range(n+1):
    if AS[i] > k:
        break

    while AS[i] + BS[j] > k:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)


Measured memory_bytes: 50400
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    vector<int> a(N);

    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }

    sort(a.rbegin(), a.rend());

    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N; i++){
        if (i % 2 == 0){
            alice += a.at(i);
        }
        else {
            bob += a.at(i);
        }
    }

    cout << alice - bob << endl;
}

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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  vector<string> c(h);
  for (auto &e : c) {
    cin >> e;
  }
  for (int i = 0; i < h; ++i) {
    cout << c[i] << "\n" << c[i] << "\n";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] switchPatterns = new int[m][];
		int[] p = new int[m];
		for ( int i = 0; i < m; i++ ) {
			int k = in.nextInt();
			int[] s = new int[k];
			for ( int j = 0; j < k; j++ ) {
				s[j] = in.nextInt();
			}
			switchPatterns[i] = s;
		}
		for ( int i = 0; i < m; i++ ) {
			p[i] = in.nextInt();
		}

		int Allpatterns = 2 << (n - 1); // 2のn乗
		int cnt = Allpatterns;

		// スイッチのパターンを上限まで列挙
		for ( int ptr = 0; ptr < Allpatterns; ptr++ ) {
			// 電球ごとのスイッチパターンと照らし合わせる
			for ( int d = 0; d < m; d++ ) {
				int temp = 0;
				for ( int i : switchPatterns[d] ) {
					// 順序：四則演算 → ビットシフト → 論理演算 → 代入
					temp += ptr >> i - 1 & 1; 
				}
				if ( temp % 2 != p[d] ) {
					cnt--;
					break;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }

    cout << sum << '\n';
    return 0;
}



Measured memory_bytes: 3640
S = input()

mid = list(S[2:-1])
if S[0] != 'A':
    print('WA')
elif mid.count('C') != 1:
    print('WA')
else:
    idx = S[2:-1].index('C')
    test = S[1] + S[2:2+idx] + S[3+idx:]
    if test.islower():
        print('AC')
    else:
        print('WA')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    double a, b, p, q, r;
    cin >> a >> b >> p >> q >> r;
    printf("%.10lf\n", b+(p*b-q*b+q*a)/(q+r));
    return 0;
}


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

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

typedef long long ll;

struct Node {
  int depth;
  map<int, Node *> children;
  Node() {}
};

void SetNum(Node *parent, const int &num) {
  if (parent->depth == 3) return;
  FOR(i, 0, 10) {
    if (parent->children.count(i)) {
      SetNum(parent->children[i], num);
    }
  }
  if (parent->children.count(num) == 0) {
    Node *n = new Node();
    n->depth = parent->depth + 1;
    parent->children[num] = n;
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  FOR(i, 0, n) {
    char c;
    cin >> c;
    vec[i] = (int)c - 48;
  }

  Node *root = new Node();
  root->depth = 0;
  FOR(i, 0, n) {
    SetNum(root, vec[i]);
  }

  int ans = 0;
  FOR(i, 0, 1000) {
    int digit0 = i / 100;
    int digit1 = (i % 100) / 10;
    int digit2 = (i % 10);
    if (root->children.count(digit0)) {
      Node *digit0_node = root->children[digit0];
      if (digit0_node->children.count(digit1)) {
        Node *digit1_node = digit0_node->children[digit1];
        if (digit1_node->children.count(digit2)) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int A,B;
int H = 96, W = 99;
char S[100][100];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> A >> B;
  REP(i,H) REP(j,W) {
    if (i*2 < H) S[i][j] = '.';
    else S[i][j] = '#';
  }
  A--; B--;
  for (int i = 1; B > 0; i += 3) {
    for (int j = 1; j < 99 && B > 0; j += 3) {
      S[i][j] = '#';
      B--;
    }
  }
  for (int i = 49; A > 0; i += 3) {
    for (int j = 1; j < 99 && A > 0; j += 3) {
      S[i][j] = '.';
      A--;
    }
  }
  cout << H << " " << W << endl;
  REP(i,H) cout << S[i] << endl;

  return 0;
}

Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            if (s.Length == 1) Console.WriteLine(0);
            else Console.WriteLine(GetCount(s));
        }
    }
    public static int GetCount(string s)
    {
        var count = 0;
        while (true)
        {
            var sL = s.Length;
            var nL = new List<int>();
            for (int i = 1; i < sL; i++)
                nL.Add(int.Parse(s.Substring(0, i)) * int.Parse(s.Substring(i)));
            count++;
            var nLmax = nL.Max();
            if (nLmax < 10) return count;
            else if (s == nLmax.ToString()) return -1;
            else s = nLmax.ToString();
        }
    }
}

Measured memory_bytes: 9788
///*****************************???????????????????

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const ll Max=1e18+100;
const int sz=310;
ll dist[2][sz][sz];
void Floyad(ll n,ll l,ll tar)
{
     for(int k=1;k<=n;k++)
     {
         for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++)
                {
                    if(dist[tar][i][k]+dist[tar][k][j]<dist[tar][i][j]) dist[tar][i][j]=dist[tar][i][k]+dist[tar][k][j];
                }
         }
     }
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    int t,cs;
    cin>>n>>m>>l;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++){
           if(i==j) dist[0][i][j]=dist[1][i][j]=0;
           else dist[0][i][j]=dist[1][i][j]=Max;
        }
    }

    for(i=1;i<=m;i++){
        cin>>p>>q>>c;
        dist[0][p][q]=dist[0][q][p]=c;
    }
    Floyad(n,l,0ll);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++){
            if(i==j) dist[1][i][j]=0;
            else dist[1][i][j]=dist[1][j][i]=((dist[0][i][j]<=l) ? 1ll: Max);
        }
    }
    Floyad(n,l,1ll);

    cin>>x;
    while(x--)
    {
        cin>>p>>q;
        if(dist[1][p][q]>=Max) cout<<"-1"<<endl;
        else{
            cout<<dist[1][p][q]-1<<endl;
        }
    }


}

/*
   help taken from: https://codeforces.com/blog/entry/70703

*/


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

int main()
{
    ll a,b,i,cnt=0;
    scanf("%lld %lld", &a, &b);
    while(a<=b){
        string s;
        s = to_string(a);
        if(s[0]==s[4] && s[1]==s[3]){
            cnt++;
        }
        a++;
    }
    printf("%lld\n", cnt);
    return 0;
}

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

int main() {

    int a;
    cin >> a;
    if(a==25){
        cout << "Christmas" << endl;
    }else if(a==24){
        cout << "Christmas Eve" << endl;
    }else if (a==23){
        cout << "Christmas Eve Eve" << endl;
    }else if(a==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 2999
using namespace std;
double v[MAX+1];
double dp[MAX+1][MAX+1];
int n;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>v[i];
	for(int i=0;i<=n;++i)
	{
		for(int j=0;j<=i;++j)
		{
			if(i==0)
				dp[i][j] = 1;
			else if(j==0)
				dp[i][j] = (1-v[i])*dp[i-1][j];
			else
				dp[i][j] = v[i]*dp[i-1][j-1]+(1-v[i])*dp[i-1][j];		
		}	
	}
	double ans = 0;
	for(int i=n/2+1;i<=n;++i)
		ans += dp[n][i];
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int N;

  cin >> N;

  vector<vector<ll>> count(10, vector<ll>(10, 0));

  for (int i = 1; i <= N; i++) {
    int right = i % 10;
    int left = i;
    while (left >= 10) {
      left /= 10;
    }

    if (left == 0 || right == 0) {
      continue;
    }

    count[left][right] += 1;
  }

  ll ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ans += count[i][j] * count[j][i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;


int main() 
{
    map<ll, ll> ans;
    ll n, k;
    cin >> n >> k;

    irep(i, n) {
        ll tmp, K;
        cin >> tmp >> K;
        ans[tmp] += K;
    }
    ll cnt = 0;
    ll ANS;
    for(auto i : ans) {
        cnt += i.second;
        //cout << i.first << "," << i.second << endl;
        if(cnt >= k) { 
            ANS = i.first;  
            break;
        }
    }

    cout << ANS << endl;
    return 0;
}


Measured memory_bytes: 4224
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let mut w: Vec<i32> = [].to_vec();
    for _i in 1..n+1 {
        let wi: i32 = read();
        w.push(wi);
    }
//    println!("{:?}", w);
    let mut ans = 0;
    let mut flag = 0;
    for t in 1..n {
        let mut s1: i32 = 0;
        let mut s2: i32 = 0;
        for x in t+1..n {
            s2 = s2 + w[x as usize];
        }
        for x in 0..t+1 {
            s1 = s1 + w[x as usize];
        }
        if (flag == 0) {
            ans = (s1 - s2).abs();
            flag = 1;
        } else {
            if (ans > (s1 - s2).abs()) {
                ans = (s1 - s2).abs();
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<stdio.h>
#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)

int main(void){
  int r;
  scanf("%d",&r);
  PRN(3*r*r);
  return 0;
}

Measured memory_bytes: 128