akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S;
  cin >> S;
  
  bool broken = false;
  REP(i, S.length()){
    if((i%2==0 && S[i] == 'L') || (i%2 && S[i] == 'R')){
      cout << "No" << endl;
      broken = true;
      break;
    };
  };
  
  if(!broken) cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

long countPatty(int l,long x);
long countFullPatty(int l);
long countFloor(int l);

int main(){

	int n;
	long x,ans;

	scanf("%d %ld",&n,&x);

	ans = countPatty(n,x);

	printf("%ld",ans);

	return 0;
}

long countPatty(int l,long x){
	
	if(x<=l){
		// 残りの食べる枚数がレベル(>0)以下　→　下から[レベル]枚はすべてバンのためパティは0枚
		// 食べる枚数が0枚以下　→　当然パティは0枚
		return 0;
	}
	else if(l==0){
		// レベル0　→　パティは1枚
		return 1;
	}
	else{
		long cnt = countFloor(l-1); // 1つ下のレベルのバーガーの枚数

		if(x<cnt+1){
			// 残りの食べる枚数が[1つ下のレベルのバーガーの枚数]+1未満　→　最初はバンのため、1つ下のレベルのバーガーのみ考える
			return countPatty(l-1,x-1);
		}else if(x==cnt+1){
			// 残りの食べる枚数が[1つ下のレベルのバーガーの枚数]+1　→　1つ下のレベルのバーガーをすべて食べられる
			return countFullPatty(l-1);
		}else if(x==cnt+2){
			// 残りの食べる枚数が[1つ下のレベルのバーガーの枚数]+2　→　1つ下のレベルのバーガーと中間パティまで食べられる
			return countFullPatty(l-1)+1;
		}else if(x<cnt*2+2){
			// 残りの食べる枚数が[1つ下のレベルのバーガーの枚数]*2+2未満　→　2つめの1つ下のレベルのバーガーまで食べられる
			return countFullPatty(l-1)+1+countPatty(l-1,x-cnt-2);
		}else{
			return countFullPatty(l-1)*2+1;
		}
	}
}

long countFullPatty(int l){
	if(l==0){
		return 1;
	}else{
		return 1+countFullPatty(l-1)*2;
	}
}

long countFloor(int l){
	if(l==0){
		return 1;
	}else{
		return 3+countFloor(l-1)*2;
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<list>
using namespace std;
int main(){
	int n;
    	cin>>n;
    	int check=1;
	list<int>data;
    	for(int i=0;i<n;i++){
		int a;
		cin>>a;
    		if(check==1){
			data.push_front(a);
    			check*=-1;
    		}else{
			data.push_back(a);
    			check*=-1;
    		}
    	}
    	if(check==-1){
    		for(int i=0;i<n;i++){
			cout<<data.front()<<' ';
			data.pop_front();
		}
    	}else{
    		for(int i=0;i<n;i++){
			cout<<data.back()<<' ';
			data.pop_back();
		}
    	}
    	cout<<endl;
    	return 0;
    }

Measured memory_bytes: 8448
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[105];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2!=0)
        {
            if(arr[i]%2!=0)
                cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3132
#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 a,b,ans;
  cin >> a >> b;
  if ((a+b)%2==1) cout << "IMPOSSIBLE" << endl;
  else {
    ans = (a+b)/2;
    cout << ans << endl;
  }
  return 0;
}

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

int H;

int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}

void maxHeapify(int *A, int i)
{
  int l = left(i);
  int r = right(i);
  int largest;
  if (l <= H && A[i] < A[l]) {
    largest = l;
  } else {
    largest = i;
  }
  if (r <= H && A[largest] < A[r]) {
    largest = r;
  }
  if (largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(A, largest);
  }
}

void buildmaxHeap(int *A)
{
  for (int i = H / 2; i > 0; i--) {
    maxHeapify(A, i);
  }
}

