akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N,M,X;
int C[12];
int A[12][12];

int main(){
    cin>>N>>M>>X;
    rep(i,N){
        cin>>C[i];
        rep(j,M){
            cin>>A[i][j];
        }
    }

    ll ans=1001001001;
    for(ll i=0;i<(1<<N);i++){
        ll price=0;
        vector<ll> a(12,0);
        for(ll j=0;j<N;j++){
            ll s=(i>>j)&1;
            if(s){
                price+=C[j];
                rep(k,M){
                    a[k]+=A[j][k];
                }
            }
        }
        bool ok=true;
        rep(j,M){
            if(a[j]<X) ok=false;
        }
        if(ok) ans=min(ans,price);
    }
    if(ans==1001001001) ans=-1;

    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll r,g,b,n,sum=0;
    cin>>r>>g>>b>>n;
    rep(i,n/r + 1){
        rep(j,n/g + 1){
            ll ans=n-(i*r+j*g);
            if(ans%b==0 && ans/b>=0 ) sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 計算
		int result = 0;
		if(b%a == 0){
		    result = a + b;
		}else{
		    result = b -a;
		}
		
		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string s,t,u;
int a,b;
int main(){
    cin>>s>>t>>a>>b>>u;
    if(s==u) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int[][] e = new int[m*2][3];
        for (int i = 0; i < m*2; i+=2) {
            e[i][0] = sc.nextInt()-1;
            e[i][1] = sc.nextInt()-1;
            e[i][2] = sc.nextInt();
            e[i+1][0] = e[i][1];
            e[i+1][1] = e[i][0];
            e[i+1][2] = e[i][2];
        }
        long[][] w1 = warshallFloyd(n, e);
        int[][] e2 = new int[n*n][3];
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(i == j)continue;
                if(w1[i][j] <= l) {
                    e2[cnt++] = new int[]{i, j, 1};
                }
            }
        }
        int[][] e3 = Arrays.copyOf(e2, cnt);
        long[][] w2 = warshallFloyd(n, e3);
        StringBuilder sb = new StringBuilder();
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int s = sc.nextInt()-1;
            int t = sc.nextInt()-1;
            sb.append(w2[s][t] == Integer.MAX_VALUE ? -1 : w2[s][t]-1).append("\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

    public static int[][][] buildWeightedGraph(int n, int[][] edges){
        int m = edges.length;
        int[][][] graph = new int[n][][];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            deg[ edges[i][0] ]++;
            deg[ edges[i][1] ]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]][2];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            int c = edges[i][2];
            graph[a][--deg[a]][0] = b;
            graph[a][deg[a]][1] = c;
            graph[b][--deg[b]][0] = a;
            graph[b][deg[b]][1] = c;
        }

        return graph;
    }

    public static long[][] warshallFloyd(int n, int[][] edge){
        long[][] d = new long[n][n];
        for (int i = 0; i < n; i++) Arrays.fill(d[i], Integer.MAX_VALUE);
        for(int i = 0; i < n; i++) d[i][i] = 0;
        for (int i = 0; i < edge.length; i++) {
            d[edge[i][0]][edge[i][1]] = edge[i][2];
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        return d;
    }

}


Measured memory_bytes: 96152
A, B = [int(i) for i in input().split()]
candidate = [i for i in range(10*B, 10*(B+1))]
result_list = [i for i in candidate if (25/2) * A <= i and i < (25/2) * (A+1)]
if result_list == []:
  print(-1)
else:
  print(min(result_list))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	char buf[1200];
	int result[26];
	int i;
	
	for(i = 0;i < 26;i++){
		result[i] = 0;
	}
	while(fgets(buf,sizeof(buf),stdin) != '\0'){
	
	for(i = 0;buf[i] != '\0';i++){
		if((int)buf[i] >= 65&&(int)buf[i] <= 90)result[(int)buf[i]-65]++;
		if((int)buf[i] >= 97&&(int)buf[i] <=122)result[(int)buf[i]-97]++;
	}
	}
	
	for(i = 0;i < 26;i++)
		printf("%c : %d\n",(char)i+97,result[i]);
	return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var h = cin.nextInt();
            var n = cin.nextInt();
            var a = cin.ArrayLong(n);


            
            Console.WriteLine(a.Sum() >= h? "Yes":"No");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 17376
