akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	ll n,m; cin>>n>>m;
	ll a=0;
	vvl g(n,vl(m));
	vl sum(m);
	rep(i,0,n){
		ll cnt=0;
		rep(j,0,m)cin>>g[i][j],cnt+=g[i][j];
		g[i].push_back(cnt);
		a+=cnt;
	}
	rep(i,0,m){
		ll cnt=0;
		rep(j,0,n){
			cnt+=g[j][i];
		}
		sum[i]=cnt;
	}
	sum.push_back(a);
	rep(i,0,n){
		rep(j,0,m+1){
			cout<<g[i][j];
			if(j!=m)cout<<" ";
		}
		cout << endl;
	}
	rep(i,0,m+1){
		cout<<sum[i];
		if(i!=m)cout<<" ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    int now = 1;
    int res = 0;
    rep(i, N) {
        if(A[i] == now) {
            res++;
            now++;
        }
    }
    res = N - res;
    if(res == N) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N;
  cin >> N;
  int a[N];
  int b[N];
  int c[N-1];

  // データを入れる
  for(int i=0; i < N; i++){
      cin >> a[i];
  }
  for(int i=0; i < N; i++){
      cin >> b[i];
  }
  for(int i=0; i < N - 1; i++){
      cin >> c[i];
  }

  int total = 0;
  int prenum = -100;
  for(int i=0; i < N; i++){
      int num = a[i] - 1;
      total += b[num];
    //   cout << b[num] << endl;
      if(prenum == num - 1){
          total += c[prenum];
        //   cout << c[prenum] << endl;

      }
      prenum = num;
  }
  
  cout << total << endl;

}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    llin(n);
    llin(p);
    if(n==1){
        sal(p);
        return 0;
    }
    ll i=0;
    ll s=1;
    ll c=2;
    while(c*c<=p){
        if(p%c==0){
            p=p/c;
            i++;
        if(i==n){
            i=0;
            s=s*c;
        }
        }else{
            i=0;
            c++;
        }
    }
    if(p%c==0&i==n-1) s*=c;
    sal(s)
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

