akhauriyash/Code-Regression huggingface dataset:
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;

int main(void){
    ll N,K;cin>>N>>K;
    vector<ll> h(N);
    REP(i,N)cin>>h[i];
    sort(ALLv(h));
    ll ans=INF;
    REP(i,N-K+1){
        //cout<<i<<","<<i+K-1<<"\n";
        ans=min(ans,h[i+K-1]-h[i]);
    }
    cout<<ans<<"\n";
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

int main(int argc, char const* argv[])
{
    string s,t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    // cout << s << " " << t << endl;
    // cout << (s<t) << endl;
    if (s < t) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int D;
  cin >> D;
  const int T = 26;     // type no kazu
  vector<ll> c(T + 1);  // penalty 1-indexed
  REP(i, T) { cin >> c[i + 1]; }
  vector<vector<ll>> s(D + 1, vector<ll>(T + 1));  // 1-indexed
  REP(i, D) REP(j, T) { cin >> s[i + 1][j + 1]; }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());

  uniform_int_distribution<int> dist_t(1, T);
  vector<ll> t(D + 1);

  FOR(i, 1, D + 1) { t[i] = dist_t(rnd); }

  REP(i, D) { cout << t[i + 1] << endl; }
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <map>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<pair<string, pair<int, int>>> v;
    string name; int a, b;
    while(cin >> name >> a >> b)
    {
        v.push_back(make_pair(name, make_pair(a + b, a * 200 + b * 300)));
    }
    for(auto &&x : v)
    {
        cout << x.first << " " << x.second.first << " " << x.second.second << endl;
    }
    return 0;
}




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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	



int main(){
	
	int a ,b ; 

	cin >> a >> b;
	
	  cout << (a % b!=0) << endl;
	
	
    return 0;
}


Measured memory_bytes: 256
import heapq

X, Y, A, B, C = map(int, input().split())
apples = []
for x in input().split():
    apples.append((int(x), 'r'))
for x in input().split():
    apples.append((int(x), 'g'))
for x in input().split():
    apples.append((int(x), 'n'))
apples.sort()
apples.reverse()

r_count = 0
g_count = 0
n_count = 0
yummy = 0
for _ in range(A+B+C):
    apple = apples[_]
    if apple[1] == 'g' and not g_count == Y:
        g_count += 1
        yummy += apple[0]
    elif apple[1] == 'r' and not r_count == X:
        r_count += 1
        yummy += apple[0]
    elif apple[1] == 'n':
        n_count += 1
        yummy += apple[0]
    if g_count + r_count + n_count == X+Y:
        break
print(yummy)


Measured memory_bytes: 49432
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t N,ans=0;
  cin>>N;
  if(N<3){
   cout<<0<<endl;
    return 0;
  }
  vector<int64_t> A(N);
  for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  int a,b,c;
  for(int i=0; i<N-2; i++){
    a=A[i];
    for(int j=i+1; j<N-1; j++){
      b=A[j];
      for(int k=j+1; k<N; k++){
         c=A[k];
        if(a+b>c  && b+c>a && a+c>b && a!=b && b!=c && a!=c) ans++;
      }
     }
   }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;

int n;
int a[100100],b[100100],c[100100];

int main(){
  cin >> n;
  rep(i,1,n+1)cin >> a[i];
  rep(i,1,n+1)cin >> b[i];
  rep(i,1,n+1)cin >> c[i];

  sort(a+1,a+n+1);
  // rep(i,1,n+1)cout << a[i] <<' ';
  // std::cout << '\n';
  sort(c+1,c+n+1);
  // rep(i,1,n+1)cout << c[i] <<' ';
  // std::cout << '\n';

  ll res =0;
  rep(j,1,n+1){
    ll tmp_a = lower_bound(a+1,a+n+1, b[j]) - (a+1);
    // cout << tmp_a << ' ' << *lower_bound(a+1,a+n+1, b[j]) <<' '<<b[j] << endl;
    ll tmp_c = c+n+1- upper_bound(c+1, c+n+1, b[j]);
    // cout << tmp_c << ' ' << *upper_bound(c+1,c+n+1, b[j]) <<' '<<b[j] << endl;
    res += tmp_a*tmp_c;
  }
  cout << res<< endl;
}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
using ll = long long;
const ll INF = 1e18L + 5;
const ll MOD = 1e9 + 7;
const int nax = 1e5 + 5;