int main()
{
  int A[1999999];
  cin >> H;
  for (int i = 1; i <= H; i++) cin >> A[i];
  buildmaxHeap(A);
  for (int i = 1; i <= H; i++) cout << " " << A[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> x(n); rep(i,n) cin >> x[i];

    int ans = 1002003004;

    rep(j,100){
        int tmp = 0;
        rep(i,n){
            tmp += ((j+1)-x[i]) * ((j+1)-x[i]);
        }

        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import collections
import sys

def solve(n, A, B):
  Ac = collections.defaultdict(int)
  ABc =  collections.defaultdict(int)
  for a in A:
    Ac[a] = 1 + Ac.get(a, 0)
    ABc[a] = 1 + ABc.get(a, 0)
  Bc =  collections.defaultdict(int)
  for b in B:
    Bc[b]  = 1 + Bc.get(b, 0)
    ABc[b] = 1 + ABc.get(b, 0)
  cAB = sorted([(c, ab) for ab, c in ABc.items()])
  #print(cAB)
  pool = collections.deque()  #[bbbb]   # [(b, count)], FIFO to match at the end

  matched = {}  # {a: bbbb}    # {a: {b, count}
  current = n   # how many are not matched yet
  for c, ab in cAB[::-1]:
    if c > current + len(pool):
      print('No')
      return
    matched[ab] = []
    while c > current:
      # take c - current from pool, add to matched
      c -= 1
      matched[ab].append(pool.popleft())
    # add (ab, Bc[ab]) to pool
    current -= Bc[ab]
    for _ in range(Bc[ab]):
      pool.append(ab)
  #  print(pool, matched)
  skipped = []
  for c, ab in cAB:
    # take c - matched[ab] from pool, add to matched
    nn = Ac[ab]-len(matched[ab])
    while skipped and  Ac[ab]-len(matched[ab]) > 0:
      matched[ab].append(skipped.pop())
    while Ac[ab]-len(matched[ab]) > 0:
      p = pool.popleft()
      if p == ab:
        skipped.append(p)
      else:
        matched[ab].append(p)
   # print(pool, matched)

  ans = []
  for a, bb in sorted(matched.items()):
    ans += [str(b) for b in bb]
  print('Yes')
  print(' '.join(ans))


def main():
  input = sys.stdin.readline
  n = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  solve(n, A, B)

main()


Measured memory_bytes: 206448
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long k = sc.nextLong();
        long d = sc.nextLong();
        x = Math.abs(x);
        long y = x / d;
        long pos = x % d;
        long neg = Math.abs(pos - d);
        if (y >= k) {
            System.out.println((y - k) * d + pos);
        } else {
            if ((k - y) % 2 == 0) {
                System.out.println(pos);    
            } else {
                System.out.println(neg);
            }
        }
	}
}

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

using namespace std;
typedef long long ll;

int N;

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;

    double ans = 0.0;
    for (int i = 0; i < N; i++)
    {
        int t; cin >> t;
        ans += 1.0 / t;
    }

    cout << fixed << setprecision(10);
    cout << 1.0 / ans << "\n";
}

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


void bfs(const vector< vector<int> > &edges, vector<int> &parent, int node)
{
    vector<int> color(parent.size());
    queue<int> Q;
    Q.push(node);
    color[node] = 1;
    parent[node] = 0;
    while(!Q.empty())
    {
        node = Q.front();
        Q.pop();
        for(int e : edges[node])
        {
            if(!color[e])
            {
                parent[e] = node;
                color[e] = 1;
                Q.push(e);
            }
        }
    }
}

int main()
{
    int N, M, a, b;
    cin >> N >> M;
    vector< vector<int> > edges(N);
    vector<int> parent(N);
    for(int i=0;i<M;++i)
    {
        cin >> a >> b;
        edges[--a].push_back(--b);
        edges[b].push_back(a);
    }

    bfs(edges, parent, 0);
    cout << "Yes" << endl;
    for(int i=1;i<N;++i)
    {
        cout << parent[i] + 1 << endl;
    }
}


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

int main(){
    int N, H, W, A, B, count=0;
    if(scanf("%d %d %d",&N,&H,&W) < 3) N=N;
    while(N>0){
        if(scanf("%d %d",&A,&B) < 2) N=N;
        if(H<=A && W<=B) count++;
        N -= 1;
    }
    printf("%d",count);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    static class Solve
    {
        public static void Answer()
        {
            var NM = IO_ShortCut.ReadSplitInt;
            var N = NM[0];
            var M = NM[1];
            var A = IO_ShortCut.ReadSplitInt;

            var total = A.Sum();
            A.Sort((x, y) => y - x);

            WriteLine(A[M - 1] < (double)total / (4 * M) ? "No" : "Yes");
        }
    }

    static class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        #endregion
    }
}

Measured memory_bytes: 13396
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 998244353

def solve():
    n,s = LI()
    a = LI()
    dp = [0]*(s+1)
    dp[0] = pow(2,n,mod)
    inv = pow(2,mod-2,mod)
    for i in a:
        for k in range(s)[::-1]:
            nk = k+i
            if nk > s:
                continue
            dp[nk] += dp[k]*inv%mod
            dp[nk] %= mod
    print(dp[s])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 68576
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
string s[2000001];

int main() {
  int n;
  cin >> n;
  map<string, int> dic;
  int max = 1;

  for (int i = 0; i < n; i++) {
    cin >> s[i];
    dic[s[i]]++;
    auto itr = dic.find(s[i]);
    if (itr->second > max) {
      max = itr->second;
    }
  }

  for (auto itr = dic.begin(); itr != dic.end(); itr++) {
    if (itr->second == max) {
      cout << itr->first << endl;
    }
  }
}