bool solve(){
    int n,r;
    cin >> n >> r;
    if(!n&&!r) return false;
    int deck[n], deck_[n];
    REP(i,n){ deck[i] = deck_[i] = n-i; }
    REP(ki,r){
        int p, c;
        cin >> p >> c;
        p--;
        REP(ci,c){
            deck_[ci] = deck[p+ci];
        }
        REP(i,n-c){
            deck_[c+i] = deck[i];
        }
        REP(i,n-p-c){
            deck_[p+c+i] = deck[p+c+i];
        }
        REP(i,n){
            deck[i] = deck_[i];
        }
    }
    cout << deck[0] << endl;
    return true;
}

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

    while(solve());
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+10;
int a[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++) {
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for(int i = 1; i < n; i ++) {
        if(a[i] == i) {
            swap(a[i], a[i+1]);
            ans++;
        }
    }
    if(a[n] == n) ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
n = int(input())
w = []
for _ in range(n):
    w.append(input())

judge = len(w) == len(set(w))

for pre, post in zip(w[:-1], w[1:]):
    judge &= pre[-1] == post[0]

if judge:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

vector<pair<long long, long long>> prime_factorize(long long n) {
    vector<pair<long long, long long>> res;
    for(long long p = 2; p * p <= n; ++p) {
        if(n % p != 0)
            continue; //因数じゃない
        int num = 0;
        while(n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if(n != 1)
        res.push_back(make_pair(n, 1)); // nが素数だった場合
    return res;
}

int main() {
    long long N;
    cin >> N;
    vector<long long> cum(N, 0);

    for(int i = 1; i <= N; i++) {
        auto res = prime_factorize(i);
        // cout << i << endl;
        REP(j, res.size()) { cum[res[j].first - 1] += res[j].second; }
    }
    long long ans = 1;
    for(int i = 1; i <= N; i++) {
        ans *= (cum[i - 1] + 1);
        // cout << cum[i] << endl;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        //out.println("AMAN");

        int n = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        int c[] = new int[n];

        for(int i=0;i<n;i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int dp[][] = new int[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];

        for(int i=1;i<n;i++) {
            for(int j=0;j<3;j++) {
                for(int k=0;k<3;k++) {
                    if(j==k) continue;
                    if(k==0) dp[i][k] = Math.max(dp[i][k],dp[i-1][j]+a[i]);
                    else if(k==1) dp[i][k] = Math.max(dp[i][k],dp[i-1][j]+b[i]);
                    else dp[i][k] = Math.max(dp[i][k],dp[i-1][j]+c[i]);
                }
            }
        }
        int res = dp[n-1][0];
        res = Math.max(res,dp[n-1][1]);
        res = Math.max(res,dp[n-1][2]);
        out.println(res);
        out.flush();
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 46832
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <set>
#define ll long long
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
	ll int K,v,i;
    cin >> K;
	queue<ll int> q;
	for(i=1;i<=9;i++){
		q.push(i);
	}
	K--;
	while(K--){
		v=q.front();
		q.pop();
		if(v%10!=0){
			q.push(10*v+v%10-1);
		}
		q.push(10*v+v%10);
		if(v%10!=9){
			q.push(10*v+v%10+1);
		}
	}
	
	cout <<q.front()<< endl;
	return 0;
		
	
}

Measured memory_bytes: 1792
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, M := getInt(), getInt()

	out(N*(N-1)/2 + M*(M-1)/2)
}


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

using namespace std;

struct dat {
	int a,b,c;
};

int G[100][100];

int main() {
	int n,m; cin >> n >> m;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			G[i][j]=1e9;
	for(int i=0;i<n;++i) G[i][i]=0;
	vector<dat> abc(m);
	for(auto &e:abc) {
		cin >> e.a >> e.b >> e.c;
		--e.a; --e.b;
		G[e.a][e.b]=G[e.b][e.a]=e.c;
	}
	for(int k=0;k<n;++k)
		for(int i=0;i<n;++i)
			for(int j=0;j<n;++j)
				G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
	int ans=0;
	for(auto e:abc)
		if(G[e.a][e.b]<e.c) ++ans;
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

const long long Mod = 1000000007;

long long n, k;
long long a[2005], dpp[2005];
long long nex[2005], all[2005];

int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    memset(dpp, 0, sizeof(dpp));
    for(int i = n; i >= 1; i--)
    {
        dpp[a[i]]++;
        nex[i] = 0;
        for (int j = i + 1; j <= n; j++)
        {
            if(a[i] > a[j])
                nex[i]++;
        }
    }
    for (int i = 1; i < 2000; i++)
        dpp[i] += dpp[i-1];
    for(int i = 1; i <= n; i++)
    {
        all[i] = dpp[a[i] - 1];
    }
    long long q = ((k * (k - 1))/2)%Mod;
    long long res = 0;
    for(int i = 1; i <= n; i++)
        res = (res + (nex[i] * k)% Mod + (all[i] * q) % Mod)%Mod;
    cout << res;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int f = 0;
  for(int i = 0; i < s.size(); i++){
    for(int j = i + 1; j < s.size(); j++){
      if (s.at(i) == s.at(j)) f = 1;
    }
  }
  if (f == 0) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}

Measured memory_bytes: 3588
n, a, b = list(map(int, input().split()))

P = 10 ** 9 + 7


def conb(n, r):
    P = 10 ** 9 + 7
    x = 1
    y = 1
    for i in range(n - r + 1, n + 1):
        x = (x * i % P)
    for i in range(1, r + 1):
        y = (y * i % P)
    y_inv = pow(y, P - 2)
    return x * y_inv


def pow(x, n):
    ans = 1
    while (n > 0):
        if (bin(n & 1) == bin(1)):
            ans = (ans * x) % P
        x = (x * x) % P
        n = n >> 1  # ビットシフト
    return ans


print((pow(2, n) - conb(n, a) - conb(n, b) - 1) % P)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int K;
  cin >> K;
  int x = 7 % K;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x * 10 + 7) % K;
    i++;
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 50472
<?php
while (true) {
    list($a, $operator, $b) = getInputStringBothEndsTrimmedSpaces();
    switch ($operator) {
        case '+':
            $result = addingTwoNum($a, $b);
            break;
        case '-':
            $result = subTractTwoNum($a, $b);
            break;
        case '*':
            $result = multiplyTwoNum($a, $b);
            break;
        case '/':
            $result = divideTwoNumAtFloorPoint($a, $b);
            break;
        case '?':
            exit;
    }
    echo $result, PHP_EOL;
}
 
function getInputStringBothEndsTrimmedSpaces()
{
    return explode(' ', trim(fgets(STDIN)));
}
  
function addingTwoNum($a, $b)
{
    return $a + $b;
}
 
function subTractTwoNum($a, $b)
{
    return $a - $b;
}
 
function multiplyTwoNum($a, $b)
{
    return $a * $b;
}
 
function divideTwoNumAtFloorPoint($a, $b)
{
    return floor($a / $b);
}

Measured memory_bytes: 15208
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 100005
int dp[MX];
int main() {
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; ++i)
		cin >> arr[i], dp[i] = INT_MAX;
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < i + k + 1; ++j)
			if(j < n)
				dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));

	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