int main(){
	int a, b;
	cin >> a >> b;
	if(a >= 1 && a <= 9 && b >= 1 && b <=9) {
		int result = a*b;
		printf("%d\n", result);
	}
	else {
		cout << "-1\n";
	}
}

 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string.h>
#include <stdio.h>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	ll a = n / 15;
	ll ans = 800 * n - a * 200;

	cout << ans << endl;

}


Measured memory_bytes: 764
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");
const N = Number(input[0]);
const h = input[1].split(" ").map(Number);

const dp = Array(N).fill(Infinity);

dp[0] = 0;
dp[1] = Math.abs(h[1] - h[0]);

for (let index = 2; index < N; index++) {
  const oneJump = Math.abs(h[index] - h[index - 1]) + dp[index - 1];
  const twoJump = Math.abs(h[index] - h[index - 2]) + dp[index - 2];
  dp[index] = Math.min(oneJump, twoJump);
}

console.log(dp[dp.length - 1]);


Measured memory_bytes: 41252
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
  swap(&a, &b)
  swap(&a, &c)
  fmt.Println(a, b, c)
}

func swap(x *int, y *int) {
	var tmp int

	tmp = *x
	*x = *y
	*y = tmp
}


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

const int mod = 1e9+7;

long long tree[10000000];
vector<int> lazy;
int n;
vector<long long> dp;
vector<int> beauty, height;

void update(int pos, int ind = 1, int l = 1, int r = n)
{
	if(l == r) {
		tree[ind] = dp[pos];
		return ;
	}
	int mid = (l+r)/2;
	if(pos <= mid) update(pos, 2*ind, l, mid);
	else update(pos, 2*ind+1, mid+1, r);
	tree[ind] = max(tree[2*ind], tree[2*ind+1]);
}

long long query(int ql, int qr, int ind = 1, int l = 1, int r = n)
{
	// printf("ql : %d qr : %d ind : %d l : %d r : %d\n", ql, qr, ind, l, r);
	if(ql > qr) return 0;
	if(l == r) return tree[ind];
	if(l == ql && r == qr) {
		return tree[ind];
	}
	int mid = (l+r)/2;
	return max(query(ql, min(qr, mid), 2*ind, l, mid), query(max(mid+1, ql), qr, 2*ind+1, mid+1, r));
}

int main() 
{
	scanf("%d", &n);
	beauty = vector<int>(n+1);
	height = vector<int>(n+1);
	dp = vector<long long>(n+1);
	for(int i = 0; i < n; i++) {
		scanf("%d", &height[i]);
	}
	for(int i = 0; i < n; i++) {
		scanf("%d", &beauty[i]);
	}
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		long long max_ = query(0, height[i]);
		dp[height[i]] = max_ + beauty[i];
		update(height[i]);
		ans = max(ans, dp[height[i]]);
	}
	printf("%lld\n", ans);
 }

Measured memory_bytes: 10648
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/perl

sub main() {
  my($A,$B,$C)=split(/ /,<>);
  chomp($C);
  my $ans = prob($A,$B,$C);
  print $ans;
}

sub prob() {
  my($A,$B,$C) = @_;
  for my $i(1..1000){
    my $tmp = $B * $i + $C;
    if($tmp%$A == 0){
      return "YES";
    }
  }
  return "NO";
}

&main();

Measured memory_bytes: 512
fun main (args: Array<String>) {
    val input = requireNotNull(readLine())
    val phraseSizes = input.split(" ")

    if (phraseSizes.size != 3) {
        println("NO")
        return
    }

    val phrasesWithSize5 = phraseSizes.filter { it == "5" }.size
    val phrasesWithSize7 = phraseSizes.filter { it == "7" }.size

    if (phrasesWithSize5 == 2 && phrasesWithSize7 == 1) {
        println("YES")
    } else {
        println("NO")
    }
}

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

#define int long long
#define endl '\n'

#ifdef LOCAL
#include <C:\Programs\prettyprint.hpp>
template <typename ...Ts>
void trace1(Ts ...T){ ((cerr << "{ " << T << " }\n" ), ...); }
#define trace(...) cerr << "[" #__VA_ARGS__ << "] : " << '\n', trace1(__VA_ARGS__), cerr << '\n';
#else
#define trace(...)
#define trace1(...)
#endif

