akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int INF = 1e9;

int main() {
  int N, M;
  cin >> N >> M;
  using P = pair<pair<int, int>, int>;
  vector<P> E;
  vector<vector<int>> dist(N, vector<int>(N, INF));
  rep(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    E.push_back(P({a, b}, c));
    dist[a][b] = c;
    dist[b][a] = c;
  }
  rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = 0;
  for(auto e : E) {
    if(dist[e.first.first][e.first.second] != e.second) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
double pi = 3.141592653;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;

	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	x /= a;

	//水が三角形を成す場合．
	if (x <= a * b / 2) {
		double angle = 90.0 - atan2(2 * x / b, b) * 180.0 / pi;
		printf("%0.10lf\r\n", angle);
	}
	//水が台形を成す場合
	else {
		double angle = 90.0 - atan2(a * a, 2 * (a * b - x)) * 180.0 / pi;
		printf("%0.10lf\r\n", angle);
	}

	return 0;
}

Measured memory_bytes: 256
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const int MOD = 1000000007;
const int MAX = 200100;

ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i) % MOD;
        finv[i]=finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}
signed main(){
    COMinit();
    ll n,a,b; cin >> n >> a >> b;
    ll ans=RepeatSquaring((ll)2,n,MOD)-1;
    //cout << ans << endl;
    
    ll a1=finv[a];
    rep(i,a){
        a1*=(n-i);
        a1%=MOD;
    }
    
    ll b1=finv[b];
    rep(i,b){
        b1*=(n-i);
        b1%=MOD;
    }
    
    ans-=a1;
    if(ans<0) ans+=MOD;
    ans-=b1;
    if(ans<0) ans+=MOD;
    
    cout << ans%MOD << endl;
    
}


Measured memory_bytes: 4992
=begin
a = gets.to_i
s = gets

if a < 3200
  puts "red"
else
  puts s
end
=end

=begin
b = gets.to_i
a = gets.split(" ").map{|x| x.to_f}
sum = 0.0
b.times do |i|
  sum += 1/a[i]
end
p 1 / sum
=end

n = gets.to_i
a = gets.split(" ").map{|x| x.to_f}

while true
  a.sort!
  a.push((a[0] + a[1]) / 2.0)
  a.delete_at(0)
  a.delete_at(0)
  break if a.size == 1
end

p a[0]


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long int a,b,x;
int main(){
	int i,j,k;
	cin>>x;
	for(i=-122;i<121;i++){
		for(j=-123;j<=i;j++){
			long long int xx=pow(i,5)-pow(j,5);
			if(xx>x)continue;
			else if(xx<x)break;
			if(xx=x){
				a=i,b=j;
				i=122;j=122;
			}
		}
	}
	cout<<a<<' '<<b;
	getchar();getchar();
}

Measured memory_bytes: 4100
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.La;
		BigInteger p=a[0];
		long z=a.Min();
		if(z==0){
			Console.WriteLine(0);
			return;
		}
		for(int i = 1;i<n;i++) {
			p*=a[i];
			if(p>(long)1e18){
				Console.WriteLine(-1);
				return;
			}
		}
		Console.WriteLine("{0}",(long)p);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int dig(int x)
{
  int res=0;
  while(x) res+=x%10, x/=10;
  return res;
}

int main()
{
  int a; cin >>a;
  if(a%dig(a)==0) puts("Yes");
  else puts("No");
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool f=false;
    int sum=0;
    for(int i=2;i<s.size()-1;++i)
        if(s[i]=='C')
            sum++;
    if(sum==1)
        f=true;
    if(s[0]!='A')
        f=false;
    else
        for(int i=0;i<s.size();++i)
            if(s[i]<=90&&s[i]>=65)
                if(i==0)
                    continue;
                else if(i<s.size()-1&&i>1&&s[i]=='C')
                    continue;
                else
                {
                    f=false;
                    break;
                }
    if(f)
        cout<<"AC";
    else
        cout<<"WA";
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, M = MI()

a = N * (N - 1) // 2
b = M * (M - 1) // 2

print(a + b)

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

namespace LinqTest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var T = int.Parse(input[1]);

            var list = new List<int>();

            for(int i=0; i<N; i++)
            {
                var input2 = Console.ReadLine().Split(' ');
                var c = int.Parse(input2[0]);
                var t = int.Parse(input2[1]);

                if(t <= T)
                {
                    list.Add(c);
                }
            }

            
            if(list.Count() == 0)
            {
                Console.WriteLine("TLE");
            } else {
                Console.WriteLine(list.Min());
            }
        }
    }
}

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