check=dict()
N,z,d=0,[],0
#ttfは235、chaはabc

def dfs_sub(n,ttf,cha):
    global check,d

    #-1ずつしていく場合
    check[0]=min(check[n]+n*d,check[0])

    #最寄りまで-してく場合
    x1,x2=n//ttf,n%ttf
    if x1 in check:
        if check[x1]>check[n]+x2*d+cha:
            check[x1]=check[n]+x2*d+cha
            dfs(x1)
    else:
        check[x1]=check[n]+x2*d+cha
        dfs(x1)

    #最寄りまで+1してく場合
    x1,x2=n//ttf+1,ttf-n%ttf
    if x1 in check:
        if check[x1]>check[n]+x2*d+cha:
            check[x1]=check[n]+x2*d+cha
            dfs(x1)
    else:
        check[x1]=check[n]+x2*d+cha
        dfs(x1)


def dfs(n):
    global b
    for i,j in zip([2,3,5],b):
        dfs_sub(n,i,j)

t=int(input())
for i in range(t):
    N,*b,d=map(int,input().split())
    z=list(zip([2,3,5],b))
    check={N:0,0:N*d}
    dfs(N)
    print(check[0])


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

int main() {
  int N,X;
  int D=0;
  int count=1;
  cin >> N>>X;

  vector<int> L(N);
  
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }

 
  for (int i = 0; i < N; i++) {
    D=D+L.at(i);
      if(D<=X){count++;}
     }
  
  cout<<count<<endl;
  
  
}

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


int main(){
    int N, K, n;
    cin >> N >> K;
    double ans=0.0;
    for (int i = 1; i <= N; i++){
        if (i >= K){
            ans += 1;
        }
        else{
        n = ceill(log2(double(K) / double(i)));
        ans += pow(2, -n);
        }
    }
    
    printf("%.9lf", ans / N);
    return 0;
}

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

using namespace std;

#define ll       long long

#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)

#define  pfi(x)   printf("%d", x)
#define  pfl(x)   printf("%lld", x)
#define  pfd(x)   printf("%lf", x)
#define  pfc(x)   printf("Case %d: ", x++)
#define  ps       printf(" ")
#define  pn       printf("\n")

#define  pb       push_back
#define  ppb      pop_back
#define  pf       push_front
#define  ppf      pop_front
#define  In       insert
#define  All(a)   a.begin(), a.end()

int dp[100005], n, k, h[100005];

int solve(int pos)
{
	if(pos == n)
		return 0;

	int ret = dp[pos];

	if(ret != -1)
		return ret;

	ret = INT_MAX;
	for(int i = 1; i <= k; i++)
	{
		if(pos + i > n)
			break;
		ret = min(ret, abs(h[pos] - h[pos + i]) + solve(pos + i));
	}
	return dp[pos] = ret;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    memset(dp, -1, sizeof dp);
    sci(n); sci(k);

    for(int i = 1; i <= n; i++)
    	sci(h[i]);

    cout << solve(1);

    return 0;
}

Measured memory_bytes: 5760
#include<iostream>

int main(){
int n,a,b;
 std::cin >> n >> a >> b;
 std::string s;
 std::cin >> s;
 int pass=0,bcnt=0;
 for(int i=0;i<n;i++){
   if(s[i]=='a' && pass<a+b){
     pass++;
     std::cout << "Yes" << std::endl;
   }
   else if(s[i]=='b' && pass<a+b && bcnt<b){
    pass++;
    bcnt++;
    std::cout << "Yes" << std::endl;
   }
   else
    std::cout << "No" << std::endl;
 }
 return 0;
}





