akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w ;
  cin >> h >> w ;
  queue<pair<int,int>> Q ;
  int ans = 0 ;
  vector<vector<char>> gra(h+2,vector<char>(w+2,'#')) ;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> gra[i][j] ;
      if(gra[i][j]=='.'){
        Q.push(MP(i,j)) ;
      }
    }
  }
  while(!Q.empty()){
    vector<vector<int>> seen(h+2,vector<int>(w+2,0)) ;
    vector<vector<int>> numb(h+2,vector<int>(w+2,0)) ;
    int x, y ;
    x = Q.front().FI ;
    y = Q.front().SE ;
    queue<pair<int,int>> que ;
    que.push(MP(x,y)) ;
    seen[x][y] = 1 ;
    while(!que.empty()){
      int xx, yy ;
      xx = que.front().FI ;
      yy = que.front().SE ;
      REP(i,4){
        int X, Y ;
        X = xx+dx[i] ;
        Y = yy+dy[i] ;
        if(seen[X][Y]==0 && gra[X][Y]=='.'){
          seen[X][Y] = 1 ;
          numb[X][Y] = numb[xx][yy] + 1 ;
          que.push(MP(X,Y)) ;
          ans = max(ans,numb[X][Y]) ;
        }
      }
      que.pop() ;
    }
    Q.pop() ;
  }
  
  cout << ans <<endl ;
    

  return 0 ;
}

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

int a,b,c;
string solve(){
	cin>>a>>b>>c;
	if(a==b&&a!=c) return "Yes";
	if(a==c&&a!=b) return "Yes";
	if(b==c&&b!=a) return "Yes";
	return "No";
}
int main()
{
	cout<<solve();
}

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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    double A,B;
    cin >> A >> B;
    double ans = ceil(max(A/0.08, B/0.10));
    if(floor(ans*0.08)==A && floor(ans*0.10)==B) cout << ans;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int l, r, d;
    cin >> l >> r >> d;
    int res = 0;
    FOR(i,l,r) res += (i % d == 0);
    cout << res;
    return 0;
}


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

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(v,a,b) for(int v=(a); v<=(b); v++)
#define fr(v,a,b) for(int v=(a); v>=(b); v--)
#define rng(v,a,b) for(int v=(a); v<(b); v++)

using namespace std;
typedef long long ll;
template<typename T> T& chmax(T& a, T b) { a = a > b ? a : b; return a;}
template<typename T> T& chmin(T& a, T b) { a = a < b ? a : b; return a;}
const int maxn=1e5+5;
int a[maxn];
int b[maxn],len;
int lb(int x)
{
	int l = 1, r = len, mid, ans = 1;
	while(l<=r) {
		mid = (l+r)>>1;
		if(b[mid] > x) {
			r = mid-1; ans = mid;
		} else {
			l = mid+1; 
		}
	}
	return ans;
}
int main()
{
	int n; cin >> n;
	fo(i,1,n) cin >> a[i];
	b[++len] = a[n];
	fr(i,n-1,1) {
		if(a[i] >= b[len]) {
			b[++len] = a[i];
		} else {
			b[lb(a[i])] = a[i];
		}
	}
	cout << len << '\n';
	return 0;
}


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

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

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

ll sum[Max];
ll ans[Max];
bool vist[Max];
vector <int> G[Max];

void dfs(int u, ll cur) {
	cur += sum[u];
	vist[u] = 1;
	ans[u] = cur;
	for(int v : G[u]) {
		if(vist[v]) continue;
		dfs(v, cur);
	}
} 

int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, q, p, x, u, v;
	cin >> n >> q;
	for(int i = 1; i < n; i++) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	while(q--) {
		cin >> p >> x;
		sum[p] += x;
	}
	dfs(1, 0);
	for(int i = 1; i <= n; i++) {
		cout << ans[i] << " \n"[i == n];
	}
	return 0;
}

Measured memory_bytes: 70016
//------------------------
// ヘッダファイル
//------------------------
#include <stdio.h>
#include <ctype.h>

//------------------------
// マクロ
//------------------------
#define STACK 100

