akhauriyash/Code-Regression huggingface dataset:
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 100;
int occ[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	int maxi = 0;
	for(int i = 1;i <= n;i++) {
		int x;
		cin>>x;
		occ[x]++;
		maxi = max(maxi, x);
	}
	int length = maxi + 1;
//	cout<<maxi<<" "<<length<<endl;
	bool bisa = 1;
	for(int i = maxi;i >= length / 2;i--) {
		if(i == length / 2) {
			if(length % 2 == 1) {
				if(occ[length / 2] != 1) bisa = 0;
			} else {
				if(occ[length / 2] != 2) bisa = 0;
			}
		} else {
			if(occ[i] < 2) bisa = 0;
			occ[i] -= 2;
		}
	}
	if(bisa) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split()) #KはN以下
P = list(map(int,input().split()))
for i,p in enumerate(P):
    P[i] = (p+1)/2
q = [0]
for p in P:
    q.append(q[-1]+p)
s,e = 0,K
ans = q[K]-q[0]
while e<len(q):
    ans = max(ans,q[e]-q[s])
    s += 1
    e += 1
print(ans)



Measured memory_bytes: 25060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.nextLine();
		if (a.length() <= 20) {
			StringBuffer buffer = new StringBuffer(a);
			System.out.println(buffer.reverse());
		}
	}
}

Measured memory_bytes: 25956
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;
int dp[100][NUM];
// dp[x][y]  = no of ways of distributing y candies till position x
/* bases Cases
    dp[x][0] = 1 // at any position not giving candy to someone
    dp[0][y] = 1
    dp[x][y] = dp[x-1][y] + dp[x-1][y-1] + dp[x-1][y-2] + .. + dp[x-1][y-a[x]] 
*/
int a[100],n,k;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        cin >> n >> k;
        FOR(i,0,n){
            cin >> a[i];
        }
        FOR(i,0,a[0]+1)
            dp[0][i] = 1;
        FOR(i,1,n){
            vector<int> ps(k+1,0);
            ps[0] = dp[i-1][0];
            FOR(j,1,k+1)
                ps[j] = (ps[j-1] + dp[i-1][j]) % mod;
            FOR(j,0,k+1){
                if(j > a[i])
                    dp[i][j] = (ps[j] - ps[j-a[i]-1] + mod) % mod;
                else 
                    dp[i][j] = ps[j];
            }
        }
        cout << dp[n-1][k];
    }   
}

Measured memory_bytes: 82832
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define INF (ll)1e18
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}
ll gcd(ll a, ll b)
{
    ll c;
    
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    
    return a;
}
int main(){
    ll t;
    in(t);
    ll a,b,c,d;
    rep(i,0,t){
        in(a,b,c,d);
        if(a<b){out("No");continue;}
        if(a>c)a-=(a-c+b-1)/b*b;
        if(a<0){out("No");continue;}
        if(b>d){out("No");continue;}
        if(b==d){out("Yes");continue;}
        ll GCD=gcd(b,d);
        a+=(c+1-a+GCD-1)/GCD*GCD;
        if(a>=b)out("Yes");
        else out("No");
    }
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define i_64 long long
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    std::map<i_64, pair<i_64, i_64>> m;
    for (i_64 i = 0; i < 1000; i++) {
        for (i_64 j = 0; j < 1000; j++) {
            i_64 x = i * i * i * i * i;
            i_64 y = j * j * j * j * j;
            m[x + y] = {i, -1 * j};
            m[abs(x - y)] = {max(i, j), min(i, j)};
        }
    }
    i_64 n;
    cin >> n;
    cout << m[n].first << " " << m[n].second << "\n";
	return 0;
}

Measured memory_bytes: 66096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

