akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)
typedef long long ll;

using namespace std;

int main(){
	int n,m;
	
	cin >> n >> m;
	
	char a[n][n],b[m][m];
	bool flag = true;
	
	
	rep(i,0,n){
		rep(j,0,n){
			cin >> a[i][j];
		}
	}
	
	rep(i,0,m){
		rep(j,0,m){
			cin >> b[i][j];
		}
	}
	
	
	rep(i,0,n-m+1){
		rep(j,0,n-m+1){
			flag = true;
			rep(k,0,m){
				rep(l,0,m){
					if(a[i+k][j+l] != b[k][l]){
						flag = false;
					}
				}
			}
			if(flag){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
typedef vector<vector<LL>> VVL;
typedef vector<string> VS;

#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL llRead(){
  LL a;
  cin >> a;
  return a;
};

string stringRead(){
  string a;
  cin >> a;
  return a;
};

vector<LL> vlRead(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> vsRead(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> vvlRead(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 0
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, VL& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, VS& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, VVL& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, char* s) {
  cout << line << ":" << name << ":char* " << s << endl;;
}
void debug1(LL line, const char* name, vector<const char*>& v) {
  cout << line << ":" << name << ":vector<const char*>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<pair<LL, LL>>& v) {
  cout << line << ":" << name << ":vector<pair<LL,LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << "<" << v.at(i).first << "," << v.at(i).second << "> ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, priority_queue<LL>& p) {
  cout << line << ":" << name << ":priority_queue<LL>(" << p.size() << ") ";
  priority_queue<LL> copy = p;
  while(!copy.empty()) {
    cout << copy.top() << " ";
    copy.pop();
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code

  auto n = llRead();
  auto a = vlRead(n);
  vector<pair<LL, LL>> b;
  REP(i, a.size()) {
    b.push_back(make_pair(i+1, a.at(i)));
  }
  debug(b);
  sort(b.begin(), b.end(), [](pair<LL,LL> a, pair<LL,LL> b) { return a.second < b.second; });
  debug(b);
  REP(i, b.size()) {
    if (i!=0) cout << " ";
    cout << b.at(i).first;
  }
  cout << endl;



  return 0;
}


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

int main() {
    int n, divisores = 0, num=0;
    scanf("%d", &n);

    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=i; ++j) {
            if(divisores>8) {
                divisores = 0;
                break;
            }

            if(i%j==0 && j%2!=0)
                ++divisores;

            if(j==i && divisores==8)
                ++num;
            //printf("%d %d %d %d\n", num, i, j, divisores);

            if (j==i)
                divisores = 0;

        }
    }

    printf("%d\n", num);
    return 0;
}


Measured memory_bytes: 128
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int a, b;
string a2, b2, c, d;
int main() {
	cin >> a2 >> b2;
	a = stoi(a2);
	b = stoi(b2);
	for (int i = 0; i < b; i++) {
		c += a2;
	}
	for (int i = 0; i < a; i++) {
		d += b2;
	}
	if (c < d) {
		cout << c << endl;
	}
	else {
		cout << d << endl;
	}
}




Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int, int> P;

int w, h, n;
char s[1000][1001];
int d[1000][1000];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main() {
  scanf("%d%d%d", &h, &w, &n);
  for (int i = 0; i < h; i++) scanf("%s", s[i]);
  int sx, sy;
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (s[i][j] == 'S') sy = i, sx = j;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    char g = '1' + (char)i;
    queue<P> que;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) d[i][j] = -1;
    d[sy][sx] = 0;
    que.push(P(sy, sx));
    bool end = false;
    while (!que.empty()) {
      P p = que.front(); que.pop();
      for (int i = 0; i < 4; i++) {
        int y = dy[i] + p.first, x = dx[i] + p.second;
        if (x < 0 || y < 0 || x == w || y == h) continue;
        if (s[y][x] == 'X' || d[y][x] != -1) continue;
        if (s[y][x] == g) {
          ans += d[p.first][p.second] + 1;
          sy = y, sx = x;
          end = true;
        }
        d[y][x] = d[p.first][p.second] + 1;
        que.push(P(y, x));
      }
      if (end) break;
    }
  }
  printf("%d\n", ans);
}



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

using namespace std;


int main()
{
	int x; cin >> x;
	int m = 120;
	for(int i = -m; i <= m; i++){
		for(int j = -m; j <= m; j++){
			if(pow(i,5)-pow(j,5) == x){
				cout << i << " " << j;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
const int inf=0x3f3f3f3f;
int f[55][55][55];
int main(){
    int a[4];
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[1]%2==a[2]%2&&a[3]%2==a[2]%2){
    	swap(a[1],a[3]);
    	cout<<(2*a[1]-a[2]-a[3])/2;
	}
	else if(a[1]%2==a[2]%2){
		a[1]++;a[2]++;
		sort(a+1,a+4);
		swap(a[1],a[3]);
		cout<<(2*a[1]-a[2]-a[3])/2+1;
	}
	else if(a[1]%2==a[3]%2){
		a[1]++;a[3]++;
		sort(a+1,a+4);
		swap(a[1],a[3]);
		cout<<(2*a[1]-a[2]-a[3])/2+1;
	}
	else if(a[2]%2==a[3]%2){
		a[3]++;a[2]++;
		sort(a+1,a+4);
		swap(a[1],a[3]);
		cout<<(2*a[1]-a[2]-a[3])/2+1;
	}
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,k;
  cin >> h >> w >> k;
  vvc c(h,vc(w));
  rep(i,h){
    rep(j,w){
      cin >> c[i][j];
    }
  }
  int ans=0;
  rep(i,1<<h){
    rep(j,1<<w){
      int cnt=0;
      rep(x,h){
        rep(y,w){
          if((i>>x)%2==0&&(j>>y)%2==0&&c[x][y]=='#'){
            cnt++;
          }
        }
      }
      if(cnt==k){
        ans++;
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int n; cin >> n;
  int a[n]; rep(i, n) cin >> a[i];
  reverse(a, a+n);
  int x[n]; 
  rep(i, n) {
    if (i%2==0) x[i/2] = a[i];
    else x[(n-1)-(i-1)/2] = a[i];
  }

  rep(i, n) {
    if (i!=0) cout << " ";
    cout << x[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;

const long long int mod=1e9+7; 

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int q[1001]={};

    for(int n=2;n<=N;n++){
        int loop = n;
        int tmp = n;
        for(int i=2;i<=loop;i++){
            if(tmp%i==0){
                while(1){
                    q[i]++;
                    tmp /= i;
                    if(tmp%i!=0) break;
                }
            }
        }
    }

    long long int ans=1;
    for(int i=2;i<=N;i++){        
        if(q[i]!=0) ans = ((ans%mod)*((q[i]+1)%mod))%mod;
    }
    p(ans)
}

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

int main(){
  int a,b,k;
  std::cin>>a>>b>>k;
  int tn=0,p=100;
  while(1){
    if(a%p==0&&b%p==0){
      tn++;
      if(tn==k){
        std::cout<<p;
        return 0;
      }
    }
    p--;
  }
}
    
  

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

int main()
{
    int A,B;
    cin >> A;
    cin >> B;
    
    if ((A+B)%2 == 0){
        cout << (A+B)/2 << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    var T = 1L
    var A = 1L
    repeat(N) {
        val (t, a) = listOfLong()
        val d = Math.max(T.ceilDiv(t), A.ceilDiv(a))
        T = t * d
        A = a * d
//System.err.println("T:$T A:$A")
    }
    val ans = T + A
    println(ans)
}
inline fun Long.ceilDiv(n: Long) = (this + n - 1) / n

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 37916
from time import time
from collections import deque

# reduce q.append()
# (constant-factor optimization)


def append(d, i, j):
    if not 0 <= i < H or not 0 <= j < W or dists[i][j] != -1:
        return
    dists[i][j] = d
    q.append((d, i, j))


q = deque()
H, W = map(int, input().split())
dists = [[-1] * W for _ in range(H)]
for i in range(H):
    for j, v in enumerate(input()):
        if v == "#":
            append(0, i, j)

while len(q):
    d, i, j = q.popleft()
    append(d+1, i-1, j)
    append(d+1, i+1, j)
    append(d+1, i, j-1)
    append(d+1, i, j+1)

# fast (0.01s)
ans = max(map(max, dists))
# very slow (4.2s)
# ans = max(sum(dists, []))

print(ans)


Measured memory_bytes: 172376
from itertools import accumulate

N, K, *A = map(int, open(0).read().split())

s = sum(A)
divisor = []
for i in range(1, int(s ** 0.5) + 1):
    if s % i == 0:
        divisor.append(i)
        if i != s // i:
            divisor.append(s // i)

ans = 0
for d in divisor:
    x = sorted(v % d for v in A)
    y = [d - r for r in x]
    x_s = [0] + list(accumulate(x))
    y_s = list(accumulate(y[::-1]))[::-1] + [0]

    for i in range(N + 1):
        if x_s[i] <= K and x_s[i] == y_s[i]:
            ans = max(ans, d)
            break

print(ans)


Measured memory_bytes: 75212
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}


int main()
{
    const auto n = read<int>();
    const auto k = read<int>();
    const auto hs = reads<int>(n);
    
    cout << count_if(begin(hs), end(hs), [=](int x){ return x >= k; }) << '\n';
    return 0;
}


Measured memory_bytes: 640
from collections import deque
def main():
    # 入力
    n = int(input())
    nodes_edges_data = {e: [] for e in range(1, n + 1)}
    edges_data_to_number = {}
    for i1 in range(n - 1):
        a, b = tuple(map(int, input().split()))
        nodes_edges_data[a].append(b)
        nodes_edges_data[b].append(a)
        edges_data_to_number[(a, b)] = i1
        edges_data_to_number[(b, a)] = i1
    # 処理
    edges_color = [-1] * (n - 1)
    nodes_num = [0] * (n + 1)
    nodes_num[1] = -1
    max_edges_per_node = 0
    nodes_next = deque([1])
    nodes_next_next = deque()
    nodes_seen = set()
    while len(nodes_seen) < n:
        while nodes_next:
            e = nodes_next.pop()
            nodes_seen.add(e)
            adj_nodes = nodes_edges_data[e]
            nodes_next_next += adj_nodes
            num_of_nodes = len(adj_nodes)
            max_edges_per_node = max(max_edges_per_node, num_of_nodes)
            num = nodes_num[e]

            for adj_node in adj_nodes:
                if not adj_node in nodes_seen:

                    num = (num + 1) % max_edges_per_node
                    edges_color[edges_data_to_number[(e, adj_node)]] = num
                    #nodes_num[adj_node] = (num + 1) % max_edges_per_node
                    nodes_num[adj_node] = num
        nodes_next_next_set = set(nodes_next_next)
        nodes_next += deque(nodes_next_next_set - nodes_seen)
        nodes_next_next = deque()

    # 出力
    print(max(edges_color) + 1)
    for i in range(n - 1):
        print(edges_color[i] + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67868
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  int n, m;
  std::cin >> n >> m;

  llint total = 0;
  for(int i=0; i<m; i++){
    llint temp;
    std::cin >> temp;
    total += temp;
  }

  n -= total;

  if(n<0) n = -1;

  std::cout << n << std::endl;

  return 0;
}


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

total = 1
trend = 0
prev = A[0]
for a in A[1:]:
    if a > prev and trend < 0:
        total += 1
        trend = 0
    elif a < prev and trend > 0:
        total += 1
        trend = 0
    elif trend == 0:
        trend = a - prev
    prev = a

print(total)

Measured memory_bytes: 14228
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int w,h,n;
	cin >> w >> h >> n;
	int a1 = 0;
	int a2 = w;
	int a3 = 0;
	int a4 = h;
	rep(i,n){
		int x,y,a;
		cin >> x >> y >> a;
		if(a == 1)chmax(a1,x);
		if(a == 2)chmin(a2,x);
		if(a == 3)chmax(a3,y);
		if(a == 4)chmin(a4,y);
	}
	if(a1 < a2 && a3 < a4){
		cout << (a2-a1)*(a4-a3) << endl;
	}else{
		cout << 0 << endl;
	}

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc047.contest.atcoder.jp/tasks/abc047_b

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	int n, m;
	string tmp;
	map<string, int> val;
	cin >> n;
	for ( int i = 0 ; i < n ; i++ ){
		cin >> tmp;
		val[tmp]++;
	}
	cin >> m;
	for ( int i = 0 ; i < m ; i++ ){
		cin >> tmp;
		val[tmp]--;
	}
	auto res = max_element(val.begin(), val.end(), [](const pair<string, int>& p1, const pair<string, int>& p2){
			return p1.second < p2.second; });
	cout << (res->second > 0 ? res->second : 0) << "\n";

	return 0;
}


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

int main() {
    int A[3][3];
    bool ans[3][3];
    
    for(int i=0; i<3; i++){
	for(int j=0; j<3; j++){
	    cin >> A[i][j];
	    ans[i][j]=false;
	}
    }
    int N;
    cin >> N;
    int b[N];
    for(int i=0; i<N; i++){
	cin >> b[i];

	for(int j=0; j<3; j++){
	    for(int k=0; k<3; k++){
		if(A[j][k]==b[i])
		    ans[j][k]=true;
	    }
	}
    }
    for(int i=0; i<N; i++){
	if(ans[0][i]==ans[1][i] && ans[1][i]==ans[2][i] && ans[2][i]==true){
	    cout << "Yes" << endl;
	    return 0;
	}
	else if(ans[i][0]==ans[i][1] && ans[i][1]==ans[i][2] && ans[i][2]==true){
	    cout << "Yes" << endl;
	    return 0;
	}
	else if(ans[0][0]==ans[1][1] && ans[1][1]==ans[2][2] && ans[2][2]==true){
	    cout << "Yes" << endl;
	    return 0;
	}
	else if(ans[0][2]==ans[1][1] && ans[1][1]==ans[2][0] && ans[2][0]==true){
	    cout << "Yes" << endl;
	    return 0;
	}
    }
    cout << "No" << endl;

    

    
} 




Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
        string t;
        int i,r,score,o,ini;
        score = 0;
        cin >> ini;
        for(i=0;i<ini;i++){
        while(1){
        cin >> t;
        if(t == "HIT"){
                r++;
                if(r == 4){
                        score++;
                        r--;
                }
        }else if(t == "OUT"){
                o++;
                if(o == 3){
                        r = o = 0;
                        break;
                }
        }else if(t == "HOMERUN"){
                score += r + 1;
                r = 0;
        }
        }
        cout << score << endl;
        score = 0;
        }
return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
vector<ll>q;

ll getAns(ll m){
	ll x=0;
	auto it=upper_bound(all(q),m)-q.begin()-1;
	return it;
}

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<=1e3;i++){
		q.pb(((i+1)*i)/2);
	}
	for(ll i=2;i*i<=n;i++){
		ll cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		ans+=getAns(cnt);
	}
	if(n>1)ans++;
	cout<<ans;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
 	int n,k,x,y,ans(0);
  	cin >> n >> k >> x >> y;
  	for(int i = 0;i < n;i++){
      if(i < k){
        ans += x;
      }else {
		ans += y;
      }
    }
  cout << ans;
  	

}
   

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

int main(){
    int h, w;

    while(1){
    cin >> h >>w ;
    if (( h ==0 && w == 0) || (300 <h || 300 < w))break;
    for( int i =0 ; i < h ; i++){
      for( int j = 0 ; j < w ; j++){
	if( i %2 == 0 && j%2 == 0 ){
	    cout << "#";}
	else if ( i%2 == 0 && j%2 ==1){
	  cout << ".";}
	else if ( i%2 == 1 && j%2 ==0) {
	    cout << ".";
	  }
	else if ( i%2 ==1 && j%2 == 1){
	  cout << "#" ;
	}
      }
      cout <<endl;
    }
    cout << endl;
    }

    return 0;
}    

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

using namespace std;

int main()
{
    int n;

    cin>>n;
    int counter = 0;
    int track = 0;
    int arr[n];
    for(int i=0; i<n;i++)
    {
        cin>>arr[i];
    }

    for(int i = 0; i<n; i++)
    {
        counter = 0;
        for(int j=0; j<n-1; j++)
        {
            if(arr[j]>arr[j+1])
            {
                int temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
                counter = 1;
                track++;
            }
        }
        if(counter==0)
        {
            break;
        }
    }

    for(int i=0; i<n; i++)
    {
        if(i<n-1)
        cout<<arr[i]<<" ";
        else
            cout<<arr[i];
    }
    cout<<endl;
    cout<<track<<endl;

}




Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<bool> infected(n+1, false);
        infected[1] = true;

        vector<pair<int, pair<int, int> > > a(m);
        for(int i=0; i<m; ++i)
            cin >> a[i].first >> a[i].second.first >> a[i].second.second;
        sort(a.begin(), a.end());

        for(int i=0; i<m; ++i){
            int s = a[i].second.first;
            int d = a[i].second.second;
            if(infected[s])
                infected[d] = true;
        }

        int ret = 0;
        for(int i=1; i<=n; ++i){
            if(infected[i])
                ++ ret;
        }
        cout << ret << endl;
    }
}

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

#define ll long long

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

    int a[n+1];

    for (int i = 1; i <= n; i++) cin >> a[i];

    sort(a+1, a+n+1);
    cout << a[n/2+1] - a[n/2] << endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
vector<int> graph[MAX_N];
int p[MAX_N];
bool vis[MAX_N];
int n, m;
vector<int> curr;

void dfs(int v){
    vis[v] = true;
    curr.push_back(v);
    for(int u : graph[v]){
        if(!vis[u])
            dfs(u);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    int i = 0;
    for(i = 0; i < n; i++)
        cin >> p[i], p[i]--;
    for(i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int cnt = 0;
    for(i = 0; i < n; i++){
        if(!vis[i]){
            curr.clear();
            dfs(i);
            set<int> s;
            for(int x : curr)
                s.insert(p[x]);
            for(int x : curr)
                if(s.find(x) != s.end())
                    cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 14328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n,m,x,y;cin>>n>>m>>x>>y;

    int X = -1000, Y = 1000;
    REP(i, n) {
        int x1;cin>>x1;
        if (X < x1) X=x1;
    }
    REP(i,m) {
        int y1;cin>>y1;
        if (Y > y1) Y=y1;
    }

    if (X >= y || Y <= x) {
        cout << "War" <<endl;
        return 0;
    }

    if (Y > X) {
        cout << "No War" << endl;
    }else {
        cout << "War" <<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint;
const int mod = 1000000007;
const double PI = acos(-1);

vector<vector<int>> GetAdjacencyList(int n, int m)
{
	vector<vector<int>> al(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		al[a].push_back(b);
		al[b].push_back(a);
	}
	return al;
}

void DFS(int id, int node, const vector<vector<int>>& al, vector<int>& group)
{
	group[node] = id;
	for (int i = 0; i < al[node].size(); i++) {
		if (group[al[node][i]]) continue;
		group[al[node][i]] = id;
		DFS(id, al[node][i], al, group);
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> al = GetAdjacencyList(n, m);
	vector<int> group(n);
	for (int i = 0; i < n; i++) {
		int id = i + 1;
		if (!group[i]) DFS(id, i, al, group);
	}

	map<int, int> freq;
	for (int i = 0; i < n; i++) freq[group[i]]++;
	cout << freq.size() - 1 << endl;
}


Measured memory_bytes: 10916
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	// writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	// scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	// defer writer.Flush()
	n := scanInt()
	a := scanInts(n)
	sort.Ints(a)

	ans := a[0]
	for i := 1; i < n; i++ {
		ans = gcd(ans, a[i])
	}
	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func perm(n, r int) int {
	ret := 1
	for i := 0; i < r; i++ {
		ret *= n
		n--
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
    } else {
        cout << n - k << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def insert_plus(numbers, plus_num)
  return [numbers] if plus_num == 0
  formula_list = Array.new
  (plus_num - 1 + 1).upto(numbers.size - 1) do |pos|
    insert_plus(numbers[0 .. (pos - 1)], plus_num - 1).each do |left|
      formula_list.push(left + "+" + numbers[pos .. -1])
    end
  end
  return formula_list
end

Numbers = gets.strip

answer = 0
Numbers.size.times do |plus_num|
  insert_plus(Numbers, plus_num).each do |formula|
    answer += eval(formula)
  end
end

puts answer


Measured memory_bytes: 1916
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%d\n",n * (n - 1) / 2 + m * (m - 1) / 2);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;
ll f(ll x){
  if(x==0){return 0;}
  else if(x%2){
    if(((x+1)/2)%2){return 1;}
    else{return 0;}
  }
  else{return f(x-1)^x;}
}
int main(){
  ll a,b,ans=0;cin>>a>>b;
  cout<<(f(b)^f(a-1))<<endl;
}



Measured memory_bytes: 256
from itertools import*
#コードが長くなりすぎたので模範解答を写経
n,m = map(int,input().split())
x = [tuple(map(int,input().split())) for _ in range(n)]
res = 0
for a in product([-1,1],[-1,1],[-1,1]):
    
    res = max(res,sum(sorted((sum(i*j for i,j in zip(a,t)) for t in x),reverse=True)[:m]))
print(res)


Measured memory_bytes: 42832
import math

#n = int(input())
n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = input()
#list = list(s)

kotae = 1
total = 0

for i in range(n) :
    if (total + list[i] > m) :
        break
    total += list[i]
    kotae += 1

print(kotae)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

template<class T>
T divisor(T n) {
	T res = 0;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			//res.emplace_back(i);
			res++;
			if (i * i != n) res++;
		}
	}
	//sort(res.begin(), res.end());
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int ans = 0;
	for (int i = 1; i <= N; i+=2) {
		if(divisor(i) == 8) ans++;
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
    
    int a, b, k;
    std::vector<int> ans;

    std::cin >> a >> b >> k;

    for(int i = 1; i <= 100; i++){
        if(a % i == 0 && b % i == 0) ans.emplace_back(i);
    }

    std::sort(ans.begin(), ans.end(), std::greater<int>());

    std::cout << ans[k - 1] << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#モンスター数
n = int(input())

#モンスターiの体力:mon[i]
mon = list(map(int, input().split()))

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

ans = mon[0]
for i in range(1,n):
    ans = gcd(ans,mon[i])

print(ans)

Measured memory_bytes: 14252
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, k, d = map(int, input().split())
    if x == 0:
        if k % 2 == 0:
            print(abs(x))
        else:
            r = abs(abs(x) - d)
            print(r)
    elif abs(x) < d:
        if k % 2 == 0:
            print(abs(x))
        else:
            print(abs(abs(x) - d))
    else:
        t1 = abs(x) // d
        if t1 > k:
            r = abs(x) - k * d
            print(r)
        else:
            k -= t1
            x = abs(x) - t1 * d
            if k % 2 == 0:
                print(x)
            else:
                print(abs(x - d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9228
import std.algorithm,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

N gcd(N)(N a, N b) if (isNumeric!N || is (N == BigInt)) { return a ? gcd(b % a, a) : b; }
N lcm(N)(N a, N b) if (isNumeric!N || is (N == BigInt)) { return a / gcd(a, b) * b; }

void main() {
  long N = readln.chomp.to!long;
  long[] T;
  foreach (_; 0..N) {
    T ~= readln.chomp.to!long;
  }
  long ans = T[0];

  foreach (long t; T[1..$]) {
    ans = lcm(ans, t);
  }

  writeln(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;

int main() {
    int n;cin>>n;
    ll d;scanf("%lld",&d);
    int res=0;
    for(int i=0;i<n;i++) {
        ll x,y;
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d) {
            res++;
        }
    }
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
struct node{
	long long x,y;
}a[10];
double s;

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].x>>a[i].y;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			s=s+sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
		}
	}
	printf("%.10lf",s/n);
}

Measured memory_bytes: 256
#include<cstdio>
 
 int main(){
     int N = 0;
     scanf("%d",&N);
     long long p = 1;
     //printf("%d\n",10^9+7);
     for(int i=1;i<=N;i++){
         p = (p*i)%(1000000007);
     }   
     printf("%lld\n",p);
     return 0;
 }

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

struct P{
	int t;
	int s;
	int d;
};

int cmp(const void *a,const void *b){
	struct P *tmp1 = (struct P *)a;
	struct P *tmp2 = (struct P *)b;
	return tmp1->t - tmp2->t;
}

int main(void){
	int n, m, count, i, p[20000];
	struct P data[20000];
	while(1){
		scanf("%d%d",&n,&m);
		if(n == 0 && m == 0)
			break;
		memset(p,0,sizeof(p));
		p[0] = 1;
		for(i = 0;i < m;i++)
			scanf("%d%d%d",&data[i].t,&data[i].s,&data[i].d);
		qsort(data,m,sizeof(data[0]),cmp);
		for(i = 0;i < m;i++){
			if(p[data[i].s - 1])
				p[data[i].d - 1] = 1;
		}
		count = 0;
		for(i = 0;i < n;i++)
			if(p[i]) count++;
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1620
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;


string S;
ll N,K,ans;
ll A, B, C;


int main() {

	cin >> A>>B;

	cout << max(max(A + B, A - B), A*B) << endl;






	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
  string s;
  cin>>s;
  int c1=0,c2=0;
  REP(i,s.size()){
    if(i%2==0){
	  if(s[i]=='0')c2++;
      else c1++;
    }else{
      if(s[i]=='0')c1++;
      else c2++;
    }
  }
  cout<<min(c1,c2)<<endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a > b && a > c){
        printf("%d\n", b*c/2);
    }
    else if(b > a && b > c){
        printf("%d\n", a*c/2);
    }
    else{
        printf("%d\n", a*b/2);
    }


}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && x <= a + b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#coding: utf-8
n=int(input())
s=input()
origin=[]
origin=list(s)
s1=[]
s2=[]
i=0
j=0
k=0
a=0
an=0
while(i<=n-1):
    while(j<=i):
        s1.append(origin[j])
        j=j+1
    while(j<=n-1):
        s2.append(origin[j])
        j=j+1
    j=0
    s1=list(set(s1))
    s2=list(set(s2))

    while(j<=len(s1)-1):
        while(k<=len(s2)-1):
            if(s1[j]==s2[k]):
                a+=1
            k+=1
        k=0
        j+=1
    j=0
    i+=1
    s1=[]
    s2=[]
    if(an<a):
        an=a
    a=0
print(an)

Measured memory_bytes: 3064
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

/* subroutines */

int num(string &s, int &pos) {
  return (s[pos++] - '0');
}

int term(string &s, int &pos) {
  int n0 = num(s, pos);
  while (pos < s.size() && s[pos] == '*') {
    pos++; // '*'
    int n1 = num(s, pos);
    n0 *= n1;
  }
  return n0;
}

int expr(string &s, int &pos) {
  int t0 = term(s, pos);
  while (pos < s.size() && s[pos] == '+') {
    pos++; // '+'
    int t1 = term(s, pos);
    t0 += t1;
  }
  return t0;
}

int ltor(string &s, int &pos) {
  int n0 = num(s, pos);
  while (pos < s.size()) {
    char op = s[pos++]; // '+' or '*'
    int n1 = num(s, pos);
    n0 = (op == '+') ? n0 + n1 : n0 * n1;
  }
  return n0;
}

/* main */

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

  int pos = 0;
  int e = expr(s, pos);

  pos = 0;
  int lr = ltor(s, pos);
  //printf("%d %d\n", e, lr);

  char ans = 'I';
  if (bans == e && bans != lr) ans = 'M';
  else if (bans != e && bans == lr) ans = 'L';
  else if (bans == e && bans == lr) ans = 'U';

  printf("%c\n", ans);
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

int main(void) {
  int N, tmp, Sn = 0;
  cin >> N;
  tmp = N;
  while (tmp > 0) {
    Sn += tmp % 10;
    tmp = tmp / 10;
  }
  if (N % Sn == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
// AOJ 1579 Array Update 2
// 2018.3.20 bal4u

#include <stdio.h>
#include <stdlib.h>

// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int x, y, z; int pos; } Q;
Q q[200005]; int M;
int N; int a, d;
int K;

int main()
{
	int i, pos, ans;

	// 入力処理
	N = in(), a = in(), d = in(), M = in();
	for (i = 0; i < M; i++) q[i].x = in(), q[i].y = in(), q[i].z = in();
	K = in();

	// 最初の数列に当たるK番目の位置を命令文の逆順で計算する
	pos = K;
	for (i = M - 1; i >= 0; i--) {
		if (q[i].x == 0) {
			if (q[i].y <= pos && pos <= q[i].z) pos = q[i].y + q[i].z - pos;
		}
		q[i].pos = pos;
	}

	// 命令文の順で値を確定していく
	ans = a + (pos - 1)*d;
//	printf("a=%d, d=%d, pos=%d, ans=%d\n", a, d, pos, ans);
	for (i = 0; i < M; i++) {
		pos = q[i].pos;
		if (q[i].y <= pos && pos <= q[i].z) {
			if (q[i].x == 1) ans++;
			else if (q[i].x == 2) ans >>= 1;
		}
//		printf("[%d] pos=%d, ans=%d\n", i, pos, ans);
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll x = 4 * a * b;
    ll y = c - (a + b);

    cout << (x < y * y && 0 < y ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

ll N, K;
ll bin_search(ll l, ll r, vector<ll> &A){
    ll mid=(l+r)/2+(l+r)%2;
    if(r-l<=1){
        return mid;
    }

    ll cnt=0;
    for(auto &a:A){
        cnt+=a/mid+(a%mid>0)-1;
    }

    if(cnt<=K){
        return bin_search(l, mid, A);
    }else{
        return bin_search(mid, r, A);
    }

}

int main(){
    cin >> N >> K;
    vector<ll> A(N,0);
    for(auto &a:A){
        cin >> a;
    }

    cout << bin_search(0,MOD*MOD,A) << endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s,t;
    cin>>s>>t;

    int len = s.size(); //slen==tlen
    int cnt = 0;
    REP(i,len){
        if(s[i]==t[i]) cnt++;
    }
    int ans = len-cnt;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3836
X,K,D = map(int,input().split())

X = abs(X)

if X >= D:
    temp = X // D
    temp = min(temp, K)
    ans1 = X - D * temp
    if temp == K:
        print(ans1)
        exit(0)
    if (K-temp) % 2 == 0:
        print(ans1)
        exit(0)
    else:
        print(abs(ans1 - D))
    exit(0)
else: # X < D
    if K % 2 == 0:
        print(X)
        exit(0)
    else:
        print(abs(X - D))
        exit(0)


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	int b[9]={};
	vector<int> a(n);
	cinf(n,a);
	for(int i=0;i<n;i++){
		if(a[i]/400<8){
			b[a[i]/400]++;
		}
		else b[8]++;
	}
	int cnt=0;
	for(int i=0;i<8;i++){
		if(b[i])cnt++;
	}
	cout <<max(1,cnt)<< " "<<cnt+b[8]<< endl;
}

Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;
 
int n,a[168],res;

int main(){FAST;    
    cin >> n;
    forp(i ,0 ,n)
        cin >> a[i];
    forp(i ,0 ,n)
        forp(j ,0 ,n)
            res = max(res ,abs(a[i] - a[j]));
    out(res);
}
 










Measured memory_bytes: 256
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[1]!=a[2]:
    cnt=a[2]-a[1]
    a[0]+=cnt
    a[1]+=cnt
if 1==(a[1]-a[0])%2:
    a[1]+=1
    a[2]+=1
    cnt+=1
if a[0]!=a[1]:
    n=int((a[1]-a[0])/2)
    cnt+=n
    #a[0]+=(n*2)
print(cnt)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		double d = sc.nextDouble();
		long qd = (long) Math.pow(Math.floor(Math.sqrt(d)), 2);

		System.out.println(qd);
	}
}


Measured memory_bytes: 23124