int main() {
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    vector<int> v={A,B,C};
    int max=*max_element(v.begin(), v.end());
    int n=max;
    for (int i=0; i<K; i++) {
        n=2*n;
    }
    cout<<A+B+C-max+n<<endl;
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
n = s.length

def check(word)
  word = word.to_s
  size = word.length / 2
  return ( word[0..size] == word.reverse[0..size] )
end

ans = "No"
ans = "Yes" if check(s) && check(s[0..((n-1)/2)-1]) && check(s[((n+3)/2)-1..-1])
puts ans

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

int main(int argc, char const *argv[])
{
    int n,a;
    int amax=1,amin=1000000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        amax=max(a,amax);
        amin=min(a,amin);
    }
    cout<<abs(amax-amin);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007

ll dp[100000];
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k,i,j,ans=0;
	cin>>n>>k;
	ll a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++){
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for(j=2;j<=k&&i-j>=0;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 5212
let () =
  let rec read () =
    try let (s,w,h) = Scanf.scanf " %d,%f,%f\n" (fun x y z->(x,y,z)) in
        let bmi = w/.(h*.h) in
        if bmi >= 25. then
          Printf.printf "%d\n" s
        else ()
        ;read ()
    with End_of_file -> ()
  in read ()
;;

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    vector<int> D(N + 1, 0);
    for (int i = 1; i <= N; i++) D[i] = D[i - 1] + L[i - 1];

    int ans = 0;
    for (int i = 0; i < N + 1; i++) {
        if (D[i] <= X) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void)
{
    int a,b,c=0,i,j,z,p;
    char number[100000];
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++){
        sprintf(number,"%d",i);
        j=0;
        while(number[j]!='\0') j++;
        z=0;
        p=j/2;
        j--;

        while((number[j-z]==number[z])&&(z<=p)){
            z++;
        }
        if(z==p+1) c++;
    }
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  N = readline() |> parseInt
  S,P=Array{String}(N),zeros(Int,N)
  for i in 1:N
    S[i], s = readline() |> split
    P[i] = parseInt(s)
  end

  ix=sortperm(S)
  S,P=S[ix],P[ix]
  s=S[1]
  jx=Int[]
  px=Int[]
  for i in 1:N
    if S[i]!=s
      jx=jx[sortperm(px,rev=true)]
      for j in jx
        println(j)
      end
      jx=Int[]
      px=Int[]
    end
    s=S[i]
    push!(jx,ix[i])
    push!(px,P[i])
  end
  jx=jx[sortperm(px,rev=true)]
  for j in jx
    println(j)
  end
end

main()

Measured memory_bytes: 116232
#include <stdio.h>
#define max 101
int p[max];
int d[max];
int n,t=0;
int use[max];
int m[max][max];


void cal(int u);

int main (){
 
  int i,j;
  int k,u,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&r);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&u);
      m[r][u] = 1;
    }
  }
  i=1;
  while(i<=n){
    if(use[i] == 0){
    t++;
	d[i]=t;
	use[i]=1;
	cal(i);
   }
    i++;
  }

  for(i=1;i<=n;i++){
printf("%d %d %d\n",i,d[i],p[i]);
  }
  return 0;
}
void cal(int u){
  
  int v;
  
  for(v=0;v<max;v++){
    if(m[u][v]==1 && use[v] == 0){
      use[v]=1;t++;
      d[v]=t;
	  cal(v);
    }
  }
    p[u] = ++t;
}