//------------------------
// 主処理
//------------------------
int main(void)
{
  //--- 宣言
  int stack[STACK]; // スタック
  int stack_n;  // スタック位置
  int sum; // 合計
  int digit_f; // 数が連続した場合のフラグ
  int k;  // 一時変数
  char ch;  // 文字取り出し用
  //--- 初期化
  stack_n = 0;
  digit_f = 0;
  //--- 入力
  
  while( (ch = getchar()) != '\n' ) { // 改行がくるまで入力を続ける
    //--- 計算
    if( isdigit(ch) ) { // 文字が整数('0'～'9')までの場合
      if( digit_f ) { // 整数が連続したかの判定
        stack[stack_n] = stack[stack_n] * 10 + (ch - '0');  // 連続した場合元の数に10かけてたす
      } else {
        stack[stack_n] = (ch - '0');
        digit_f++;
      }
    }
    if( isspace(ch) ) { // 空白なら
      if( digit_f ) { // 前の文字が整数だった場合
        stack_n++;
        digit_f = 0;
      }
    }
    if( ch == '+' ) { // 足し算
      //printf("+\n");  // デバッグ用
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] += stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '-' ) { // 引き算
      //printf("-\n");  // デバッグ用
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] -= stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '*' ) { // 掛け算
      //printf("*\n");  // デバッグ用
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] *= stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '/' ) { // 割り算
      //printf("/\n");  // デバッグ用
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] /= stack[stack_n];
      stack[stack_n] = 0;
    }
    /* for( k=0; k<=stack_n; k++ ) {  // デバッグ用
      printf("%d ",stack[k]);
    }
    printf("\n"); */
  }
  //--- 出力
  printf("%d\n",stack[0]);
  //--- 終了
  return 0;
}


Measured memory_bytes: 2140
#include<iostream>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u) {
	if (u == NIL) return;
	cout << " " << u;
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u) {
	if (u == NIL) return;
	inParse(T[u].l);
	cout << " " << u;
	inParse(T[u].r);
}

void postParse(int u) {
	if (u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	cout << " " << u;
}


int main()
{
	int i, v, l, r, root;
	cin >> n;
	for (i = 0; i < n; i++) T[i].p = NIL;
	
	for (i = 0; i < n; i++) {
		cin >> v >> l >> r;
		T[v].l = l;
		T[v].r = r;
		if (l != NIL)T[l].p = v;
		if (r != NIL)T[r].p = v;
	}

	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) root = i;
	}

	cout << "Preorder" << endl;
	preParse(root);
	cout << endl;
	cout << "Inorder" << endl;
	inParse(root);
	cout << endl;
	cout << "Postorder" << endl;
	postParse(root);
	cout << endl;

    return 0;
}

Measured memory_bytes: 3112
N = int(input())
list_d = list(map(int, input().split()))
len_d = len(list_d)
list_2d = []

for i in range(len_d-1):
    for j in range(i+1,len_d):
        recovery = list_d[i] * list_d[j]
        list_2d.append(recovery)

print(sum(list_2d))

Measured memory_bytes: 3060
dic = {}
dic[(0, 0)] = [""]
dic[(1, 0)] = ["A"]
dic[(0, 1)] = ["B"]
for s in range(2, 9):
  for i in range(min(5, s + 1)):
    j = s - i
    if j >= 5 or j <= -1:
      continue
    dic[(i, j)] = []
    if i - 1 >= 0:
      dic[(i, j)] += [lst + "A" for lst in dic[(i - 1, j)]]
    if j - 1 >= 0:
      dic[(i, j)] += [lst + "B" for lst in dic[(i, j - 1)]]
for i in range(4):
  dic[(5, i)] = [lst + "A" for lst in dic[(4, i)]]
  dic[(i, 5)] = [lst + "B" for lst in dic[(i, 4)]]

dic[(5, 4)] = [lst + "A" for lst in dic[(4, 4)]]
dic[(4, 5)] = [lst + "B" for lst in dic[(4, 4)]]
dic[(5, 5)] = [lst + "A" for lst in dic[(4, 5)]] + [lst + "B" for lst in dic[(5, 4)]]
dic[(6, 4)] = [lst + "A" for lst in dic[(5, 4)]]
dic[(4, 6)] = [lst + "B" for lst in dic[(4, 5)]]
j, y = map(int, input().split())
print(*sorted(dic[(j, y)]), sep="\n")


Measured memory_bytes: 5632
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
int main()
{
	// freopen("AGC024-A.in", "r", stdin); 
	ll a, b, c, k; 
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k); 
	printf("%lld\n", k & 1 ? b - a : a - b);
	return 0; 
}


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