void factorize(int n, map<int, int> &m) {
    for (int i = 2; i * i <= n; i++) {
        int c = 0;
        while (n % i == 0)
            n /= i, c++;
        if (c == 0) continue;
        m[i] += c;
    }
    if (n > 1)
        m[n]++;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    map<int, int> m;
    for (int i = 2; i <= n; i++)
        factorize(i, m);
    trace(m);
    vector<int> gr(100);
    for (auto i: m) 
        gr[i.second]++;
    for (int i = 98; i >= 0; i--)
        gr[i] += gr[i + 1];
    int ans = 0;
    //2 * 4 * 4
    ans += (gr[2] - gr[4]) * gr[4] * (gr[4] - 1) / 2;
    if (gr[4] > 1)
        ans += gr[4] * (gr[4] - 1) * (gr[4] - 2) / 2;
    //2 * 24
    ans += (gr[2] - gr[24]) * gr[24];
    ans += gr[24] * (gr[24] - 1);
    //4 * 14
    ans += (gr[4] - gr[14]) * gr[14];
    ans += gr[14] * (gr[14] - 1);
    //74
    ans += gr[74];
    cout << ans;
}

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

B = []
i = 0
while i < N:
  a = A[i]
  if a >= 0:
    B.append(a)
    i += 1
  else:
    if i+1 < N:
      if A[i+1] <= 0:
        B.extend([-a, -A[i+1]])
        i += 2
      else:
        B.append(-a)
        i += 1
        A[i] *= -1
    else:
      B.append(a)
      i += 1

if B[-1] >= 0:
  print(sum(B))
else:
  b = - B.pop()
  m = min(B)
  print(sum(B) + b - 2*min(m, b))  

Measured memory_bytes: 14496
# N = int(input())
# A = map(int, input().split())
# cnt = 0
# for i, a in enumerate(A):
#     if ((i + 1) * a) % 2:
#         cnt += 1
# print(cnt)

N = int(input())
A = map(int, input().split())
print(sum(((i + 1) * a) % 2 for i, a in enumerate(A)))


Measured memory_bytes: 8936
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
      	int c = X / 100;
		int x = X % 100;
      
      	if(c>=20){
          System.out.println("1");
        }else if(x>c*5){
          System.out.println("0");
        }else{
          System.out.println("1");
        }
    }
}
      	

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

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    int n; cin >> n;
    int arr[N] , dd[N] = {};
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    dd[0] = 0;
    dd[1] = abs(arr[0] - arr[1]);

    for (int i = 2; i < n; ++i) {
        dd[i] = min(dd[i-1] + abs(arr[i] - arr[i - 1])  , dd[i - 2] + abs(arr[i] - arr[i - 2]));
    }

    cout << dd[n - 1];
}

Measured memory_bytes: 8064
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        map<int,int> mp;
        Rep(i,n)
        {
            cin>>x;
            mp[x]=i;
        }
        Rep(i,n)
        {
            cout<<mp[i]<< " ";
        }
        cout<<en;
    }
}




Measured memory_bytes: 5504
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   string s;
   cin>>s;
   int a=10,b=100,c=1000;
   rep(i,0,s.size()-2){
      if (stoi(s.substr(i,3))==753) {
         cout<<0;
         return 0;
      }
      else if(stoi(s.substr(i,2))==75){
         int n=stoi(s.substr (i+2,1)) ;
         if(abs(n-3)<a) a=abs(n-3);         
      }
      else if(stoi(s.substr(i,1))==7) {
         int m=stoi(s.substr (i+1,2));
         if(abs(m-53)<b) b=abs(m-53);
      }
      else {
          int l=stoi(s.substr (i,3));
          if(abs(l-753)<c) c=abs(l-753);
      }
   }
   if (a!=10) cout<<a;
   else if(b!=100)cout<<b;
   else cout <<c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T> T factorial(T N) {
    // int 型だとたかだか N <= 12 まで
    // long long 型だと N <= 20 まで
    T ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= (i + 1);
    }
    return ans;
}

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

    int N, K;
    cin >> N >> K;
    ll ans = 0;
    ll x = 0, y = 0;
    FOR(i, 1, N + 1) {
        if (i % K == 0)
            x++;
        if (i % K == (K / 2))
            y++;
    }
    ans = x * x * x;
    if (K % 2 == 0) {
        ans += y * y * y;
    }

    print(ans);

    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long[] arr = new long[N];
		long[] OG = new long[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextLong();
			OG[i]=arr[i];
		}
		Arrays.sort(arr);
		int hi = N/2;
		int lo = hi-1;
		for (int i = 0; i < N; i++) {
			if (OG[i]<=arr[lo]) System.out.println(arr[hi]);
			else System.out.println(arr[lo]);
		}
	}
}

