akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct node { int pr, l, r; };
node t[25];
int d[25], h[25];

void setd(int u, int p) {
	if (!~u)return;
	d[u] = p;
	setd(t[u].l, p + 1);
	setd(t[u].r, p + 1);
}
int seth(int u) {
	int h1 = 0, h2 = 0;
	if (~t[u].l)h1 = seth(t[u].l) + 1;
	if (~t[u].r)h2 = seth(t[u].r) + 1;
	return h[u] = max(h1, h2);
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n)t[i].pr = -1;
	rep(i, n) {
		int id, l, r; scanf("%d%d%d", &id, &l, &r);
		t[id].l = l; t[id].r = r;
		t[l].pr = t[r].pr = id;
	}
	rep(i, n) {
		if (!~t[i].pr) {
			setd(i, 0); seth(i);
			break;
		}
	}
	rep(i, n) {
		int deg = 0, s = -1;
		if (~t[i].l)deg++; if (~t[i].r)deg++;
		if (~t[i].pr) {
			if (i == t[t[i].pr].l)s = t[t[i].pr].r;
			else s = t[t[i].pr].l;
		}
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, t[i].pr, s, deg, d[i], h[i]);
		if (!~t[i].pr)puts("root");
		else if (!~t[i].l && !~t[i].r)puts("leaf");
		else puts("internal node");
	}
}

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

const int max_n = 40, max_ab = 10, INF = 100001;

int a[max_n], b[max_n], c[max_n];
int dp[max_n + 1][max_n*max_ab + 1][max_n*max_ab + 1];