Measured memory_bytes: 3732
#include <stdio.h>


int main()
{
    int i[3],a,b;
    scanf("%d %d %d", &i[0],&i[1],&i[2]);
    
    for(a=0;a<2;a++){
        if(i[a]>i[a+1]){
            b=i[a],i[a]=i[a+1],i[a+1]=b;
        }
    }
    
    for(a=0;a<2;a++){
        if(i[a]>i[a+1]){
            b=i[a],i[a]=i[a+1],i[a+1]=b;
        }
    }
    
    
    printf("%d %d %d",i[0],i[1],i[2]);
    printf("\n");
    return 0;
    
}




Measured memory_bytes: 2132
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<int,int> P;
typedef set<int> S;
ll n;
int main(){ 
    int n,m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m) cin>>p[i].first>>p[i].second;
    rep(k,1000){
        int keta = 1;
        int nx = k/10;
        vector<int> d(1,k%10);
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx/=10;
        }
        if(keta != n) continue;//桁数が不一致ならば飛ばす
        reverse(d.begin(),d.end());
        bool  ok =1;
        rep(i,m){
            if(d[p[i].first-1]!=p[i].second) ok=0;
        }
        if(ok) {
            cout<<k<<endl;
            return 0; 
        }
    }
    cout<< -1 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;

map<int, int> used;

bool check(string s)
{
  bool three = false;
  bool five = false;
  bool seven = false;
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i] == '3')
    {
      three = true;
    }else if(s[i] == '5')
    {
      five = true;
    }else if(s[i] == '7')
    {
      seven = true;
    }else{
      return false;
    }
  }
  if(three && five && seven)
  {
    if(used.count(stoi(s)) == 0)
    {
      used[stoi(s)] = 1;
      return true;
    }
  }
  return false;
}

int dfs(string &s, string current, int index)
{
  if(index == s.size())
  {
    if(check(current))
    {
      if(stoi(s) >= stoi(current))
      {
        //cout << current << endl;
        return 1;
      }else{
        return 0;
      }
    }else{
      return 0;
    }
  }
  int count = 0;
  string temp1, temp2, temp3, temp4;
  temp1 = temp2 = temp3 = temp4 = current;
  temp1.push_back('3');
  temp2.push_back('5');
  temp3.push_back('7');
  if(index == 0)
  {
    if(s[index] - '0' >= 7)
    {
      count += dfs(s, temp1, index + 1);
      count += dfs(s, temp2, index + 1);
      count += dfs(s, temp3, index + 1);
      count += dfs(s, temp4, index + 1);
    }else if(s[index] - '0' >= 5)
    {
      count += dfs(s, temp1, index + 1);
      count += dfs(s, temp2, index + 1);
      count += dfs(s, temp4, index + 1);
    }else if(s[index] - '0' >= 3)
    {
      count += dfs(s, temp1, index + 1);
      count += dfs(s, temp4, index + 1);
    }else{
      count += dfs(s, temp4, index + 1);
    }
  }else{
      count += dfs(s, temp1, index + 1);
      count += dfs(s, temp2, index + 1);
      count += dfs(s, temp3, index + 1);
      count += dfs(s, temp4, index + 1);
  }
  return count;
}

int main()
{
  int n;
  cin >> n;
  string ns = to_string(n);
  int result = dfs(ns, "", 0);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <string>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for(ll i=0; i<n; ++i){cin >> a[i];}
    for(ll i=0; i<n-k; ++i){
        bool rate = (a[k+i] > a[i]);
        if(rate){cout << "Yes" << endl;}
        else{cout << "No" << endl;}
    }
    return 0;
}

Measured memory_bytes: 4812
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

int n;
ll a[3005], dp[3005][3005];
const ll inf = 1e15;

ll rek(int l, int r){
	if(l > r)
		return 0;
	ll &ret = dp[l][r];
	if(ret != -1)
		return ret;
	ret = (((r - l + 1) & 1) == (n & 1) ? max(rek(l + 1, r) + a[l], rek(l, r - 1) + a[r]) : min(rek(l + 1, r) - a[l], rek(l, r - 1) - a[r]));
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1 ; i <= n ; ++i){
	cin >> a[i];
}
memset(dp, -1, sizeof(dp));
cout << rek(1, n) << endl;