using P=pair<int,int>;
int main(){
    int n;
    cin >> n;
    //コンテナはmapとし、キー＝都市名、pairのfirst=点数、pairのsecond=番号とする
    map<string, vector<P>> mp;
    rep(i,n){
        string s;
        int p;
        cin >> s >> p;
        //map.find(x)はxと等価なキーの要素を検索する
        //map.find()はキーが見つからない場合にはendを返す
        //つまり!=mp.end()は「すでにその市があるなら」という意味
        if(mp.find(s) != mp.end()){
            mp[s].push_back(P(p,i+1));
        }
        else{
            mp[s]=vector<P>{P(p,i+1)};
        }
    }
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        //->は関節メンバ演算子 ドットと大体同じ
        sort(mp[itr->first].rbegin(),mp[itr->first].rend());
        for(P x:mp[itr->first]){
            cout << x.second << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	int x;
	cin >> x;
	int c = 100;
	int ans = 0;
	while (c < x) {
		c += c / 100;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3184
#include <iostream>

using namespace std;

const int MAX = 1400;

bool Graph[MAX+1][MAX+1];
int h,w;

int A[MAX+1][MAX+1];

int main() {
	cin >> h >> w;
	int ans = -1;
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cin >> Graph[i][j];
			if (Graph[i][j]) {
				A[i][j] = 0;
			} else {
				A[i][j] = 1;
			}
			ans = max(ans,A[i][j]);
 		}
	}

	//开始动态规划
	for (int i=1; i<h; i++) {
		for (int j=1; j<w; j++) {
			if (Graph[i][j]) {
				A[i][j] = 0;
			} else {
				A[i][j] = min(A[i-1][j-1],min(A[i-1][j],A[i][j-1])) + 1;
			}
			ans = max(ans,A[i][j]);
		}
	}
	cout << ans * ans << endl;
	return 0;
}


Measured memory_bytes: 12652
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,c,b;
    scanf("%d%d%d",&a,&b,&c);
    if(c<=b&&c>=a)
    {
    printf("Yes");
    }
    else
    {
    printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<vector<pair<int, int>>> G(N);
    vector<bool> ans(N), visited(N);
    for (int i = 0; i < N-1; i++) {
        int u, v, w; cin >> u >> v >> w; u--, v--;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }
    function<void(int, bool)> recur = [&](int node, bool color) {
        ans[node] = color;
        visited[node] = true;
        for (auto p : G[node]) {
            if (!visited[p.first]) {
                recur(p.first, color ^ (p.second % 2 == 1));
            }
        }
    };
    recur(0, false);
    for (auto a : ans) cout << "01"[a] << '\n';
    return 0;
}


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

int main(){
	int x; cin >> x;
	vector<bool> expo(x+1);
	expo[1] = 1;
	for(int b= 2; b <= x; ++b){
		int v = b * b;
		while(v <= x){
			expo[v] = 1;
			v *= b;
		}
	}
	for(int i = x; i >= 1; i--){
		if(expo[i]) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, k = map(int, input().split())
    print("YES" if n >= 2*k-1 else "NO")
if __name__ == "__main__":
    main() #endline===============================================

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

int main() {
    int m,n_min,n_max;
    while (true) {
        cin >> m >> n_min >> n_max;
        if (m == 0 && n_min == 0 && n_max == 0) {
            break;
        }
        vector<int> P(m);
        rep(i, m) {
            cin >> P[i];
        }
        int diff = 0;
        int ans = 0;
        repi(i, n_min, n_max+1) {
            if ( (P[i-1] - P[i]) >=  diff) {
                diff = P[i-1] - P[i];
                ans = i;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3000
#include<iostream>
using namespace std;
int main(){
  int z,g,max,maxd;
  char a[5]={'A','B','C','D','E'};
  while(cin>>z>>g){
    if(z==0&&g==0) break;
    max = z + g;
    maxd = 0;
    for(int i=1;i<=4;i++){
      cin >> z >> g;
      if(z+g>max){
	max = z+g;
	maxd = i;
      }
    }
    cout << a[maxd] << ' ' << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>
#include <set> 
#include <map> 

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int n, l;
	cin >> n >> l;
	vector<string> str(n);
	string tmp;
	REP(i, n) {
		cin >> str[i];
	}
	FOR(i, 1, n) FOR(j, 1, n) {
		if (str[j - 1] > str[j]) { swap(str[j - 1], str[j]); }
	}
	REP(i, n) {
		cout << str[i];
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int b,c,d;
  b = a / 3600;
  a = a - b * 3600;
  c = a / 60;
  a = a - c * 60;
  d = a;
  cout << b << ':' << c <<':' <<d <<endl;
}


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

int main(){
    int a,b,c,t;
    cin >> a >> b >> c;
    if (a > b){
        t = a;
        a = b;
        b = t;
    }
    if (b > c){
        t = b;
        b = c;
        c = t;
    }
    if (a > b){
        t = a;
        a = b;
        b = t;
    }
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


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

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<long long> a_sub;
    vector<vector<long long> > a;
    long long i, j;
    for(j = 0; j <= W; j++){
        a_sub.push_back(0);
    }
    for(i = 0; i <= H; i++){
        a.push_back(a_sub);
    }
    string S;
    const char *s = NULL;
    for(i = 1; i <= H; i++){
        cin >> S;
        s = S.c_str();
        for(j = 1; j<= W; j++){
            if(s[j-1] == '#') a[i][j] = 1;
        }
    }
    vector<long long> b_sub;
    vector<vector<long long> > b;
    for(j = 0; j <= W; j++){
        b_sub.push_back(0);
    }
    for(i = 0; i <= H; i++){
        b.push_back(a_sub);
    }
    for(i = 2; i <= H; i++){
        if(a[i-1][1] == 1 && a[i][1] == 0) b[i][1] = b[i-1][1] + 1;
        else b[i][1] = b[i-1][1];
    }
    for(j = 2; j <= W; j++){
        if(a[1][j-1] == 1 && a[1][j] == 0) b[1][j] = b[1][j-1] + 1;
        else b[1][j] = b[1][j-1];
    }
    long long bwr;
    long long bwu;
    for(i = 2; i <= H; i++){
        for(j = 2; j <= W; j++){
            if(a[i][j-1] == 1 && a[i][j] == 0) bwr = 1;
            else bwr = 0;
            if(a[i-1][j] == 1 && a[i][j] == 0) bwu = 1;
            else bwu = 0;
            b[i][j] = min(b[i][j-1]+bwr,b[i-1][j]+bwu);
        }
    }
    if(a[H][W] == 1) b[H][W] = b[H][W] + 1;
    cout << b[H][W] << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 632
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const int maxn = 3030;

int dp[maxn][maxn];
pair<int, int> p[maxn][maxn];

string s, t;

string ans;

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

  cin >> s >> t;

  for (int i = 1; i <= s.size(); i ++)
    for (int j = 1; j <= t.size(); j ++)
      {
	if (dp[i - 1][j] >= dp[i][j])
	  dp[i][j] = dp[i - 1][j], p[i][j] = {i - 1, j};
	if (dp[i][j - 1] >= dp[i][j])
	  dp[i][j] = dp[i][j - 1], p[i][j] = {i, j - 1};
	if (s[i - 1] == t[j - 1] and dp[i - 1][j - 1] + 1 >= dp[i][j])
	  dp[i][j] = dp[i - 1][j - 1] + 1, p[i][j] = {i - 1, j - 1};
      }

  for (int i = s.size(), j = t.size(); i and j; )
    {
      if (p[i][j] == make_pair(i - 1, j - 1))
	ans += s[i - 1];
      auto P = p[i][j];
      i = P.first, j = P.second;
    }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 107520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int a, b, x;
  cin >> x >> a >> b;
  if (a >= b)
    cout << "delicious" << endl;
  else
    cout << (b - a <= x ? "safe" : "dangerous") << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

int p, q, a, n;

int solve(int num, int denom, int cnt, int idx)
{
  if(cnt > n || denom > a) return 0;
  if(num*q == denom*p) return 1;
  int ret = 0;
  for(int i = idx; denom*i <= a; i++) {
    ret += solve(num*i+denom, denom*i, cnt+1, i);
  }
  return ret;
}

int main()
{
  while(cin >> p >> q >> a >> n, p) {
    cout << solve(0, 1, 0, 1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
int x,y;
int main()
{
	cin>>x>>y;
	if((y-x*2)/2>=0&&(y-x*2)%2==0&&(y-x*2)/2<=x)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

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

int main() {
	int N, M;
	int x = 0, y = 0, z = 0;
	int s[9] = { 0 };
	int c[9] = { 0 };
	int ans = 0;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> s[i] >> c[i];
		if (N == 3 && s[i] == 1 && c[i] == 0) {
			cout << -1;
			return 0;
		}
		else if (N == 2 && s[i] == 1 && c[i] == 0) {
			cout << -1;
			return 0;
		}
		if (s[i] == 1) {
			x = c[i];
		}
		else if (s[i] == 2) {
			y = c[i];
		}
		else {
			z = c[i];
		}
	}
	for (int i = 0; i < M-1; i++) {
		for (int j = i; j < M; j++) {
			if (s[i] == s[j]&&c[i]!=c[j]){
					cout << -1;
					return 0;
			}
		}
	}
	if (N == 3) {
		ans = x * 100 + y * 10 + z;
	}
	else if (N == 2) {
		ans = x * 10 + y;
	}
	else {
		ans = x;
	}
	if (N == 3 && x== 0) {
		ans += 100;
	}
	if (N == 2 && x == 0) {
		ans += 10;
	}
	if (N == 1 && x == 0) {
		ans = 0;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, x = 0;
  cin >> a; 
  if (a / 1000 == 2) {
    x++;
  }
  if (a / 100 % 10 == 2) {
    x++;
  }
  if (a / 10 % 10 == 2) {
    x++;
  }
  if (a % 10 == 2) {
    x++;
  }
  cout << x;
}

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

int main(){
    long long n;
    cin>>n;
    long long ans=0;
    for(long long i=1;i<=n;i++){
        if(i%3==0||i%5==0){
            continue;
        }
        ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long n;
    cin >> n;
    vector<long> vec;
    for (int i = 1, a; i <= n; ++i) {
        cin >> a;
        if (i < a) {
            cout << -1 << '\n';
            return 0;
        }
        vec.insert(vec.begin() + a - 1, a);
    }
    for (int i : vec) {
        cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>  
using namespace std;  
int main() { 	
	int a,b,c; 	
	scanf("%d %d %d", &a, &b, &c); 	
	if(b>=c){
			printf("delicious");
	}
	else if((a+b)-c>=0){
		printf("safe");
	}
	
	else{
		printf("dangerous");
	}
	
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	long n, k;
	cin >> n >> k;
	long num = k * pow(k-1, n-1);
	cout << num << '\n';
	
	return 0;
}


Measured memory_bytes: 256
public class
Main
{
  @SuppressWarnings("unchecked")
  public void
  run (
    java.io.InputStream in,
    java.io.PrintStream out
    )
  {
    java.util.Scanner sc = new java.util.Scanner ( in );
    java.util.List[ ] G;
    int[ ] res;
    int n, m;
    int i;

    n = sc.nextInt ( );
    m = sc.nextInt ( );

    G  = new java.util.List[ n ];
    for ( i = 0; i < G.length; ++i )
      G[ i ] = new java.util.LinkedList ( );
    for ( i = 0; i < m; ++i )
    {
      int s, t;

      s = sc.nextInt ( );
      t = sc.nextInt ( );
      G[ s ].add ( t );
    }

    res = topologicalSort ( convertGraph ( G ) );
    for ( i = 0; i < res.length; ++i )
      out.println ( res[ i ] );

    sc.close ( );
  }

  /** ??°?????????List ??¨???????¨?????????????????????? */
  private static int[ ][ ]
  convertGraph (
    java.util.List[ ] G
    )
  {
    int[ ][ ] r = new int[ G.length ][ ];
    java.util.Iterator it;
    int i, j;
   
    for ( i = 0; i < r.length; ++i )
    {
      r[ i ] = new int[ G[ i ].size ( ) ];
      for ( j = 0, it = G[ i ].iterator ( ); it.hasNext ( ); ++j )
        r[ i ][ j ] = ( (Integer)it.next ( ) ).intValue ( );
    }
   
    return ( r );
  }

  private static int[ ]
  topologicalSort (
    int[ ][ ] G
    )
  {
    java.util.Queue<Integer> lis = new java.util.LinkedList<Integer> ( );
    int[ ] deg = new int[ G.length ];
    int[ ] res = new int[ G.length ];
    int sp = 0;
    int i, j;

    for ( i = 0; i < G.length; ++i )
    for ( j = 0; j < G[ i ].length; ++j )
      ++deg[ G[ i ][ j ] ];

    for ( i = 0; i < G.length; ++i )
    {
      lis.add ( i );
      while ( !lis.isEmpty ( ) )
      {
        final int s = lis.poll ( );
        if ( deg[ s ] == 0 )
        {
          res[ sp++ ] = s;
          deg[ s ] = -1;
          for ( j = 0; j < G[ s ].length; ++j )
          {
            --deg[ G[ s ][ j ] ];
            lis.add ( G[ s ][ j ] );
          }
        }
      }
    }

    return ( res );
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( System.in, System.out );
  }
}

Measured memory_bytes: 73212
#include<stdio.h>

int main(){
  while(1){
    int c, r, i, j, k;
    int field[10][10000], res = 0;
    scanf("%d%d", &c, &r);
    if(c == 0 && r == 0){
      return 0;
    }
    for(i = 0;i < c;i++){
      for(j = 0;j < r;j++){
	scanf("%d", field[i] + j);
      }
    }
    for(i = 0;i < 1 << c;i ++){
      int sum = 0;
      for(j = 0;j < r;j++){
	int col = 0;
	for(k = 0;k < c;k++){
	  int uragaesi = (i >> k) & 1;
	  if(field[k][j] == uragaesi){
	    col++;
	  }
	}
	if(c - col > col){
	  col = c - col;
	}
	sum += col;
      }
      if(res < sum){
	res = sum;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 992
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <string>

using namespace std;

int main(){
 int n, m;
 cin >> n >> m;
 vector <double> a(n);
 for (int i = 0; i < n; i++)
  cin >> a[i];
 double suma = 0;
 for (int i = 0; i < n; i++)
  suma += a[i];
 double potrebni = suma/4;
 potrebni /= m;
 int moguci = 0;
 for (int i = 0; i < n; i++)
  if (a[i] >= potrebni)
   moguci++;
 if (moguci >= m)
  cout << "Yes";
 else
  cout << "No";
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a,b int
	var x float64
	fmt.Scan(&a,&b)
	
	
	if (a + b) % 2 == 0 {
		x = float64((a + b) / 2)
	} else {
		x = float64((a + b) / 2 + 1)
	}
	
	fmt.Println(int(x))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N) { cin >> A.at(i); }
    REP(i, N) { cin >> B.at(i); }

    int ans = INF;
    int bit = 0;
    REP(bit, 1 << N) {
        vector<pair<int, int>> even, odd;
        int mask = 1;
        REP(i, N) {
            if (mask & bit) { // ビットが立てば裏
                if (i % 2 == 0) {
                    odd.push_back(make_pair(B[i], i));
                } else {
                    even.push_back(make_pair(B[i], i));
                }
            } else {
                if (i % 2 == 0) {
                    even.push_back(make_pair(A[i], i));
                } else {
                    odd.push_back(make_pair(A[i], i));
                }
            }
            mask = mask << 1;
        }

        // 遷移先が偶数になるものは (N + 1) / 2 枚、奇数は N / 2 枚
        if (!((even.size() == (N + 1) / 2) && (odd.size() == N / 2))) {
            continue;
        }

        // 偶奇で分けてソート
        sort(ALL(even));
        sort(ALL(odd));

        // 全体として広義単調増加か確認
        vector<pair<int, int>> whole;
        REP(i, N) {
            if (i % 2 == 0) {
                whole.push_back(even[i / 2]);
            } else {
                whole.push_back(odd[i / 2]);
            }
        }
        bool flag = false;
        REP(i, N - 1) {
            if (whole[i].first > whole[i + 1].first) {
                flag = true;
                break;
            }
        }
        if (flag) {
            continue;
        }

        // 転倒数の計算（もとの並び方に戻して計算する）
        int t = 0;
        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if (whole[j].second > whole[j + 1].second) {
                    swap(whole[j], whole[j + 1]);
                    t++;
                }
            }
        }

        chmin(ans, t);
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 384
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
min=13*100000

for i in range(2**n):
    s=0
    m1=[0 for i in range(m)]
    for j in range(n):
        if (i>>j&1):
            s+=a[j][0]
            for k in range(m):
                m1[k]+=a[j][k+1]
    for j in range(m):
        if m1[j]<x:
            break
    else:
        if s<min:
            min=s
if min!=13*100000:
    print(min)
else:
    print(-1)

Measured memory_bytes: 9224
#include <stdio.h>

int main() {
  int N, num = 0, i;
  scanf("%d", &N);
  int a[N];
  for(i = 0; i < N; i++) scanf("%d", &a[i]);
  
  for(i = 0; i < N; i += 2) {
    if (a[i] % 2 ==1) num++;
  }
  
  printf("%d", num);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {

    //freopen(" E:\\workspace\\CLionProjects\\demo\\index.txt","r",stdin);
    int x,y,divisor=1;

    int maxDiver=2000;
    vector<int >diverList;
    diverList.push_back(1);
    diverList.push_back(2);
    for(int i=3;i<maxDiver;i++){
        bool  flag=true;
        for(int j=2;j<sqrt(i);j++){
            if(i%j==0){
                flag=false;
                break;
            }
        }
        if(flag)diverList.push_back(i);
    }
    int length=diverList.size();
    cin>>x>>y;

    for(int i=1;i<length;){
        if(x%diverList[i]==0&&y%diverList[i]==0){
            divisor*=diverList[i];
            x=x/diverList[i];
            y=y/diverList[i];
        } else{
            i++;
        }
    }
    cout<<divisor<<endl;

    return 0;
}

Measured memory_bytes: 3160
package main

import "fmt"


func main() {

	var A int
	fmt.Scan(&A)
	
	var B int
	fmt.Scan(&B)
	
	var C int
	fmt.Scan(&C)
	
	var X int
	fmt.Scan(&X)
	
	count := 0;
	
	for i := 0; i < A + 1; i++ {
		for j := 0; j < B + 1; j++ {
			for k := 0; k < C + 1; k++ {
				if 500*i + 100*j + 50*k == X {
					count++
				}
			}
		}
	}
	
	fmt.Println(count)
				
}

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

void dfs(ll i){
  if(i > 3234566667) return ;
  A.push_back(i) ;
    if( i%10-1 >= 0 )dfs(10*i + i%10-1 ) ;
	dfs(10*i + i%10   ) ;
    if( i%10+1 < 10 )dfs(10*i + i%10+1 ) ;
}
int main() {
  dfs(1) ;
  dfs(2) ;
  dfs(3) ;
  dfs(4) ;
  dfs(5) ;
  dfs(6) ;
  dfs(7) ;
  dfs(8) ;
  dfs(9) ;
  sort(A.begin(),A.end()) ;
  int K ;
  cin >> K ;
  //cout << A.size() << endl;
  cout <<A[K-1] << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdlib>

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,j,k) for(int i=j;i<(int)(k);++i)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();++i)
#define all(x) (x).begin(),(x).end()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 99999999;
const double EPS = 1e-9;

struct UnionFind
{
    vi par,rank;
    UnionFind(int n){
        par.resize(n),rank.resize(n,0);
        rep(i,n) par[i]=i;
    }

    int find(int x){
        return par[x]==x ? x : par[x]=find(par[x]);
    }

    void unite(int x, int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return find(x)==find(y);
    }
};

struct Edge
{
    int s,d,c;
    Edge(int s, int d, int c) : s(s),d(d),c(c){}
    bool operator<(const Edge &x) const{
        return c < x.c;
    }
};

int n,m,a,b,c;

int main()
{
    while(cin>>n,n){
        cin >> m;
        vector<Edge> ve;

        rep(i,m){
            scanf("%d,%d,%d",&a,&b,&c);
            ve.pb(Edge(a,b,c));
        }

        UnionFind uf(n);
        sort(all(ve));

        int ans=0;
        rep(i,ve.size()){
            if(uf.same(ve[i].s,ve[i].d)) continue;
            ans+=ve[i].c/100-1;
            uf.unite(ve[i].s,ve[i].d);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n+m==15)
    {
        printf("+");
    }
    else if(n*m==15)
    {
        printf("*");
    }
    else
    {
        printf("x");
    }
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int i;
	bool t = 0;
	for (i = 0; i < s.length(); i++) {

		if (s.at(i) == '7') {
			t = 1;
		}

	}
	if (t == 1) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;

}


Measured memory_bytes: 3628
#include<stdio.h>

int main()
{
  int a, b;
  int i, j;

  scanf("%d", &a);
  for(i=1; i<=9; i++) {
    for(j=1; j<=9; j++) {
      b = i * j;
      if(a == b) {
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end());
#define IN(n,m)  (!(m.find(n) == m.end()))
#define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
#define ENUM_v(vec) for (auto e : vec)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
using namespace std;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<long> VI;
typedef vector<VI> VVI;

template <typename T,typename D>
class Tree {
private:
	typedef struct {T node;D dist;T prev;} P;
	typedef pair<T,D> pr;
	typedef vector<pr> VP;
	vector<VP> E;
	T V;
public:
	Tree() : V(0){}
	Tree(T v) : V(v),E(v) {}

	void addEdgeDirected(long start,long goal,long weight){
		E[start].push_back(pr(goal,weight));
	}

	void addEdgeUndirected(long start,long goal,long weight){
		E[start].push_back(pr(goal,weight));
		E[goal].push_back(pr(start,weight));
	}

	pair<T,D> getDiameter(void){
		stack<P> st;
		pair<T,D> farV(V-1,0);
		st.push(P {V-1,0,-1});
		while (!st.empty()) {
			P e = st.top();
			st.pop();
			if (farV.second < e.dist) farV = pair<T,D> (e.node,e.dist);
			for ( auto &p : E[e.node]) {
				if (p.first != e.prev) st.push(P {p.first,e.dist+p.second,e.node});
			}
		}
		pair<T,D> farV2(farV.first,0);
		st.push(P {farV.first,0,-1});
		while (!st.empty()) {
			P e = st.top();
			st.pop();
			if (farV2.second < e.dist) farV2 = pair<T,D> (e.node,e.dist);
			for ( auto &p : E[e.node]) {
				if (p.first != e.prev) st.push(P {p.first,e.dist+p.second,e.node});
			}
		}

		return farV2;
	}
};

int main(void) {
	long N,s,t,w;
	cin >> N;
	Tree<long,long> tr(N);
	REP(i,N-1){
		cin >> s >> t >> w;
		tr.addEdgeUndirected(s,t,w);
	}
	auto p = tr.getDiameter();
	cout << p.second << endl;
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v)
{
    for (auto& e : v) {
        is >> e;
    }
    return is;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> X(N);
    constexpr int MAX = 100000;
    vector<int> num(MAX + 1, 0);
    vector<int> mnum(M, 0);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        num[X[i]]++;
        mnum[X[i] % M]++;
    }
    vector<int> pnum(M);
    for (int i = 0; i <= MAX; i++) {
        num[i] /= 2;
        pnum[i % M] += num[i];
    }

    if (M == 1) {
        cout << N / 2 << endl;
        return 0;
    } else {
        ll sum = 0;
        for (int i = 0; i + i <= M; i++) {
            if ((i + i) % M == 0) {
                sum += mnum[i] / 2;
            } else {
                if (mnum[i] < mnum[M - i]) {
                    sum += mnum[i];
                    const int res = (mnum[M - i] - mnum[i]) / 2;
                    sum += min(res, pnum[M - i]);
                } else {
                    sum += mnum[M - i];
                    const int res = (mnum[i] - mnum[M - i]) / 2;
                    sum += min(res, pnum[i]);
                }
            }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
n = gets.chomp.to_i;
length_array = gets.chomp.split(" ").map(&:to_i)
sum_length = 0
length_array.each{|length|
  sum_length += length
}
is_polygon = true
length_array.each{|length|
  if (sum_length - length) <= length
    is_polygon = false
    break
  end
}
if is_polygon
  print("Yes\n")
else
  print("No\n")
end

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline
n,m = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p = tuple(p)
chk = [[set(),set()] for i in range(n)]
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True
      
par = [-1]*n
ans = 0
for i in range(m):
  x,y = [int(i) for i in input().split()]
  unite(x-1,y-1)

for i in range(n):
  m = find(i)
  chk[m][0].add(p[i])
  chk[m][1].add(i+1)

for i in range(n):
  ans += len(chk[i][0] & chk[i][1])
    
print(ans)

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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 

#define ll                     long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define print(x)                cout<<x<<endl
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

 

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
const long long MOD= 1000000007;



void solve(){
    int k; cin>>k;
    ll ans = -1, seven = 0;
    for(int i = 1; i <= k; ++i){
        seven = (seven*10 + 7)%k;
        if(seven == 0){
            ans = i;
            break;
        }
    }
    print(ans);

}
int main()
{
#ifndef ONLINE_JUDGE  
    input_output  
#else   
    fastio
#endif

    int t =1 ;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
#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> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>
#include <iterator>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

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

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    if (a == 1) {
        return b;
    }
    else {
        return b / a * (a - 1);
    }
}

int main()
{
    IO;

    ll n; cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll x = 1;
    rep(i, n) x = lcm(x, a[i]);
    cout << x << endl;

}


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


int main()
{
    int M,D;
    cin >> M >> D;
    int count = 0;
    for(int m = 4; m <= M; ++m)
    {
        for(int d = 12; d <= D; ++d)
        {
            int d1 = d % 10;
            int d10 = d / 10;
            if(d1 >= 2 && d10 >= 2 && d1*d10 == m)
            {
                //cout << m << '/' << d << '\n';
                count += 1;
            }
        }
    }
    cout << count << '\n';
    return 0;
}


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

res = 0
cnt = 0

for i in range(N-1):
  if H[i] >= H[i+1]:
    cnt += 1
    if i == N-2:
      res = max(res,cnt)
  else:
    res = max(res,cnt)
    cnt = 0
    
print(res)

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> table(H,vector<char>(W));
  vector<bool> row(H,false);
  vector<bool> col(W,false);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
      if (table.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << table.at(i).at(j);
        }
      }
      cout << endl;
    }
  }    
}


Measured memory_bytes: 256
X,N=(int(x) for x in input().split())
p=list(map(int,input().split()))
ans_sa=101
ans=-1
for n in range(-1,102):
    if n in p:
        continue
    sa=abs(X-n)
    if sa<ans_sa:
        ans_sa=sa
        ans=n
print(ans)


Measured memory_bytes: 9180
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    string s;
    ll n;
    cin>>s>>n;
    int i;
    for(i=0;i<min(ll(s.size()),n);i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
}


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

template <typename T>
void print(const T &v);

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> as(n + 1), bs(m + 1);
    ll at = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        at += a;
        as[i + 1] = at;
    }
    ll bt = 0;
    for (int i = 0; i < m; i++)
    {
        int b;
        cin >> b;
        bt += b;
        bs[i + 1] = bt;
    }
    int maxi = 0;
    for (int i = 0; i <= n && as[i] <= k; i++)
    {
        // cout << "---" << i << "---" << endl;
        int a = as[i];
        // 二分探索する
        int left = 0, right = m;
        // cout << k - a << endl;
        while (right - left > 1)
        {
            int middle = left + (right - left) / 2;
            if (k - a <= bs[middle])
            {
                right = middle;
            }
            else if (bs[middle] < k - a)
            {
                left = middle;
            }
            else
            {
                cout << "error ocured" << endl;
            }
        }
        if (bs[right] == k - a)
        {
            left = right;
        }
        // cout << left << " : " << right << endl;
        maxi = max(maxi, i + left);
    }
    cout << maxi << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 6356
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  for(int i=0;i<2;i++){
    for(int j=i+1;j<3;j++){
      if(a[i]<a[j])swap(a[i],a[j]);
    }
  }
  cout<<a[0]*10+a[1]+a[2]<<endl;
}

Measured memory_bytes: 256
import math
while True:
	n=int(input())
	if n==0:
		break
	table=list(map(int,input().split()))
	ave=sum(table)/n
	bun=0
	for i in range(n):
		s=(table[i]-ave)**2
		bun+=s
	print(math.sqrt(bun/n))


Measured memory_bytes: 5696
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long N,A[100000],B,sum=0,res=0;
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++){
		cin>>B;
		A[i]-=B;
		if(A[i]<0){
			sum-=A[i];
			res++;
		}
	}
	sort(A,A+N);
	for(int i=N-1;i>=0;i--){
		if(sum>0){
			if(A[i]<=0){cout<<-1<<endl;return 0;}
			sum-=A[i];
			res++;
		}else break;
	}
	if(sum>0)cout<<-1<<endl;
	else cout<<res<<endl;
	return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int calculate(int n){
	int digit_sum = 0;
	while(n > 0){
		digit_sum += n % 10;
		n/=10;
	}
	return digit_sum;
}

int solve(string N){
	int ans = 0;
	REP(i, 0, (int)N.size()) if(N[i] != '9') ++ans;
	
	//if (N.size() == 1) ans = N[0] - '0';
	if (ans == 1 && N[0] != '9') ans = (N[0]-'0')+9*((int)N.size()-1);
	else if( ans == 0) ans = 9*((int)N.size());
	else ans = (N[0]-'0')+9*((int)N.size()-1)-1;
	return ans;
}

int test(int n){
	int m = 0;
	REP(i, 1, n+1){
		int d = calculate(i);
		m = max(d, m);
		//string s(1, i);
		int solution = solve(to_string(i));
		if(m != solution)
			cout<< i << " "  << m << " " << solution << endl;
	}
	
	return m;
}

int main() {
	string N;
	cin >> N;
	
	//test(1000000);
	cout << solve(N);
	
	
	//if(ans == 0) ans=((int)N.size() - 1)*9;
	//cout << ans;
 

}


Measured memory_bytes: 256