Measured memory_bytes: 94628
import sys
f=1
for s in sys.stdin:
    b=map(int,s.split())
    if f:
        a=b
        f=0
        continue
    c1=0
    c2=0
    for i,e in enumerate(b):
        if e==a[i]: c1+=1
        elif e in a: c2+=1
    print c1, c2
    f=1

Measured memory_bytes: 4208
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		String s1 = s.substring(0, 4);
		String s2 = s.substring(4);
		
		System.out.println(s1 + " " + s2);
	}
}

Measured memory_bytes: 9684
candidate = []
S = input()
T = input()
L = list(S)
for i in range(len(S)) :
    a = L[0]
    L.pop(0)
    L.append(a)
    b = ''.join(L)
    candidate.append(b)

if T in candidate :
    print("Yes")
else :
    print("No")



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

int main(){
    int n;
    int a[210];

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int count = 0; 
    while(true){
        bool odd = false;
        for(int i = 0; i < n; i++){
            if((a[i] % 2) != 0){
                odd = true;
            }
        } 
        if(odd){
            break;
        }
        for(int i = 0; i < n; i++){
            a[i] /= 2;
        }
        count += 1;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				int[] date = new int[3];
				for(int i = 0; i < 3; i++){
					date[i] = stdIn.nextInt();
				}
				if( date[0] < 1868 || (date[0] == 1868 && (date[1] < 9 || (date[1] == 9 && date[2] < 8))) ){
					System.out.println("pre-meiji");
				} else if( date[0] < 1912 || (date[0] == 1912 && (date[1] < 7 || (date[1] == 7 && date[2] < 30))) ){
					
					System.out.println("meiji" + " " + (date[0]-1867) + " " + date[1] + " " + date[2]);
				} else if( date[0] < 1926 || (date[0] == 1926 && (date[1] < 12 || (date[1] == 12 && date[2] < 25))) ){
					System.out.println("taisho" + " " + (date[0]-1911) + " " + date[1] + " " + date[2]);
				} else if( date[0] < 1989 || (date[0] == 1989 && (date[1] < 1 || (date[1] == 1 && date[2] < 8))) ){
					System.out.println("showa" + " " + (date[0]-1925) + " " + date[1] + " " + date[2]);	
				} else 	{
					System.out.println("heisei" + " " + (date[0]-1988) + " " + date[1] + " " + date[2]);
				}
			}
		} finally {
			if( stdIn != null){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        q: usize,
        s: String,
        lrs: [(usize, usize); q],

    }
    let mut vals = vec![0; n];
    let mut chars = vec!['X'; n];
    for (i, c) in s.chars().into_iter().enumerate() {
        chars[i] = c;
    }
    for i in (0..n).rev() {
        if i != n - 1 {
            vals[i] = vals[i + 1];
            if chars[i] == 'A' {
                if chars[i + 1] == 'C' {
                    vals[i] += 1;
                }
            }
        }
    }
    for (l, r) in lrs {
        println!("{}", vals[l - 1] - vals[r - 1]);
    }
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		PriorityQueue<Long> queue = new PriorityQueue<Long>(Collections.reverseOrder());
		HashSet<Long> has = new HashSet<Long>();
		
		queue.add((long) 0); queue.add((long) 0);
		for(int i = 1; i<=N; i++) {
			long n = sc.nextInt();
			if(has.contains(n)) {
				queue.add((n));
				has.remove(n);
			}
			else {
				has.add(n);
			}
		}
		
		System.out.println(queue.poll()*queue.poll());
		
	}

}


