akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

//Operation of Frequency of Appearance
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			int k = 0;
			while(true){
				int[] next = new int[n];
				int[] c = new int[101];
				for(int i:a)c[i]++;
				boolean f = true;
				for(int i=0;i<n;i++){
					next[i]=c[a[i]];
					if(next[i]!=a[i])f = false;
				}
				if(f){
					System.out.print(k+"\n"+a[0]);
					for(int i=1;i<n;i++)System.out.print(" " + a[i]);
					System.out.println();
					break;
				}
				k++;
				a = next;
			}
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;
 
#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;
 
int main() {
 
    for (string s, t; cin >> s >> t;) {
        vector<VI> dp(s.size() + 1, VI(t.size() + 1, 0));
        
        for (int i = 1; i <= s.size(); i++) {
            for (int j = 1; j <= t.size(); j++) {
                dp[i][j] = max(max(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1] + (s[i - 1] == t[j - 1]));
            }
        }
 
        vector<char> res;
        int tpos, spos;
        tpos = t.size();
        spos = s.size();
 
        while (tpos > 0 and spos > 0) {
            if (dp[spos][tpos] > max(dp[spos - 1][tpos], dp[spos][tpos - 1])) {
                res.push_back(s[spos - 1]);
                spos--;
                tpos--;
            } else if (dp[spos][tpos] == dp[spos - 1][tpos]) {
                spos --;
            } else {
                tpos --;
            }
        }
 
        for (int i = res.size() -1; i >= 0; i--) {
            cout << res[i];
        }
        cout << "\n";
    }
 
return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
long long s(long long x){
    if(x>0) return x;
    return -x;
}

int main(){
    string s;
    cin>>s;
    cout<<s.at(0)<<s.at(1)<<s.at(2);
}

Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC126_b solver = new ABC126_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC126_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            boolean gate[] = new boolean[2];

            int first = Integer.parseInt(S.substring(0, 2));
            int second = Integer.parseInt(S.substring(2, 4));

            if ((first > 0) && (first < 13)) {
                gate[0] = true;
            }
            if ((second > 0) && (second < 13)) {
                gate[1] = true;
            }
            if ((gate[0]) && (gate[1])) {
                out.println("AMBIGUOUS");
                return;
            }
            if ((!gate[0]) && (gate[1])) {
                out.println("YYMM");
                return;
            }
            if ((gate[0]) && (!gate[1])) {
                out.println("MMYY");
                return;
            }
            out.println("NA");
        }

    }
}



Measured memory_bytes: 21204
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}

int32_t  main(){
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<Endl;
    return 0;
}