"use strict";
class UnionFind {
    // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    constructor(n) { //最初は全てが根であるとして初期化
        this.par = new Array(n).fill(0).map((v, i) => i);
    }

    root(x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (this.par[x] == x) return x;
        return this.par[x] = this.root(this.par[x]);
    }

    unite(x, y) { // xとyの木を併合
        let rx = this.root(x); //xの根をrx
        let ry = this.root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        this.par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    same(x, y) { // 2つのデータx, yが属する木が同じならtrueを返す
        let rx = this.root(x);
        let ry = this.root(y);
        return rx == ry;
    }
}

function Main(input) {
    let lines = input.split("\n");
    let num = lines.shift().split(/\s/).map((v) => v - 0);
    let N = num[0];
    let M = num[1];
    let tree = new UnionFind(N);
    let P = lines.shift().split(/\s/).map((v) => v - 0);

    for(let i = 0; i < M; i++) {
        let n = lines.shift().split(/\s/).map((v) => v - 0);
        let x = n[0];
        let y = n[1];
        tree.unite(x-1, y-1); // x-1の木とy-1の木を併合する
    }

    let cnt = 0;
    for(let i = 0; i < N; i++) {
        if (tree.same(i, P[i]-1)) { //iとP[i]-1が同じ木に属するなら，カウンタに1追加
            cnt++;
        }
    }

    console.log(cnt);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 49680
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def cc(s):
	if s <= 10**9:
		r = [0,0,s,0,0,1]
		return r
		
	ok=10**9
	ng=1
	while ok-ng > 1:
		mid = (ok+ng)//2
		if mid * mid >= s:
			ok = mid
		else:
			ng = mid
	if ok*ok == s:
		r = [0,0,ok,0,0,ok]
		return r
		
	mx = ok
	ok = mx
	ng = 1
	while ok - ng > 1:
		mid = (ok+ng)//2
		if mx * mid >= s:
			ok = mid
		else:
			ng = mid
			
	if mx * ok == s:
		return [0,0,mx, 0, 0, ok]
		
	else:
		diff = (mx * ok) - s
		#dd=s-(mx*ok)
		#pa(dd)
		#pa(mx*ok-diff)
		#pa(s)
		return [0,0,mx,1,diff, ok]
		
	
	
		
		

def main():
	s = int(input())
	#b , c = tin()
	#s = input()
	ret = cc(s)
	print(*ret)
		
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62288
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main()
{
  ll k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; i++)
  {
    a.push_back(i);
  }
  while (1)
  {
    if (k <= a.size())
    {
      cout << a[k - 1] << endl;
      //cout << a.size() << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old)
    {
      for (int i = -1; i <= 1; i++)
      {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
        {
          continue;
        }
        ll nx = x * 10 + d;
        a.push_back(nx);
        //cout << a.size() << endl;
      }
    }
  }
  return 0;
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	REP(i, n) {
		int a;
		cin >> a;
		x += ((d - 1) / a) + 1;
	}
	cout << x << endl;
	return 0;
}

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

int main()
{
	int a, b;
  	cin >> a >> b;
    if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else if (a < 0 || b < 0) cout << ((b - a + 1) % 2 ? "Negative" : "Positive") << endl;
    else cout << "Positive" << endl;
    return 0;
}

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

// #pragma comment(linker, "/STACK:16777216")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define int ll
#define pii pair<int, int>
const int SZ = 1e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct custom_hash {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return x + FIXED_RANDOM;
    }
};

int n, x, y;
vector<int> g[SZ];