Measured memory_bytes: 2112
#include <cmath>
#include <iostream>

using namespace std;


unsigned long long attack(unsigned long long h) {
  if (h == 1) {
    return 1;
  }

  unsigned long long new_h = (unsigned long long)(floor(double(h) / 2.0));
  unsigned long long r = 1 + 2 * attack(new_h);
  return r;
}

int main(void) {
  unsigned long long h;

  cin >> h;

  unsigned long long r = attack(h);

  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main(){
	string s;
	cin >> s;

	rep(i, s.size())
		if (s[i] == ',')
			cout << " ";
		else
			cout << s[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define int long long
using namespace std;
 
int N, T, Q;
int A[100001], D[100001];
int X[1001];
int P[100001];  //P[i] = ???i???????????????
 
signed main()
{
    int i, j;
     
    cin >> N >> T >> Q;
    for( i = 1; i <= N; i++ ){
        cin >> A[i] >> D[i];
    }
    for( i = 1; i <= Q; i++ ){
        cin >> X[i];
    }
     
    for( i = N; i >= 1; i-- ){
        if( D[i] == 2 )
            continue;
        //????????????????????????????????????
        if( i == N )
            P[i] = A[i] + T;
        else if( D[i + 1] == 2 )
            P[i] = min(A[i] + T, (A[i] + A[i + 1]) / 2);
        else
            P[i] = min(A[i] + T, P[i + 1]);
    }
    for( i = 1; i <= N; i++ ){
        if( D[i] == 1 )
            continue;
        //????????????????????????????????????
        if( i == 1 )
            P[i] = A[i] - T;
        else if( D[i - 1] == 1 )
            P[i] = max(A[i] - T, (A[i - 1] + A[i]) / 2);
        else
            P[i] = max(A[i] - T, P[i - 1]);
    }
     
    for( i = 1; i <= Q; i++ ){
        cout << P[X[i]] << endl;
    }
    return 0;
}

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

int main(){
    long long h;
    cin >> h;
    long long x = h;
    long long count = 0;
    long long ans = 0;
    
    while (x > 1){
        count++;
        x /= 2;
        ans += pow(2, count);
    }
    
    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N=2e5+5;
int a[N]={0},n,m,x,y,res,i;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}
	for(i=1;i<100000;i++)res=max(res,a[i-1]+a[i]+a[i+1]);
	cout<<res;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
int main () {
    
    int n,a,b; cin >>n>>a>>b;

    cout << min(n*a , b) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
S = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(n):
    S[input()] += 1
print("AC x {}".format(S["AC"]))
print("WA x {}".format(S["WA"]))
print("TLE x {}".format(S["TLE"]))
print("RE x {}".format(S["RE"]))

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
using Edges = vector<Edge<T>>;
template <typename T>
using AdjList = vector<Edges<T>>;

template <typename T>
class Dijkstra {
    private:
        T INF = numeric_limits<T>::max() / 10;
        int V;           // 頂点数
        AdjList<T> adj;  // adj[始点][動的配列で始点から伸びる枝]
        vector<int> prever;

    public:
        Dijkstra(int n);
        vector<T> cost;
        void AddEdge(int f, int t, T c);
        bool HasPath(int t);                 // tに至るパスはあるか
        vector<int> GetShortestPath(int t);  // tへの最短路
        void Run(int f);
};

template <typename T>
Dijkstra<T>::Dijkstra(int n) : 
    V(n + 1), adj(V), prever(vector<int>(V, -1)), cost(V)
{
    fill(cost.begin(), cost.end(), INF);
}

template <typename T>
void Dijkstra<T>::AddEdge(int f, int t, T c) {
    adj[f].push_back(Edge<T>(t, c));
}

template <typename T>
bool Dijkstra<T>::HasPath(int t) {
    return cost[t] != INF;
}

template <typename T>
vector<int> Dijkstra<T>::GetShortestPath(int t) {
    vector<int> path;
    for (; t != -1; t = prever[t]) path.push_back(t);

    reverse(path.begin(), path.end());
    return path;
}

template <typename T>
void Dijkstra<T>::Run(int firstNode) {
    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> pq;

    cost[firstNode] = 0;
    pq.push(Pi(cost[firstNode], firstNode));

    while (!pq.empty()) {
        Pi currentEdge = pq.top();
        pq.pop();
        if (cost[currentEdge.second] < currentEdge.first) continue;

        for (Edge<T> tmp : adj[currentEdge.second]) {
            T sumCost = currentEdge.first + tmp.cost;
            if (cost[tmp.to] > sumCost) {
                cost[tmp.to] = sumCost;
                prever[tmp.to] = currentEdge.second;
                pq.push(Pi(cost[tmp.to], tmp.to));
            }
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    Dijkstra<int> dij(k+1);
    REP(i, k){
        dij.AddEdge(i, (i+1) % k, 1);
        dij.AddEdge(i, (i*10) % k, 0);
    }
    dij.Run(1);
    cout << dij.cost[0] + 1 << endl;
}


Measured memory_bytes: 11644
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long add[100005],del[100005];
int a[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		int l=a[i],r=a[i+1];
		if(l<r)
		{
			add[1]+=r-l;
			add[l+1]+=l+1;
			add[r+1]-=l+1;
			del[l+1]-=1;
			del[r+1]+=1;
		}
		else if(l>r)
		{
			add[1]+=r+1;
			del[1]-=1;
			add[r+1]+=m-l-1;
			del[r+1]+=1;
			add[l+1]+=l+1;
			del[l+1]-=1;
		}
	}
	for(int i=2;i<=m;i++)add[i]+=add[i-1],del[i]+=del[i-1];
	long long ans=1e16;
	for(int i=1;i<=m;i++)ans=min(ans,add[i]+i*del[i]);
	printf("%lld\n",ans);
	return 0;
}

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

int cnt[26];
char s[1000][1000];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < n; i++)
        scanf("%s", s[i]);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cnt[s[i][j] - 'a']++;
    bool flag = true;
    if((n % 2 == 0) && (m % 2 == 0)) {
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 4 != 0) {
                flag = false;
                break;
            }
        }
        puts(flag ? "Yes" : "No");
    }

    else if((n % 2 == 0) && (m % 2 != 0)) {
        int cur = 0;
        bool flag = true;
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 2 != 0) {
                flag = false;
                break;
            }
            if(cnt[i] % 4 != 0 && cnt[i] % 2 == 0)
                cur ++;
        }
        if(flag && cur <= n / 2)
            puts("Yes");
        else
            puts("No");
    }
    else if((n % 2 != 0) && (m % 2 == 0)) {
        int cur = 0;
        bool flag = true;
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 2 != 0) {
                flag = false;
                break;
            }
            if(cnt[i] % 4 != 0 && cnt[i] % 2 == 0)
                cur ++;
        }
        if(flag && cur <= m / 2)
            puts("Yes");
        else
            puts("No");
    }
    else {
        int center = 0;
        int cur = 0;
        for(int i = 0; i < 26; i++) {
            if(cnt[i] % 2 == 1) {
                center++;
            }
            else if (cnt[i]%4!=0&&cnt[i]%2==0)
                cur++;
        }
        if(cur<=n/2+m/2&&center<=1)
                printf("Yes");
            else
                printf("No");
    }
    return 0;
}


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