Measured memory_bytes: 12960
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    char x,y;
    cin>>x>>y;
    if(x<y) cout << '<' << endl;
    else if(x>y) cout << '>' << endl;
    else if(x==y) cout << '=' << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        int amax = N / 10000;
        int bmax = (N % 10000) / 1000;
        int cmax = (N % 1000) / 100;
        int dmax = (N % 100) / 10;
        int emax = N % 10;

        int sum = 0;

        if (amax == 1 && A == 1) {
            sum += 10000;
        }
        int brange;
        if (amax == 1) {
            brange = Math.min(B, 9);
        } else {
            brange = Math.min(B, bmax);
        }
        for (int b = 0; b < brange + 1; b++) {
            int crange;
            if (b != bmax || amax == 1) {
                crange = Math.min(B, 9);
            } else {
                crange = Math.min(B - b, cmax);
            }
            for (int c = 0; c < crange + 1; c++) {
                int drange;
                if (c != cmax || b != bmax || amax == 1) {
                    drange = Math.min(B - b - c, 9);
                } else {
                    drange = Math.min(B - b - c, dmax);
                }
                for (int d = 0; d < drange + 1; d++) {
                    int erange;
                    if (d != dmax || c != cmax || b != bmax || amax == 1) {
                        erange = Math.min(B - b - c - d, 9);
                    } else {
                        erange = Math.min(B - b - c - d, emax);
                    }
                    for (int e = Math.max(A - b - c - d, 0); e < erange + 1; e++) {
                        //System.out.println("add " + b + " "+ c +" " + d +" "+ e);
                        sum += (1000 * b) + (100 * c) + (10 * d) + e;

                    }
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e5;
vector<int> dp(N+1);
int ans[N+1];
vector<int> v[N+1];
int vis[N+1];
int a[N+1];
void dfs(int node){
    vis[node]=1;
    int pos=lower_bound(all(dp),a[node])-dp.begin();
    int pre=dp[pos];
    dp[pos]=a[node];
    ans[node]=lower_bound(all(dp),inf)-dp.begin();
    for(auto it:v[node]){
        if(vis[it]==0){
            dfs(it);
        }
    }
    dp[pos]=pre;
}
signed main()
{
    
    CHAL_BAAP_KO_MT_SIKHA
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n-1;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    for(int i=0;i<=N;i++){
        dp[i]=inf;
    }
    dfs(1);

    for(int i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

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

  auto test = [&](long long x) {
    for (auto d : a) {
      x = x / d * d;
    }
    return x;
  };

  long long down, up;
  {
    long long l = 0, r = 5e16;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (test(m) >= 2) r = m;
      else l = m;
    }
    down = r;
  }
  {
    long long l = 0, r = 5e16;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (test(m) > 2) r = m;
      else l = m;
    }
    up = r;
  }

  if (down == up) {
    cout << -1 << '\n';
  } else {
    cout << down << ' ' << up - 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;
 
int main() {
	int N,M;
    cin >> N >> M;
  	vi a(M);
  	vi b(M);
  	vi ans(N);
  	rep(i,M){
    	cin >> a[i];
      	cin >> b[i];
    }
  	rep(i,M){
    	ans[a[i]-1]++;
      	ans[b[i]-1]++;
    }
  	rep(i,N) cout << ans[i] << endl;
}

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

const int N = 1e6+10;
int n;
int a[N], id[N], cnt[N], tp;

void push(int x, int c) {
    if (c <= 0) return;
    if (tp > 0 && id[tp] == x) cnt[tp] += c;
    else {
        ++tp;
        id[tp] = x;
        cnt[tp] = c;
    }
}

void pop(int c) {
    while (c > 0) {
        int erase_c = min(c, cnt[tp]);
        cnt[tp] -= erase_c;
        c -= erase_c;
        if (cnt[tp] == 0) tp--;
    }
}

int pop_x(int x) {
    int res = 0;
    while (tp > 0 && id[tp] == x) {
        res += cnt[tp];
        tp--;
    }
    return res;
}

bool check(int sz) {
    if (sz == 1) {
        for (int i = 1; i <= n; i++) {
            if (a[i] <= a[i-1]) return false;
        }
        return true;
    }
    tp = 0;
    for (int i = 1; i <= n; i++) {

        if (a[i] > a[i-1]) push(1, a[i]-a[i-1]);
        else {
            if (a[i] < a[i-1]) pop(a[i-1]-a[i]);
            int rest = pop_x(sz);
            if (tp == 0) return false;
            int x = id[tp];
            pop(1);
            push(x+1, 1);
            if (rest > 0) push(1, rest);
        }
    }
    return true;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    int l = 0, r = n;
    while (l + 1 < r) {
        int mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid;
    }
    printf("%d\n", r);
}

Measured memory_bytes: 6400
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	int cnt=0;
	cin>>n;
	int ans=0;
	for(int j=1;j<=n;j++)
	{
		cnt=0;
		if(j%2==1)
		for(int i=1;i<=j;i++)
		{
			if(j%i==0)
			cnt++;
		}
		if(cnt==8)
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

char S[64];

int main() {

	scanf("%s", S);

	char A[8], B[8];
	A[0] = S[0];
	A[1] = S[1];
	A[2] = 0;
	B[0] = S[2];
	B[1] = S[3];
	B[2] = 0;

	int a = atoi(A);
	int b = atoi(B);

	if (a >= 1 && a <= 12) {
		if (b >= 1 && b <= 12) {
			printf("AMBIGUOUS\n");
		}
		else {
			printf("MMYY\n");
		}
	}
	else {	
		if (b >= 1 && b <= 12) {
			printf("YYMM\n");
		}
		else {
			printf("NA\n");
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
typedef long long ll;

ll f(ll x){
    if(x<=0){
        return 0;
    }
    ll res=0;
    ll y=1,z;
    for(int i=0;i<40;i++){
        if(y==1&&(x%4==2||x%4==1)){
            res+=1;
        }
        else if(y!=1&&x%(2*y)>=y&&x%(2*y)%2==0){
            res+=y;
        }
        y*=2;
    }
    return res;
}

int main(){
    ll a,b,res=0;
    scanf("%lld %lld",&a,&b);
    printf("%lld\n",f(b)^f(a-1));
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;






int main() {

	int n;
	cin >> n;

	REP(i, 100000) {
		int j = i * 100;
		int k = i * 105;
		if (j <= n && n <= k) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;


}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<(n/(a+b))*a + min(n%(a+b),a)<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string word;
  cin >> word;
  int A;
  
  
  if(word.at(2) == word.at(3)){
  A++;
  }
  
  if(word.at(4) == word.at(5)){
  A++;
  }
  
  if(2 <= A){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,K;
  cin >> A >> B >> K;
  if(A>K)A -= K;
  else {
    B -= K - A;
    if(B<0)B=0;
    A = 0;
  }

  cout << A << " " << B << endl;
  return 0;
}

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

namespace Atcoder_0404
{
    class Program
    {

        static long mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var sw=GetInput_int();
            int seep = sw[0];
            int wolf = sw[1];
            if (seep <= wolf)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
    }
}

Measured memory_bytes: 27484
function main()
  
  N = parse(Int,readline())
  V = map(x -> parse(Int,x), split(readline()))
  C = map(x -> parse(Int,x), split(readline()))
  
  ans = 0
  
  for i in 1:N
    if V[i] - C[i] > 0
      ans += V[i] - C[i]
    end
  end
  
  println(ans)
  
end

main()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) abs((a)*(b))/gcd((a),(b))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///******************************** C o d e ********************************///



main()
{
    ll n,k,d,a,i;
    cin>>n>>k;
    map<ll,ll>m;
    while(k--){
        cin>>d;
        while(d--){
            cin>>a;
            m[a]++;
        }
    }
    a=0;
    for(i=1;i<=n;i++){
        if(!m[i]) a++;
    }
    cout<<a el;
}



///Thank you.



///Brainless_Loco Terminates Here!


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define lp(it, it1, it2) for (auto it = it1; it < it2; it++)                              //loop
#define present(c, x) (c.find(x) != c.end())
using namespace std;
using namespace std::chrono;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii

stack<int> s;
void topsort(ll v, vvi &adjList, vi &vis) {
    vis[v] = 1;
    for (auto u : adjList[v])
        if (!vis[u])
            topsort(u, adjList, vis);
    s.push(v);
}
void dfs(ll v, vvi &adjList, vi &dist, ll p) {
    dist[v] = max(dist[p] + 1, dist[v]);
    for (auto i : adjList[v])
        dfs(i, adjList, dist, v);
}
int main() {
    ll n, m, u, v, w = 1;
    cin >> n >> m;
    vvi adjList(n + 1);
    vi vis(n + 1);
    for (int i = 0; i < m; i++) {
        cin >> u >> v;
        adjList[u].pb(v);
    }
    for (int i = 1; i <= n; i++) {
        if (!vis[i])
            topsort(i, adjList, vis);
    }
    vi dist(n + 1);
    vis.assign(n + 1, 0);
    while (!s.empty()) {
        v = s.top();
        s.pop();
        for (auto i : adjList[v])
            dist[i] = max(dist[i], dist[v] + 1);
    }
    cout << *max_element(all(dist)) << "\n";
    return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main()
{
	int n,l;
	int ans=0;
	cin >> n >> l;
//0に近いのを消す。味を足す。
	vector<int> vector(n);
	rep(i,n) vector.at(i)=l+i;
	sort(vector.begin(), vector.end());
	
	int minm=150, min_i=200;
	rep(i,n){
	  ans += vector.at(i);
	 // cout << ans << endl;
	  if(minm < abs(vector.at(i))) continue;
	  minm = abs(vector.at(i));
	  min_i = i;
	}
	ans -= vector.at(min_i);

	cout << ans << endl;
// 	if() cout << "Yes" << endl;
// 	else cout << "No" << endl;
}

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


int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  
  long long ans = A*X+B*Y;
  for(int i=0;i<=100000;i++){
    long long work = A*max(0,X-i)+B*max(0,Y-i)+2*C*i;
    ans = min(ans,work);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long sum=0,n,max=-1000000,min=1000000,i,x;
	cin>>i;
	for(x=0;x<i;x++){
		cin>>n;
		if(n>max){
			max=n;
		}
		if(n<min){
			min=n;
		}
		sum=sum+n;
	}
		cout<<min<<" "<<max<<" "<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 3100
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int[] a=new int[1];
    int[] b=new int[1];
    a[0]=sc.nextInt();
    b[0]=sc.nextInt();
    int kari=b[0];
    while(kari!=0){
      a[0]*=10;
      kari/=10;
    }
    double kari2=a[0]+b[0];
    double kari3=Math.sqrt(kari2);
    if((int)kari2==(int)kari3*(int)kari3) System.out.println("Yes");
    else System.out.println("No");
    System.out.flush();
  }
}

Measured memory_bytes: 23764
import Data.List
import Control.Monad
import Data.Maybe
import Data.Ord
import qualified Data.ByteString.Char8 as BS

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [Int]
readIntLists n = map (fst . fromJust . BS.readInt) <$> replicateM n BS.getLine


solve n max k q ss | n >= max = []
                   | otherwise = do
                        if x == (n + 1)
                            then
                                if y + k - q > 0
                                    then "Yes" : solve (n+1) max k q (tail ss)
                                    else "No" : solve (n+1) max k q (tail ss)
                            else
                                "No" : solve (n+1) max k q ss
                        where
                            (x,y) = if ss /= [] then head ss else (0,0)


elemCountOrd :: (Ord a) => [a] -> [(a, Int)]
elemCountOrd = map (\l -> (head l, length l) ) . group . sort

main = do
    [n,k,q] <- readInts
    aq <- readIntLists q
    if k > q
        then putStr $ unlines $ replicate n "Yes"
        else putStr $ unlines $ solve 0 n k q (elemCountOrd aq)


Measured memory_bytes: 30312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

using namespace std;

int main() {
    int n; cin >> n;
    int max; cin >> max;

    for (int i = 1; i < n; i++)
    {
        int h; cin >> h;

        if (max > h + 1)
        {
            cout << "No" << endl;
            return 0;
        }

        if (max < h)
        {
            max = h;
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
    ll p;
    cin>>p;
    ll cnt=100;
    int ans=0;
    while(cnt<p)
    {
        cnt+=cnt/100;
        ans++;
    }
    cout<<ans<<endl;





}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  cout << n/(a+b)*a+min(n%(a+b),a) << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    if (S <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij=[(1,0),(0,1),(-1,0),(0,-1)]

def main():
    n=II()
    aa=LI()

    pre=[0]*(n+1)
    for i in range(n):pre[i+1]+=pre[i]+aa[i]

    ll=[[0]*2 for _ in range(n)]
    rr=[[0]*2 for _ in range(n)]
    j=1
    for i in range(2,n-1):
        while j<i-1 and pre[i]-pre[j]*2>0:j+=1
        if pre[i]-pre[j-1]*2<-pre[i]+pre[j]*2:j-=1
        ll[i][0]=min(pre[i]-pre[j],pre[j])
        ll[i][1]=max(pre[i]-pre[j],pre[j])
    j=n-1
    for i in range(n-2,1,-1):
        while j>i+1 and pre[n]+pre[i]-pre[j]*2<0:j-=1
        if -pre[n]-pre[i]+pre[j+1]*2<pre[n]+pre[i]-pre[j]*2:j+=1
        rr[i][0]=min(pre[n]-pre[j],pre[j]-pre[i])
        rr[i][1]=max(pre[n]-pre[j],pre[j]-pre[i])
    #print(ll,rr)

    ans=10**16
    for i in range(2,n-1):
        mn=min(ll[i][0],rr[i][0])
        mx=max(ll[i][1],rr[i][1])
        cur=mx-mn
        if cur<ans:ans=cur
    print(ans)

main()

Measured memory_bytes: 116216
#include <stdio.h>

#define W 4
#define H 4

void input(int bingo[H][W]);
void work(int bingo[H][W]);
int hcheck(int bingo[H][W]);
int wcheck(int bingo[H][W]);
int ncheck(int bingo[H][W]);

int main()
{
	int bingo[H][W];
	int flag = 0;

	input(bingo);
	work(bingo);
	flag = hcheck(bingo);
	if (flag == 0)
		flag = wcheck(bingo);
	if (flag == 0)
		flag = ncheck(bingo);

	if (flag == 1)
		printf("Yes\n");
	else
		printf("No\n");


	return 0;
}

void input(int  bingo[H][W])
{
	for (int i = 0; i < H-1; i++) {
		for (int j = 0; j < W - 1; j++)
			scanf("%d", &bingo[i][j]);
	}
}

void work(int  bingo[H][W])
{
	int start = 0, limit;
	int n;

	scanf("%d", &limit);

	while (start < limit) {
		scanf("%d", &n);

		for (int i = 0; i < H - 1; i++) {
			for (int j = 0; j < W - 1; j++) {
				if (bingo[i][j] == n)
					bingo[i][j] = 101;
			}
		}
		start++;
	}
}

int hcheck(int  bingo[H][W])
{
	int flag = 0;

	for (int i = 0; i < W - 1; i++) {
		if (bingo[i][0] == 101 && bingo[i][1] == 101 && bingo[i][2] == 101)
			flag = 1;
	}
	return flag;
}

int wcheck(int  bingo[H][W])
{
	int flag = 0;

	for (int i = 0; i < W - 1; i++) {
		if (bingo[0][i] == 101 && bingo[1][i] == 101 && bingo[2][i] == 101)
			flag = 1;
	}
	return flag;
}

int ncheck(int  bingo[H][W])
{
	int flag = 0;

	if (bingo[0][0] == 101 && bingo[1][1] == 101 && bingo[2][2] == 101)
		flag = 1;

	if (bingo[0][2] == 101 && bingo[1][1] == 101 && bingo[2][0] == 101)
		flag = 1;

	return flag;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  long long ans = 0;
  for(int b = 1;b <= N;b++){
    int amari = N % b;
    int syo = (N - amari)/b;
    ans += max(0,b -K) * syo + max(0,amari - K + 1);
  }
  // a = 0
  if (K == 0) {
    ans -= N;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int s,w; cin >>s >>w;
  print(s<=w?"unsafe":"safe");
}



Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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





int main(){
    int N; long long K, sum(0);
    std::cin >> N >> K;
    std::vector<int> A(N), F(N);
    for(int i(0); i < N; ++i){
        std::cin >> A[i];
        sum += A[i];
    }
    if(sum <= K){
        std::cout << 0 << std::endl;
        return 0;
    }
    for(int i(0); i < N; ++i) std::cin >> F[i];

    std::sort(std::begin(A), std::end(A));
    std::sort(std::rbegin(F), std::rend(F));

    long long mx(0);
    for(int i(0); i < N; ++i) chmax(mx, (long long)A[i] * F[i]);
    long long ng(0), ok(mx);
    while(std::abs(ok-ng) > 1){
        long long mid((ng+ok)/2), difSum(0);
        for(int i(0); i < N; ++i){
            difSum += std::max(0LL, A[i] - mid/F[i]);
        }
        if(difSum <= K) ok = mid;
        else ng = mid;
    }
    std::cout << ok << std::endl;
    return 0;
}


Measured memory_bytes: 1792
S = input()

s1 = int(S[:2])
s2 = int(S[2:])


def is_yymm(i1, i2):
    return (0 <= i1 < 100) and (0 < i2 < 13)


if is_yymm(s1, s2):
    if is_yymm(s2, s1):
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if is_yymm(s2, s1):
        print("MMYY")
    else:
        print("NA")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

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

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

    lint n,k,in,ans=0;cin>>n>>k;
    vector<lint> a;
    rep(i,n){
        cin>>in;
        a.push_back(in);
    }
    trev(a);
    rep(i,k)ans+=a[i];
    co(ans);
}

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

int main(){
	int n;
	cin >> n;
	for(int rep=0; rep<n; rep++){
		double x[2],y[2],r[2];
		cin>>x[0]>>y[0]>>r[0]>>x[1]>>y[1]>>r[1];
		double d = sqrt((x[1]-x[0])*(x[1]-x[0]) +(y[1]-y[0])*(y[1]-y[0]));
		if(d>r[0]+r[1]) cout << 0 << endl;
		else if(d<r[0]-r[1]) cout << 2 << endl;
		else if(d<r[1]-r[0]) cout << -2 << endl;
		else cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def lcm(x, y):
    return (x * y) // gcd(x, y)
n = int(input())
a = list(map(int,input().split()))
x = 1
for i in range(n-1):
    x *= lcm(a[i],a[i+1])
Sum = 0
for i in range(n):
    Sum += (x-1)%a[i]
print(Sum)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 3333;
int n,mo,res,C[N][N],ni[N],f[N][N];
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline int power(int a, int n, int mo) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
int main() {
	read(n);read(mo);rep(i,0,n){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	f[0][0]=1;
	rep(m,1,n)rep(i,0,m)f[m][i]=((i-1>=0?f[m-1][i-1]:0)+1LL*f[m-1][i]*(i+1))%mo;
	rep(m,0,n){
		int ans=0,xs=power(2,n-m,mo);static int a[N];
		a[0]=1;rep(i,1,n)a[i]=1LL*a[i-1]*xs%mo;
		rep(i,0,m)ans=(ans+1LL*f[m][i]*a[i])%mo;ans=1LL*ans*power(2,power(2,n-m,mo-1),mo)%mo;
	//	cerr<<m<<' '<<ans<<endl;
		res=(res+1LL*ans*C[n][m]*(m&1?-1:1))%mo;
	}
	cout<<(res+mo)%mo;
	return 0;
}


Measured memory_bytes: 80768
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
int main(){
    int n,k;
    cin>>n>>k;
    vi p(n);
    rep(i,n)cin>>p[i];
    sort(all(p));
    int sum=0;
    rep(i,k)sum+=p[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vll a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    ll ans = 0;
    rrep(i, n) {
        a[i] += ans;
        if (a[i] % b[i] != 0) ans += b[i] - a[i] % b[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

/********** Good Luck :) **********/
int main()
{
    IOS();
    ll n;
    cin >> n;
    cout << (n-2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
n, a, b = map(int, sys.stdin.readline().split())
c = b - a
if c % 2:
  d = min(a - 1, n - b)
  e = 1
  f = (b - a - 1) // 2
  print(d + e + f)
else:
  print(c // 2)


Measured memory_bytes: 9180
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    List<Integer> a = new ArrayList<Integer>();
    while (scanner.hasNext()) {
      a.add(scanner.nextInt());
    }
    Collections.sort(a);
    Collections.reverse(a);
    String out = "";
    for (int ii = 0; ii < a.size(); ii++) {
      out += a.get(ii) + " ";
    }
    System.out.println(out.trim());
  }
}

Measured memory_bytes: 17372
import copy


N = int(input())
h = list(map(int, input().split()))

i=0
leftH = copy.deepcopy(h)
while max(leftH) > 0:
    flag = False
    for j in range(N):
        if leftH[j] > 0:
            leftH[j] -= 1
            if flag == False:
                i += 1
            flag = True
        elif flag == True:
            flag = False
print(i)


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

#define TOTAL 120*60 // sec

int main()
{
	int a, b, c;
	while(cin>>a>>b>>c){
		if(a==-1&&b==-1&&c==-1) break;
		const int input = a*60*60 + b*60 + c;
		int sec = TOTAL - input;
		int h, m;
		h = (int)floor(sec/3600); sec -= 3600*h;
		m = (int)floor(sec/60); sec -= 60*m;
		printf("%02d:%02d:%02d\n", h, m, sec);
		
		int sec3 = 3*(TOTAL-input);
		h = (int)floor(sec3/3600); sec3 -= 3600*h;
		m = (int)floor(sec3/60); sec3 -= 60*m;
		printf("%02d:%02d:%02d\n", h, m, sec3);
	}
	
	return 0;
}

Measured memory_bytes: 1144
import fractions, math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
  
A, B = map(int, input().split()) 
ans = set(make_divisors(A)) &  set(make_divisors(B))
print(sum([is_prime3(i) for i in ans])+1)



Measured memory_bytes: 7492
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vll x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}

//=======================================================================================================

int main()
{
    ll n;
    cin >> n;
    vll p(n);
    vll psrt(n);
    rep(i,n){
        cin >> p[i];
        psrt[i] = p[i];
    }
    srt(psrt);

    int x = 0;
    rep(i,n) {
        if(p[i] != psrt[i] ) ++x;
    }

    cout << ((x==0||x==2)?"YES":"NO") << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

count = 0
(a.size - 1).times do |j|
  (a.size - 1 - j).times do |i|
    if a[i] > a[i + 1]
      a[i], a[i + 1] = a[i + 1], a[i] 
      count += 1
    end
  end
end

count *= k
a.each { |num| count += a.sort.find_index(num) * (k * (k - 1)/ 2) }

puts count % (10**9 + 7)


Measured memory_bytes: 28664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;

int main() {
	int n,k;
	cin >> n>>k;
	vector<ll> a(n),dp(n,1000000000);
	dp[0] = 0;
	rep(i, n)cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0;j<=k; j++) {
			if (j + i > n-1)break;
			dp[i+j] = min(dp[i+j], dp[i]+abs(a[i] - a[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
	please AC;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 118, 87
// 169, 133, 17, 98
// 180, 106, 125, 39
// 171, 42, 159, 14
// 45, 76, 101, 56
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	long long ret2=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		if(i==0)ret2=(ret2+ks)%d;
		ks=ks*2%d;
	}
	int sz=d%200;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

Measured memory_bytes: 101204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S; cin >> N >>S;
  if(N%2==1) {cout << "No" << endl;return 0;}
  N /= 2;
  for(int i = 0; i < N; ++i){
    if(S[i] != S[N+i]) {cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
module Main (main) where

import           Control.Monad
import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [[s1], [s2]] <- replicateM 2 readStrings
  print . showAnswer $ solve (s1, s2)

type Input  = (String, String)
type Output = Bool

solve :: Input -> Output
solve (s1,s2) = s1 == reverse s2

showAnswer :: Output -> Answer
showAnswer = YESNO

-- utils
readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int

instance Show Answer where
  show (YesNo b)        = if b then "Yes" else "No"
  show (YESNO b)        = if b then "YES" else "NO"
  show (AB b)           = if b then "A"   else "B"
  show (Number i)       = show i

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define llint long long

using namespace std;

llint n;
string s;
map<string, llint> mp;
vector<string> vec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s;
		mp[s]++;
	}
	
	llint mx = 0;
	for(auto it = mp.begin(); it != mp.end(); it++) mx = max(mx, it->second);
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second == mx) vec.push_back(it->first);
	}
	sort(vec.begin(), vec.end());
	
	for(int i = 0; i < vec.size(); i++) cout << vec[i] << endl;
	
	return 0;
}

Measured memory_bytes: 25584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define len 1000050

int prev(int pos) {
    return (pos == 0) ? len - 1 : pos - 1;
}

int next(int pos) {
    return (pos == len - 1) ? 0 : pos + 1;
}

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

    int n; cin >> n;

    vector<int> li(len);
    int fi=0, la=0;

    string op;
    int key;
    for (int i=0; i<n; ++i) {
        cin >> op;
        if (op[0] == 'i') {
            cin >> key;
            fi = prev(fi);
            li[fi] = key;
        } else if (op.size() > 6 && op[6] == 'F') {
            while (li[fi] == -1) {
                fi = next(fi);
            }
            fi = next(fi);
        } else if (op.size() > 6 && op[6] == 'L') {
            while (li[prev(la)] == -1) {
                la = prev(la);
            }
            la = prev(la);
        } else {
            cin >> key;
            for (int j=fi; j!=la; j=next(j)) {
                if (li[j] == key) {
                    li[j] = -1;
                    break;
                }
            }
        }
    }
    bool nospace = true;
    for (int i=fi; i!=la; i=next(i)) {
        if (li[i] == -1) continue;
        if (nospace) {
            cout << li[i];
            nospace = false;
        } else {
            cout << " " << li[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4900