int main()
{
    ll m, n;
    cin >> n >> m;
    int ans = 1;
    for (ll i = 1; i * i <= m; i++)
    {
        if (m % i == 0)
        {
            int a = i;
            int b = m / i;
            if (m / a >= n)
                ans = max(ans, a);
            if (m / b >= n)
                ans = max(ans, b);
        }
    }
    cout << ans << endl;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(n);
    for1(i, n) cin1(a[i]);

    ll mx = 0;
    for1(i, n) {
        if(mx <= a[i]) {
            mx = a[i];
            continue;
        }
        ans += (mx - a[i]);
        mx = max(mx, a[i]);
    }
    cot1(ans);

    return 0;
}



Measured memory_bytes: 5152
#include "bits/stdc++.h"
#define int long long
#define fi first
#define se second
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n;
string s;
int a[1000006],pref[1000006][4],dp[1000006][4];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    cin>>s;
    cin>>n;
    vector<int> k;
    for (int i=0; i<n; i++){
        int n1;
        cin>>n1;
        k.push_back(n1);
    }
    for (int i=0; i<s.size(); i++){
        if (s[i]=='D') {
            a[i] = 1;
        }else
        if (s[i]=='M'){
            a[i]=2;
        }else
        if (s[i]=='C'){
            a[i]=3;
        }
        else
            a[i]=0;
    }
    /*cout<<"OK"<<endl;
    cout<<s.size()<<endl;
     */
    for (int i=0; i<s.size(); i++){
        if (a[i]==0 && i!=0){
            pref[i][1]+=pref[i-1][1];
            pref[i][2]+=pref[i-1][2];
            continue;
        }
        pref[i][a[i]]++;
        if (i!=0) {
            pref[i][1] += pref[i - 1][1];
            pref[i][2] += pref[i - 1][2];
        }

    }
    for (int i=0; i<s.size(); i++)
    {
        if (a[i]==1) dp[i][1]++;
        if (a[i]==2 && i!=0) dp[i][2]+=dp[i-1][1];
        if (a[i]==3 && i!=0) dp[i][3]+=dp[i-1][2];
        if (i!=0){
            dp[i][1]+=dp[i-1][1];
            dp[i][2]+=dp[i-1][2];
            dp[i][3]+=dp[i-1][3];
        }
    }
    for (auto kk:k) {
        int ans = 0;
        for (int i = kk ; i < s.size(); i++) {
            if (a[i] == 3 && i!=0) {

                int p1 = pref[i - 1][2] - pref[i - kk][2];
                int D = pref[i - kk][1];
                //cout << p1 << " " << D << endl;
                ans += dp[i - kk][2] + D * p1;


            }

        }
        //cout<<ans<<endl;
        cout << dp[s.size() - 1][3] - ans<<endl;
    }
}

Measured memory_bytes: 71708
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    int n = s.size();

    string as = "";
    rep(i, n){
        if (s[i] == '0') as += "0";
        else if (s[i] == '1') as+= "1";
        else {
            if (as.size() != 0) as.erase(as.end()-1);
        }
    }
    cout << as << endl;

}



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

int main() {
    vector<int> a;
    int l, i = 0;
    while (cin >> l) {
        a.push_back(l);
        i++;
    }
    int b = (a[0]*(a[0]-1)+a[1]*(a[1]-1))/2 ;
    cout << b << endl;
}

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final int[][] graph = new int[n + 1][n + 1];
        for (final int[] array : graph) {
            Arrays.fill(array, Integer.MAX_VALUE / 2);
        }
        final List<Edge> edges = new LinkedList<>();
        for (int i = 0; i < m; i++) {
            final int from = scanner.nextInt();
            final int to = scanner.nextInt();
            final int cost = scanner.nextInt();

            edges.add(new Edge(from, to, cost));
            graph[from][to] = cost;
            graph[to][from] = cost;
        }

        for (int k = 0; k < n + 1; k++) {
            for (int i = 0; i < n + 1; i++) {
                for (int j = 0; j < n + 1; j++) {
                    graph[i][j] = Math.min(graph[i][j], graph[i][k] + graph[k][j]);
                }
            }
        }

        final long answer = edges.stream()
                .filter(edge -> edge.cost > graph[edge.from][edge.to])
                .count();

        System.out.println(answer);
    }

    static class Edge {
        int from;
        int to;
        int cost;

        Edge(final int from, final int to, final int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
    }
}


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