Measured memory_bytes: 40832
a=[]
for i in range(4):
    n=int(input())
    a.append(n)
a.sort(reverse=True)
b=[]
for i in range(2):
    m=int(input())
    b.append(m)
b.sort(reverse=True)
sum=0
for k in range(3):
    sum+=a[k]
print(sum+b[0])


Measured memory_bytes: 5596
n,*a=map(int,open(0).read().split())
ma=1001001
nums=[0]*ma

for q in a:
  nums[q]+=1
  if nums[q]==1:
    for j in range(2*q,ma,q):
      nums[j]+=2

cnt=0
for elem in nums:
  if elem==1:
    cnt+=1
    
print(cnt)

Measured memory_bytes: 33196
#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

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


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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

template<class T>
class heap {
public:
    heap(int s) : size {}, max_size {s}, xs {new T[s]} {};
    heap(int* ys, int n, int s) : size {}, max_size {s}, xs {new T[s]} {
        for(int i = 0; i < n; ++i){
            xs[i] = ys[i];
        }
        size = n;
        for(int i = size/2; i >= 0; --i){
            max_heapify(i);
        }
    };
    void max_heapify(int t){
        int left = t*2 + 1;
        int right = left + 1;
        int max_i = t;
        if(left < size && xs[left] > xs[max_i]){
            max_i = left;
        }
        if(right < size && xs[right] > xs[max_i]){
            max_i = right;
        }
        if(max_i == t){
            return;
        }
        swap(xs[t], xs[max_i]);
        max_heapify(max_i);
    };
    void print(){
        for(int i = 0; i < size; ++i){
            cout << ' ' << xs[i];
        }
        cout << endl;
    };
private:
    T* xs;
    int max_size;
    int size;
};

int main(){
    int n;
    cin >> n;
    int xs[n];
    for(int i = 0; i < n; ++i){
        cin >> xs[i];
    }
    auto h = heap<int>(xs, n, n);
    h.print();
}

Measured memory_bytes: 5084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;

#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
 
string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
constexpr int mod = 1e9 + 7;
ll POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (a == 0) {
		return b;
	}
	return gcd(b % a,a);
}
ll lcm(ll a, ll b) {
	return (a * b) / gcd(a,b);
}
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}

ll power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}     

ll call(ll cnt,string s) {
	ll p = 0;
	ll x = 0;
	for (int i = (int)s.size() - 1; i >= 0; --i) {
		ll y = 0;
		if (s[i] == '1') {
			y = power_mod(2LL,p,cnt);
		}
		x = (y % cnt + x % cnt) % cnt; 
		p++;
	}
	return x;
}

int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '1')cnt++; 
	}
	//cout << cnt << endl;
	ll inc_val = call(cnt + 1,s);
	ll dec_val = (cnt > 1)?call(cnt - 1,s):inc_val;
	//cout << inc_val << " "<< dec_val << endl;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '0')cnt++,s[i] = '1';
		else cnt--,s[i] = '0';
		if (cnt == 0) {
			cout << 0 << endl;
			if (s[i] == '1')cnt--,s[i] = '0';
			else cnt++,s[i] = '1';
			continue;
		}
		ll val = 0;
		if (s[i] == '1') {
			//inc_val
			val = (power_mod(2LL,n - i - 1,cnt) + inc_val + cnt) % cnt; 
		}else {
			val = (-power_mod(2LL,n - i - 1,cnt) + dec_val + cnt) % cnt; 
		}
		ll step = 1;
		//cout << val << " " << cnt << " ";
		if (s[i] == '1')cnt--,s[i] = '0';
		else cnt++,s[i] = '1';
		
		while (val) {
			ll p = 0;
			ll x = val;
			while (x) {
				if (x & 1) p++;
				x /= 2;
			}
			val = val % p;
			step++;
		}
	  cout << step << endl;
	}
}









Measured memory_bytes: 3932
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2*/

