akhauriyash/Code-Regression huggingface dataset:
//
// Created by tattsun on 2017/02/16.
//

#include <iostream>

#define MAX_N 101
#define NIL -1
#define INFTY 1000000
#define TOTAL_INFTY INFTY*MAX_N

using namespace std;

enum Status {
    White,
    Gray,
    Black,
};

int n;
int w[MAX_N][MAX_N];
int d[MAX_N], parent[MAX_N];
Status st[MAX_N];

int min(int x, int y) {
    if(x < y) return x;
    return y;
}

void dijkstra() {
    for(int i=0; i<n; i++) {
        d[i] = TOTAL_INFTY;
        st[i] = White;
        parent[i] = NIL;
    }

    int p = 0;
    d[p] = 0;

    while(true) {
        if(p == -1) break;
        st[p] = Black;

        for(int i=0; i<n; i++) {
            if(w[p][i] != TOTAL_INFTY && st[i] != Black) {
                d[i] = min(d[i], d[p] + w[p][i]);
                st[i] = Gray;
            }
        }

        p = -1;
        int c = TOTAL_INFTY;
        for(int i=0; i<n; i++) {
            if(st[i] == Gray && d[i] < c) {
                p = i;
                c = d[i];
            }
        }
    }
}

int main() {
    for(int i=0; i<MAX_N; i++) {
        for (int j = 0; j < MAX_N; j++) {
            w[i][j] = TOTAL_INFTY;
        }
    }

    cin >> n;

    int u, k, v, c;
    for(int i=0; i<n; i++) {
        cin >> u >> k;
        for(int j=0; j<k; j++) {
            cin >> v >> c;
            w[u][v] = c;
        }
    }

    dijkstra();

    for(int i=0; i<n; i++) {
        cout << i << " " << d[i] << endl;
    }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};     

int w, h;
bool data[51][51];

void dfs( int y, int x )
{
  data[y][x] = 0;

  Rep(i, 8) {
    int nx = x + dx[i], ny = y + dy[i];
    if( nx < 0 || nx >= w || ny < 0 || ny >= h || !data[ny][nx] ) continue;
    dfs( ny, nx );
   }
}