int main(){
  set<int> S;
  for(int i=0;i<3;++i){
    int a;
    cin>>a;
    S.insert(a);
  }
  if(S.size()==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int h,w,dp[105][105]={},x,y;
  cin >> h >> w;
  string s[105]={};
  for(int i=0; i<h; i++) {
    cin >> s[i];
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      dp[i][j]=inf;
    }
  }
  if(s[0][0]=='.') {
    dp[0][0]=0;
  }
  else {
    dp[0][0]=1;
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(i==0&&j==0) {
        continue;
      }
      else {
        if(i==0) {
          dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'));
        }
        else if(j==0) {
          dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
        }
        else {
          x=dp[i-1][j]+(s[i][j]=='#'&&s[i-1][j]=='.');
          y=dp[i][j-1]+(s[i][j]=='#'&&s[i][j-1]=='.');
          dp[i][j]=min(x,y);
        }
      }
    }
  }
  cout << dp[h-1][w-1] << "\n";
}

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

int main() {
    string  s;
    cin >> s;
    int year = stoi(s.substr (0,4));
    int month = stoi(s.substr (5,2));
    int day = stoi(s.substr(8,2));
    if (year <=2019)
    {
        if (month <=4)
        {
            if (day<=30)
            {
                cout << "Heisei";
                return 0;
            }
        }
    }

    cout << "TBD";
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long double a,b;
    cin >> a >> b;
    cout << fixed << setprecision(0) << floor(a*b) << "\n";
    return 0;
}


Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while (cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 0;
	while (1){
		if (cur == nil) break;
		// if (isf++ > 0) printf(" ");
		if (isf++ > 0) cout << " ";
		// printf("%d", cur->key);
		cout << cur->key;
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){

	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x =  (Node *)malloc(sizeof(Node));
	x->key = key;

	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	//cin >> &n;
	init();
	for (i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		//cin >> com >> &key;
		if (com[0] == 'i'){ insert(key); np++; size++; }
		else if (com[0] == 'd'){
			if (strlen(com) > 6){
				if (com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();

	return 0;
}

Measured memory_bytes: 32364
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    sc.close();

    int[][] d = new int[N + 1][N + 1];
    for (int i = 1; i < N + 1; i++)
      for (int j = i + 1; j < N + 1; j++)
        d[i][j] = Integer.min(j - i,
            Math.abs(X - i) + 1 + Math.abs(j - Y));

    int[] ans = new int[N];
    for (int i = 1; i < N + 1; i++)
      for (int j = i + 1; j < N + 1; j++)
        ans[d[i][j]]++;

    for (int i = 1; i < N; i++)
      System.out.println(ans[i]);
  }
}


Measured memory_bytes: 53456
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i, 1, n){
        a[i] += a[i - 1];
    }
    int ans = 1e12;
    rep(i, 0, n - 1){
        ans = min(ans, abs((sum - a[i]) - a[i]));
    }
    cout << ans << endl;
}

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

int main(){
	long long a,b,c;
	long long x,y;
	cin>>a>>b>>c>>x>>y;
	long long minpizza = min(x,y);
	long long money = 0;
	if(a+b>2*c){
		money+=(2*c)*minpizza;
		x-=minpizza;
		y-=minpizza;
	}
	else{
		money+=(a+b)*minpizza;
		x-=minpizza;
		y-=minpizza;
	}
	if(y){
		if(b>2*c) money+=2*c*y;
		else money+=b*y;
	}
	else{
		if(a>2*c) money+=2*c*x;
		else money+=a*x;
	}
	cout<<money;
}

Measured memory_bytes: 3168
a, i = gets.chomp.split.map(&:to_i)
n = Array.new(a)
d = Array.new
a.times do |hoge|
    n[hoge] = gets.chomp.split.map(&:to_i)
    n[hoge].delete_at(0)
    if hoge != 0 then
        d = n[hoge] & n[hoge - 1]
        n[hoge] = d
    else 
        d = n[hoge]
    end
end
puts d.size


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;
int dx[] = {0, 1};
int dy[] = {1, 0};
int H, W;
vector<string> s;
vector<vector<int>> cnt;
int main(){
  cin >> H >> W;
  s.resize(H);
  REP(i, H){
    cin >> s[i];
  }
  cnt.resize(H, vector<int>(W, INF));
  if(s[0][0] == '.'){
    cnt[0][0] = 0;
  }
  else{
    cnt[0][0] = 1;
  }
  REP(i, H){
    REP(j, W){
      REP(k, 2){
        int nx = j+dx[k], ny = i+dy[k];
        if(W <= nx || H <= ny) continue;
        if(s[i][j] == '.' && s[ny][nx] == '#'){
          cnt[ny][nx] = min(cnt[ny][nx], cnt[i][j]+1);
        }
        else{
          cnt[ny][nx] = min(cnt[ny][nx], cnt[i][j]);
        }
      }
    }
  }
  cout << cnt[H-1][W-1] << endl;

  return 0;
}



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

int main() {
	int N,K;
	cin >>N>>K;
	vector<int> A(N);
	for(int i = 0;i<N;i++){
			cin >>A.at(i);
	}
	for(int i =K;i<N;i++){
			if(A.at(i)<=A.at(i-K)){
				cout<<"No"<<endl;
			}else{
					cout<<"Yes"<<endl;
			}
	}
			

} 


Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int a=0,i,s;
      char b[4];
      scanf("%s",b);
      for(i=0;i<3;i++)
      {
             if(b[i]=='o')
             {
                   a++;
             }
      }
      s=700+a*100;
      printf("%d",s);
      return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
typedef long long LL;
using namespace std;
LL dp[55][2501];
int now;
int main(){
    dp[0][0]=1;
    int n,m,k,t;
    int a;
    LL ans=0;
    cin>>n>>a;
    for (int i=1; i<=n; ++i) {
        scanf("%d",&k);
        now+=k;
        for (int j=i; j>=1; --j) {
            for (t=now; t>=k; --t) {
                dp[j][t]+=dp[j-1][t-k];
            }

        }
    }
    for (int i=1; i<=n; ++i)ans+=dp[i][a*i];
    printf("%lld\n",ans);
}


Measured memory_bytes: 1280
x, n = map(int, input().split())
p = list(map(int, input().split()))
min_num = 0

if n == 0:
    print(x)
    exit()

for i in range(100 + 2):
    if not(i in p):
        if abs(x - i) < abs(x - min_num):
            min_num = i

print(min_num)

Measured memory_bytes: 61824
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N,M = map(int,input().split())
    uf = UnionFind(N+1)
    for i in range(M):
        a, b = map(int,input().split())
        uf.union(a,b)
    print(uf.group_count()-2)
main()

Measured memory_bytes: 74532
require "prime"
P = 10 ** 9 + 7
N = gets.to_i
nf = 1
(2..N).each{|i|
    nf *= i
}
pd = Prime.prime_division(nf)
result = 1
pd.each{|i|
    result = result * (i[1] + 1) % P
}
puts result


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

int main(){
  bool f=0;
  int x,y;cin>>x>>y;
  REP(i,x+1){
    int tr=i,km=x-i;
    int ashi = tr*2 + km*4;
    if(ashi==y) f=1;
  }

  cout<<(f?"Yes":"No");
}

Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const ll LINF = (ll)1 << 60;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int count=0;
  vint a(3);
  set<tuple<int,int,int> > S;
  rep(i,n){
    cin>>a[0]>>a[1]>>a[2];
    sort(all(a));
    if(S.find(make_tuple(a[0],a[1],a[2]))==S.end()){
      S.insert(make_tuple(a[0],a[1],a[2]));
    }
    else{
      count++;
    }
  }
  cout<<count<<'\n';
  return(0);
}