using namespace std;

int N, L;

int main()
{
    cin >> N >> L;
    string arr[N];
    for (int i = 0 ; i < N ; i ++) {
        cin >> arr[i];
    }
    sort (arr, arr + N);
    for (int i = 0 ; i < N ; i ++) {
        cout << arr[i];
    }
    return 0;
}

Measured memory_bytes: 3648
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[200] = {};
	ll b[200] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	

	//char p;
	cin >> N >> M >> A >> B ;
	//cin >> S;
	rep(i, 0, N) {
		cin >> a[i];
	}
	rep(i, 0, M) {
		cin >> b[i];
	}
	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(N+1);
	//vector<bool> flag(N);
	
	//count--;
	//	cout << X << endl;
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(v.begin(), v.end());
	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/

	if (A >= B) {
		cout << "War" << endl;
		return 0;
	}

	rep(j, A+1, B+1) {

		rep(i, 0, N) {

			//cout << j << "," << a[i] << endl;

			if (a[i] >= j)
				break;

			if (i == N - 1)
				sum++;

			//cout << sum << endl;
		}

		rep(i, 0, M) {

			//cout << j << "," << b[i] << endl;

			if (b[i] < j)
				break;

			if (i == M - 1)
				sum++;

			//cout << sum << endl;
		}

		if (sum == 2)
			break;
		else
			sum = 0;



		//cout << j << endl;
	}
	
	if(sum==2)
	cout << "No War" << endl;
	else
		cout << "War" << endl;
	
	

	



	


	return 0;

}