int main()
{
	int n, ma, mb;
	cin >> n >> ma >> mb;

	for (int i = 0;i < n;i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 0;i <= max_n;i++) {
		for (int j = 0;j <= max_n * max_ab;j++) {
			for (int k = 0;k <= max_n * max_ab;k++) {
				dp[i][j][k] = INF;
			}
		}
	}

	for (int i = 0;i <= max_n;i++) dp[i][0][0] = 0;

	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n * max_ab;j++) {
			for (int k = 1;k <= n * max_ab;k++) {
				if (a[i - 1] <= j && b[i - 1] <= k) {
					dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
				}
				else dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}

	int min_cost = INF;
	for (int i = 1;i <= n * max_ab;i++) {
		for (int j = 1;j <= n * max_ab;j++) {
			if (i * mb == j * ma) min_cost = min(min_cost, dp[n][i][j]);
		}
	}

	if (min_cost == INF) cout << -1 << endl;
	else cout << min_cost << endl;

    return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, m;
    cin >> n >> m;
    int field[105][105];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            field[i][j] = INF;
        }
        field[i][i] = 0;
    }
    int a[1005], b[1005], c[1005];
    for(int i = 1; i <= m; i++){
        cin >> a[i] >> b[i] >> c[i];
        field[a[i]][b[i]] = c[i];
        field[b[i]][a[i]] = c[i];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                field[j][k] = min(field[j][k], field[j][i] + field[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= m; i++){
        if(field[a[i]][b[i]] < c[i]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def main():

    S = input()
    T = input()

    dp = [[0 for _ in range(len(T)+1)] for _ in range(len(S)+1)]


    for i, s in enumerate(S):
        for j,t in enumerate(T):

            #Sのi文字目とTのｊ文字目が同じなら、共通部分列にそれを付け足すとよい。
            if s == t:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                # 異なる場合はそれまでの最長の共通部分列と同じ
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]) 

    
    i, j = len(S), len(T)
    substr = ""
    while i != 0 and j != 0:
        # 同じ文字で部分列が伸びた場合、その文字を部分列に加える
        if S[i-1] == T[j-1]:
            substr += S[i-1]
            i,j = i-1, j-1
        else:
            #　それまでの最長の共通部分列を引き継いだ場合、より長いほうに戻る
            if dp[i][j-1] >= dp[i-1][j]:
                j -= 1
            else:
                i -= 1
    print(substr[::-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 120028
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int l, r, d;
	cin >> l >> r >> d;
	cout << r / d - (--l) / d << endl;
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int test[123456];
signed main() {
	int n, m, a, sum = 0, ans = 0; string s, t; cin >> n >> m >> a;
	
	cout << (a + max(n,m) - 1) / max(n, m) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>




int n,m,q;






int main(void)
{
    
    cin>>n>>m>>q;
    vector<int> s;
    s.push_back(1);
    vector<int> a(q+3);
    vector<int> b(q+3);
    vector<int> c(q+3);
    vector<int> d(q+3);
    ll ans = -1;
    rep(i,q)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    stack<vector<int> > st;

    st.push(s);

    while(!st.empty())
    {
       vector<int> now =  st.top();
       st.pop();

        for(int i = now.back();i<=m;i++)
        {
            
            if(now.size()==n)
            {
        
                vector<int> nowww = now;
                nowww.push_back(i); 
                ll nowans = 0;
                for(int j=0;j<q;j++)
                {
                    if(nowww[b[j]]-nowww[a[j]]==c[j]) nowans += d[j];

                }
                
                ans = max(ans,nowans);
                
            }//点数計算

            else
            {
                vector<int> next= now;
                next.push_back(i);
                st.push(next);
            }

        }

    }
    
    

cout<<ans<<endl;

}

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

int main(void){
    ll a; double b;
    cin >> a >> b;

    int ib = b*100+0.5;
    cout << a*ib/100 << endl;

    return 0;
}


Measured memory_bytes: 3724
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int a[40003], b[40003];

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int n, i, k, ans;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d", a+i);
		for (i = 0; i < n; i++) scanf("%d", b+i);
		qsort(a, n, sizeof(int), cmp);
		qsort(b, n, sizeof(int), cmp);

		for (ans = n, i = k = 0; k < n; i++, k += 2) {
			if (a[k] > b[i]) { ans = k + 1; break; }
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

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

string to_string(const string& s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 998244353, nn = 3003;

void solve(){
    int n, s;
    cin >> n >> s;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<vector<int>> dp(n+1, vector<int>(s+1));
    
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= s; j++) {
            dp[i][j] = 2 * dp[i-1][j] % mod;
            if(j >= a[i]) {
                dp[i][j] = (dp[i][j] + dp[i-1][j-a[i]]) % mod;
            }
        }
    }
    cout << dp[n][s] << '\n';
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 73652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);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; }

int n;
vector<vector<int>> G;

void dfs(int v, vector<bool>& fg){
    for(int e: G[v]){
        if(!fg[e]){
            fg[e] = true;
            dfs(e, fg);
        }
    }
}

int main() {
    int m; cin >> n >> m;
    G.assign(n, vector<int>());
    rep(i, m){
        int x, y, z; cin >> x >> y >> z; x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    vector<bool> visited(n, false);
    int cnt = 0;
    rep(i, n){
        if(!visited[i]){
            visited[i] = true;
            cnt++;
            dfs(i, visited);
        }
    }
    cout << cnt << ln;
}



Measured memory_bytes: 7680
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if (c<=a+b)
		cout<<"No"<<endl;
	else
	{
		ll k=c-a-b;
		if (a*b*4<k*k)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

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

int main() {
	// your code goes here
	int a,b;
	cin >> a >> b;
	if(a>b)
	cout << "a > b" << endl;
	else if(a==b)
	cout << "a == b" << endl;
	else
	cout << "a < b" << endl;
	return 0;
}

Measured memory_bytes: 3056
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		string[] strArray = Console.ReadLine().Split(' ').ToArray();
		string S = strArray[0];
		string T = strArray[1];

		int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int A = intArray[0];
		int B = intArray[1];

		string U = Console.ReadLine();

		if(S == U)
		{
			A -= 1;
		}
		else
		{
			B -= 1;
		}
		Console.WriteLine(A + " " + B);
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();


Measured memory_bytes: 11348
n=str(input())
if n[len(n)-1]=="3":
    print("bon")
elif n[len(n)-1]=="2" or n[len(n)-1]=="4" or n[len(n)-1]=="5" or n[len(n)-1]=="7" or n[len(n)-1]=="9":
    print("hon")
else:
    print("pon")

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

//printVector(配列, 区切り文字)
template <typename T>
void printVector(vector<T> v, string delimiter) {
  for (int i=0; i<v.size(); i++) {
    if (i>0) cout << delimiter;
    cout << v[i];
  }
  cout << endl;
}

void bubbleSort(vector<string> &A, int N) {
  for (int i=0; i<N; i++) {
    for (int j=N-1; j>i; j--) {
      if (int(A.at(j).at(1)) < int(A.at(j-1).at(1))) {
        swap(A.at(j), A.at(j-1));
      }
    }
  }
}

void selectionSort(vector<string> &A, int N) {
  for (int i=0; i<N; i++) {
    int minj = i;
    for (int j=i; j<N; j++) {
      if (int(A.at(j).at(1)) < int(A.at(minj).at(1))) {
        minj = j;
      }
    }
    swap(A.at(i), A.at(minj));
  }
}

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

  vector<string> a(n);
  vector<string> b(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }

  bubbleSort(a, n);
  selectionSort(b, n);

  printVector(a, " ");
  cout << "Stable" << endl;
  printVector(b, " ");
  if (equal(a.begin(), a.end(), b.begin(), b.end())) {
    cout << "Stable" << endl;
  }
  else {
    cout << "Not stable" << endl;
  }


}



Measured memory_bytes: 3168
console.log((args=>{
  const [[N],D] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0));
  if ( N === 1 ) return `${D[0]}`;
  const q = Array(13).fill(0);
  let _s = 12, s = 1;
  for ( let i = 0; i < N; i++ ) {
    if ( ++q[D[i]] > 2 ) return '0';
    if ( D[i] < _s ) _s = D[i];
    if ( q[D[i]] === 2 ) _s = Math.min(_s,24-2*D[i]);
  }
  if ( q[12] > 1 || q[0] > 0 ) return '0';
  const mask = q.reduce((a,b,i)=>a|(b===1?0:1<<i),1);
  for ( let m = 0; m < 1<<13; m = m+1|mask ) {
    let min = _s;
    for ( let a = 1; a <= 12; a++ ) {
      if ( !q[a] ) continue;
      for ( let b = a+1; b <= 12; b++ ) {
        if ( !q[b] ) continue;
        let t = b - a;
        if ( q[a]===1 && q[b] === 1 ) t = (m>>a&1^m>>b&1)?24-a-b:t;
        min = Math.min( min, t );
      }
    }
    if ( s < min ) s = min;
  }
  return `${s}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32264
#include <bits/stdc++.h>
using namespace std;
char a[100000],b[100000];
int main()
{
	cin>>a>>b;
	int la=strlen(a),lb=strlen(b); 
	for (int i=0;i<lb;i++)
	   cout<<a[i]<<b[i];
	if (la>lb)
	  cout<<a[la-1];
	return 0;
}

Measured memory_bytes: 256
def s(n):
  return n / sum(map(int, str(n)))
k = int(input())
p = 1
e = 0
i = 0
while i < k:
  n = (p + 1) * 10**e - 1
  nxt = (p + 2) * 10**e - 1
  if s(n) <= s(nxt):
    print(n)
    p += 1
    i += 1
  else:
    e += 1
    p = (p + 1) // 10


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using LD = long double;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL x, y;
    cin >> x >> y;
    if (abs(x - y) < 2) cout << "Brown\n";
    else cout << "Alice\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector<int> r;
    vector<int> g;
    int b=0;
    REP(i,n){
        if(s[i]=='R') r.push_back(i);
        if(s[i]=='G') g.push_back(i);
        if(s[i]=='B') b++;
    }
    if (r.empty() || g.empty() || b==0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=0;
    REP(i,r.size()){
        REP(j,g.size()){
            int x=r[i];
            int y=g[j];
            ans+=b;
            int sa=abs(x-y);
            if(x<y){
                if(x-sa>=0&&s[x-sa]=='B')ans--;
                if(y+sa<n&&s[y+sa]=='B')ans--;
                if(sa%2==0&&s[(x+y)/2]=='B')ans--;
            }
            else{
                if (y - sa >= 0 && s[y - sa] == 'B')
                    ans--;
                if (x + sa < n && s[x + sa] == 'B')
                    ans--;
                if (sa % 2 == 0 && s[(x + y) / 2] == 'B')
                    ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3668
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<String>();
    let a = v[0].parse::<i128>().unwrap();
    let b = v[1].chars().collect::<Vec<_>>();
    let mut ans = 0;
    ans += a * b[0].to_digit(10).unwrap() as i128 * 100;
    ans += a * b[2].to_digit(10).unwrap() as i128 * 10;
    ans += a * b[3].to_digit(10).unwrap() as i128 * 1;
    ans /= 100;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int A,B,K;
  cin>>A>>B>>K;
  int a[101]={};
  for(int i=A; 0<i;i--){
    if(B%i==0 && A%i==0){
      a[i]=i;}
  }
    sort(a,a+A+1);
    reverse(a,a+A+1);
    cout<<a[K-1]<<endl;
  }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    string A,B;
    cin>>A>>B;
    if(A.at(2)==B.at(0)&&A.at(1)==B.at(1)&&A.at(0)==B.at(2)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 2e9
#define ALL(v) v.begin(), v.end()
int n;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    cout << 180*(n-2)<< "\n";
}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  string s;
  cin>>n>>s;
  if(n>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
}


Measured memory_bytes: 256
# include <stdio.h>

int main(){
  int flag1=0;
  int flag2=0;
  int s;
  int n=0;
  int m;
  
  scanf("%d",&s);
  
  for(int i=1;i>0;i++){
    if((n+1)*100<=s){
      n=n+1;
    }else{
      break;
    }
  }
  
  m=s-n*100;
  
  if((1<=n) && (n<=12)){
    flag1=1;
  }
  if((1<=m) && (m<=12)){
    flag2=2;
  }
  
  if(flag1+flag2==0){
    printf("NA");
  }
  if(flag1+flag2==1){
    printf("MMYY");
  }
  if(flag1+flag2==2){
    printf("YYMM");
  }
  if(flag1+flag2==3){
    printf("AMBIGUOUS");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end(),greater<string>());
  vector<string> ans;
  int cnt=0,tmpCnt=0;
  for(int i = 0; i < N-1; i++){
    tmpCnt++;
    if(vec.at(i)!=vec.at(i+1)){
      cnt = max(cnt,tmpCnt);
      tmpCnt = 0;
    }
  }
  if(vec.at(N-1)!=vec.at(N-2)) tmpCnt = 1;
  else tmpCnt++;
  cnt = max(cnt,tmpCnt);
  tmpCnt = 0;
  for(int i = 0; i < N-1; i++){
    tmpCnt++;
    if(vec.at(i)!=vec.at(i+1)){
      if(cnt==tmpCnt) ans.push_back(vec.at(i));
      tmpCnt = 0;
    }
  }
  if(vec.at(N-1)!=vec.at(N-2)) tmpCnt = 1;
  else tmpCnt++;
  if(cnt==tmpCnt) ans.push_back(vec.at(N-1));      
  sort(ans.begin(),ans.end());
  for(int i = 0; i < ans.size(); i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 15988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      int n,m; cin>>n>>m;
      vector<int> box(m);
      rep(i,0,n){
            int k; cin>>k;
            rep(j,0,k){
                  int x; cin>>x;
                  box[x-1]++;
            }
      }
      int ans=0;
      rep(i,0,m){
            if(box[i]==n) ans++;
      }
      cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=10001;
int a[maxn],b[maxn],n,ans,x;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
signed main()
{
    cin>>n>>x;
    int m=n/gcd(n,x),y=x/gcd(n,x);
    cout<<(m-1)*3*gcd(n,x);

}

Measured memory_bytes: 3620
#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)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[n-1]-a[0];
    return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

int main(){
    ll n;
    cin >> n;
    n=n-1;
    int remainder;
    string ans="";
    while (n>=0) {
        remainder = n % 26;
        // ans = remainder+'a';
        ans.insert(ans.begin(), remainder+'a');
        n /= 26;
        n -= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include <numeric>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int H, W;
    cin >> H >> W;

    string A[H];
    FOR(i, 0, H){
        cin >> A[i];
    }

    // y check
    vector<int> okY;
    FOR(i, 0, H){
        string s = A[i];
        FOR(j, 0, W){
            char c = s[j];
            if(c == '#'){
                okY.push_back(i);
                break;
            }
        }
    }

    // x check (i column)
    vector<int> okX;
    FOR(i, 0, W){
        FOR(j, 0, H){
            string s = A[j];
            if(s[i] == '#'){
                okX.push_back(i);
                break;
            }
        }
    }

    for(int y : okY){
        for(int x : okX){
            cout << A[y][x];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
    
n,k=MI()
def standard(a,b):
    return b*(a-b+1)+1
def ansum(a,b):
    ansum=0
    for i in range(b,a):
        ansum+=standard(a,i)
    return ansum
#print(ansum(4,2))
anslarge=n+2
if k==1:
    if n==1:
        ans=3
    else:
        ans=ansum(n,2)+n+1+anslarge
elif k==n+1:
    ans=1
elif k==n:
    ans=n+2
else:
    ans=ansum(n,k)+anslarge
print(ans%mod)

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    string s;
    cin >> s;
    cout << 700 + 100 * count(s.begin(), s.end(), 'o') << endl;
}


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

using namespace std;

vector<int> tamanho, parent;

int root (int x) {
  while (x != parent[x]) x = parent[x];
  return x;
}

void join (int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return;
  if (tamanho[a] < tamanho[b]) swap(a, b);
  tamanho[a] += tamanho[b];
  parent[b] = a;
}

int main () {
  int n, m;
  cin >> n >> m;
  tamanho = parent = vector<int> (n + 1);
  for (int i = 0; i <= n; i++) {
    parent[i] = i;
    tamanho[i] = 1;
  }
  
  while (m--) {
    int s, e, foo;
    cin >> s >> e >> foo;
    join (s, e);
  }
  unordered_set<int> ans;
  for (int i = 1; i <= n; i++) {
    ans.insert(root(i));
  }
  cout << ans.size() << '\n';
  return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    int v[n],c[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(v[i]-c[i]>0)ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 out;
  if (N % 2 == 0) {
    out = N / 2;
  } else {
    out = N / 2 + 1;
  }
  
  cout << out << endl;
}

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

using namespace std;

typedef long long ll;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

const ll MAX = 10000000000ll;

int main()
{
    // dp[num][sum][max]
    ll dp[10][1001][101] = {{{}}};

    rep(k, 101) {
        dp[0][0][k] = 1;
        dp[1][0][k] = 1;
    }

    reps(i, 1, 10) reps(j, 1, 1001) reps(k, 1, 101){
        dp[i][j][k] = dp[i][j][k - 1];

        if(k <= j){
            dp[i][j][k] += dp[i-1][j-k][k-1];
            dp[i][j][k] = min(dp[i][j][k], MAX);
        }
    }

    int n, s;
    while(cin >> n >> s, n){
        cout << dp[n][s][100] << endl;
    }
}

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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 1E5 + 10;

int n;
int a[MAXN << 1];

bool check(int limit){
	static int b[MAXN << 1];
	int n0 = n << 1;
	for (int i = 1; i < n0; ++i)
		b[i] = a[i] >= limit;

	int l, r;
	for (l = n; l > 1 && b[l] != b[l - 1]; --l);
	for (r = n; r < n0 - 1 && b[r] != b[r + 1]; ++r);
	if (l == 1 && r == n0 - 1)
		return b[1];
	if (l == n || r == n)
		return b[n];
	if (b[l] == b[r])
		return b[l];
	return n - l < r - n ? b[l] : b[r];
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i < 2 * n; ++i)
		scanf("%d", &a[i]);
	int low = 2, high = 2 * n, mid;
	while (low < high){
		mid = low + (high - low >> 1);
		if (check(mid))
			low = mid + 1;
		else
			high = mid;
	}
	printf("%d\n", low - 1);
	return 0;
}


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

using namespace std;
const int maxn = 105;
int a[maxn];

int main()
{
    int n;
    while(~scanf("%d",&n)){
        int sum = 0;
        for(int i=0;i<n;++i){
            scanf("%d",a+i);
            sum += a[i];
        }
        if(sum % 10 == 0){
            int index = -1;
            for(int i=0;i<n;++i){
                if(a[i]%10 != 0 && ( index == -1 || a[i] < a[index] ) ) index = i;
            }

            if(~index) printf("%d\n",sum-=a[index]);
            else puts("0");
        }
        else printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    A.append(K+A[0])
    ans = K

    for i in range(0, N):
        tmp = K - (A[i+1] - A[i])
        if tmp < ans:
            ans = tmp
    print(ans)







    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 77516
#include<iostream>
#include<cmath>

using namespace std;

double dis=0;

int main(){
 int k,s;
   cin >> k >> s;
  
  int res=0;
  
  for(int i=0;i<=k;i++){
  for(int j=0;j<=k;j++){
    int tot=i+j;
    if(s-tot>=0 && k>=s-tot) res++;
  }
  }
  
  cout << res << endl;
  }

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static class unionfind{
		int[] parent;
		int[] rank;
		int[] size;
		public unionfind(int n){
			this.parent = new int[n+1];
			this.rank = new int[n+1];
			this.size = new int[n+1];
			for(int i = 1; i <= n; i++) set(i);
		}
		public void set(int i) {
			parent[i] = i;
			rank[i] = 0;
			size[i] = 1;
		}
		public int find(int i) {
			if (i == parent[i])
				return parent[i];
			else
				return parent[i] = find(parent[i]);
			
		}
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
		public void unite(int x, int y) {
			int xroot = find(x);
			int yroot = find(y);
			if(xroot == yroot)
				return;
			if(rank[xroot] > rank[yroot]) {
				parent[yroot] = xroot;
				size[xroot] += size[yroot];
			}
			else if(rank[xroot] < rank[yroot]) {
				parent[xroot] = yroot;
				size[yroot] += size[xroot];
			}
			else {
				parent[yroot] = xroot;
				size[xroot] += size[yroot];
				rank[xroot]++;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] p = new int[N];
		Arrays.setAll(p, i -> sc.nextInt());
		unionfind u = new unionfind(N);
		for(int i = 0; i < M; i++)
			u.unite(sc.nextInt(), sc.nextInt());
		int ans = 0;
		for(int i = 1; i <= N; i++)
			if(u.same(p[i-1], i))
				ans++;
		System.out.println(ans);
	}

}

Measured memory_bytes: 92328
#include <stdio.h>
int main(void)
{
int h1, m1, h2, m2, k;
int start =0;
int end = 0;
scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
  
start = h1*60 + m1;
end = h2*60 + m2;
printf("%d", end -start - k);
return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b,x;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
  

}


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

int main()
{
    int N;
    cin>>N;
    if((N%100)%10==2||(N%100)%10==4||(N%100)%10==5||(N%100)%10==7||(N%100)%10==9)
    {
        cout<<"hon";
    }
    else if((N%100)%10==0||(N%100)%10==1||(N%100)%10==6||(N%100)%10==8)
    {
        cout<<"pon";
    }
    else if((N%100)%10==3)
    {
        cout<<"bon";
    }
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

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

  if (S.length() != 26){
    vector <bool> ABC(26);
    for (int i = 0; i < S.length(); i++){
      int A = S[i] - 'a';
      ABC[A] = true;
    }

    for (int i = 0; i < 26; i++){
      if (ABC[i] == false){
        char A = 'a' + i;
        S = S + A;
        break;
      }
    }
    
    cout << S << endl;
  }else{
    bool flag = true;
    string ans;
    for (int i = 25; i >= 1; i--){
      if (S[i - 1] - S[i] >= 0){
      }else{
        flag = false;
        int num = i - 2;
        for (int j = 0; j < num + 1; j++){
          ans += S[j];
        }


        char A = 'z';
        for (int j = num + 2; j < 26; j++){
          if (S[num + 1] <= S[j] && S[j] <= A) A = S[j]; 
        }
        ans += A;
        cout << ans << endl;
        break;
      }
    }
    if (flag == true){
      cout << -1 << endl;
    }
    

  }
  
  return 0;
}


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

int G[101][101];

main(){
  int i, j, k, l, n, adj;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d%d", &l, &k);
    for(j=0; j<k; j++){
      scanf("%d", &adj);
      G[l][adj] = 1;
    }
  }

  for(i=1; i<=n; i++){
    for(j=1; j<n; j++){
      printf("%d ", G[i][j]);
    }
    printf("%d\n", G[i][j]);
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#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 cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,m;
  cin>>n>>m;
  vec p(m);
  vector<string> s(m);
  vec ac(n+1);
  vec wa(n+1);
  loop(i,m)cin>>p[i]>>s[i];
  vec check(n+1,1);
  loop(i,m){
    if(s[i]=="AC"){
      ac[p[i]]++;
      check[p[i]]=0;
    }
    if(s[i]=="WA"&&check[p[i]])wa[p[i]]++;
  }
  ll account=0,wacount=0;
  loop(i,n+1){
    if(ac[i]>0){
      account++;
      wacount+=wa[i];
    }
  }
  putout2(account,wacount);
}

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

//int nm[10001][10001] = {0};

map<pair<int,int>,int> nm;

long long c[10001];

int b[10000];

int main() {
    int n,m;

    cin >> n >> m;

    while(1){
        int s,t,e;
        scanf(" %d %d %d",&s,&t,&e);
        if( (s+t+e) == 0) break;
        //nm[s][t] = e;
        nm[make_pair(s,t)] = e;
    }

    int l;

    cin >> l;

    pair<int,int> tmp;

    while(l--) {

        for(int i=1;i<=m;i++){
            scanf(" %d",&b[i]);
        }

        int i, j;
        for (i = 1; i <= n; i++) {
            c[i] = 0;
            /*for (j = 0; j < m; j++) {
                c[i] = c[i] + nm[i][j+1] * b[j];
            }*/
        }
        for(map<pair<int,int>,int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) {
            tmp = itr->first;
            c[tmp.first] += b[tmp.second] * itr->second;
            //cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << tmp.second << endl;
        }


        for(int i=1;i<=n;i++){
            //cout << c[i];
            printf("%d",c[i]);
            if(i!=n) printf(" ");//cout <<  ' ';
        }
        printf("\n");

    }
    return 0;
}

Measured memory_bytes: 6472
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

template <typename T> bool isOK(ll index, T key,vector<T> a) {
    if (a[index] >= key) return true;
    else return false;
}

template <typename T> ll search2(T key,vector<T> a) {
    ll left = -1;
    ll right = (ll)a.size();

    while (right - left > 1) {
        ll mid = left + (right - left) / 2;

        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }

    return right;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll X;
    cin>>X;
    
    vll P;
    for(ll i=0;pow(i,5)<=LLMAX;i++){
        P.push_back(pow(i,5));
        //printf("%lld:%lld\n",i,P[i]);
    }
    
    for(ll i=0;i<P.size();i++){
        for(ll j=0;j<P.size();j++){
            if(P[i]-P[j]==X){
                printf("%lld %lld\n",i,j);
                return 0;
            }
            if(P[i]+P[j]==X){
                printf("%lld %lld\n",i,-j);
                return 0;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 4440
while True:
    a=[int(x) for x in input().split()]
    if a[0]==a[1]==0:
        break
    else:
        for x in range(a[0]):
            if x%2!=0:
                for y in range(a[1]):
                    if y%2!=0:
                        print("#", end="")
                    else:
                        print(".", end="")
                print("\n",end="")
            elif x%2==0:
                for y in range(a[1]):
                    if y%2!=0:
                        print(".", end="")
                    else:
                        print("#", end="")
                print("\n",end="")
    print("")

Measured memory_bytes: 8976
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>

int main() {
  size_t n;
  scanf("%zu", &n);

  char buf[262144];
  scanf("%s", buf);
  std::string s = buf;

  if (s == std::string(n, '.'))
    return puts("0"), 0;

  if (s == std::string(n, '#'))
    return puts("0"), 0;

  std::reverse(s.begin(), s.end());

  std::vector<std::vector<size_t>> dp(n+1, std::vector<size_t>(2, n+1));
  dp[0][0] = dp[0][1] = 0;
  for (size_t i = 0; i < n; ++i) {
    dp[i+1][1] = std::min(dp[i+1][1], dp[i][1] + (s[i] != '.'));
    dp[i+1][1] = std::min(dp[i+1][1], dp[i][0] + (s[i] != '#'));
    dp[i+1][0] = std::min(dp[i+1][0], dp[i][0] + (s[i] != '#'));
  }

  printf("%zu\n", std::min(dp[n][0], dp[n][1]));
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N,0);
  rep(i,N) cin >> A.at(i);
  rep(ki,K){
    vector<int> B(N+1,0);
    rep(i,N){
      int l = max(0, i-A.at(i));
      int r = min(i+A.at(i)+1,N);
      B.at(l)++; B.at(r)--;
    }
    rep(i,N) B.at(i+1) += B.at(i);
    if(A == B) break;
    A = B;
  }
  
  rep(i,N) cout << A.at(i) <<' ';
  cout << endl;
  
}

Measured memory_bytes: 5632
from collections import deque
import sys

H,W=map(int,input().split())
S=[[x for x in input()] for _ in range(H)]

count=0
for i in range(len(S)):
  count+=S[i].count('.')

d=deque([(0,0)])
distance=[[-1]*W for _ in range(H)]
distance[0][0]=0
goal_distance=0

while d:
  h,w=d.popleft()
  if h==H-1 and w==W-1:
    goal_distance=distance[h][w]
    break
  
  if h-1>=0 and S[h-1][w]=='.':
    d.append((h-1,w))
    distance[h-1][w]=distance[h][w]+1
    S[h-1][w]='#'
    
  if h+1<=H-1 and S[h+1][w]=='.':
    d.append((h+1,w))
    distance[h+1][w]=distance[h][w]+1
    S[h+1][w]='#'
    
  if w-1>=0 and S[h][w-1]=='.':
    d.append((h,w-1))
    distance[h][w-1]=distance[h][w]+1
    S[h][w-1]='#'
    
  if w+1<=W-1 and S[h][w+1]=='.':
    d.append((h,w+1))
    distance[h][w+1]=distance[h][w]+1
    S[h][w+1]='#'
else:
  if distance[H-1][W-1]==-1:
    print(-1)
    sys.exit()

print(count-(goal_distance+1))

Measured memory_bytes: 9540
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int x,a;
  cin >> x >> a;
  if(x<a){
    cout << 0 << endl;
  }
  else{
    cout << 10 << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int n;
    cin >> n;
    int b[110];
    b[0] = b[n] = INF;
    rep(i, n - 1) cin >> b[i + 1];
    int sum = 0;
    rep(i, n) sum += min(b[i], b[i + 1]);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
(* O(|s|) *)
let string_to_char_array s = Array.init (String.length s) (fun i -> s.[i])

(* O(|s|) *)
let solve s =
  let cs1 = string_to_char_array s |> Array.to_list |> List.mapi (fun i c -> i, c) in
  let cs2 = List.rev cs1 in
  let start = List.find (fun (_, c) -> c = 'A') cs1 |> fst in
  let stop = List.find (fun (_, c) -> c = 'Z') cs2 |> fst in
  stop - start + 1

let _ = read_line () |> solve |> string_of_int |> print_endline

Measured memory_bytes: 27008