akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void EducationalDP_M()
{
	const ll MOD = 1000000007;
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for(auto& x : a)
		cin >> x;
	sort(a.begin(), a.end());

	vvl dp(N, vl(K+1));
	for (int j = 0; j <= a[0]; ++j)
		dp[0][j] = 1;
	vl tmp(K + 1);
	for (int i = 1; i < N; ++i)
	{
		tmp[0] = dp[i - 1][0] % MOD;
		for (int j = 1; j <= K; ++j)
			tmp[j] = (tmp[j - 1] + dp[i - 1][j]) % MOD;
		for (int j = 0; j <= K; ++j)
		{
			int k = max(j - a[i], 0) - 1;
			dp[i][j] = tmp[j] - (k > -1 ? tmp[k] : 0) + MOD;
			dp[i][j] %= MOD;
		}
	}
	cout << dp[N - 1][K] << endl;

}
int main()
{
	EducationalDP_M();
	return 0;
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
char a[1000001];
int la,ans;
int main()
{
	cin>>a;
	la=strlen(a);
	for(int i=1;i<la;i++)
	{
		if(a[i]!=a[i-1])
		ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}


int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll res=a[0];
    rep(i,n) res=gcd(res, a[i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
  using namespace std;
  #define int long long int 
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define hell 998244353
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
  
  void solve()
  { 
    
      int a,b;
      cin>>a>>b;
      int g=__gcd(a,b);
      int ans=1;

      for(int i=2;i*i<=g;i++)
      {
         if(g%i==0)
         {
            ans++;
            while(g%i==0)
            {
              g=g/i;
            }
         }
      }
      if(g>1)
        ans++;
      cout<<ans;

  }



  signed main()
  {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


   
    
     
    
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }

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

main() {
    int N,M,C; cin >> N >> M >> C;
    int ans=0;
    int B[M];
    rep(i,M) cin >> B[i];
    int A[N][M];
    rep(i,N){
        rep(j,M){
            cin >> A[i][j];
        }
    }
    rep(i,N){
        int sum=0;
        rep(j,M){
            sum+=A[i][j]*B[j];
        }
        if(sum+C>0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
a=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
def dfs(k):
  while k<=a:
    s=q.popleft()
    if s%10-1>=0:
      q.append(s*10+s%10-1)
      k=k+1
      if k==a:
        print(q.pop())
    q.append(s*10+s%10)
    k=k+1
    if k==a:
        print(q.pop())
    if s%10+1<=9:
      q.append(s*10+s%10+1)
      k=k+1
      if k==a:
        print(q.pop())
  
 
if a<=9:
  print(a)
else:
  dfs(9)
  

Measured memory_bytes: 40944
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
h,w = LI()
ans = float("inf")
x = w//2
y = h//2
if not w%2:
    for i in range(1,h):
        if (h-i)%2 == 0:
            ans = min(ans,abs(w*i-w*(h-i)//2))
        ans = min(ans,abs(w*i-x*(h-i)))
else:
    for i in range(1,h):
        if (h-i)%2 == 0:
            ans = min(ans,abs(w*i-w*(h-i)//2))
        if w*i < x*(h-i):
            ans = min(ans,abs(w*i-(x+1)*(h-i)))
        elif w*i < (x+1)*(h-i):
            ans = min(ans,h-i)
        else:
            ans = min(ans,abs(w*i-x*(h-i)))
if not h%2:
    for i in range(1,w):
        if (w-i)%2 == 0:
            ans = min(ans,abs(h*i-h*(w-i)//2))
        ans = min(ans,abs(h*i-y*(w-i)))
else:
    for i in range(1,w):
        if (w-i)%2 == 0:
            ans = min(ans,abs(h*i-h*(w-i)//2))
        if h*i < y*(w-i):
            ans = min(ans,abs(h*i-(y+1)*(w-i)))
        elif h*i < (y+1)*(w-i):
            ans = min(ans,w-i)
        else:
            ans = min(ans,abs(h*i-y*(w-i)))
print(ans)

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 42864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif



vector<int> p;
ll n, a, b;


/*
	右へ移動するコストA
	左へ移動するコストB
	移動しなかった数だけを選ぶと単調増加数列になる
	
	p0～piで移動しなかった数の最大値がj以下のとき、コストの最小値がdp[i][j]
*/

int main(){
	cin >> n >> a >> b;
	p.resize(n+1);
	p[0] = 0;
	rep(i,n)
		cin >> p[i+1];
	n++;
	
	
	vector<ll> dp(n);
	for ( int i = 1; i < n; i++ ){
		int pi = p[i];
		ll dppi1 = dp[pi-1];
		
		rep(j,n){
			if ( j < pi ){
				dp[j] += a;
			}
			else if ( j == pi ){
				dp[j] = dppi1;
			}
			else {
				dp[j] = min( dp[j]+b, dppi1 );
			}
		}
		
		//rep(k,n)
		//	cout << dp[k] << " ";
		//cout << endl;
	}
	
	cout << dp[n-1] << endl;
	
	
	return 0;
}




Measured memory_bytes: 3644
var n = readInt()
var An = readInts()
var q = readInt()
let query: [(Int, Int)] = (1...q)
    .map { _ in let a = readInts(); return (a[0], a[1]) }

var array = Array(repeating: 0, count: 100005)
for a in An {
    array[a] += 1
}

var sum = An.reduce(0, +)

for (b, c) in query {
    let count = array[b]
    array[b] = 0
    array[c] += count
    
    sum -= b * count
    sum += c * count
    print(sum)
}


// MARK: -----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


Measured memory_bytes: 12640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	ll K, A, B;
	cin >> K >> A >> B;
	if (A >= B || B - A < 2) {
		cout << K + 1 << endl;
	}
	else {
		if (K <= A) cout << K + 1 << endl;
		else cout << A + (K - A + 1) / 2 * (B - A) + (K - A + 1) % 2 << endl;
	}
}


Measured memory_bytes: 256
<?php
$mountain=trim(fgets(STDIN));
$heights=trim(fgets(STDIN));
$heights=explode(" ",$heights);
$count=0;
for($i=count($heights)-1;$i>=0;$i--){
  	if($i===0){
    	$count+=1;
      	continue;
    }
	for($j=$i-1;$j>=0;$j--){
    	if($heights[$i]<$heights[$j]){
        	break;
        }elseif($j===0){
        	$count+=1;
          	break;
        }
    }
}
echo $count;

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>

int main()
{
    char a[16];
    int c = 0,flag = 0;
    scanf("%s", &a);

    int len = strlen(a);

    if(a[0]== 'A')
    {
        for( int i = 2; i<=len-2; i++)
        {
            if(a[i] == 'C')
            {
                c++;
                a[i]=c;
            }
        }
        if(c==1)
        {
            for( int i = 1; i<=len-1;i++)
            {
                if(a[i]>= 'A' && a[i]<= 'Z')
                {
                    flag = 1;
                    break;
                }
            }

        }
        else
        {
            printf("WA\n");
            return 0;
        }
        if(flag == 1)
            {
               printf("WA\n");
            }
        if(flag == 0)
           {
               printf("AC\n");
           }
    }
    else
    {
        printf("WA\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
bool chk(ll n,ll k)
{
    while(n>=k && n%k==0) n/=k;
    return (n%k)==1;
}
int main()
{
    int t=1;
//    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll lim=sqrt(n)+1;
        set<ll> s;
        fpr(i,2,lim)
        {
            if((n-1)%i==0)
            {
                s.insert(i);
                s.insert((n-1)/i);
            }
            if(n%i==0)
            {
                if(chk(n,i)) s.insert(i);
                if(chk(n,n/i)) s.insert(n/i);
            }
        }
        s.insert(n-1);
        s.insert(n);
        s.erase(1);
        print(s.sz)
    }
    return 0;
}





Measured memory_bytes: 256
n,m,l=[int(x) for x in input().split()]

arrays1,arrays2=[], []

for i in range(n):
	arrays1.append([int(x) for x in input().split()])

for j in range(m):
	arrays2.append([int(x) for x in input().split()])


for a in range(len(arrays1)):	
	for b in range(len(arrays2[0])):
		sss=0
		for c in range(len(arrays1[0])):
			sss+=arrays1[a][c]*arrays2[c][b]
		print(f"{sss}",end="")
		if b != len(arrays2[0])-1:
			print(" ",end="")
	print()


Measured memory_bytes: 6556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n,x,m;
    cin>>n>>x>>m;
    ll pe=0,ch=x;
    ve<ll> a,mp(m,0);
    sll sum=0;
    while(mp[ch]==0)
    {
        a.pb(ch);
        mp[ch]=1;
        ch=(ch*ch)%m;
        pe++;
    }
    if(n<=pe)
    {
        for(ll i=0;i<n;i++)
            sum=(sum+a[i]);
        cout<<sum;
        return 0;
    }
    ch=0;
    ll xx=(a[pe-1]*a[pe-1])%m;
    while(a[ch]!=xx)
    {
        sum+=a[ch];
        ch++;
    }
    ll in=ch;
    ch=0;
    for(ll i=in;i<pe;i++)
        ch+=a[i];
    pe=pe-in;
    n-=in;
    sum+=(n/pe)*ch;
    n%=pe;
    ch=a[in];
    for(ll i=0;i<n;i++)
    {
        sum=(sum+ch);
        ch=(ch*ch)%m;
    }
    cout<<sum;
    subt;
    return 0;
}


Measured memory_bytes: 4612
import java.util.*;
import java.lang.*;
public class Main {
        public static void main (String[]args){
            Scanner scanner = new Scanner(System.in);
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            double rateA=.08;
            double rateB=.1;
            int price=0;
            boolean answerFound=false;
            boolean possible=false;
            while(answerFound==false){
                if((int)(price*rateA)==A&&(int)(price*rateB)==B){
                    possible=true;
                    answerFound=true;
                    break;
                }
                if((int)(price*rateA)>A||(int)(price*rateB)>B){
                    answerFound=true;
                    break;
                }
                price++;
            }
            if(possible){
                System.out.println(price);
            }else{
                System.out.println(-1);
            }
        }
}





Measured memory_bytes: 25172
input_lines = raw_input()
n1_n2_n3 = input_lines.rstrip().split(" ")
n1 = int(n1_n2_n3[0])
n2 = int(n1_n2_n3[1])
n3 = int(n1_n2_n3[2])
num_list = []
num_list.append(n1)
num_list.append(n2)
num_list.append(n3)
num_list.sort()
print str(num_list[0]) + " " + str(num_list[1]) + " " + str(num_list[2])

Measured memory_bytes: 6456
gohyaku = int(input())
hyaku = int(input())
gozyuu = int(input())
x = int(input())

count = 0
for i in range(gohyaku+1):
    for j in range(hyaku+1):
        for k in range(gozyuu+1):
            if (500*i+100*j+50*k)==x:
                count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, ans=0; cin>>n;
    string s; cin>>s;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                ll cnt=0;
                rep(l,s.size()){
                    if(cnt==0 && s[l]-'0'==i){
                        cnt++;
                    }
                    else if(cnt==1 && s[l]-'0'==j){
                        cnt++;
                    }
                    else if(cnt==2 && s[l]-'0'==k){
                        cnt++;
                        break;
                    }
                }
                if(cnt==3) ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N=int(input())
A=[[] for i in range(0,N)]
nodes=[]
for i in range(0,N-1):
    for j in range(i+1,N):
        nodes.append((i,j))

order={i:[0 for j in range(0,N)] for i in range(0,N)}
for i in range(0,N):
    A[i]=list(map(int,input().split()))
    for j in range(0,N-1):
        order[i][A[i][j]-1]=j
        #i番目の人がj番目の人と戦うのが何番目か


q=set([])
for battle in nodes:
    i,j=battle
    if order[i][j]==0 and order[j][i]==0:
        q.add(battle)

flag=[0 for i in range(0,N)]

day=0
sub=set([])
while q:
    while q:
        i,j=q.pop()
        flag[i]+=1
        flag[j]+=1
        if flag[i]!=N-1:
            s=A[i][order[i][j]+1]-1
            if flag[s]>=order[s][i]:
                sub.add((i,s))
        if flag[j]!=N-1:
            t=A[j][order[j][i]+1]-1
            if flag[t]>=order[t][j]:
                sub.add((j,t))

        if not q:
            day+=1
            q=sub
            sub=set([])
            break

able=True
for i in range(0,N):
    if flag[i]!=N-1:
        able=False

if able:
    print(day)
else:
    print(-1)

Measured memory_bytes: 85988
n=int(input())
a=list(map(int,input().split()))
mode=0
from collections import deque
b=deque([])
for i in range(n):
  if i%2==0:
    b.append(a[i])
    mode+=1
    mode%=2
  else:
    b.appendleft(a[i])
    mode+=1
    mode%=2
if mode==1:
  b=list(b)
  b=b[::-1]
print(*b)


Measured memory_bytes: 30824
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long LL;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l * 10+a-48;
	return l * f;
}
char ss;
int x = 0;
int main()
{
	scanf("%c", &ss);
	while(ss < '0' || ss > '9') scanf("%c", &ss);
	x = x*10+ss-48;
	scanf("%c", &ss);
	while(ss < '0' || ss > '9') scanf("%c", &ss);
	x = x*10+ss-48;
	scanf("%c", &ss);
	while(ss < '0' || ss > '9') scanf("%c", &ss);
	x = x*10+ss-48;
	if (x%4 == 0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
<?php
$inputNum = trim(fgets(STDIN));
  
for ($i=1; $i <= $inputNum; $i++) {
    if (($i % 3 == 0) || preg_match('/3/', $i)) {
        $nums[] = $i;
    }
}

echo sprintf(' %s', implode(' ', $nums)), PHP_EOL;

Measured memory_bytes: 16292
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(x, y):
    return (x * y) // gcd(x, y)

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

a=int(listA[0])
b=int(listA[1])

print(lcm(a, b))

Measured memory_bytes: 3060
import numpy as np

DIV = 998244353

N = input()
a = []
for i in range(N):
    a.append(input())
a.sort()
suma = sum(a)

dp = np.zeros((N,suma+1,2),dtype = np.int)
dp[0,0,0] = 2
dp[0,a[0],0] = 1
dp[0,0,1] = 1
dp[0,a[0],1] = 1

allc = 3
for i in range(1,N):
	allc = allc*3
	k = a[i]
	dp[i,k:,0] += dp[i-1,:-k,0]
	dp[i,:,0] += dp[i-1,:,0]*2
	dp[i,k:,1] += dp[i-1,:-k,1]
	dp[i,:,1] += dp[i-1,:,1]
	if(i%10 == 0):
		dp[i,:,:] = dp[i,:,:]%DIV
allc = allc - sum(dp[N-1,suma-suma/2:,0])*3
if(suma % 2 == 0):			
	allc += dp[N-1,suma/2,1]*3
print(int(allc%DIV))

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

int main() {
  LL N, K, Q;
  cin >> N >> K >> Q;
  LL A[Q];
  for (LL i = 0; i < Q; i++) {
    cin >> A[i];
  }
  
  LL ans[N];
  for (LL i = 0; i < N; i++) {
    ans[i] = 0;
  }
  
  for (LL i = 0; i < Q; i++) {
    ans[A[i] - 1] ++;
  }
  
  for (LL i = 0; i < N; i++) {
    if (Q - ans[i] >= K) {cout << "No" << endl;}
    else {cout << "Yes" << endl;}
  }
}

Measured memory_bytes: 2176
N, M = gets.split.map(&:to_i)
shop_array = []
current_value = 0
current_number = 0

N.times{|i|
  a, b = gets.split.map(&:to_i)
  shop_array << {value: a, number: b}
}

shop_array.sort!{|a,b|a[:value] <=> b[:value]}
shop_array.each{|item|
  current_number += item[:number]
  current_value += (item[:value])*(item[:number])

  if (current_number > M)
    current_value -= (current_number-M)*item[:value]
    break
  end
}

puts current_value


Measured memory_bytes: 32376
m = map(int,raw_input().split())
w = m[0]
h = m[1]
x = m[2]
y = m[3]
r = m[4]

if 2*r > w or 2*r >h:
 print "No"
else:
 if 0 < x + r <= w and 0 < y + r <= h:
  print "Yes"
 else:
  print "No"

Measured memory_bytes: 6440
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n,d,x1,y1,count=0;
  double sum = 0.0;
  cin>>n>>d;
  for(ll i=1;i<=n;i++)
  {
    cin>>x1>>y1;
    sum = sqrt((x1*x1)+(y1*y1));
    if(sum<=d)
      count++;
  }
  cout<<count<<endl;
  
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int h, cnt=0;
    for (int i=0; i<N; i++) {
        cin >> h;
        if (h >= K) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
S = gets.chomp.split.map(&:to_i)
Q = gets.chomp.to_i
T = gets.chomp.split.map(&:to_i)

ans = 0

def binary_search(array, target)
  left = 0
  right = array.count - 1
  while left <= right
    mid = (left + right) / 2
    if target == array[mid]
      return 1
    elsif target < array[mid]
      right = mid - 1
    else
      left = mid + 1
    end
  end
  return 0
end

T.each do |i|
  ans += binary_search(S, i)
end

puts ans



Measured memory_bytes: 15636
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;


int main(){
	int N;
	cin>>N;
	vector<int> h(N);
	for(int i=0;i<N;i++){
		cin>>h[i];
	}
	vector<int> min_h(N,0);
	for(int i=1;i<N;i++){
		if(i==1){
			min_h[i]=abs(h[0]-h[1]);
		}
		else{
			min_h[i]=min(min_h[i-1]+abs(h[i]-h[i-1]),min_h[i-2]+abs(h[i]-h[i-2]));
		}
	}
	cout<<min_h[N-1]<<endl;
	return 0;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

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

    switch(N%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;        
    }

    return 0;
}



Measured memory_bytes: 3624
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0,T=0,A=0,Temp=1000000000;
  cin >> N >> T >> A;
  int H[N],Num=0;
  for(int i=0;i<N;++i){
    cin >> H[i];
    int x = fabs(T*1000-H[i]*6-A*1000);
    if(x<Temp){
      Temp = x;
      Num = i;
    }
  }
  cout << Num + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,e=0;
  int c[1000],d[100000];
  cin>>a>>b;
  for(int i=0;i<a;i++) cin>>c[i];
  sort(c,c+a,greater<int>());
  for(int i=0;i<b;i++){
    e+=c[i];
  }
  cout<<e<<"\n";
}

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

using namespace std;
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
#define pint(x) printf("%d",x)
#define ps printf(" "); 
#define plint(x) printf("%lld",x)
//#define sort(a,n) qsort(a,n,sizeof(int),cmpfunc)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bg begin()
#define ed end()
#define itn int
#define Set(a, s) memset(a, s, sizeof (a))
#define mod 1000000007
#define tmod(k) if ((k) >= mod) k %= mod;
#define EPS 1e-9
#define endl '\n'
#define nl printf("\n");
#define fors(i,n) for(int i=0; i<n; i++)
#define fore(i,n) for(int i=n-1; i>=0; i--)
#define forv(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef pair<int,int> pii;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
void ASCII_Chart(){int i,j,k;printf("ASCII Chart:(30-129)\n");forv(i,30,50){fors(j,5){k=i+j*20;printf("%3d---> '%c'   ",k,k);}printf("\n");}}
const int INF = 0x3f3f3f3f;
#define pi 3.14159265
#define PI 2*acos(0.0)
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}

//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
class node{
public:
	int id;
	int prio;
	int prd;
};

class compare{
public:
	bool operator()(node &n1, node &n2){
		if(n1.prio>n2.prio)//ascending
			return true;
		else if(n1.prio==n2.prio){
			return n1.id>n2.id;
		}
		return false;
	}
};
//priority_queue<node, vector<node>, compare> pq;

struct nd{
    int v,cnt;
};

int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #else
    // online submission
    #endif*/
    int n;
    int1(n);
    vector<nd> mnset;
    vector<nd> reqset;
    // nd temp
    // mnset.pb()
    map<int,int> mp1;
    map<int,int> mp2;
    int cnt = 0;
    fors(i,n){
        int t;
        int1(t);
        if(mp1[t]!=0){
            mp1[t]++;
        }
        else{
            mp1[t]++;
        }
    }
    int r;
    int1(r);
    fors(i,r){
        int t;
        int1(t);
        if(mp1[t]!=0){
            mp1[t]--;
        }
        else{
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    
    return 0;
}



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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    string s[H];
    REP(i, H) {
        cin >> s[i];
    }

    REP(i, W + 2) {
        cout << "#";
    }
    cout << endl;
    REP(i, H) {
        cout << "#";
        cout << s[i];
        cout << "#" << endl;;
    }
    REP(i, W + 2) {
        cout << "#";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    ll n, m;
    cin >> n >> m;
    cout << min(n, m/2) + max(m-2*n, (ll)0) / 4 << endl;
}

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    vector<long long> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    vector<long long> x_asc(x), y_asc(y);
    sort(x_asc.begin(), x_asc.end());
    sort(y_asc.begin(), y_asc.end());

    long long res = -1;
    for (int ii = 0; ii < n; ii++) {
        for (int jj = 0; jj < n; jj++) {
            for (int kk = ii; kk < n; kk++) {
                for (int ll = jj; ll < n; ll++) {
                    int cnt = 0;
                    for (int mm = 0; mm < n; mm++) {
                        if (x_asc[ii] <= x[mm] && x[mm] <= x_asc[kk]
                                && y_asc[jj] <= y[mm] && y[mm] <= y_asc[ll]) {
                            cnt++;
                        }
                    }

                    long long r = (x_asc[kk] - x_asc[ii]) * (y_asc[ll] - y_asc[jj]);
                    if (cnt >= k && (res == -1 || res > r)) {
                        res = r;
                    }
                }
            }
        }
    }

    cout << res << endl;
}


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

typedef long long LL;
const int MN = 1 << 17 | 7;

int N, p[MN], v[MN], d[MN];

struct dat {
	LL x, y;
	dat() { x = y = 0; }
	dat(LL a, LL b) { x = a, y = b; }
} tmp1[MN], tmp2[MN];
std::vector<dat> f[MN];
int vis[MN];
inline bool check(LL w) {
	for (int i = 1; i <= N; ++i)
		if (d[i]) f[i].clear(), vis[i] = 0;
	for (int u = N; u >= 2; --u) if (vis[p[u]]) {
		int a = u, c = p[u], b = vis[c];
		if (f[a].size() > f[b].size()) std::swap(a, b);
		int na = f[a].size(), nb = f[b].size(), k1 = 0, k2 = 0;
		LL t = w - v[a] - v[b];
		for (int i = 0, j1 = -1, j2 = 0; i < na; ++i) {
			while (j1 + 1 < nb && f[a][i].y + f[b][j1 + 1].x <= t) ++j1;
			while (j2 < nb && f[a][i].x + f[b][j2].y > t) ++j2;
			if (j1 >= 0) tmp1[++k1] = dat(f[a][i].x + v[a], f[b][j1].y + v[b]);
			if (j2 < nb) tmp2[++k2] = dat(f[b][j2].x + v[b], f[a][i].y + v[a]);
		}
		int d1 = 1, d2 = 1;
		while (d1 <= k1 || d2 <= k2) {
			dat g = d2 > k2 || (d1 <= k1 && tmp1[d1].x <= tmp2[d2].x) ? tmp1[d1++] : tmp2[d2++];
			if (f[c].empty()) f[c].push_back(g);
			else if (f[c].back().x == g.x && f[c].back().y >= g.y) f[c].back() = g;
			else if (f[c].back().y > g.y) f[c].push_back(g);
		}
		if (f[c].empty()) return 0;
	} else vis[p[u]] = u;
	return 1;
}

int main() {
	scanf("%d", &N);
	for (int i = 2; i <= N; ++i)
		scanf("%d%d", &p[i], &v[i]), d[p[i]] = 1;
	for (int i = 1; i <= N; ++i) if (!d[i]) f[i].resize(1);
	LL lb = 0, rb = (N - 1ll) << 17, mid, ans = -1;
	while (lb <= rb) {
		mid = (lb + rb) >> 1;
		if (check(mid)) ans = mid, rb = mid - 1;
		else lb = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 34784
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0 ; i<n ; i++)
    {
        cin>>arr[i];

    }

    sort(arr,arr+n);

    for(int i=0 ; i<k; i++)
    {
        sum=sum+arr[i];
    }
cout<<sum;

return 0;
}


Measured memory_bytes: 3520
use std::vec::Vec;
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 3);
  (v[0], v[1], v[2])
}

fn main() {
    let n: usize = read();
    let mut g = vec![vec![]; n];
    for _ in 0..n-1 {
      let (u, v, w) = read_touple::<usize>();
      g[u-1].push((v-1, w as i64));
      g[v-1].push((u-1, w as i64));
    }

    let res = bfs(&g);

    for &e in &res {
      println!("{}", e);
    }
}

fn bfs(g: &Vec<Vec<(usize, i64)>>) -> Vec<i64> {
  let n = g.len();
  let mut res = vec![0; n];
  let mut q = VecDeque::new();
  let mut visited = vec![false; n];

  // init
  let start = 0;
  res[start] = 0;
  q.push_back(start);
  visited[start] = true;

  while let Some(now) = q.pop_front() {
    for &(to, w) in &g[now] {
      if !visited[to] {
         res[to] = (res[now] + w) % 2;
         visited[to] = true;
         q.push_back(to);
      }
    }
  }

  res
}

Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()


int main(){
  string s;
  cin >> s;
  int n = s.size();
  string t = to_string(n-2);
  string ans = s[0] + t + s[n-1];
  cout << ans << endl;
}


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

int main(){
  int r;
  cin >> r;
  if (r < 1200){
    cout << "ABC" << endl;
  }
  else if (r < 2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,k,n) for(int i=(k); i<(n); i++)
int main() {
  int a, b;
  cin >> a >> b;
  int s = b - a;
  int sum=0;
  rp(i,1,s){
    sum += i;
  }
  cout << sum - a << endl;
}

Measured memory_bytes: 256
import heapq
n = int(input())
vlist = list(map(int,input().split()))
heapq.heapify(vlist)
while len(vlist) > 1:
  a = (heapq.heappop(vlist) + heapq.heappop(vlist)) / 2
  heapq.heappush(vlist,a)
print(vlist[0])

Measured memory_bytes: 38256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    x, y = map(int, readline().split())
    f = False
    for n in range(1000):
        for m in range(1000): 
            if (2*n+4*m == y) and (n+m == x):
                f = True
                break
    if f:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 9248
#include "iostream"
#include "algorithm"

using namespace std;
typedef long long ll;

int valu2(ll a)
{
  int i = 0;
  while (true)
  {
    if (a % 2 == 0)
    {
      i++;
      a /= 2;
    }
    else
    {
      break;
    }
  }
  return i;
}

int main()
{
  int n;
  cin >> n;
  int ans = 0;
  ll a[10010];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    ans += valu2(a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	string[] inputs = split(readln());
	int A = to!int(inputs[0]);
	char op = inputs[1][0];
	int B = to!int(inputs[2]);
	
	if(op == '+') (A + B).writeln;
	else (A - B).writeln;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;

int main() {

	int n;
	cin >> n;
	VI a(n), x(n), y(n);
	FOR(i, n)cin >> x[i];
	FOR(i, n)cin >> y[i];
	FOR(i, n)a[i] = x[i] - y[i];
	SORT(a);
	
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] < 0)break;
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

vector<ll> nums;

void add_num(ll num){
  if(num>1000000000) return;
  if(num!=0) nums.push_back(num);
  add_num(num*10+3);
  add_num(num*10+5);
  add_num(num*10+7);
}

int main(){
  ll n;
  cin >> n;
  add_num(0);
  ll ans = 0;
  for(ll num : nums){
    str s = to_string(num);
    bool exist_3 = false, exist_5 = false, exist_7 = false;
    REP(i,s.length()){
      switch(s[i]){
        case '3': exist_3 = true; break;
        case '5': exist_5 = true; break;
        case '7': exist_7 = true; break;
      }
    }
    if(exist_3&exist_5&exist_7&(num<=n))ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

int main() {
  int n;
  int t;

  std::cin >> n;

  int w_index = -1;
  int e_index = -1;

  for (int i = 0; i < n; ++i) {
    std::cin >> t;

    if (w_index == -1) {
      w_index = t;
    }

    if (e_index == -1) {
      e_index = t;
    }

    if (t < w_index) {
      w_index = t;
    }

    if (e_index < t) {
      e_index = t;
    }
  }

  t = (e_index - w_index) % 2 == 0 ? ((e_index - w_index) / 2) : ((e_index - w_index) / 2 + 1);
  std::cout << std::max(w_index + t - w_index, e_index - w_index - t) << std::endl;

  return 0;
}



Measured memory_bytes: 3104
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*2 for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
  if s[i]=='0':
    dp[i+1][0]=(dp[i+1][0]+dp[i][0])%mod
    dp[i+1][1]=(dp[i+1][1]+dp[i][1]*3)%mod
  else:
    dp[i+1][0]=(dp[i+1][0]+dp[i][0]*2)%mod
    dp[i+1][1]=(dp[i+1][1]+dp[i][1]*3)%mod
    dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod
    
print(sum(dp[n])%mod)


Measured memory_bytes: 54236
#include <cstdio>
#include <cmath>

int main(){
    int a,b,c,x,y;
    
    x = y = 0;
    
    while(scanf("%d,%d,%d" ,&a,&b,&c) != EOF){
        if(pow(a,2)+pow(b,2)==pow(c,2)) x++;
        if(a==b) y++;
    }
    
    printf("%d\n%d\n" ,x ,y);
    
    return 0;
}

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

int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    int mod = a % b;
    while (mod != 0)
    {
        a = b;
        b = mod;
        mod = a % b;
    }
    return b;
}

int main()
{
    int N;
    cin >> N;
    int x[N + 1];
    for (int i = 0; i <= N; i++)
    {
        cin >> x[i];
    }
    int ans = abs(x[0] - x[1]);
    for (int i = 1; i < N; i++)
    {
        ans = gcd(ans, abs(x[i] - x[i + 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        String[] s = new String[n];
        for(int i =0;i<n;i++){
            s[i] = stdIn.next();
        }
        int m = stdIn.nextInt();
        String[] t = new String[m];
        int cnt=0;
        int max=0;


        for(int i =0;i<m;i++){
            t[i] = stdIn.next();
        }

        for(int i =0;i<n;i++){
            for(int j =0;j<n;j++){
                if(s[i].equals(s[j])){
                    cnt++;
                }
            }
            for(int j =0;j<m;j++){
                if(s[i].equals(t[j])){
                    cnt--;
                }
            }
            if(max<cnt){
                max=cnt;
            }
            cnt=0;
        }
        System.out.println(max);
    }
}






Measured memory_bytes: 21844
#include <iostream>
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
using namespace std;

int main(void){
  int n,h,pr;
  int len=0, ans=0;

  pr = 0;
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> h;
    if (pr>=h){
      len++;
    } else {
      len=0;
    }
    ans = MAX(ans,len);
    pr = h;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int fib(int);
int f[45];

int main()
{
  int a,n;

  scanf("%d",&n);

  a = fib(n);
  printf("%d\n",a);

  return 0;
}

int fib(int n){

  int a;

  if(a = f[n])
    return a;
  
  if(n==0 || n==1){
    a = 1;
  }
  else
    a = fib(n-1)+fib(n-2);

  f[n] = a;
  return a;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;

#define pb push_back
#define mod 1000000007
#define rep(n) for(int i = 0; i < n; i++)
#define dep(n) for(int i = n; i >= 0; i--)
#define For(n, m) for(int i = n; i < m; i++)
#define dor(n, m) for(int i = n; i >= m; i--)
#define out(n) cout << n << endl;
#define vut(a) for(int i = 0; i < a.size(); i++) COUT(a[i])
#define aut(a) for(int i = 0; i < a.length(); i++) COUT(a[i])
#define sort(a) for(int i = 0; i < a.size() - 1; i++) for(int j = 0; j < a.size() - i - 1; j++) if(a[j] > a[j + 1]) swap(a[j], a[j + 1]);
#define dort(a) for(int i = 0; i < a.size() - 1; i++) for(int j = 0; j < a.size() - i - 1; j++) if(a[j] < a[j + 1]) swap(a[j], a[j + 1]);

int main() {
  int a, b;
  cin >> a >> b;
  out((a + b >= 24 ? a + b - 24 : a + b));
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	long long int count = 0;
	long long int countC = 0;
	long long int countC2 = 0;
	long long int countD = 0;
	long long int countD2 = 0;
	long long int countCD = 0;
	long long int countCD2 = 0;
	count = B - A + 1;
	countC = B / C - (A - 1) / C;
	countD = B / D - (A - 1) / D;
	long long int tmp;
	if (C > D) {
		tmp = C;
		C = D;
		D = tmp;
	}
	long long int C2 = C;
	long long int D2 = D;
	long long int r = D2 % C2;
	while (r != 0) {
		D2 = C2;
		C2 = r;
		r = D2 % C2;
	}
	long long CD = (C * D) / C2;
	countCD = B / CD - (A - 1) / CD;
	cout << count - countC - countD + countCD << endl;
	return 0;
}

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

long long mod = 998244353;

long long power(long long x, long long y)
{
    long long ret = 1;
    while(y > 0)
    {
        if (y & 1)
        {
            ret = (ret * x) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return ret;
}

int main(void)
{
    long long N, M, K;
    cin >> N >> M >> K;

    long long ans = (M * power(M-1, N-1)) % mod;
    long long preans = ans;
    for (long long i = 0; i < K; i++)
    {
        preans = ((((((preans * power((M-1), mod-2)) % mod) * (N-1-i)) % mod) * power((i+1), mod-2)) % mod) % mod;
        ans = (ans + preans) % mod;
    }
    if (M == 1 && K == N-1)
    {
        ans = 1;
    }
    cout << ans << endl;
}

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


int main() {
int N;
cin>>N;
vector<long> a(N);
for(int i=0;i<N;i++) cin>>a[i];
long ans=0;
long mod=1e9+7;
long base=1;
for(int i=0;i<=60;i++){
  long one=0;
  long zero=0;
  for(int j=0;j<N;j++){
    if(a[j]&1) one++;
    else zero++;
    a[j]=a[j]>>1;
  }
  ans+=base*one%mod*zero%mod;
  ans %= mod;
  base *= 2;
  base %= mod;

}
cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

vector<ll> V;
map<ll,bool> MAP;

int ans = -1;

void recursive(ll N,int index,int count){

	if(N == 1){
		ans = max(ans,count);
		return;
	}

	if(N < V[index] || index == (int)V.size())return;

	if(N%V[index] == 0){

		recursive(N,index+1,count);

		while(N%V[index] == 0){
			N /= V[index];
			recursive(N,index+1,++count);
		}

	}else{
		recursive(N,index+1,count);
	}
}

int main(){

	ll POW[18];

	for(int i = 0; i <= 17; i++){
		POW[i] = pow(10,i);
	}

	ll tmp;
	int limit;

	for(int length = 1; length <= 18; length++){
		limit = pow(2,length);
		for(int state = 0; state < limit; state++){
			tmp = 0;
			for(int loop = 0; loop < length; loop++){
				if(state & (1 << loop)){
					tmp += 8*POW[loop];
				}else{
					tmp += 2*POW[loop];
				}
			}
			MAP[tmp] = true;
			V.push_back(tmp);
		}
	}

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

	ll N;
	scanf("%lld",&N);
	if(N == 1){
		printf("-1\n");
		return 0;
	}

	recursive(N,0,0);

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

	return 0;
}

Measured memory_bytes: 39696
#include<stdio.h>

int main(void){
    int N = 0;
    scanf("%d\n", &N);
    int H[20];
    for(int i = 0; i < N; i++){
        scanf("%d", &H[i]);
    }

    int cnt = 1;
    for(int i = 1; i < N; i++){ //基準値が配列０番目位に入るため、１から開始
        int clear = 0;
        for(int j = 0; j < i; j++ ){ // 全探索
            if(H[j] <= H[i]){
                clear++;
            }
        }
        if(clear == i){
            cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        int[][][] ans=new int[4][3][10];
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            int b=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            int v=sc.nextInt();
            ans[b-1][f-1][r-1]+=v;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    System.out.printf(" ");
                    System.out.printf("%d",ans[i][j][k]);
                }
                System.out.println();
            }
            if(i!=3)System.out.println("####################");
        }
        sc.close();
    }
}


Measured memory_bytes: 30740