ll gcd(ll a, ll b) {
	ll c;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}

Measured memory_bytes: 256
from math import atan, pi
a, b, x = map(int, input().split())
h = x / (a*a)

l = 2*h - b
c = 2 * a * h / b

if l >= 0:
    print("%.10f"%(180 / pi * atan((b-l)/a)))
else:
    print("%.10f"%(180 / pi * atan(b/c)))

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a,b,c,d;
	int wa[2];

	for (int i = 0; i < 2; i++) {
		cin >> a >> b >> c >> d;
		wa[i] = a + b + c + d;
	}
	if (wa[0] > wa[1]) {
		cout << wa[0] << endl;
	} else {
		cout << wa[1] << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,s;
	cin >> n >> k >> s;
	if(s==1000000000){
		rep(i,k) cout << s << " ";
		rep(i,n-k) cout << 1 << (i==n-k-1?"\n":" ");
	}
	else{
		rep(i,k) cout << s << " ";
		rep(i,n-k) cout << s+1 << (i==n-k-1?"\n":" ");;
	}
	return 0;
}

Measured memory_bytes: 1280
/* ex3_4
   kento_titech*/
#include<stdio.h>
int main(void){
    int i;
    int N,n,r;//N,n,rが変数
    scanf("%d",&N);
    for(i=1;i<10;++i){//forループで１０より小さい数で割ったとき商が1~9になりかつあまり0の場合を考える
        n=N/i;
        r=N%i;
        if(0<n && n<10 && r==0){
            printf("Yes\n");
            break;
        }
    }
    if(i==10){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	float height;
	float min, max;
	
	scanf("%f", &height);
	min = max = height;
	while (scanf("%f", &height) != EOF){
		if (min > height){
			min = height;
		}
		if (max < height){
			max = height;
		}
	}
	printf("%f\n", max - min);
	
	return 0;
}

Measured memory_bytes: 644
n = int(input())
ans, a, b, ba = 0, 0, 0, 0

for _ in range(n):
    s = input()
    if s[-1] == "A" and s[0] == "B":
        ba += 1
    elif s[-1] == "A":
        a += 1
    elif s[0] == "B":
        b += 1
    ans += s.count("AB")

if ba == 0:
    ans += min(a, b)
elif a+b == 0:
    ans += ba-1
else:
    ans += ba+min(a, b)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  int n, ans = 1;
  cin >> n ;
  int a[100000] = {0};
  a[n] = 1;
  while(1){
    ans += 1;
    if(n%2==0) n /= 2;
    else n = 3*n + 1;
    if(a[n]==1) break;
    else a[n]=1;
  }
  cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int b[1000],sum=0;
int main(){
	int a;
	cin>>a;
	for(int i=1;i<=2*a;i++){
		cin>>b[i];
	}
	sort(b+1,b+a+a+1);
	for(int i=1;i<=2*a;i+=2){
		sum+=b[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long n,d,a[15],i,j,k,s,h,l,f;
    cin>>n>>d;
    for(i=1;i<=d;i++)
    {
        cin>>a[i];
    }
    for(j=n;j>=n;j++)
    {
        k=j;
        l=f=0;
        while(k!=0)
        {
            s=k%10;
            k/=10;
            h=0;
            f++;
            for(i=1;i<=d;i++)
            {
                if(a[i]==s)
                {
                    h++;
                    break;
                }
            }
            if(h==0)
            {
                l++;
            }
            else
            {
                break;
            }
        }
        if(l==f)
        {
            cout<<j<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();  	
}

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> dt;
    for (int i = 0; i < n; ++i) {
        int num; cin >> num;
        dt.emplace_back(num, i);
    }

    sort(all(dt));

    for (auto it : dt) {
        cout << it.y + 1 << " ";
    }
}

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

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)cnt+=1;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int x,y,a;
	while(cin>>x>>y){
		if(x==0&&y==0) break;
		if(x>y){
			a=x;
			x=y;
			y=a;
			}
		cout<<x<<" "<<y<<endl;
		}
	return 0;
}

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

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

	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] - '0' == i % 2) ans1++;
		else ans2++;
	}
	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int a,b,c=0;
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			c=a*b;
			printf("%dx%d=%d\n",a,b,c);
		}
	}
	return 0;
}