main()
{
  while( cin >> w >> h, !(w == 0 && h == 0) ) {
    
    Rep(i, h) Rep(j, w) cin >> data[i][j];

    int cnt = 0;
    Rep(i, h) Rep(j, w) {
      if( data[i][j] ) dfs(i, j), cnt++; 
    }

    cout << cnt << endl;
  }
   
}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	cin >> N;
	vector<LLI>vec(N);
	for (int i = 0; i < N;i++) {
		cin >> vec[i];
	}
	LLI cnt = 0;
	for (int i = 1; i < N - 1;i++) {
		if (vec[i] < vec[i + 1] && vec[i] > vec[i - 1]) {
			cnt++;
		}else if (vec[i] > vec[i + 1] && vec[i] < vec[i - 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int K, A, B, x = 1, flag = 0;
    cin >> K >> A >> B;
    while (K * x <= B)
    {
        if (K * x >= A)
        {
            flag = 1;
        }
        x++;
    }
    if (flag)
    {
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    
}

Measured memory_bytes: 3632
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    ___    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

#define Task ""

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define BIT(x, i) (x >> i) & 1

using namespace std;

typedef long long ll;

const int maxn = 100;

void Solve()
{
    int h, w, k;
    char a[maxn][maxn];
    cin >> h >> w >> k;
    for (int i = 0; i < h; i ++)
        for (int j = 0; j < w; j ++)
            cin >> a[i][j];
    int res = 0;
    for (int mask1 = 0; mask1 < (1 << h); mask1 ++)
        for (int mask2 = 0; mask2 < (1 << w); mask2 ++)
        {
            int B = 0;
            for (int i = 0; i < h; i ++)
                for (int j = 0; j < w; j ++)
                    if (a[i][j] == '#' && BIT(mask1, i) && BIT(mask2, j)) B ++;
            if (B == k) res ++;
        }
    cout << res << " ";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    if(fopen(Task".inp", "r"))
    {
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }

    int test_case = 1;
//    cin >> test_case;
    while (test_case --)
        Solve();
    return 0;
}



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, a, b, c;
  std::cin >> n >> a >> b >> c;

  std::vector<std::string> s(n);
  std::cin >> s;

  std::vector<std::string> ans(n);

  for (int64_t i = 0; i < n; i++) {
    if (s[i] == "AB") {
      if (a == 0 && b == 0) {
        std::cout << "No" << std::endl;
        return 0;
      }

      if (a == 1 && b == 1) {
        if (i + 1 != n && c == 0 && s[i + 1] == "AC") {
          b--;
          a++;
          ans[i] = "A";
        } else if (i + 1 != n && c == 0 && s[i + 1] == "BC") {
          a--;
          b++;
          ans[i] = "B";
        } else {
          b--;
          a++;
          ans[i] = "A";
        }

      } else {
        if (a < b) {
          b--;
          a++;
          ans[i] = "A";
        } else {
          b++;
          a--;
          ans[i] = "B";
        }
      }

    } else if (s[i] == "AC") {
      if (a == 0 && c == 0) {
        std::cout << "No" << std::endl;
        return 0;
      }

      if (a == 1 && c == 1) {
        if (i + 1 != n && b == 0 && s[i + 1] == "AB") {
          c--;
          a++;
          ans[i] = "A";
        } else if (i + 1 != n && b == 0 && s[i + 1] == "BC") {
          a--;
          c++;
          ans[i] = "C";
        } else {
          c--;
          a++;
          ans[i] = "A";
        }
      } else {
        if (a < c) {
          c--;
          a++;
          ans[i] = "A";
        } else {
          c++;
          a--;
          ans[i] = "C";
        }
      }
    } else {
      if (b == 0 && c == 0) {
        std::cout << "No" << std::endl;
        return 0;
      }

      if (b == 1 && c == 1) {
        if (i + 1 != n && a == 0 && s[i + 1] == "AB") {
          c--;
          b++;
          ans[i] = "B";
        } else if (i + 1 != n && a == 0 && s[i + 1] == "AC") {
          b--;
          c++;
          ans[i] = "C";
        } else {
          c--;
          b++;
          ans[i] = "B";
        }
      } else {
        if (b < c) {
          c--;
          b++;
          ans[i] = "B";
        } else {
          c++;
          b--;
          ans[i] = "C";
        }
      }
    }
  }

  std::cout << "Yes" << std::endl;
  for (const auto &c : ans) {
    std::cout << c << std::endl;
  }

  return 0;
}


Measured memory_bytes: 9588
#include<stdio.h>
#include<string.h>

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(long long key){ return key % M; }
int h2(long long key){ return 1 + (key % (M-1)); }

int h(long long key, int i){ return (h1(key) + i*h2(key)) % M ;}

int find(char str[]){
  int i = 0, j;
  long long k;

  k = getKey(str);

  while(1){

    j = h(k, i);

    if( H[j][0] == '\0' || i == M){
      break;
    } 

    if(strcmp(H[j], str) == 0) return 1; //?
    else i = i+1;

  }

  return 0;

}

int insert(char str[]){
  int i=0, j;
  long long k;

  k = getKey(str);

  while(1){
    if(i == M) break;

    j = h(k, i);

    if(H[j][0] == '\0'){
      strcpy(H[j],str); //?
      return j;
    }else{
      i = i+1;
    }
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve():
    # 数値取得サンプル
    #   1行N項目 x, y = map(int, input().split())
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    x1, x2, x3, x4, x5 = map(int, input().split())

    if x1 == 0:
        print(1)
        return
    if x2 == 0:
        print(2)
        return
    if x3 == 0:
        print(3)
        return
    if x4 == 0:
        print(4)
        return
    if x5 == 0:
        print(5)
        return

    # テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """0 2 3 4 5"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """1 2 0 4 5"""
        output = """3"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 70880
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; scanf("%d%d", &n, &q);
	vector<int> a(q), v(q); rep(i, 0, q) {
		scanf("%d%d", &a[i], &v[i]);
		a[i]--;
	}
	using T = tuple<int, int>;
	priority_queue<T> pq;
	rep(i, 0, n)pq.emplace(0, -i);
	vector<int> point(n);
	rep(i, 0, q) {
		point[a[i]] += v[i];
		pq.emplace(point[a[i]], -a[i]);
		while (true) {
			int p, u; tie(p, u) = pq.top(); pq.pop();
			if (point[-u] != p)continue;
			printf("%d %d\n", -u + 1, p);
			pq.emplace(p, u);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 23816
import sys
sys.setrecursionlimit(100000)

N=int(input())
edges=[[] for _ in range(N)]
for _ in range(N-1):
    u,v,w=map(int,input().split())
    edges[u-1].append((v-1,w))
    edges[v-1].append((u-1,w))

dist=[-1 for _ in range(N)]
def measure(src):
    for v,w in edges[src]:
        if dist[v]==-1:
            dist[v]=dist[src]+w
            measure(v)

dist[0]=0
measure(0)

for i in range(N):
    if dist[i]%2:
        print(1)
    else:
        print(0)

Measured memory_bytes: 82300
n = int(input())
flag=0
lst = [int(i) for i in input().split()][:n]
for i in lst:
    if i%2==0 and i%3!=0 and i%5!=0:
        flag=1 
    else:
        continue
if flag==1:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  int a[n][3];
  rep(i, n) rep(j, 3) cin >> a[i][j];

  int dp[n + 1][3]; // 前日に何した?
  rep(i, n + 1) rep(j, 3) dp[i][j] = 0;

  rep(i, n) rep(j, 3) rep(k, 3) {
    if (j == k) continue;
    chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    char sunuke_num[3];
    
    cin >> sunuke_num;

    for(int i = 0; i < 3; i++){
        if(sunuke_num[i] == '1'){
            cout << '9';
        }else{
            cout << '1';
        }
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
string word;
int main()
{
  priority_queue<int> Q;
  while (cin >> word && word != "end") {
    if (word == "insert") {
    } else if (word == "extract") {
      int n = Q.top();
      Q.pop(); // 先頭要素を廃棄
      cout << n << endl; // 4, 3, 1 の順に表示される
    } else {
      Q.push(atoi(word.c_str()));
    }
  }
}


Measured memory_bytes: 7124
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int s = scan.nextInt();
        int index = 1;
        HashSet<Integer> set = new HashSet<>();
        set.add(s);
        while(true) {
            index += 1;
            if (s % 2 == 0) {
                s = s / 2;
            } else {
                s = 3 * s + 1;
            }
            if (set.contains(s)) {
                break;
            }
            set.add(s);
        }
        System.out.println(index);
    }
}


Measured memory_bytes: 23892
from fractions import gcd
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
if k>A[-1]:
    print('IMPOSSIBLE')
else:
    a=A[0]
    for i in range(n):
        a=gcd(a,A[i])
    if a==1:
        print('POSSIBLE')
    else:
        if k%a==0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')

Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[10];
int main(){
    int n;
    scanf("%d", &n);
    int ans = n / 500 * 1000;
    n = n - n / 500 * 500;
    ans += n / 5 * 5;
    printf("%d\n", ans);
    return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

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

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int a,b;
int solve(){
    int ans=0;
    return ans;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    while(cin >> a >> b){
        int ans = 0;
        //cout << solve() << endl;
        //cout << ans << endl;
        str tmp = to_string(a) + to_string(b);
        ans = stoi(tmp);

        rrep(i,1000){
            //cout << ans << " " << i+i << endl;
            if(ans == i*i){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
    int n;
    vector<pair<int, int>> p;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        p.push_back(make_pair(x + l, x - l));
    }

    int cur = -1000000000;
    int ans = 0;
    sort(p.begin(), p.end());
    for (int i = 0; i < n; i++) {
        if (p.at(i).second >= cur) {
            ans++;
            cur = p.at(i).first;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


#define N 	 100005
void solve(){
	string s;
	cin>>s;
	rep(i,0,sz(s)) cout<<((s[i] != ',')?s[i] : ' ');
	cout<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,M; cin >> N >> M;
    VVI s(M,VI(N,0));
    REP(i,M){
        int k; cin >> k;
        REP(j,k){
            int ss; cin >> ss; ss--;
            s[i][ss] = 1;
        }
    }
    VI p(M); REP(i,M) cin >> p[i];
    int ans = 0;
    REP(i,1<<N){
        bitset<10> b;
        REP(j,N) if(i & 1<<j) b[j] = 1;
        bool flag = true;
        REP(j,M){
            int tmp = 0;
            REP(k,N) if(s[j][k] & b[k]) tmp++;
            if(tmp%2 != p[j]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int main()
{
    long long n,m;
    int a[1000000];
    long long sum = 0;
    cin >> n >> m;
    for (long i = 0;i < m;i++){
        cin >> a[i];
        sum += a[i];
    }
    if (n >= sum){
        cout << n-sum << endl;
    }
    else {
        cout << "-1" << endl;
    }
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[200001];
int main() {
	scanf("%s",s);
	ll ans=0,tmp=0;
	int n=strlen(s);
	fup(i,0,n-2,1)
	{
		if(s[i]=='A')tmp++;
		else if(s[i]=='B' && s[i+1]=='C')ans+=tmp,i++;
		else tmp=0;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 384
def main():
    k, s = map(int, input().split())
    
    ans = 0
    for x in range(k + 1):
        for y in range(k + 1):
            z = s - x - y
            if z >= 0 and z <= k:
                ans += 1
    
    print(ans)
                    

if __name__ == '__main__':  
    main()

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 999999

int main(){
  int i,N,min = MAX;
  int W[100],S1=0,S2=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&W[i]);
    S2 += W[i];
  }
  int temp;
  for(i=0;i<N;i++){
    S1 += W[i];
    S2 -= W[i];
    temp = S1 -S2;
    if(S1-S2 < 0)
      temp *= -1;

    if(min > temp)
      min = temp;
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int dp[100001];

signed main(void) {
	int n,k;
	cin >> n>>k;
	vector<int>p(n);
	rep(i, n) {
		cin >> p[i];
	}
	rep(i, 10001) {
		dp[i] = INF;
	}
	dp[0] = 0;
	dp[1] = abs(p[1] - p[0]);

	FOR(i, 2, n) {
		int mincost = INF;
		rep1(j, min(i,k)+1) {
			mincost = min(mincost, dp[i - j] + abs(p[i - j] - p[i]));
		}
		dp[i] =mincost;
	}

	print(dp[n-1]);
}

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

int main()
{
	int n,m;
	cin>>n>>m;
	string s[n];
	for(int i=0;i<n;i++)cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)cout<<s[i];
	return 0;
	
}





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

using namespace std;

int main(){
	//your code goes here
	int n;
	cin >> n;
	int a[2*n];
	for(int i=0; i<2*n; i++){
		cin >> a[i];
	}
	bool bl = false;
	for(int i=0; i<2*n; i+=2){
		if(a[i]==a[i+1]){
			if(a[i+2]==a[i+3]){
				if(a[i+4]==a[i+5]){
					bl = true;
				}
			}
		}
	}
	if(bl) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
ll pow(ll a,ll b){
	if(b==0) return 1;
	if(b==1) return a;
	ll x=pow(a,b/2);
	if(b&1) return x*x*a;
	return x*x;
}
int main(){
	ll n,k; cin>>n>>k;
	cout<<k*pow(k-1,n-1);
}


Measured memory_bytes: 3632
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio> // }}}

#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,s,n) for(int i=s; i<n; i++)

using ll = long long;

using namespace std;

int main() {
    long n,h;
    vector<long> a,b;
    cin >> n >> h;
    rep(i,n){
        long x,y;
        cin >> x >> y;
        a.push_back(x);
        b.push_back(y);
    }
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    long amax = a[0];
    int cnt=0;
    while(cnt < b.size() && b[cnt] > amax && h > 0){
        h -= b[cnt];
        cnt++;
    }
    if(h>0) {
        cnt += ceil((double)h/(double)amax);
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2036
import sys

N = int(input())
S = sys.stdin.readlines()
C = [0] * 4

for i in range(N):
  if S[i].rstrip() == 'AC':
    C[0] += 1
    continue
  if S[i].rstrip() == 'WA':
    C[1] += 1
    continue
  if S[i].rstrip() == 'TLE':
    C[2] += 1
    continue
  if S[i].rstrip() == 'RE':
    C[3] += 1
    continue

print("AC x {}".format(C[0]))
print("WA x {}".format(C[1]))
print("TLE x {}".format(C[2]))
print("RE x {}".format(C[3]))


Measured memory_bytes: 16128
# -*- coding: utf-8 -*-


class Dice:
    def __init__(self, n):
        self.upper    = n[0]
        self.backward = n[1]
        self.right    = n[2]
        self.left     = n[3]
        self.ahead    = n[4]
        self.bottom   = n[5]

    def __eq__(self, other):
        return self.upper == other.upper and self.backward == other.backward and self.right == other.right and self.left == other.left and self.ahead == other.ahead and self.bottom == other.bottom

    def roll_north(self):
        self.upper, self.ahead, self.bottom, self.backward = self.backward, self.upper, self.ahead, self.bottom

    def roll_south(self):
        self.upper, self.ahead, self.bottom, self.backward = self.ahead, self.bottom, self.backward, self.upper

    def roll_east(self):
        self.upper, self.right, self.bottom, self.left = self.left, self.upper, self.right, self.bottom

    def roll_west(self):
        self.upper, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.upper

    def roll_side(self):
        self.ahead, self.right, self.backward, self.left = self.left, self.ahead, self.right, self.backward


def match_dice(dice1, dice2):
    for i in range(4):
        dice1.roll_north()

        for j in range(4):
            dice1.roll_east()

            for k in range(4):
                dice1.roll_side()

                if dice2 == dice1:
                    return 0
    return 1


dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))
result = match_dice(dice1, dice2)

if result is 0:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5612
N,M = gets.split.map(&:to_i)
A = (0...N).map{ gets.chomp.split("") }
T = (0...M).map{ gets.chomp  }.join
(0...N-M+1).each{ |i|
  (0...N-M+1).each{ |j|
    if A[i...i+M].map{ |a| a[j...j+M].join }.join == T
      puts "Yes"; exit
    end
  }
}
puts "No"


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    int N, A;
    cin >> N;
    REP(i, N){
        cin >> A;
        if(A % 2 != 0 || A % 6 == 0 || A % 10 == 0)
            continue;
        cout << "DENIED" << endl;
        return 0;
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <list>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

int main() {
	int n;
	
	while(cin >> n) {
		int ans = 0;
		REP(a, 10) REP(b, 10) REP(c, 10) REP(d, 10)
			if(a+b+c+d == n) ans++;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  string A,B;
  cin >> A >> B;
  int count=0;
  if(A.at(0)==B.at(2))
    count++;
  if(A.at(1)==B.at(1))
    count++;
  if(A.at(2)==B.at(0))
    count++;
  if(count==3)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int ans = 0;
        int sum = 1;
        while(true){
            if(sum >= b) break;
            sum--;
            sum += a;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long i;
	long long mina=10e12+5;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			mina=min(mina,n/i+i-2);
		}
	}
	cout<<mina;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int maxr = (int)1e5;
	vector<int> pr(maxr+1,1);
    for(int i=2; i<=maxr; i++){
        if(pr[i]){
            int j = 2*i;
            while(j<=maxr){
                pr[j]=0;
                j+=i;
            }
        }
    }
    vector<ll> sum(maxr+1,0);
    for(int i=3; i<=maxr; i++){
        if(i%2==1&&pr[i]&&pr[(i+1)/2]){
            sum[i]=sum[i-1]+1;
        }
        else{
            sum[i]=sum[i-1];
        }
    }
    int q;cin>>q;
    for(int i=0; i<q; i++){
        int l,r;cin>>l>>r;
        cout<<sum[r]-sum[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
function main(input){
  const   args = input.split(" ");
  const N = args[0];
  const   A = args[1];
  const   B = args[2];
  if(N*A>B){
console.log(B);
  }else{
console.log(N*A);}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e6 + 5)

#define maxn (long long int) (2147483647);

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;


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

    if (x >= 30)
    {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


















Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}

int main(){
  int N; cin >>N;
  printf("%d\n",180*(N-2));

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 21;
lli dp[N][(1 << N)];
//dp[i][msk] - how many ways if we take 'i' mans and connect them with womans in 'msk'. bits(msk) = i. 
bool matrix[N][N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			int inp;
			cin >> inp;
			matrix[i][j] = (inp ? 1 : 0);
		}
	}
	
	for(int i = 0; i < n; i++)
		for(int ii = 0; ii < n; ii++) 
			if(matrix[0][ii])
				dp[0][(1 << ii)] = 1;
	
	for(int i = 1; i < n; i++) {
		for(int msk = (1 << i)-1; msk < (1 << n); msk++) {
			if(__builtin_popcount(msk) != i+1) continue;
			for(int ii = 0; ii < n; ii++) {
				int prev = msk ^ (1 << ii); 
				if(matrix[i][ii] && prev < msk) 
					dp[i][msk] += dp[i-1][prev];
			}
			dp[i][msk] %= MOD;
		}
	}
	cout << dp[n-1][(1 << n) - 1] << "\n";
	return 0;
}

Measured memory_bytes: 307456
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int N=0,S=0,E=0,W=0;
    for (int i=0;i<s.size();i++) {
        if (s[i]=='N') {
            N++;
        } else if (s[i]=='S') {
            S++;
        } else if (s[i]=='E') {
            E++;
        } else if (s[i]=='W') {
            W++;
        }
    }
    int flag=0;
    if (N>0&&S>0) {
        flag=1;
    } else if ((N>0&&S==0)||(N==0&&S>0)) {
        cout<<"No"<<endl;
        return 0;
    }
    if (E>0&&W>0) {
        flag=1;
    } else if ((E>0&&W==0)||(E==0&&W>0)) {
        cout<<"No"<<endl;
        return 0;
    }
    if (flag==1) {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = sc.nextInt();
        }

        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
        }
        dp[0] = 0;

        for (int i = 1; i < n; i++) {
            for (int j=Math.max(i - k, 0); j < i; j++) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(heights[i] - heights[j]));
            }
        }
        System.out.println(dp[n - 1]);
    }
}

Measured memory_bytes: 51700
#include<bits/stdc++.h>
using namespace std;
const int _max = 100010;
typedef long long ll;


int main()
{
    int n,k;
    cin>>n>>k;
    int a[1001];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=a[i];
    }
    cout<<sum;
    return 0;
}

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;

  if (-A + B <= 0) {
    cout << "delicious" << endl;
  }
  else if (-A + B <= X) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N+1];
		int[] aa = new int[N];
		int count = 0;
		int ans = 0;
		for( int i=1; i<=N; i++ ){
			A[sc.nextInt()]++;
		}
		for( int i=1; i<=N; i++ ){
			if( A[i]>0 ){
				aa[count] = A[i];
				count++;
			}
		}
		int[] AA = new int[count];
		for( int i=0; i<count; i++ ){
			AA[i] = aa[i];
		}
		Arrays.sort(AA);
		if( count<=K ){
			ans = 0;
		}else{
			for( int i=0; i<count-K; i++ ){
				ans += AA[i];
			}
		}
		System.out.println(ans);     
	}
}


Measured memory_bytes: 83768
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
//using ll=long long;

int main(){
    int D, N;
    cin >> D >> N;
    int ans;
    if(N < 100){
        ans = pow(100, D) * N;
    } else {
        ans = pow(100, D) * 101;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 

ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);

int main()
{
	int n;
	cin>>n;
	int arr[n];
	forl(i,0,n)cin>>arr[i];
	sort(arr,arr+n);
	forl(i,1,n)
	{
		if(arr[i]==arr[i-1])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
def main():
    S = input()
    sa = [-1]*len(S)
    T = input()
    ta = [-1]*len(T)
    dict_s = {}
    dict_t = {}
    for index, c in enumerate(S):
        if not (c in dict_s.keys()):
            dict_s[c] = len(dict_s.keys())
        sa[index] = dict_s[c]
    for index, c in enumerate(T):
        if not (c in dict_t.keys()):
            dict_t[c] = len(dict_t.keys())
        ta[index] = dict_t[c]
    for i in range(len(sa)):
        if sa[i] != ta[i]:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 45244
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int a,b; cin>>a>>b;
  cout<<(a+b)%24<<endl;

  return 0;
}


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

using namespace std;

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

    char s[100];
    cin >> s;

    int x = (s[0] - '0') * 10 + (s[1] - '0');
    int y = (s[2] - '0') * 10 + (s[3] - '0');

    bool mx = false;
    bool my = false;

    if (x >= 1 && x <= 12) mx = true;
    if (y >= 1 && y <= 12) my = true;

    if (mx && my) cout << "AMBIGUOUS" << "\n";
    if (mx && !my) cout << "MMYY" << "\n";
    if (!mx && my) cout << "YYMM" << "\n";
    if (!mx && !my) cout << "NA" << "\n";

    return 0;
}

Measured memory_bytes: 256