Measured memory_bytes: 62668
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N = 1e5;

int N, Q;
int A[MAX_N + 5];
LL cnt[MAX_N + 5];
LL sum = 0;

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
    {
        scanf("%d", &A[i]);
        cnt[A[i]]++;
        sum += A[i];
    }
    scanf("%d", &Q);
    while (Q--)
    {
        int B, C;
        scanf("%d %d", &B, &C);
        sum += cnt[B]*(C-B);
        cnt[C] += cnt[B];
        cnt[B] = 0;
        printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 459384
using namespace std;
char a[p]; 
int main()
{
	int n;
	cin>>n;
	scanf("%s",a+1);
	int ans=0;
	int j=n;
	for(fint i=1;i<=n;i++)
	{
		if(a[i]=='W')
		for(;j>=1;j--)
		{
			if(j<=i)
			goto flag;
			if(a[j]=='R')
			{
				a[i]='R',a[j]='W',ans++;
				break;
			}
		}
	}
	flag:
	cout<<ans;
	return 0;
}

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

ll n, ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;

    for (ll mod = 1; mod * mod <= n; mod++) {
        if ((n % mod) || (n == 1 && mod == 1) || n % (n / mod - 1) != mod) continue;
        ans += n / mod - 1;
    }
    
    cout << ans;
}



Measured memory_bytes: 256
a,b,c = list(map(int,input().split()))



def bfs(a,b,c):
    count = 0
    queue = [[a,b,c,count]]

    while queue:
        a,b,c,count = queue.pop(0)


        if a == b and b == c:
            return count
        
        if b > a and b > c:
            queue.append([a+1,b,c+1,count+1])

        elif a > b and a > c:
            queue.append([a,b+1,c+1,count+1])
        
        elif c > a and c > b:
            queue.append([a+1,b+1,c,count+1])
        
        elif a < b:
            # queue.append([a+1,b+1,c,count+1])
            queue.append([a+2,b,c,count+1])
        
        
        elif b < c:
            queue.append([a,b+2,c,count+1])
            # queue.append([a,b+1,c+1,count+1])

        elif c < a:
            # queue.append([a+1,b,c+1,count+1])
            queue.append([a,b,c+2,count+1])


        






print(bfs(a,b,c))


    


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		
		long sum = 0;
		for( int i=1 ; i<=n ; i++ ) {
			if( i%3 != 0 && i%5 != 0  ) {
				sum+=i;
			}
		}
		System.out.println(sum);
	}

}



Measured memory_bytes: 27232
#include <stdio.h>

int main (int argc, const char * argv[]) {
    int i;
	int j;
	
	for (i=1; i<10; i++) {
		for (j=1; j<10; j++) {
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
    return 0;
}

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


public class Test
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        List <int> list = new List<int>();
        list.Add(n[0]+n[1]);
        list.Add(n[0]-n[1]);
        list.Add(n[0]*n[1]);
        list.Sort();
        Console.WriteLine(list[list.Count-1]);
	} 
}

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

using namespace std;

#define P(s) cout << s << endl;
#define DEBUG(x) cout << #x << ": " << x << endl;

vector<int> rs; // 巡回必要なもの全てRs
int Cs[201][201] = {0}; // 全パスの距離