Measured memory_bytes: 2008
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int m, n;
	int a, b, c;

	cin >> a >> b >> c;
	int cnt1 = 0;

	//for (int i = 0, cnt=0; i < c; cnt+=b, i+=a) {
	//	cnt1 = cnt;
	//}

	int sum = 0;

	for (int i = 0, cnt = a; i <= c; i++) {
		if (i == cnt) {
			sum += b;
			cnt += a;
		}
	}




	cout << sum << endl;

	getchar();
	getchar();
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const LL INF=(LL)1e9*(LL)1e9;


int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    REP(i,m)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<char> reach(n);
    for(auto&& e:g[0])
        reach[e]=1;
    
    bool flag=0;
    for(auto&& e:g[n-1])
        if(reach[e])
        {
            flag=1;
            break;
        }
    
    if(flag)
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 12144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A <= 8 && B <= 8){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


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


int main() {
  int n;
  cin >> n;
  rep(i,n) {
    rep(j,n) {
      if (4 * i + 7 * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  char A,B;
  cin>>A>>B;
  bool ch=true;
  if(A=='H'){
    if(B=='D')ch=false;
  }
  if(A=='D'){
    if(B=='H')ch=false;
  }
  if(ch)cout<<'H'<<endl;
  else cout<<'D'<<endl;
  return 0;
}

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

const int MAXV = 100000;
const int MAXE = 100000;

int parent[MAXV] = { 0 };
int prenum[MAXV] = { 0 };
int lowest[MAXV] = { 0 };
int visited[MAXV] = { 0 };

vector<int> edges[MAXV];

void dfs(int u, int prev, int timer) {
  prenum[u] = timer;
  lowest[u] = timer;

  visited[u] = true;

  for(auto v : edges[u]) {
    if(!visited[v]) {
      parent[v] = u;
      dfs(v, u, timer + 1);
      lowest[u] = min(lowest[u], lowest[v]);
    } else if(v != prev) {
      lowest[u] = min(lowest[u], prenum[v]);
    }
  }
}

int main() {
  int V, E;
  cin >> V >> E;

  for(int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;

    edges[s].push_back(t);
    edges[t].push_back(s);
  }

  dfs(0, -1, 1);

  int root_children = -1;
  for(int u = 0; u < V; u++) {
    root_children += (parent[u] == 0);
  }

  if(root_children > 1) {
    cout << 0 << endl;
  }

  vector<int> articulations;
  for(int u = 1; u < V; u++) {
    if(prenum[parent[u]] <= lowest[u]) {
      articulations.push_back(parent[u]);
    }
  }

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

  articulations.erase(unique(articulations.begin(), articulations.end()), articulations.end());

  for(auto a : articulations) {
    if(a != 0) {
      cout << a << endl;
    }
  }
}

Measured memory_bytes: 6956
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	string s,t;
	char a[200],b[200];
	cin>>s>>t;
	for (int i=0;i<s.size();i++)
		for (int j=s.size()-1;j>i;j--)
			if (s[j]<s[j-1]) swap(s[j],s[j-1]);
	for (int i=0;i<t.size();i++)
		for (int j=t.size()-1;j>i;j--)
			if (t[j]>t[j-1]) swap(t[j],t[j-1]);
	if (s<t)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
i = 1
for i in range(1,N+1):
    a,b,c = map(int,input().split())
    if a>b:
        a,b = b,a
    if b>c:
        b,c = c,b
    if a>c:
        a,c = c,a
    if a**2+b**2 == c**2:
        print('YES')
    else:
        print('NO')
    i += 1



Measured memory_bytes: 5600
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var arr=Arr[I].split(":");
   var h=parseInt(arr[0],10);
   var m=parseInt(arr[1],10);
   var H=h*(360/12)+m*((360/12)/60);
   var M=m*(360/60);
   var hm=Math.abs(H-M);
   hm=Math.min(hm,360-hm);
   var ans;
   if(hm>=0 && hm<30)ans="alert";
   else if(hm>=90 && hm<=180)ans="safe";
   else ans="warning"
   console.log(ans);
}

Measured memory_bytes: 9800
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n;
    string s;

    cin>>n>>s;
    int r=0,rr=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='R')
            r++;
    }

    for(int i=0; i<r; i++)
    {
        if(s[i]=='R')
            rr++;
    }

    cout<<r-rr<<endl;








    return 0;
}