#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main()
{
    long long int a,b,c,d,e,i,j,n,m=0,x,y;
    cin>>a>>b>>c;
    d=(a+b)*c;
    printf("%lld\n",d/2);
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N,i,x;
    scanf("%d", &N);
    for(i=1;i<=9;i++){
        if(N%i==0){
            x=N/i;
        }
    }
    if(x>=1&&x<=9){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<stack>
using namespace std;
int main(){
	stack <int> s;
	char c[10];
	while(scanf("%s",c)!=EOF){
		if(c[0]=='+'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			int sum=a+b;
			s.push(sum);
		}else if(c[0]=='-'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			int sum=b-a;
			s.push(sum);
		}else if(c[0]=='*'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			int sum=a*b;
			s.push(sum);
		}else if(c[0]=='/'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			int sum=b/a; 
			s.push(sum);
		}else{
			s.push(atoi(c));
		}
	}
	cout<<s.top()<<endl;
	return 0;
} 


Measured memory_bytes: 3248
N=int(input())
H=list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(H[1]-H[0])

for i in range(N-2):
  dp[i+2]=min(dp[i+1]+abs(H[i+2]-H[i+1]),dp[i]+abs(H[i+2]-H[i]))

print(str(dp[N-1]))

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

int main(void){
        int N;
        int a,b,c;
        cin>>N;
        for(int i=0; i<N; i++) {
                cin>>a>>b>>c;

                if(a*a+b*b==c*c or a*a+c*c==b*b or b*b+c*c==a*a) {
                        cout<<"YES"<<endl;
                }
                else{
                        cout<<"NO"<<endl;
                }
        }
        return 0;

}



Measured memory_bytes: 2972
#include <bits/stdc++.h>
#define reg register

using namespace std;

const int mod = 1e9 + 7;
long long A, B;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline long long ksm(long long base, int mi) {
	long long res = 1;
	while(mi) {
		if(mi & 1) (res *= base) %= mod;
		(base *= base) %= mod, mi >>= 1;
	}
	return res;
}

int main() {
	cin >> A >> B;
	cout << max(A + B, max(A - B, A * B)) << endl;
	return 0;
}


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

typedef long long ll;
typedef pair <int , int> pii;
typedef long double ld;

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

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , x , t;
   cin >> n >> x >> t;
   cout << 1ll * (n / x + ((n % x) > 0)) * t;
   return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int N = std.nextInt();
        int K = std.nextInt();

        double rate = 0;
        for (int i = 0; i < N; i++) {
            int point = i + 1;
            if (point >= K) {
                rate += 1 / (double) N;
                continue;
            }

            double v = K /(double) point;
            double count = Math.log10(v) / Math.log10(2);
            int c = (int)Math.ceil(count);
            double result = 1 / (double) N * Math.pow(0.5, c);
            rate += result;
        }

        System.out.println(rate);
    }
}


Measured memory_bytes: 21812
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>9||b>9)
        cout<<-1<<endl;
    else cout<<a*b<<endl;
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,M;
vector<edge> G[200010];
bool flag=true;
int L[200010],R[200010],D[200010];
bool F[200010];
int X[200010];

void DFS(int s){
	F[s]=true;
	REP(i,G[s].size()){
		if(F[G[s][i].to]==true){
			if(X[G[s][i].to]-X[s]!=G[s][i].cost){
				flag=false;
				break;
			}
		}
		else{
			X[G[s][i].to]=X[s]+G[s][i].cost;
			DFS(G[s][i].to);
		}
	}
}