int main() {

  int N, M, R;
  cin >> N >> M >> R;
  
  for (int i = 0; i < R; i++) {
    int r;
    cin >> r;
    rs.push_back(r);
  }

  for (int i = 1; i <= N; i++) { 
    for (int j = 1; j <= N; j++) { 
      if (i != j) {
        Cs[i][j] = INT_MAX;
      }
    }
  } // fill

  for (int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    Cs[A][B] = C;
    Cs[B][A] = C;
  }

  // cout << "---------" << endl;
  // for (int i = 1; i <= N; i++) { 
  //   for (int j = 1; j <= N; j++) { 
  //     DEBUG(i);
  //     DEBUG(j);
  //     DEBUG(Cs[i][j]);
  //   }
  // }
  // cout << "---------" << endl;

  // 1. ワーシャルフロイドですべての頂点の対の最小距離を求める
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) { 
      for (int j = 1; j <= N; j++) { 
        if(Cs[i][k] != INT_MAX && Cs[k][j] != INT_MAX) { // オーバーフロー対策!!!!
          Cs[i][j] = min(Cs[i][j], Cs[i][k] + Cs[k][j]);
        }
      }
    }
  }

  // for (int i = 1; i <= N; i++) { 
  //   for (int j = 1; j <= N; j++) { 
  //     DEBUG(i);
  //     DEBUG(j);
  //     DEBUG(Cs[i][j]);
  //   }
  // }

  // 2. rsのすべての順列組み合わせを作り、最短距離を使ってそれぞれの全コストを求め、最短を出力
  vector<int> paths = rs;
  int min = INT_MAX;
  sort(paths.begin(), paths.end()); // next_permutation は sortされている必要があった！
  do {
    int sum = 0;
    for (int i = 0; i < R - 1; i++) {
      int start = paths[i];
      int end = paths[i + 1];
      sum = sum + Cs[start][end];
      // cout << start << "->" << end << " ";
    }
    // cout << " : " << sum << endl;
    if (sum <= min) min = sum;
  } while (next_permutation(paths.begin(), paths.end()));

  cout << min << endl;
}


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

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

use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let m: i64 = read();
    let mut a: Vec<i64> = vec![];

    for _ in 0..n {
        a.push(read());
    }

    let mut sum = 0;
    let mut ans = 0;
    let mut b: HashMap<i64, i64> = HashMap::new();
    b.insert(0, 1);
    let mut c: Vec<i64> = vec![];
    for i in 0..a.len() {
        sum += a[i];
        match b.get(&(sum % m)) {
            Some(s) => ans += *s,
            None => (),
        }
        let current = b.entry((sum % m)).or_insert(0);
        *current += 1;
    }
    println!("{}", ans);
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

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

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

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

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