Measured memory_bytes: 3756
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
import heapq as hq
gcd = math.gcd
n,k = ma()
A = list(ma())
mi = min(A)
cnt = 0
ans = 0
f = True #これまでにmiが含まれていないか
for a in A:
    if a==mi:
        if f or cnt==0:
            f = False
            continue
    cnt+=1
    if cnt ==k-1:
        ans+=1
        cnt=0
        f=True
if cnt>0:ans+=1

print(ans)


Measured memory_bytes: 20736
#include<iostream>
using namespace std;
#include<stdio.h>
int main( )
{ 
	double a,n;
	cin>>a;
	double s=0;
	for(int i=1;i<=a;i++)
	{
		if(i%2!=0)
		{
			s++; 
		}
		
	}
	n=s/a;
printf("%.10f",n);
return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL dp[1005][1005];

int main() {
	int h, w;
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dp[i][j] = 0LL;
			char c;
			cin >> c;
			if (c == '.') {
				if (i == 0 && j == 0)
					dp[i][j] = 1;
				else if (i == 0)
					dp[i][j] = dp[i][j - 1];
				else if (j == 0)
					dp[i][j] = dp[i - 1][j];
				else
					dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
			} else dp[i][j] = 0;

			// cout << dp[i][j] << " ";
		}
		// cout << endl;
	}
	printf("%lld\n", dp[h - 1][w - 1]);
	return 0;
}
		

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  if(c >= 'a' && c <= 'z') cout << "a" << endl;
  else cout << "A" << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
main(){
  int i,j;
  int n,m;
  int A[100],cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j] < A[j-1]){
        m = A[j];
        A[j] = A[j-1];
        A[j-1] = m;
        cnt++;
       }
     }
   }
   for(i=0;i<n;i++){
     printf("%d",A[i]);
     if(i==n-1){
       printf("\n%d\n",cnt);
     }else{
       printf(" ");
     }
   }
}