return 0;
}



Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
using namespace std;
const int MOD = 1e9+7;
int n;
int a[1000];
signed main(){
cin >> n; for(int i = 0; i < 2*n; i++) cin >> a[i];
sort(a, a+2*n);
int res = 0;
for (int i = 0; i < 2*n; i+=2) res += a[i];
cout << res <<"\n";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//std::cout << std::setfill('0') << std::right << std::setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int main(){
  int N,M; cin>>N>>M;
  int x[M]; CINA(x,M);
  if(N>=M){
    cout << "0\n";
  }else{
    sort(x,x+M);
    int d[M-1];
    REP(i,M-1){d[i] = x[i+1]-x[i];}
    sort(d,d+M-1);
    ll r = 0;
    REP(i,M-N){
      r += d[i];
    }
    cout << r << "\n";
  }
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int[] x = new int[N];
		for(int i=0; i<N; i++)
			x[i] = sc.nextInt();
		
		long[][] dp = new long[N+1][50*N+1];
		dp[0][0] = 1;
		for(int i=0; i<N; i++)
			for(int j=i; j>=0; j--)
				for(int k=0; k<=50*i; k++)
					dp[j+1][k+x[i]] += dp[j][k];
		
		long ans = 0;
		for(int i=1; i<=N; i++)
			ans += dp[i][i*A];
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 11208
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
ll a[100010];
ll b[100010];

int main(){

  n = in();
  REP( i , n ){
    a[i] = in();
    b[i] = in();
  }

  ll cur = 0;
  for( int i = n-1; i >= 0; i-- ){
    a[i] += cur;
    ll x = ( b[i] - a[i] % b[i] ) % b[i];
    cur += x;
  }

  printf( "%lld\n" , cur );
  
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  int p = 0;
  long long res = 0;
  for (int i = 0; i < N; i++) {
    int x; cin >> x;
    res += max(p - x, 0);
    p = max(p, x);
  }
  cout << res << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0
int gcd(int x, int y)
{
    int r;

    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    // ユーグリッドの互除法
    while((r = x % y) != 0)  // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}
 int main()
 {
 	int n;
 	cin >> n;
 	int x;
 	cin >> x;
 	for (int i = 0; i < n-1; i++){
 		int y;
 		cin >> y;
 		int z = gcd(x,y);
 		x=z;
 	}
 	cout << x << endl;
 }
 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int s=0,p=0,n,x,t;
  double a;
  scanf("%d",&n);
  for(int i=0;i<n;i++){scanf("%d",&t);s+=t;p+=t*t;}
  a=(double)s/n;
  x=a;
  x+=(a-(double)x)>=0.5;
  printf("%d",n*x*x+p-2*x*s);
}


Measured memory_bytes: 128
using System;
class aoj{
    public static void Main(){
        search s = new search();
        String str1 = Console.ReadLine();
        String str2 = Console.ReadLine();
        bool ans = false;
        for(int i=0; i<str1.Length; i++){
            if(str1[i] == str2[0]){
                ans = ans || s.check(str1, str2, i);
            }
        }
        if(ans){
            Console.WriteLine("Yes");
        }
        else{
            Console.WriteLine("No");
        }
    }
}

class  forw{
    public int forward(int n, int m){
        return (++n)%m;
    }
}
    
class search{
    public bool check(String s1, String s2, int n){
        forw f = new forw();
        bool temp = true;
        for(int i=0; i<s2.Length; i++){
            if(s1[n] == s2[i]){
                temp = temp && true;
            }
            else{
                temp = temp && false;
            }
            n = f.forward(n,s1.Length);
        }
        return temp;
    }
}


Measured memory_bytes: 17864
import java.io.*;
public class Main{
	public static void main(String [] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] st=br.readLine().split(" ");
		int a=Integer.parseInt(st[0]);
		int b=Integer.parseInt(st[1]);
		int c=Integer.parseInt(st[2]);
		int count=0;
		for(int i=a;i<=b;i++){
			if(c%i==0)count++;
		}System.out.println(count);
		}}

Measured memory_bytes: 17088
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

int32_t N, M, X;

int32_t book_cost[12];
int32_t A[12][12];

int32_t minimum_cost;
int32_t look_up[1 << 13];

int32_t Decode(const int32_t tried_book, vector<bool> book_studied) {
  book_studied[tried_book] = true;
  int32_t decoded = 0;
  for (int32_t i = 0; i < N; ++i) {
    decoded += (book_studied[i] ? 1 : 0);
    decoded *= 2;
  }
  return decoded;
}

void Dfs(const int32_t target_book, const int32_t cost_so_far, vector<int32_t> rikaido, vector<bool> book_studied) {
  for (int32_t j = 0; j < M; ++j) {
    rikaido[j] += A[target_book][j];
  }
  book_studied[target_book] = true;
  bool done = true;
  for (const int32_t r : rikaido) {
    done = done && (r >= X);
  }
  const int32_t c_cost = cost_so_far + book_cost[target_book];
  if (done) {
    if (c_cost < minimum_cost) {
      minimum_cost = c_cost;
    }
    return;
  }

  for (int32_t i = 0; i < N; ++i) {
    if (!book_studied[i] && (c_cost + book_cost[i] < minimum_cost)) {
      int32_t decoded = Decode(i, book_studied);
      if (look_up[decoded] == 0) {
        look_up[decoded] = 1;
        Dfs(i, c_cost, rikaido, book_studied);
      }
    }
  }
}

int main() {
  minimum_cost = INT32_MAX;
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cin >> N >> M >> X;

  for (int32_t i = 0; i < N; ++i) {
    cin >> book_cost[i];
    for (int32_t j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }

  vector<int32_t> rikaido(M, 0);
  vector<bool> book_studied(N, false);
  for (int32_t i = 0; i < N; ++i) {
    Dfs(i, 0, rikaido, book_studied);
  }
  if (minimum_cost != INT32_MAX) {
    cout << minimum_cost << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
s = input()
K = int(input())
List = []

alphabet = [chr(i) for i in range(97,97+26)]
n1,n2,n3,n4,n5 = 0,0,0,0,0

while len(List) < K:
    for a in range(n1,26):
        if alphabet[a] in s:
            break
    if not alphabet[a] in List:
        List.append(alphabet[a])
    
    if len(List) >= K:
        continue

    num = s.index(alphabet[a])
    if num == len(s)-1:
        n1 = a+1
        continue

    for b in range(n2,26):
        sumple1 = alphabet[a] + alphabet[b]
        if sumple1 in s:
            break
    if not sumple1 in List:
        List.append(sumple1)

    if len(List) >= K:
        continue

    if not sumple1 in s:
        n1 += 1
        n2,n3,n4,n5 = 0,0,0,0
        continue
        
    num = s.index(sumple1)
    if num == len(s)-2:
        n2 = b+1
        continue

    for c in range(n3,26):
        sumple2 = sumple1 + alphabet[c]
        if sumple2 in s:
            List.append(sumple2)
            break

    if len(List) >= K:
        continue
    
    if not sumple2 in s:
        n1 += 1
        n2,n3,n4,n5 = 0,0,0,0
        continue
    
    num = s.index(sumple2)
    if num == len(s)-3:
        n3 = c+1
        continue

    for d in range(n4,26):
        sumple3 = sumple2 + alphabet[d]
        if sumple3 in s:
            List.append(sumple3)
            break

    if len(List) >= K:
        continue
        
    num = s.index(sumple3)
    if num == len(s)-4:
        n4 = d+1
        continue

    for e in range(n5,26):
        sumple4 = sumple3 + alphabet[e]
        if sumple4 in s:
            List.append(sumple4)
            break

    if len(List) >= K:
        continue
        
answer = List[K-1]

print(answer)

Measured memory_bytes: 3192
read a b
n=0
if [ "${a}" = "0" ] || [ "${b}" = "0" ] || [ "${a:0:1}" = "-" -a "${b:0:1}" != "-" ] || [ "${a:0:1}" != "-" -a "${b:0:1}" = "-" ]
then
	echo Zero ;exit
elif [ "${a:0:1}" = "-" -a  "${b:0:1}" = "-" ]
then
	n=$(( $(( a - b )) * -1 ))
	if [ "$(( n % 2 ))" = "1" ]
	then
		echo Positive
		exit
	elif [ "$(( n % 2 ))" = "0" ]
	then
		echo Negative
		exit
	fi
else
	echo Positive ;exit
fi


Measured memory_bytes: 376
def main():
    N = int(input())
    C = list(input())
    ans = 0
    red = C.count('R')
    white = C.count('W')
    # 左に赤、右に白を寄せる場合
    cnt = 0
    for i in range(red):
        if C[i] == 'W':
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 77112
import qualified Data.ByteString.Char8 as BS

main = BS.getLine >>= print . compute

compute :: BS.ByteString -> Int
compute = uncurry (+) . BS.foldl' step (0,0)

-- (Tをやり過ごした数, Sの余っている数)
step :: (Int,Int) -> Char -> (Int,Int)
step (t,s) 'S' = (t, succ s)
step (t,0) 'T' = (succ t, 0)
step (t,s) 'T' = (t, pred s)


Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[101];
long long mem[100][256];
bool flag[100][256]={false};
const long long cc = pow(10,9)+7;
bool ng(int n){
    if(n < 3) return false;
    if(strncmp(&s[n-3], "AGC", 3)==0) return true;
    if(strncmp(&s[n-3], "ACG", 3)==0) return true;
    if(strncmp(&s[n-3], "GAC", 3)==0) return true;
    
    if(n < 4) return false;
    if((strncmp(&s[n-4], "A", 1)==0)&&(strncmp(&s[n-2],"GC", 2)==0)) return true;
    if((strncmp(&s[n-4], "AG", 2)==0)&&(strncmp(&s[n-1], "C", 1)==0)) return true;

    return false;    
}
ll dfs(int p, int size){
    char cand[4]={'A', 'C', 'G', 'T' };
    ll result = 0;
    int index=0;
    if( p > 2 ){
        for(int i=0; i<3; i++){
            index = index << 2;
            if( s[p-1-i] == 'A') index+=0;
            if( s[p-1-i] == 'G') index+=1;
            if( s[p-1-i] == 'C') index+=2;
            if( s[p-1-i] == 'T') index+=3;
        }
        if( flag[p][index]==true){
            return mem[p][index];
        }
    }
    if( ng(p) == true) {
        //ll c1 = pow(4,size-p);
        ll c1 = 1;
        for(int i=0; i<(size-p); i++) c1 = (c1*4)%cc;
        return c1;
    }
    if( p==size ) return 0;

    for(int i=0; i<4; i++){
        s[p]=cand[i];
        result += dfs(p+1, size)%cc;
    }
    result = result%cc;
    if( p>2){
        mem[p][index] = result;
        flag[p][index]=true;
    }
    return result;
}
int main(){
    int n;
    std::cin >> n;
    //long long result=pow(4, n);
    long long result=1;
    for(int i=0; i<n; i++){
        result = (result*4)%cc;
    }
    long long search;
    result = result;
    search = dfs(0,n)%cc;
    //result -= search;
    //cerr << " " << result << " " << search << endl;
    if (result > search ) cout << (result -search)%cc << endl;
    else cout << cc+ ((result - search)%cc) << endl;
    return 0;
}

/*
*agc*
*acg*
*gac*
*a+gc*
*ag+c*
*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

int n, k;
ll a[(int)2e5+10];
void solve() {
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    ll l = 1, r = 1e9, res = -1;
    while(l <= r) {
        ll mid = l + r >> 1;
        ll ans = 0;
        for(int i = 1; i <= n; ++i) ans += (a[i] + mid - 1) / mid;
        if(ans - n <= k) res = mid, r = mid - 1;
        else l = mid + 1;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 5132
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc =  new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long Q = N/(A+B);
		long ex = N%(A+B);
		long R = 0;
		if(A > 0) {
			if(ex < A) {
				R = A * Q + ex;
			}
			else if(ex >= A) {
				R = (Q+1) * A;
			}
		}
		System.out.println(R);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void){
    ll n;
    cin>>n;
    
    int a=n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9){
        cout<<"hon"<<endl;
    }
    else if(a==3){
        cout<<"bon"<<endl;
    }else{
        cout<<"pon"<<endl;
    }
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;

    int lim = S.size();

    int ans = 0;

    for(int i = lim-2;i >= 0;i--){
        if(i % 2 == 0)continue;

        int tmp = (i+2-1)/2;
        rep(j,tmp){
            if(j == tmp-1 && S[j] == S[j + tmp])ans = max(ans,tmp);
            else{
                if(S[j] == S[j + tmp])continue;
                else break;
            }
        }
    }

    cout << ans * 2 << endl;
}


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

int main() {
	int x, y;
	int G[12] = { 1,-1,1,2,1,2,1,1,2,1,2,1 };
  
  	cin >> x >> y;

	if (G[x - 1] == G[y - 1])cout << "Yes";
	else cout << "No";

	
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            double ans = 0;

            for (int i = 0; i < n; i++) {
                ans = k * Math.pow(k - 1, n - 1);
            }

            // 出力
            out.println((long) ans);

        }

    }
}



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

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

    ll n, r; cin >> n >> r;

    if (n>=10) cout << r << "\n";
    else cout << r + 100 * (10 - n) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int max=a;
  if(max<b)max=b;
  if(max<c)max=c;
  if(max==a)cout<<b+c<<endl;
  else if(max==b)cout<<a+c<<endl;
  else cout<<a+b<<endl;
}

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

int main(){
  int x,y,a;
  cin >> x >> y;
  a=0;
  if(x==1){
    a+=300000;
  }else if(x==2){
    a+=200000;
  }else if(x==3){
    a+=100000;
  }
  if(y==1){
    a+=300000;
  }else if(y==2){
    a+=200000;
  }else if(y==3){
    a+=100000;
  }
  if(x==1 && y==1){
    a+=400000;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    bool ok=false;
    while (N)
    {
        if(N%10 == 7) ok = true;
        N /= 10;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
#define print(x) printf("%lld ", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int M, K, m;
	cin >> M >> K;
	//m = pow(2, M);
	m = (1 << M);
	if(K >= m){
		cout << -1 << endl;
		return;
	}else if(M == 1){
		if(K == 1){
			cout << -1 << endl;
			return;
		}else if(K == 0){
			cout << "0 0 1 1" << endl;
			return;
		}
	}

	rep(i, m){
		if(i == K) continue;
		print(i);
	}
	print(K);
	rep(i, m){
		ll x = m-1-i;
		if(x == K) continue;
		print(x);
	}
	cout << K << endl;

}

int main()
{
	Main();

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
char s[55];
int n, m;	bool map[55][55];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s);
		for (int j = 1; j <= m; j++)
			map[i][j] = (s[j-1] == '#');
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			if (map[i][j])	printf("#");
			else	printf("%d", map[i-1][j]+map[i][j-1]+map[i][j+1]+map[i+1][j]+map[i-1][j-1]+map[i+1][j+1]+map[i-1][j+1]+map[i+1][j-1]);
		printf("\n");
	}
	return 0;
}


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

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

fn div(mut num: i64) -> i64 {
    let mut cnt = 0;
    while num % 2 == 0 {
        cnt += 1;
        num /= 2;
    }
    return cnt;
}

fn main() {
    let N: i64 = read();
    let A: i64 = read();
    let B: i64 = read();
    let ans = if N * A < B { N * A } else { B };
    println!("{}", ans);
}


Measured memory_bytes: 2076
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,h,i,t,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;

	
	vector<ll>	v(n),c(n);
	for(i=0;i<n;i++) cin >> v[i];
	for(i=0;i<n;i++) cin >> c[i];
	for(i=0;i<(1<<n);i++) {
		x = y = 0;
		for(j=0;j<=n;j++) {
			if ((i & (1<<j))!=0) {
				x += v[j];
				y += c[j];
			}
			ans = max( ans , x-y );
		}
	}
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

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

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  int count1 = 0;
  int count0 = 0;
  rep(i, s.size()){
    if (s[i] == '0'){
      count0++;
    }else{
      count1++;
    }
  }
  cout << min(count1, count0)*2 << endl;
  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int cnt[26]={0};
    for(int i=0;i<s.length();i++)
    {
       int a=s[i]-'a'+1;
       cnt[a]++; 
    }  
    
    bool abc=true;
    for(int i=1;i<=26;i++)
    {
        if(cnt[i]%2!=0)
        abc=false;
    }
    if(abc==false)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int fx = 0;
  
  for (int i = N; i > 0; i /= 10) {
    int x = i % 10;
    fx += x;
  }
  
  if (N % fx == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String[] S = new String[N];
		for(int i = 0 ; i < N ; i++) {
			S[i] = sc.next();
		}
		Arrays.sort(S);
		String word = "";
		for(int i = 0 ; i < N ; i++) {
			word += S[i];
		}
		System.out.println(word);
	}
}


Measured memory_bytes: 23504