map<long long,long long> prime_factor(long long n) {
    map<long long,long long> ret;
    for(long long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main()
{
	ll n;
	map<ll,ll> m;
	cin >> n;
	for(ll i=1;i<=n;i++){
		map<ll,ll> tmp=prime_factor(i);
		for(auto&& e:tmp) m[e.first]+=e.second;
	}
	auto cnt=[&](ll x){
		ll ret=0;
		for(auto&& e:m){
			if(e.second>=x-1) ret++;
		}
		return ret;
	};
	ll ans=cnt(75)+cnt(25)*(cnt(3)-1)+cnt(15)*(cnt(5)-1)+cnt(5)*(cnt(5)-1)*(cnt(3)-2)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(std::vector<long long> M, std::vector<long long> D){
  if(M[0]!=M[1]) cout << 1 << endl;
  else cout << 0 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  std::vector<long long> M(2);
  std::vector<long long> D(2);
  for(int i = 0 ; i < 2 ; i++){
    scanf("%lld",&M[i]);
    scanf("%lld",&D[i]);
  }
  solve(std::move(M), std::move(D));
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORD(i,a,b) for(int i=(a);i>=(int)(b);i--)
#define sf(n) scanf("%d", &n)
#define sfc(x) scanf("%c", &x)
#define pf(x) printf("%d", x)
#define pff(x) printf("%lf", x)
#define pfc(x) printf("%c", x)
#define pfs(x) printf("%s", x)
#define sf2(a,b) scanf("%d %d", &a, &b)
#define sf3(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()
#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
bool prime[500010];
void SieveOfEratosthenes(ll n)
{
    memset(prime,true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

int main(){
  fast
  ll a[4];
  FOR0(i,4)cin>>a[i];
  sort(a,a+4);
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout<<"YES\n";
  else{
  	cout<<"NO\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void) {
    LL A, B;
    cin >> A >> B;
    LL ans = (A*B) / __gcd(A, B);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,v[55],c[55],cost = 0;
    cin >> n;
    for(int i = 0;i < n;i++){cin >> v[i];}
    for(int i = 0;i < n;i++){cin >> c[i];}
    for(int i = 0;i < n;i++)
    {
        if(c[i] < v[i])
        {
            cost += v[i] - c[i];
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define loop(i,n)for(i=0;i<n;i++)
#define INF 1000000000
using ll = long long int;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;


#define MAX 100005


int main()
{
    IOS;
    //freopen("inputfile.txt","r",stdin);
   ll n;cin>>n;
   map <string,ll> ma;
   ll ans = 0;
   //memset(vec,0,sizeof(vec));
   for(ll i=0;i<n;i++)
   {
       string x;cin>>x;
       ma[x]++;
       ans = max(ans,ma[x]);
   }
   for(auto x:ma)
   {
       if(x.second==ans)cout<<x.first<<endl;
   }
    return 0;
}


Measured memory_bytes: 19160
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, M; std::cin >> N >> M;

  if (N >= M) {
    std::cout << 0 << std::endl;
    return 0;
  }

  std::vector<int> X(M);
  for (int i = 0; i < M; ++i) std::cin >> X[i];

  std::sort(X.begin(), X.end());

  std::vector<int> dists(M-1);
  for (int i = 0; i < M-1; ++i) {
    dists[i] = X[i+1] - X[i];
  }

  std::sort(dists.rbegin(), dists.rend());

  int sum = 0;
  for (int i = N-1; i < M-1; ++i) {
    sum += dists[i];
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string e;
int main(){
    q a,b,c,o;
    cin>>a>>b>>c;
    while(b<a){
        b++;
        c--;
    }
if(c>=0){cout<<c;} else {cout<<0;}
return 0;}


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

using namespace std;

int a[100];

int main()
{
    int n, p;
    int cnt = 0;
    while(scanf("%d%d", &n, &p) != EOF)
    {
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
            if(a[i] % 2 == 1) cnt ++;
        }
        if(cnt == 0)
        {
            if(p) printf("0");
            else printf("%lld\n", (long long)1 << n);
        }
        else
        printf("%lld\n", (long long)1 << (n - 1));
    }
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc137/tasks/abc137_c

import math

N = int(input())

s_dic = {}
s_set = set()

for i in range(N):
    s = input()

    s = ''.join(sorted(s))

    if s in s_set:
        s_dic[s] += 1

    else:
        s_set.add(s)
        s_dic[s] = 1


result = 0

for val in s_dic.values():

    if val > 1:
        result += int((val * (val - 1)) / 2)

print(result)








Measured memory_bytes: 26080
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	if(n == 1) {
		cout << m << endl;
		return 0;
	}
	int ans = 0;
	for(int i=1;i*i<=m;i++) {
		if(m % i == 0) {
			if(m/i >= n) ans = max(ans, i);
			if(i >= n) ans = max(ans, m/i);
		}
	}
	cout << ans << endl;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
const string YES = "Yes";
const string NO = "No";
void solve(long long A, long long B, long long C, long long D){
  ll i = 0;
  while(!(A <= 0 || C <= 0)){
    if(i % 2 == 0)C -= B;
    else A -= D;
    i++;
  }
  cout << (i%2 == 0 ? NO : YES) << endl;
}

int main(){
    long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	long long C;
	scanf("%lld",&C);
	long long D;
	scanf("%lld",&D);
    solve(A, B, C, D);
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin >> N;
    vector<vector<pair<int,ll>>> G(N);
    REP(i,N-1) {
        int u,v;
        ll w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].pb(make_pair(v,w));
        G[v].pb(make_pair(u,w));
    }
    vector<ll> dist(N,INF);
    vector<bool> used(N,false);
    queue<int> q;
    dist[0] = 0;
    q.push(0);
    while(q.size()) {
        int now = q.front();
        q.pop();
        used[now] = true;
        REP(i,G[now].size()) {
            int to = G[now][i].fi;
            int cost = G[now][i].se;
            if (used[to]) continue;
            dist[to] = dist[now] + cost;
            q.push(to);
        }
    }
    REP(i,N) {
        cout << dist[i] % 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  vector<int> t(n);
  int sum=0;
  rep(i,n){
    cin >> t.at(i);
    sum += t.at(i);
  }
  int m; cin >> m;
  rep(i,m){
    int p,x; cin >> p >> x;
    int save = t.at(p-1)-x;
    cout << sum -save << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

ll mod = 1e9+7;


int main(){
    int A,B,ans = 0;
    cin >> A >> B;
    FOR(i,A,B+1) {
        string str = toString(i);
        FOR (j,0,str.size()/2) {
            if (str[j] != str[str.size()-1-j]) break;
            if (j==str.size()/2-1) {
                ans ++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512