Measured memory_bytes: 1032
#include<iostream>
#include<cstdio>
using namespace std;
int count(int i){
	int cou=0;
	for(int j=1;j<=i;j++){
		if(i%j==0)cou++;
	}
	return cou;
}
int main()
{
	int N;
	scanf("%d",&N);
	int ans=1;
	while(true){
		if(count(ans)==N)break;
		ans++;
	}
	printf("%d\n",ans);
}

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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    r *= 100;
    g *= 10;
    int sum;
    sum = r + g + b;

    if(sum % 4 == 0)
    cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
    
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,q;string s;
    cin >> n >> s >> q;
    vector<set<int>> is(26);
    rep(i,0,n) is[s[i]-'a'].insert(i);
    rep(i,0,q){
        int which; cin >> which;
        if(which == 1){
            int i; char c; cin >> i >> c; i--;
            is[s[i]-'a'].erase(i);
            s[i] = c; 
            is[s[i]-'a'].insert(i);
        }else{
            int l,r; cin >> l >> r; l--;
            int ans = 0;
            rep(i,0,26){
                auto it = is[i].lower_bound(l);
                if(it != is[i].end() && *it < r) ans++;
            }
            cout << ans << endl;
        }

    }
}

Measured memory_bytes: 24220
import sys
input=sys.stdin.readline
n=int(input())

#グラフの連結成分を調べる
def Graph():
    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for i in range(n-1):
        a,b,c=map(int,input().split())
        c=0 if c%2==0 else 1
        G[a-1].append((b,c))
        G[b-1].append((a,c))
    return G

#木上のDFSテンプレ
from collections import deque
def dfs(G,v,p):
    q=deque()
    q.append((v,p))
    dis=0
    dis_l=[-1]*n
    dis_l[0]=0
    while q:
        V,P=q.pop()
        for new_v in G[V-1]:
            v0,v1=new_v
            #new_vが頂点の時はアウト
            if v0==P:continue
            if dis_l[v0-1]>=0:continue
            dis=(dis_l[V-1]+v1)%2
            dis_l[v0-1]=dis
            q.append((v0,V))

    return dis_l


log=Graph()
ans=dfs(log,1,-1)
print(*ans,sep='\n')


Measured memory_bytes: 68256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    int m;
    cin >> n >> m;

    vector<string> A(n);
    vector<string> B(m);

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> B[i];
    }

    if (n < m) {
        cout << "No\n";
        return 0;
    }

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

    vector<vector<pair<int,int>>> pos(2);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            int idx = B[i][j] == '.' ? 0 : 1;
            pos[idx].emplace_back(i, j);
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int idx = A[i][j] == '.' ? 0 : 1;
            for (auto& p : pos[idx]) {
                int x = p.first, y = p.second;
                if (-x + i >= 0 && -y + j >= 0) {
                    cnts[-x + i][-y + j] += 1;
                }
            }
        }
    }

    bool res = false;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (cnts[i][j] == m * m) {
                res = true;
            }
        }
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <chrono>
#include <regex>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define Ichar(_x) char _x=_getchar_nolock();
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define Istring(_x) string _x;cin>>_x; 
#define inc(a,b,x)(x)>=a && (x)<=b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
//#define DEBUG
template<typename T>
int sUm(T* t1, T* t2)
{
	int s = 0;

	for (T* pi = t1; pi != t2; pi++)
	{
		s += *pi;
	}
	return s;
}

ll modo(ll a)
{
	return a % (int)(1e9+7);
}

int main()
{
	int a, b, n = 0;
	std::cin >> a >>b;
	for (int i = a; i <= b; ++i)
	{
		int x = i / 1000;
		if (i % 100 == x/10+(x%10)*10)n++;
	}
	std::cout << n;

}





Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  char a, b;
  bool ah, bh;
  cin >> a >> b;
  if(a=='H'){
    ah=true;
  }
  else{
    ah=false;
  }
  if(b=='H'){
    bh=true;
  }
  else{
    bh=false;
  }
  if(!(ah^bh)){
    cout << "H" << endl;
  }
  else{
    cout << "D" << endl;
  }
}

Measured memory_bytes: 256