void read() {
    cin >> n >> x >> y;
    --x, --y;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

int tim1[SZ];
bool used1[SZ];
void dfs1(int u, int t = 0) {
    used1[u] = true;
    tim1[u] = t;
    for (int v : g[u]) {
        if (!used1[v]) {
            dfs1(v, t + 1);
        }
    }
}

bool used[SZ];
int ans = 0;
int tim[SZ];
void dfs2(int u, int t = 0) {
    used[u] = true;
    tim[u] = t;
    for (int v : g[u]) {
        if (!used[v] && t + 1 < tim1[v]) {
            dfs2(v, t + 1);
        }
    }
}

void solve() {
    if (g[x].size() == 1 && g[x][0] == y) {
        cout << 0;
        return;
    }
    dfs1(y);
    fill(tim, tim + n, -1);
    dfs2(x);
    int ans = 1;
    for (int u = 0; u < n; ++u) {
        if (g[u].size() == 1 && used[u]) {
            ans = max(ans, tim1[u] - 1);
        }
    }
    cout << ans;
}

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

    read();
    solve();

    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
#define F first
#define S second

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vint k(m); vvint s(m);
    vint p(m);
    rep(i,m){
        cin >> k[i]; s[i].resize(k[i]);
        rep(j,k[i]) cin >> s[i][j];
    }
    rep(i,m) cin >> p[i];

    int res=0;
    for(int bit=0; bit<(1<<n); bit++){
        bool can=true;
        rep(j,m){
            int hit=0;
            rep(l,k[j]){
                if(bit&(1<<(s[j][l]-1))){
                    hit++;
                }
            }
            if(hit%2!=p[j]) can=false;
        }
        if(can) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
int main() {
    int a,b,n;
    while (scanf("%d%d%d",&a,&b,&n)!=EOF) {
        int res=0;
        for (int i=0; i<n; i++) {
            a*=10;
            res+=a/b%10;
            a%=b;
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int a[11];

int dfs(int left,int right,int cnt){
  //cout<<left<<" "<<right<<" "<<cnt<<endl;
  if(cnt==10)return cnt;
  if(left<a[cnt]&&right<a[cnt]) cnt=max(dfs(a[cnt],right,cnt+1),dfs(left,a[cnt],cnt+1));
  else if(left<a[cnt])cnt=dfs(a[cnt],right,cnt+1);
  else if(right<a[cnt]) cnt=dfs(left,a[cnt],cnt+1);
  
  return cnt;
}

int main(){
  int n;
  cin>>n;
  rep(i,n){
    rep(j,10)cin>>a[j];
    //rep(j,10)cout<<a[i]<<" ";
    //cout<<endl;
    if(dfs(a[0],-INF,1)==10)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 2976
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n;
	cin>>n;
	long long tone[n+3][3],i,j,k;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++)cin>>tone[i][j];
	}
	
	long long dp[n+3][3];
	for(i=1;i<n+3;i++)dp[i][0]=dp[i][1]=dp[i][2]=0;
	dp[0][0]=dp[0][1]=dp[0][2]=0;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				if(j==k)continue;
				chmax(dp[i+1][k],dp[i][j]+tone[i][k]);
			}
		}
		
	}
//	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	long long res = 0;
    for (j = 0; j < 3; ++j) chmax(res, dp[n][j]);
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
 
using namespace std;
 
typedef pair<int,int> P;
const int MAX = 20;
P pos;
char m[MAX][MAX];
int r,c;
 
void input(){
  for(int i = 0; i < r; i++)
    for(int j = 0; j < c; j++){
      cin >> m[i][j];
      if(m[i][j] == '<' || m[i][j] == '>' ||
     m[i][j] == '^' || m[i][j] == 'v') pos = P(i,j);
    }
}
 
bool inside(P p){
  return (0 <= p.first && p.first < r && 0 <= p.second && p.second < c);
}
 
void shoot(char c){
 
  int x = 0, y = 0;
  P p = pos;
  if(c == '^') y = -1;
  if(c == 'v') y = 1;
  if(c == '>') x = 1;
  if(c == '<') x = -1;
 
  while(1){
    p.first += y;
    p.second += x;
    if(!inside(p)) break;
    if(m[p.first][p.second] == '#') break;
    if(m[p.first][p.second] == '*'){
      m[p.first][p.second] = '.';
      break;
    }
  }
}
 
void move(char c, int x, int y){
  if(inside(P(pos.first+y,pos.second+x)) && m[pos.first+y][pos.second+x] == '.'){
    m[pos.first][pos.second] = '.';
    m[pos.first+y][pos.second+x] = c;
    pos.first += y;
    pos.second += x;
  }else{
    m[pos.first][pos.second] = c;
  }
}
 
int main(){
  bool flag = false;
  int X;
  cin >> X;
  while(X--){
    if(flag) cout << endl;
    flag = true;
 
    cin >> r >> c;
    input();
    int num;
    cin >> num;
    for(int i = 0; i < num; i++){
      char c;
      cin >> c;
      if(c == 'S') shoot(m[pos.first][pos.second]);
      if(c == 'U') move('^',0,-1);
      if(c == 'D') move('v',0,1);
      if(c == 'L') move('<',-1,0);
      if(c == 'R') move('>',1,0);
    }
 
    for(int i = 0; i < r; i++){
      for(int j = 0; j < c; j++)
    cout << m[i][j];
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=ll(1e16)+ll(7);

int main(){
	ll N,D,A;
	cin >> N >> D >> A;
	vector< pair<ll,ll> > XH(N);
	vector<ll> sumd(N+1,0);
	for(int i=0;i<N;i++) cin >> XH[i].first >> XH[i].second;
	sort(XH.begin(),XH.end());
	ll ans = 0;
	for(int i=0;i<N;i++){
		if(i) sumd[i] += sumd[i-1];
		if(sumd[i]>=XH[i].second) continue;
		ll cnt = (XH[i].second-sumd[i]+A-1)/A;
		ans += cnt;
		ll r = upper_bound(XH.begin(),XH.end(),make_pair(XH[i].first+2*D,INF))-XH.begin();
		sumd[i] += cnt*A;
		sumd[r] -= cnt*A;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
import math
import copy

neko = 1
a,b = map(int,input().split())
if (a < 0)and(b < 0):
    if (abs(a-b)+1)%2:
        neko = -1
elif (a<=0)and(0<=b):
    neko = 0
if neko == 1:
    print('Positive')
elif neko == 0:
    print('Zero')
else:
    print('Negative')

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

int main(void)
{
    int n, a;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d",&a);
        if(a%2 == 1) {
            puts("first");
            return 0;
        }
    }
    puts("second");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  vector<int> A(N);
  for(auto& a: A) {
    cin>>a;
  }

  int min_sum = 0;
  for(int i=0; i<N-1; i++) {
    min_sum += min(A[i], A[i+1]);
  }

  int sum = accumulate(A.begin(), A.end(), 0);
  cout << sum - min_sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    ll tmp = 1;
    ll prev = 0;//前の段の頂点の数
    vll a(n+1, 0);
    vll sum(n+2, 0);//sum[n+1]を0としてよい
    REP(i, n+1) cin >> a[i];
    REPR(i, n+1) sum[i] = sum[i+1] + a[i];
    REP(i, n+1){
        if(tmp < a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans += tmp;
        tmp -= a[i];
        tmp = min(tmp*2, sum[i+1]);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4788
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(j,k) for (int j = 0; j < (int)(k); j++)

int n;
ll x[100010];
ll L;
int Q;
int a[100010], b[100010];

// x[i]から2^i回のジャンプで行けるところ
const int LOG = 33;
ll go[100010][LOG];

int solve(int a, int b) {
    int ans = 0;
    while (1) {
        if (go[a][0] >= b) return ans + 1;
        int i = 0;
        while (go[a][i] < b) ++i;
        --i;
        ans += 1 << i;
        a = go[a][i];
        // cout << a << ' ' << b << endl;
    }
}

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

    while (cin >> n) {
        for (int i = 0; i < n; i++) {
            cin >> x[i];
        }
        x[n] = 2e9;
        cin >> L >> Q;
        for (int i = 0; i < n; i++) {
            int k = upper_bound(x + i, x + n, x[i] + L) - x;
            go[i][0] = k - 1;
        }
        for (int i = 0; i < LOG - 1; i++) {
            for (int j = 0; j < n; j++) {
                go[j][i + 1] = go[go[j][i]][i];
            }
        }
        for (int i = 0; i < Q; i++) {
            int a, b;
            cin >> a >> b;
            --a; --b;
            if (a > b) swap(a, b);
            //cout << 'a' << endl;
            cout << solve(a, b) << endl;
        }
    }
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y; 
  cin >> x>> y;
  for (int c =0; c<=x; c++){
    int t= x-c;
    int asi = c*2+t*4;
    if (asi == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }  
  cout << "No" << endl;
  return 0;
 }


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  vector<int> dp(n, int(2e9));
  dp[0] = 0;

  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    __int128_t now=100;
    ll X;cin>>X;
    
    for(int i=1;;i++){
        now*=101;
        now/=100;
        if(now>=X){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3660
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
const ll M = 1000000007;

const int MAX_SIZE = 1010;
bool isprime[MAX_SIZE];
vector<int> prime_num;
map<int, ll> nums;

void init() {
  fill(isprime, isprime+MAX_SIZE, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<MAX_SIZE; i++) {
    if (isprime[i]) {
      prime_num.push_back(i);
      nums[i] = 0;
      for (auto j=2; i*j<MAX_SIZE; j++) {
        isprime[i*j] = false;
      }
    }
  }
}

bool prime(long long x) { // 2 \leq x \leq MAX_SIZE^2
  if (x < MAX_SIZE) {
    return isprime[x];
  }
  for (auto e : prime_num) {
    if (x%e == 0) return false;
  }
  return true;
}

void add(int n) {
  for (auto x : prime_num) {
    while (n % x == 0) {
      n /= x;
      nums[x]++;
    }
  }
}

int main() {
  init();
  int N;
  cin >> N;
  for (auto i = 1; i <= N; i++) {
    add(i);
  }
  ll ans = 1;
  for (auto x : nums) {
    ans *= x.second + 1;
    ans %= M;
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    string S; cin >> S;
    for(int i = 0; i < S.size(); ++i) {
        if(i%2) {
            corner(S[i]=='R',"No");
        }
        else {
            corner(S[i]=='L',"No");
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;

int main() {
    int N; cin >> N;
    vector<ll> Lucas(N + 1);
    Lucas[0] = 2;
    Lucas[1] = 1;
    for (int i = 2; i <= N; i++) {
        Lucas[i] = Lucas[i - 1] + Lucas[i - 2];
    }

    cout << Lucas[N] << endl;
    return 0;
}

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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)

long long dp[110][21];

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

    vector<int> a(n);

    rep(i, n) cin >> a[i];

    dp[1][a[0]] = 1;

    rep(i, n - 1) {
        if (i == 0) continue;
        rep(j, 21) {
            if (j + a[i] <= 20) dp[i + 1][j + a[i]] += dp[i][j];
            if (j - a[i] >= 0) dp[i + 1][j - a[i]] += dp[i][j];
        }
    }

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

Measured memory_bytes: 3072
use proconio::input;
use proconio::marker::Chars;


fn main() {
  input! {
    s: Chars,
  }
  
  let mut max = 0;
  'outer: for len in 1..s.len()/2 {
    for i in 0..len {
      if s[i] != s[i+len] {
        continue 'outer;
      }
    }
    max = len;
  }
  
  println!("{}", max*2);
}

Measured memory_bytes: 2112
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2) 
		if(n % i == 0) return false;
	return true;
}

int main(){ 
    do_not_disturb
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //freopen("milkvisits.in", "r", stdin);
    //freopen("milkvisits.out", "w", stdout);
	ll n, m, i, j;
	cin >> n >> m;
	char maze[n][m];
	int dp[n][m];
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			cin >> maze[i][j];
		}
	}
	dp[0][0] = 1;
	for(i = 1; i < m; i++){
		if(maze[0][i] == '#') dp[0][i] = 0;
		else dp[0][i] = dp[0][i-1];
	}
	for(i = 1; i < n; i++){
		if(maze[i][0] == '#') dp[i][0] = 0;
		else dp[i][0] = dp[i-1][0];
	}
	for(i = 1; i < n; i++){
		for(j = 1; j < m; j++){
			if(maze[i][j] == '#'){
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = dp[i-1][j]+dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n-1][m-1];
    
    return 0;
} // What is to be written here?


Measured memory_bytes: 5120
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[101],l,i;
    long long K;
    scanf("%s",s);
    l = strlen(s);
    scanf("%lld",&K);
    for(i = 0; i < l && s[i] == '1'; i++);
    if(i == l || i >= K)
    {
        printf("%d\n",1);
    }
    else
    {
        printf("%d\n",s[i]-48);
    }
}

Measured memory_bytes: 128
def C():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for i in range(N):
        temp = [int(n) for n in input().split()]
        C.append(temp[0])
        A.append(temp[1:])
    
    ans = [float('inf')]
    def helper(i, skills, cost):
        if i == N:
            for s in skills:
                if s < X:
                    return
            ans[0] = min(ans[0], cost)
            return
        helper(i+1, [skills[j]+A[i][j] for j in range(M)], cost+C[i])
        helper(i+1, skills, cost)

    for i in range(N):
        helper(i, [0]*M, 0)
    
    if ans == [float('inf')]:
        print(-1)
        return
    print(ans[0])
C()

Measured memory_bytes: 9224
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
q,k=map(int,input().split())
ql=[list(map(int,input().split())) for i in range(q)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append([l[i][1]-1,l[i][2]])
  connection[l[i][1]-1].append([l[i][0]-1,l[i][2]])

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=[v]
  next2=set()
  visited=[-1]*n
  visitct=0
  while len(next)!=0 and visitct!=n:
    for i in range(len(next)):
      if visited[next[i]]==-1:
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j][0]]==-1:
            distance[connection[next[i]][j][0]]=distance[next[i]]+connection[next[i]][j][1]
            next2.add(connection[next[i]][j][0])
    next=list(next2)
    next2=set()
  return distance
x=bfs(k-1)
for i in range(q):
  print(x[ql[i][0]-1]+x[ql[i][1]-1])

Measured memory_bytes: 121944
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

signed main() {
  int N; cin >> N;
  vector<int> a(3*N);
  for(int i = 0; i < 3 * N; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans = 0;
  for(int i = 1; i <= 2 * N; i += 2) {
    ans += a[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 2560
fun main(args : Array<String>) {
    val s = readLine()!!
    val ss = mutableMapOf('a' to 0, 'b' to 0, 'c' to 0)

    s.forEach {
        ss[it] = ss[it]?.plus(1) ?: 0
    }

    val diffAB = Math.abs(ss['a']!! - ss['b']!!)
    val diffAC = Math.abs(ss['a']!! - ss['c']!!)
    val diffBC = Math.abs(ss['b']!! - ss['c']!!)

    if (diffAB in 0..1 && diffAC in 0..1 && diffBC in 0..1) {
        println("YES")
    } else {
        println("NO")
    }
}

Measured memory_bytes: 36524
#include<bits/stdc++.h>
using namespace std;
int A[21];
int main(){
	int a,i,w=0;
	cin>>a;
	for(i=1;i<=a;i++)cin>>A[i];
	for(i=2;i<a;i++)if(A[i]>A[i-1]&&A[i]<A[i+1]||A[i]<A[i-1]&&A[i]>A[i+1])w++;
	cout<<w;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

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

vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> div;
    ll d = n;
    for(ll i = 2; i*i <= n; i++){
        pair<ll,int> p;
        if(d % i == 0){
            p = make_pair(i,0);
            while(d % i == 0){
                d /= i;
                p.second++;
            }
            div.emplace_back(p);
        }
    }
    if(d != 1) div.emplace_back(d,1);
    return div;
}

int main(){
    ll n; cin >> n;
    vector<pair<ll,int>> div = factorize(n);
    int ans = 0;
    rep(i,div.size()){
        int now = 1;
        while(div[i].second >= now){
            div[i].second -= now;
            now++;
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N >> K;
    N--;
    ans = K;
    while (N--) {
        ans *= (K - 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int A,B;cin >> A >> B;
    cout << A * B << endl;

}

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

using namespace std;

int n;
int a;
long long int sum;

int main() {
    while (cin>>n) {
        sum = 0;

        for (int i=0; i<n; i++)
        {
            cin>>a;
            sum += a-1;
        }

        cout<<sum<<endl;
    }

    return 0;
}


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

#define MAX 72
#define INV (-1)

struct Dig{
	vector<char> s;
	void push( char c ){
		s.push_back( c );
	}
	void pop(){
		s.pop_back();
	}
	void simplify(){
		while( true ){
			if( s.size() == 1 )
				break;
			if( s[0] == '0' ){
				s.erase( s.begin() );
			}else
				break;
		}
	}
	bool operator<(const Dig &t){
		if( s.size() < t.s.size() )
			return true;
		else if( s.size() == t.s.size() ){
			for(unsigned int i = 0; i < s.size(); ++i){
				if( s[i] == t.s[i] )
					continue;
				if( s[i] < t.s[i] )
					return true;
				else
					return false;
			}
		}
		return false;
	}
};

vector< Dig > vdigs;
void ResetMap(char map[MAX][MAX]){
	for(int i = 0; i < MAX; ++i){
		for( int j = 0; j < MAX; ++j){
			map[i][j] = INV;
		}
	}
}
template<typename _T>
ostream &operator << (ostream &os, const vector<_T> &v){
	for(unsigned int i = 0; i < v.size(); ++i){
		os << v[i];
	}
	return os;
}
int main(){	
	while(true){
		int H,W;
		Dig ans;
		char map[MAX][MAX];
		Dig dmap[MAX][MAX];

		cin >> W >> H;
		
		if( W == 0 && H == 0 ) break;
		vdigs.clear();
		ResetMap( map );
		for(int i = 1; i <= H; ++i){
			string s;
			cin >> s;
			for(int j = 1; j <= W; ++j){
				map[i][j] = s[j-1];
			}
		}
		for(int i = 1; i <= H; ++i){
			for(int j = 1; j <= W; ++j){
				if( !isdigit(map[i][j]) )
					continue;
				else{
					Dig d,d1,d2;
					Dig dmax;
					d.push( map[i][j] );
					if( isdigit( map[i-1][j] ) ){
						d1 = dmap[i-1][j];
						d1.push( map[i][j] );
					}
					if( isdigit( map[i][j-1] ) ){
						d2 = dmap[i][j-1];
						d2.push( map[i][j] );
					}
					dmax = d;
					if( dmax < d1 )
						dmax = d1;
					if( dmax < d2 )
						dmax = d2;
					dmax.simplify();
					dmap[i][j] = dmax;
				}
			}
		}
		for(int i = 1; i <= H; ++i){
			for(int j = 1; j <= W; ++j){
				if( ans < dmap[i][j] ){
					ans = dmap[i][j];
				}
			}
		}
		cout << ans.s << endl;
	}
	return 0;
}

Measured memory_bytes: 1032