Measured memory_bytes: 3320
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc =  new Scanner(System.in);
		int t[] = new int[5];
		int sum = 0;
		for(int i = 0; i < t.length; i++){
			t[i] = sc.nextInt();
			if(t[i] < 40) t[i] = 40;
			sum += t[i];
		}
		System.out.println(sum / 5);
	}
}

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

using namespace std;

typedef long long         ll;
typedef vector<int> vi;

#define pb(v)           push_back(v)
#define all(v)          v.begin(),v.end()
#define sz(v)           (int)v.size()
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define p(x)			cout<<#x<<" = { "<<x<<" }\n"
#define mp				make_pair


const int OO = (int)2e9;
const ll oo = 5e18;
const int M = 1e5+50;


int main()
{
    int n,a[20],x=0;
    cin >> n;
    lp(i,n)cin >> a[i];
    for(int i = 1;i<n-1;i++)
    {
        int f=0;
        if(a[i]>a[i-1])f++;
        if(a[i+1]>a[i])f++;
        if(f!=1)x++;
    }
    cout << x;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a[40], b[40], c[40], x, y;
int dp[505][505];

int main(){
	cin >> n >> x >> y;
	for(int i = 0; i < n; i++){cin >> a[i] >> b[i] >> c[i];}
	
	for(int i = 0; i < 505; i++) for(int j = 0; j < 505; j++){
		dp[i][j] = INF;
	}
	
	dp[0][0] = 0;
	for(int k = 0; k < n; k++){
		for(int i = 504; i >= 0; i--){
			for(int j = 504; j >= 0; j--){
				if(i < a[k] || j < b[k]) continue;
				dp[i][j] = min(dp[i][j], dp[i-a[k]][j-b[k]] + c[k]);
			}
		}
	}
	
	int ans = INF;
	for(int i = x, j = y; i < 505 && j < 505; i += x, j += y){
		ans = min(ans, dp[i][j]);
	}
	
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cctype>
using namespace std;
int main(){
    string W;
    string tex;
    int count = 0;
    cin >> W;
    while(true){
        cin >> tex;
        if(tex == "END_OF_TEXT"){
            break;
        }
        for(int i = 0; i < tex.size(); i++){
            if(isupper(tex[i])){
                tex[i] = tolower(tex[i]);
            }
        }
        if(tex == W){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3128
import sys
input = sys.stdin.readline

h, w, d = map(int, input().split())
n = h*w
a = [0]*n
for i in range(h):
    t = list(map(int, input().split()))
    for j in range(w):
        a[w*i+j] = t[j]-1

def dist(i, j):
    dh = abs(i//w - j//w)
    dw = abs(i%w - j%w)
    return dh + dw

idx_list = [0] * n
for i in range(n):
    idx_list[a[i]] = i

dist_list = [0]*n
for i in range(n):
    if i < d:
        dist_list[i] = 0
    else:
        dist_list[i] = dist_list[i-d] + dist(idx_list[i-d], idx_list[i])

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    l-=1; r-=1
    print(dist_list[r] - dist_list[l])



Measured memory_bytes: 19940
import sys
input=sys.stdin.readline
import fractions

d,n = map(int, input().split())
ans = 100**d*n
if d == 0:
    if ans == 100:
        ans += 1
elif d == 1:
    if ans == 10000:
        ans += 100
elif d == 2:
    if ans == 1000000:
        ans += 10000

print(ans)


Measured memory_bytes: 5176
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>

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

  int k;
  std::cin >> k;

  int sum = a + b + c + std::max({a, b, c}) * (std::pow(2, k) - 1);
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    int res=0;
    vector<int> a,b;
    set<int> c;
    for(int i=0;i<n;i++){
        if(s[i]=='R')a.push_back(i);
        else if(s[i]=='G')b.push_back(i);
        else c.insert(i);
    }
    sort(All(a));
    sort(All(b));
    int num=c.size();
    for(auto r:a){
        for(auto g:b){
            int mi=0;
            if(r<g){
                int d=g-r;
                if(c.count(g+d))mi++;
                if(c.count(r-d))mi++;
                if(d%2==0){
                    int x=(r+g)/2;
                    if(c.count(x))mi++;
                }
            }else{
                int d=r-g;
                if(c.count(r+d))mi++;
                if(c.count(g-d))mi++;
                if(d%2==0){
                    int x=(r+g)/2;
                    if(c.count(x))mi++;
                }
            }
            res+=num-mi;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3676
fmod v m
  | v >  m    = fmod (v-2*m) m
  | v < -m    = fmod (v+2*m) m
  | otherwise = v

fmod' v m
  | v >  m    = fmod (v-m) m
  | v <  0    = fmod (v+m) m
  | otherwise = v

ans [t1,t2] =
  let t0 = fmod (t1 - t2 + 360) 180
      s0 = (fromIntegral t0) / 2.0 + (fromIntegral t2) :: Float
      s1 = fmod' s0 360
  in
    s1

main = do
  c <- getContents
  let i = map read $ lines c :: [Int]
      o = ans i
  print o



Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int N;
vector<int> A;

int S[200010];

pair<int, int> solve(int start, int end) {
	int low = 0;
	int high = end - 1;
	while (high - low > 3) {
		int mid1 = low + (high - low) / 3;
		int mid2 = low + 2 * (high - low) / 3;
		int val1 = abs(S[end] - S[mid1] - (S[mid1] - S[start]));
		int val2 = abs(S[end] - S[mid2] - (S[mid2] - S[start]));
		if (val1 > val2) {
			low = mid1;
		} else {
			high = mid2;
		}
	}

	int minval = LLONG_MAX;
	pair<int, int> ret;
	REP(i, max(1LL, low - 5), min(end - 1, low + 5)) {
		int val = abs(S[end] - S[i] - (S[i] - S[start]));
		if (val < minval) {
			minval = val;
			ret = mp(min(S[end] - S[i], (S[i] - S[start])), max(S[end] - S[i], (S[i] - S[start])));
		}
	}
	return ret;
}

signed main() {
	cin >> N;

	inputVector(A, N);

	S[0] = 0;
	rep(i, N) {
		S[i + 1] = S[i] + A[i];
	}

	int ret = LLONG_MAX;
	REP(i, 2, N - 2) {
		pair<int, int> res1 = solve(0, i);
		pair<int, int> res2 = solve(i, N);
		int minval = min(res1.first, res2.first);
		int maxval = max(res1.second, res2.second);
		ret = min(ret, maxval - minval);
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

bool P[110000] = {};
int PP[110000] = {};

void prime1() {
	for (int i = 2; i <= 100000; i++) {
		P[i] = true;
	}

	for (int i = 2; i <= sqrt(100000); i++) {
		if (P[i]) {
			for (int j = 2; j <= 100000 / i; j++) {
				P[i * j] = false;
			}
		}
	}
}

void prime2() {
	for (int i = 1; i <= 100000; i++) {
		if (P[i] && i % 2 == 1 && P[(i + 1) / 2]) PP[i] = PP[i - 1] + 1;
		else PP[i] = PP[i - 1];
	}
}

int main() {
	int Q, l, r;
	cin >> Q;
	prime1();
	prime2();
	for (int i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << PP[r] - PP[l - 1] << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int t[N], x[N], y[N];
    REP(i, N){
        cin >> t[i] >> x[i] >> y[i];
    }

    int count = 0;
    REP(i, N){
        if((t[i] - x[i] - y[i]) % 2 == 0 && t[i] - x[i] - y[i] >= 0){
            count++;
        }
    }

    if(count == N){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
    long long n;
    long long p;
  	cin >> n >> p ;
    long long root;
    long long r =2;
    root = sqrt(p);

    vector<long long> f;
    while(root>= r){
        if(p%r==0){
            f.push_back(r);
            p = p / r;
        }
        else{
            r += 1;
        }
    }
    if(p>2){
        f.push_back(p);
    }

/*	for(int i=0;i<f.size();i++){

        cout << f.at(i) << endl;
    }
*/
    long long answer = 1;
    long long now = 1;
    long long k = 0;
    for(long long i =0;i<f.size();i++){
        if(now==f.at(i)){
            k += 1;
        }
        else{
            answer = answer * pow(now , (k / n));
            now = f.at(i);
            k=1;
        }
    }
    answer = answer *  pow(now , (k / n));
    cout << answer << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
 
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if(a > 0) cout << "Positive" << endl;
  else if(a <= 0 && b >= 0) cout << "Zero" << endl;
  else {
    if((abs(a) - abs(b)) % 2 == 0) {
      cout << "Negative" << endl;
    }else {
      cout << "Positive" << endl;
    }
  }
 
}

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

int main(){
    int K, N;
    cin >> K >> N;
    int A[N];
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    int temp = A[N-1] - A[0];

    for(int i = 0; i < N-1; i++){
        if(K - A[i+1] + A[i] < temp) temp = K - A[i+1] + A[i];
    }

    cout << temp << endl;




}

Measured memory_bytes: 1024
from collections import deque
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
ma = 0
for i in range(H):
    for j in range(W):
        d=deque()
        if S[i][j]==".":
            dp=[[float("inf") for _ in range(W)] for _ in range(H)]
            dp[i][j]=0
            d.append([i,j])
            while len(d)>0:
                x,y=d.popleft()
                if x!=0:
                    if S[x-1][y]==".":
                        if dp[x-1][y]>(dp[x][y]+1):
                            dp[x-1][y]=dp[x][y]+1
                            d.append([x-1,y])
                if x!=H-1:
                    if S[x+1][y]==".":
                        if dp[x+1][y]>(dp[x][y]+1):
                            dp[x+1][y]=dp[x][y]+1
                            d.append([x+1,y])
                if y!=0:
                    if S[x][y-1]==".":
                        if dp[x][y-1]>(dp[x][y]+1):
                            dp[x][y-1]=dp[x][y]+1
                            d.append([x,y-1])
                if y!=W-1:
                    if S[x][y+1]==".":
                        if dp[x][y+1]>(dp[x][y]+1):
                            dp[x][y+1]=dp[x][y]+1
                            d.append([x,y+1])
                #print(dp,d)
            for k in range(H):
                for l in range(W):
                    if dp[k][l]!=float("inf"):
                        ma=max(ma,dp[k][l])
print(ma)




Measured memory_bytes: 76016
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll a, b;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> a >> b;
	for(ll i = 1; i <= 100000	; i++){
		ll temp = i * 8ll / 100ll;
		ll temp2 = i * 10ll / 100ll;
		if(temp == a && temp2 == b){
			 cout << i << '\n';
			 return 0;
		 }
	 }
	 cout << -1 << '\n';
}


Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll X;
    cin >> X;
    ll ans = 0;
    ans += 1000 * (X / 500);
    ll mod = X % 500;
    X /= 500;
    X += mod;
    ans += 5 * (mod / 5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
  Contest 062
  B - Picture Frame
  Rakesh Kumar --> 28/08/2020
 */

#include <bits/stdc++.h>



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

    int h = 0, w = 0;
    std::cin >> h >> w;
    std::cin.ignore();
    std::string top(w + 2, '#');

    std::vector<std::string> v;
    while (h--) {
        std::string s;
        std::getline(std::cin, s);
        v.emplace_back(s);
    }

    std::cout << top << std::endl;
    for (const std::string& s : v)
        std::cout << "#" << s << "#" << std::endl;
    std::cout << top << std::endl;

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N, K;

	cin >> N >> K;

	cout << N-K+1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <cassert>
#include <time.h>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>
#define print_time()cout<<clock()/CLOCKS_PER_SEC<<" s"<<endl;

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//  std::ios::sync_with_stdio(false);
//  std::cin.tie(NULL);
//  return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


char s[200010];
int ans[200010];
int main() {
	IOS;
	cin >> s;
	int n = strlen(s), c = 0;
	bool f = true;
	repi(0, n) {
		if (s[i] == 'R')c++;
		if (s[i] == 'L' && f) {
			f = false;
			int p = 1, c2 = 1;
			while (s[i + p] == 'L') { p++; c2++; }
			ans[i] += c / 2 + (c2 + 1) / 2;
			ans[i - 1] += (c + 1) / 2 + c2 / 2;
			i += p - 1;
			c = 0;
		}
		else if (s[i] == 'R' && !f)f = true;
	}
	repi(0, n)cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
flag = 0
cnt = 1
state = [0,0,0]
# print(a)
for i in range(1,n):
#     print(state,'cnt=',cnt)
    if a[i] > a[i-1]:
        if flag == -1:
            cnt += 1
            flag = 0
        else:
            flag = 1
        state[0] += 1
    elif a[i] == a[i-1]:
        continue
        state[1] += 1
    elif a[i] < a[i-1]:
        if flag == 1:
            cnt += 1
            flag = 0
        else:
            flag = -1
        state[2] += 1
print(cnt)
    

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

int main(){
  int n,k,a[200010]={},b[200010]={};
  cin>>n>>k;
  for(int i=0;i<n;++i)cin>>a[i];

  sort(a,a+n);

  int j=0;
  for(int i=0;i<n;++i){
    if(a[i]==a[i+1])b[j]++;
    else{
      b[j]++;
      j++;
    }
  }

  sort(b,b+j);
  reverse(b,b+j);

  int ans=0;
  while(j>k){
    ans+=b[--j];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#coding:utf-8
n = int(input())
l = list(map(int, input().split()))

for i in range(n):
    id = i + 1
    ans = "node " + str(id) + ": key = " + str(l[id - 1])
    if id != 1:
        parent = id // 2 - 1
        ans += ", parent key = " + str(l[parent])
    if n > 2 * i + 1:
        ans += ", left key = " + str(l[2 * i + 1])
    if n > 2 * i + 2:
        ans += ", right key = " + str(l[2*i + 2])
    ans += ", "
    print(ans)
   

Measured memory_bytes: 7676