signed main(){
	cin>>N>>M;
	REP(i,M){
		cin>>L[i]>>R[i]>>D[i];
		edge e;
		e.to=R[i],e.cost=D[i];
		G[L[i]].push_back(e);
		e.to=L[i],e.cost=-D[i];
		G[R[i]].push_back(e);
	}
	for(int i=1;i<=N;i++){
		if(F[i]==false){
			DFS(i);
		}
		if(flag==false){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 23552
import Control.Monad
import Data.Maybe
import Data.List
import Data.Array
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as C

parseInt :: C.ByteString -> Int
parseInt = fst . fromJust . C.readInt

data Tree = Tree Int Int [Tree]

createTree :: Array Int Int -> M.IntMap [Int] -> Int -> Int -> Tree
createTree vals graph u par =
  let val = vals ! u
      vs = fromJust $ M.lookup u graph
      childs = map (\v -> createTree vals graph v u) $ filter (/= par) vs
  in Tree u val childs

dfs :: Tree -> Int -> M.IntMap Int -> [(Int, Int)] -> [(Int, Int)]
dfs (Tree u val childs) size mp results =
  (u, size') : foldl' (\results' child -> dfs child size' mp' results') results childs
  where
  (size', mp') = case M.lookupGE val mp of
    Nothing -> (size + 1, M.insert val (size + 1) mp)
    Just (val', len) -> (size, M.insert val len (M.delete val' mp))

main :: IO ()
main = do
  n <- parseInt <$> C.getLine
  as <- map parseInt . C.words <$> C.getLine
  es <- replicateM (n - 1) $ do
    [u, v] <- map parseInt . C.words <$> C.getLine
    return (u, v)
  let update x Nothing = Just [x]
      update x (Just xs) = Just (x : xs)
      vals = array (1, n) $ zip [1..n] as
      graph = foldl' (\mp (u, v) -> M.alter (update v) u $ M.alter (update u) v mp) M.empty es
      tree = createTree vals graph 1 0
      ans = array (1, n) $ dfs tree 0 M.empty []
  C.putStr $ C.unlines $ map (C.pack . show) [ans ! i | i <- [1..n]]

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N, Q;
  scanf("%lld %lld", &N, &Q);

  string s;
  cin >> s;

  vector<ll> acc(N);

  ll count = 0;

  for (ll i = 1; i < s.size(); i++) {
    char ch0 = s[i - 1];
    char ch1 = s[i];

    if (ch1 == 'C' && ch0 == 'A') {
      count++;
    }
    acc[i] = count;
  }

  for (ll i = 0; i < Q; i++) {
    ll l, r;
    scanf("%lld %lld", &l, &r);

    ll a = acc[r - 1] - acc[l - 1];
    cout << a << endl;
  }
}

// 12345678
// ACACTACG
// 1 2  3
//  1 2  3

// 3 7:2
// 2 3:0
// 1 8:3


Measured memory_bytes: 1792
/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL
 
Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
int main()
{
  ll n,k,i;
  cin>>n>>k;
  ll arr[n],sum=0;
  ffor(i,0,n)
  {
      cin>>arr[i];
  }
  sort(arr,arr+n);
  for(i=0;i<n-k;i++)
  sum+=arr[i];
  cout<<sum;
}

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

int main() {
	long long n,k,i,j,ans=0,cur=0;
	cin >> n;
	vector<long long> a(n+1),b(n);
    for(i=0; i<=n; i++){
    	cin >> a[i];
    }
    for(i=0; i<n; i++){
    	cin >> b[i];
    }
    for(i=0; i<n; i++){
    	j=min(a[i],b[i]);
    	cur+=j;
    	if(b[i]>a[i]){
    		b[i]-=a[i];
    		j=min(a[i+1],b[i]);
    		cur+=j;
    		a[i+1]-=j;
    	}
    }
    cout << cur;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();

		if (1 <= a && a <= 1000000000 && 1 <= b && b <= 1000000000) {
			int d = a / b;
			int r = a % b;
			double f = (double)a / (double)b;
			System.out.print(d + " " + r + " ");
			System.out.printf("%5.8f", f);
		}

	}

}

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

int main(int argc, char const *argv[])
{
	string s;
	int x,y;
	cin>>s>>x>>y;
	int now=0;
	while (s[now]=='F')
	{
		++now;
	}
	vector<int> h,w;
	int d=0,cnt=0;
	for (int i = now; i < s.size(); ++i)
	{
		if (s[i]=='F')
		{
			++cnt;
		}
		else
		{
			if (cnt==0)
			{
				++d;
				continue;
			}
			if (d%2==0)
			{
				h.push_back(cnt);
			}
			else
			{
				w.push_back(cnt);
			}
			++d;cnt=0;
		}
	}
	if (cnt>0)
	{
		if (d%2==0)
		{
			h.push_back(cnt);
		}
		else
		{
			w.push_back(cnt);
		}
	}
	int dph[h.size()+5][2*s.size()+5]={},dpw[w.size()+5][2*s.size()]={};
	dph[0][now+s.size()]=1;
	for (int i = 0; i < h.size(); ++i)
	{
		for (int j = 0; j < 2*s.size()+5; ++j)
		{
			if (j-h[i]>=0)
			{
				dph[i+1][j-h[i]]|=dph[i][j];
			}
			if (j+h[i]<2*s.size()+5)
			{
				dph[i+1][j+h[i]]|=dph[i][j];
			}
		}
	}
	dpw[0][s.size()]=1;
	for (int i = 0; i < w.size(); ++i)
	{
		for (int j = 0; j < 2*s.size()+5; ++j)
		{
			if (j-w[i]>=0)
			{
				dpw[i+1][j-w[i]]|=dpw[i][j];
			}
			if (j+w[i]<2*s.size()+5)
			{
				dpw[i+1][j+w[i]]|=dpw[i][j];
			}
		}
	}
	if (dph[h.size()][x+s.size()]==1&&dpw[w.size()][y+s.size()]==1)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 250880
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int h[n];
    for (int i=0; i<n; i++) cin>>h[i];
    vector <int> v[n];
    for (int i=0; i<m; i++){
        int f,s;
        cin>>f>>s;
        v[f-1].push_back(s);
        v[s-1].push_back(f);
    }
    int ans=0;
    for (int i=0; i<n; i++){
        int vs=v[i].size();
        if (vs==0) ans++;
        else {
            bool rej=0;
            int he=h[i];
            for (int j=0; j<vs; j++){
                if (h[i]<=h[v[i].at(j)-1]){
                    rej=1;
                    break;
                }
            }
            if (rej==0) ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 9160
#include <iostream>
#include <cstdio>

const double inf = 1000;

int n, m;
double g[101][101];
double dp[101][101]; //i???????????????j,??????k???????????????????????§???

int main(){
	while(true){
		for(int i = 0; i < 101; ++i){
			for(int j = 0; j < 101; ++j){
				dp[i][j] = -1;
			}
		}
		
		std::cin >> n >> m;
		if(n == 0 && m == 0)break;
		
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				std::cin >> g[i][j];
			}
		}
		
		for(int i = 0; i < n; ++i)dp[0][i] = 1.0;
		
		for(int i = 0; i < m - 1; ++i){
			for(int j = 0; j < n; ++j){
				for(int k = 0; k < n; ++k){
					dp[i + 1][k] = std::max(dp[i + 1][k], dp[i][j] * g[j][k]);
				}
			}
		}
		
		double ans = 0;
		for(int i = 0; i < n; ++i){
			if(dp[m - 1][i] > ans)ans = dp[m - 1][i];
		}
		
		printf("%.2f\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1404
H, W, K = gets.split.map(&:to_i)
c = Array.new H
total = 0
h_count = Array.new H
H.times do |i|
    c[i] = gets.split('')
    h_count = c[i].count('#')
    total += h_count
end

result = 0
hlist = (0..H-1).to_a
wlist = (0..W-1).to_a
0.upto(H) do |hc|
    hlist.combination(hc) do |delhlist|
        dels = 0
        delhlist.each do |dh|
            dels += h_count[dh]
        end
        next if total - dels < K
        map = c.reject.with_index do |_, i|
            delhlist.include?(i)
        end
        w_count = Array.new W
        W.times do |w|
            cx = 0
            map.each do |line|
                cx += 1 if line[w] == "#"
            end
            w_count[w] = cx
        end
        0.upto(W) do |wc|
            wlist.combination(wc) do |cntlist|
                cnt = 0
                cntlist.each do |cl|
                    cnt += w_count[cl]
                end
                if cnt == K
                    result += 1
                end
            end
        end
    end
end

puts result

Measured memory_bytes: 14384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535

int main()
{
  int L,R,d;
  cin >> L >> R >> d;

  int ans = 0;
  for(int i = L; i <= R; i++){
    if(i % d == 0){
      ans++;
    }
  }

  cout << ans;

  return 0; 
}

Measured memory_bytes: 3592
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    string s, t;
    cin >> s >> t;
    int ans = 1001;
    rep(i, s.size() - t.size() + 1)
    {
        int tmp = 0;
        rep(j, t.size())
        {
            tmp += (s[i + j] != t[j]);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, M, C;
    cin >> N >> M >> C;
    int *B;
    B = new int[M];
    urept(i, 0, M)
    {
        cin >> B[i];
    }
    int **A = new int *[N];
    urept(i, 0, N)
    {
        A[i] = new int[M];
    }
    urept(i, 0, N)
    {
        urept(j, 0, M)
        {
            cin >> A[i][j];
        }
    }
    int *D;
    D = new int [N];
  	urept(i,0,N){
    	D[i] = 0;
    }
  	int tmp = 0;
    urept(i, 0, N)
    {
        urept(j, 0, M)
        {
            tmp += A[i][j] * B[j];
        }
      	D[i] = tmp + C;
      	tmp = 0;
    }
    int count = 0;
    urept(i, 0, N)
    {
        if (D[i] > 0)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

string s,t;
ll dp[3005][3005];

ll find(ll x,ll y){
	if (x==0 || y==0)return 0;
	if (dp[x][y]!=-1)return dp[x][y];
	if (s[x-1]==t[y-1]){
		dp[x][y]=find(x-1,y-1)+1;
	}
	dp[x][y]=max(dp[x][y],max(find(x-1,y),max(find(x-1,y-1),find(x,y-1))));
	return dp[x][y];
}

void solve() {
    cin>>s>>t;
    memset(dp,-1,sizeof dp);
    rep(i,0,sz(s)){
    	rep(j,0,sz(t)){
    		find(i+1,j+1);
    	}
    }
    ll meow=dp[sz(s)][sz(t)];
    string ans;
    ll x=sz(s),y=sz(t);
    while (meow && x>0 && y>0){
    	if (s[x-1]==t[y-1]){
    		ans.pb(s[x-1]);
    		x--;y--;
    		meow--;
    	}
    	else if (dp[x-1][y]>dp[x][y-1]){
    		x--;
    	}
    	else {
    		y--;
    	}
    }
    rep(i,0,sz(ans)){
    	cout<<ans[sz(ans)-i-1];
    }
    cout<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 70912
def pow_kai(a, n):
    x = 1
    while(n > 0):
        if(n&1):
            x = x*a
        a = a*a
        n >>= 1
    return x


def main():
    X = int(input())
    pow5 = []

    for i in range(0,10**9):
        pow5.append(pow_kai(i,5))
        for k in range(0, i+1):
            if pow5[i]-X == pow5[k]:
                print(i, k)
                return
            elif pow5[i]-X == -pow5[k]:
                print(i, -k)
                return

if __name__ == '__main__':
    main()

Measured memory_bytes: 63320
#include<stdio.h>
main(){
  int i,j,k,n,x,count;
  while(1){
    count=0;
    scanf("%d%d",&n,&x);
    if(n==0&&x==0) break;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
        for(k=j+1;k<=n;k++){
          if(i+j+k==x) count++;
        }
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

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

	if (X == 3 || X == 5 || X == 7) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
}

Measured memory_bytes: 256
while True:
    a = input()
    n, x = a.split(' ')
    n, x = int(n), int(x)
    
    if n == 0 and x == 0:
        break
    
    list = []
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if (i + 1) + (j + 1) + (k + 1) == x:
                    list.append(x)
    
    print(len(list))
    


Measured memory_bytes: 5604
#include <cstdio>
#include <queue>
#include <bitset>
using namespace std;

bitset <100> maskdiv[100], full, invmaskdiv[100];
int n;
vector <int> a;
long long ans=0ll;
void bruteForcePrune(long long potential, long long curr=0ll, bitset <100> currmask=full, int pos=1){
	if(potential<=ans)
		return;
	if(pos==n){
		ans=curr;
		return;
	}
	if(!currmask[pos]){
		return bruteForcePrune(potential, curr, currmask, pos+1);
	}
	if(a[pos]>=0){
		return bruteForcePrune(potential, curr+a[pos], currmask, pos+1);
	}
	bruteForcePrune(potential+a[pos], curr+a[pos], currmask, pos+1);
	bitset <100> toDelete=currmask&maskdiv[pos];
	for(int i = pos+1;i < n;i ++){
		if(toDelete[i]){
			if(a[i]>0){
				potential-=a[i];
			}
		}
	}
	return bruteForcePrune(potential, curr, currmask&invmaskdiv[pos], pos+1);
}
int main(){
	full.set();
	for(int i = 0;i < 100;i ++){
		for(int j = i+1;j <= 100;j += i+1){
			maskdiv[i][j-1]=true;
		}
		invmaskdiv[i]=~maskdiv[i];
	}
	scanf("%d", &n);
	a.resize(n);
	long long fullPotential=0ll;
	for(int&i:a){
		scanf("%d", &i);
	}
	for(int i = 1;i < n;i ++){
		fullPotential+=max(a[i], 0);
	}
	bruteForcePrune(fullPotential);
	printf("%lld\n", max(ans+a[0], 0ll));
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   long long a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<max({a*c,a*d,b*c,b*d})<<"\n";
   
}


Measured memory_bytes: 3668
#-*-coding:utf-8-*-

from collections import deque

def main():
    tasks={}
    task_number,quantum = map(int,input().split())
    tasks=list(input().split() for _ in range(task_number))
    q = deque()
    calculate_time=0
    for i in range(task_number):
        q.append(tasks[i])
    while len(q) > 0:
        value = q.popleft()
        if quantum < int(value[1]):
            tmp=int(value[1])-quantum
            value[1]=tmp
            q.append(value)
            calculate_time+=quantum
        else:
            calculate_time+=int(value[1])
            print(value[0],calculate_time)

if __name__=="__main__":
    main()


Measured memory_bytes: 17860
import sys,math,copy,queue,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

X = NI()
y = 100
i = 0
while y < X:
    y = int(y*1.01)
    i += 1
print(i)

Measured memory_bytes: 69072
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  cout << sum - n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

set<long long>s;
void decompositPrime(long long n)
{
    
    long long  a = 2;
    while (n >= a * a) {
        
        if (n % a == 0) {
            //printf("%d * ", a);
            s.insert(a);
            n /= a;
        } else {
            a++;
        }
    }
    
    s.insert(n);
  //  printf("%d\n", n);
}

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long a,b;
	cin>>a>>b;
	decompositPrime(gcd(a,b));
	s.insert(1);
	cout<<s.size();
}
	


Measured memory_bytes: 256
n,m,p=map(int,input().split())
def BellmanFord(edges,num_v,s):
  #グラフの初期化
  inf=float("inf")
  dist=[inf]*num_v
  dist[s]=0
  #辺の緩和
  for i in range(num_v-1):
    for edge in edges: #edges[頂点][頂点][重み]
      if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]+p:
        dist[edge[1]] = dist[edge[0]] + edge[2]+p
  cnt1=-dist[n-1]
  neg=[False]*num_v
  for i in range(num_v):
    for edge in edges: #edges[頂点][頂点][重み]
      if dist[edge[1]] > dist[edge[0]] + edge[2]+p:
        dist[edge[1]] = dist[edge[0]] + edge[2]+p
        neg[edge[1]]=True
      if neg[edge[0]]:
        neg[edge[1]]=True
  if neg[n-1]:
    ans=-1
  else:
    ans=max(cnt1,0)
  return ans
edges=[]
for i in range(m):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  c*=-1
  edges.append((a,b,c))
print(BellmanFord(edges,n,0))


Measured memory_bytes: 48216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H,W;
    cin >> H >> W;
    int count = 0;
    for(int i=0;i<H;i++){
        string str;
        cin >> str;
        for(int j=0;j<W;j++){
            if(str[j] == '#')count++;
        }
    }
    if(count == H + W - 1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
n, k ,q = list(map(int, input().split()))
ans = [0]*n
for i in range(q):
  temp = int(input())
  ans[temp-1]+=1
  
#print(ans)
for i in range(n):
  if ans[i] >= q-k+1:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4680
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{
	return a>b;
}
long double cl(long double x1, long double y1, long double x2, long double y2)
{
	long double dist=(long double)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	return dist;
}
long double finddist(vector<pair<long double,long double>>& v)
{
	 long double dist=0;
	for(int i=0;i+1<v.size();i++)
	{
		dist+=(cl(v[i].first,v[i].second,v[i+1].first,v[i+1].second));
	}
	return dist;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	vector<pair<long double,long double>> v;
	for(int i=0;i<n;i++)
	{   
	    long double x,y;cin>>x>>y;
		v.pb({x,y});
	}
	sort(v.begin(),v.end());
	long double ans=0;
	do { 
        ans+=finddist(v);
    } while (next_permutation(v.begin(),v.end())); 
	std::cout << std::fixed;
	long double  fect=1;
	for(int i=1;i<=n;i++)
	{
		fect*=i;
	}
	ans=ans/fect;
	std::cout << std::fixed;
    std::cout << std::setprecision(10)<<ans<<endl;
	return 0;
}
 















 
 

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

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

	double area = x / a;
	double ans = atan2( area, a * b / 2 );
	if( area > a * b / 2 ) {
		double h = (a * b - area) * 2 / a;
		ans = atan2( h, a );
	}
	else if( area < a * b / 2 ) {
		double w = area * 2 / b;
		ans = atan2( b, w );
	}
	ans *= 180 / M_PI;

	cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 384
h, w = gets.split.map { |x| x.to_i - 1 }
maze = Array.new
dots = 0
while line = gets
  maze << line.chomp.split('')
  dots += line.count '.'
end
costs = Array.new(h + 1) {|i| Array.new}
costs[0][0] = 0
ans = -1
q = [[0,0]]
while q.length >= 1
  cy, cx = q.shift
  up = [cy - 1, cx] if cy - 1 >= 0
  down = [cy + 1, cx] if cy + 1 <= h
  left = [cy, cx - 1] if cx - 1 >= 0
  right = [cy, cx + 1] if cx + 1 <= w
  if up == [h, w] || down == [h, w] || left == [h,w] || right == [h, w]     
    ans = dots - costs[cy][cx] - 2
    break
  end
  if up && !costs[up[0]][up[1]] && maze[up[0]][up[1]] == '.'
    costs[up[0]][up[1]] = costs[cy][cx] + 1
    q.push up
  end
  if down && !costs[down[0]][down[1]] && maze[down[0]][down[1]] == '.'      
    costs[down[0]][down[1]] = costs[cy][cx] + 1
    q.push down
  end
  if left && !costs[left[0]][left[1]] && maze[left[0]][left[1]] == '.'      
    costs[left[0]][left[1]] = costs[cy][cx] + 1
    q.push left
  end
  if  right && !costs[right[0]][right[1]] && maze[right[0]][right[1]] == '.'
    costs[right[0]][right[1]] = costs[cy][cx] + 1
    q.push right
  end
end
puts ans

Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>

#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>s= ;i--)

int read() {
    int x=0,f=1,ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

#define MAXN 10000+10
int a[MAXN],n;

void print() {
    REP(i,0,n-1) {
        if(i>0) printf(" ");
        printf("%d",a[i]);
    }
    puts("");
}

int main() {
    n=read();
    REP(i,0,n-1) a[i]=read();
    
    print();
    REP(i,1,n-1) {
        int v=a[i];
        int j=i-1;
        while(j>=0&&a[j]>v) {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        print();
    }
    return 0;
}


Measured memory_bytes: 3164
use std::str::FromStr;

fn main() {
	let mut xs = read_vec_i32();
	xs.sort();
	println!("{}", if xs == [5, 5, 7] { "YES" } else { "NO" });
}

fn read_vec_i32() -> Vec<i32> {
	let mut line = String::new();
	std::io::stdin().read_line(&mut line).unwrap();
	line.trim().split(' ').map(|str| i32::from_str(str).unwrap()).collect()
}

Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int k,x;
    cin>>k>>x;
    FOR(i,x-k+1,x+k-1){
        cout<<i<<" ";
    }
    cout<<x+k-1<<endl;

    return 0;
}


Measured memory_bytes: 888