akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

vector<ll> A;
vector<ll> G[200001];
int ans[200001] = {0};
vector<ll> dp;

void dfs(ll now, ll par){
  //int cnt = int(dp.size());
  auto ptr = lower_bound(dp.begin(),dp.end(),A[now]);
  ll mae_i = ptr - dp.begin(),mae_v;

  //cout << now << " " << A[now] << " " << ptr-dp.begin() << ":";
  //for(int i(0);i<int(dp.size());i++){
    //cout << dp[i] << " ";
  //}

  //cout << endl;
  if(ptr == dp.end()){
    dp.push_back(A[now]);
    mae_v = -1;
  }else{
    mae_v = dp[ptr-dp.begin()];
    dp[ptr-dp.begin()] = A[now];
  }
  ans[now] = int(dp.size());
  

  for(int i(0);i<int(G[now].size());i++){
    int next = G[now][i];
    if(next != par){
      dfs(next,now);
    }
  }

  if(mae_v == -1){
    dp.pop_back();
  }else{
    dp[mae_i] = mae_v;
  }
}

int main(){
  ll N;
  cin>>N;
  A.resize(N);
  for(int i(0);i<N;i++) cin>>A[i];
  for(int i(0);i<N-1;i++){
    int u,v;
    cin>>u>>v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0ll,-1);
  for(int i(0);i<N;i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 30668
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve;

/*
template<typename TARGA,typename TARGB>
ll gcdt(TARGA targa,TARGB targb){
    targa%=targb;
    return targa ? gcdt(targb,targa):targb;
}
*/

template<typename TARG> ll gcdt(TARG targ) {return targ;}
template<typename TARGA,typename HEAD,typename ... CALL>
ll gcdt(TARGA targa,HEAD targh=-1,CALL ... targc){
    targa%=targh;
    return targa ? gcdt(targh,targa,targc...): gcdt(targh,targc...);
}
template<typename TARG> ll gcdt(vector<TARG> targ) { for(TARG it:targ)targ[0]=gcdt(targ[0],it);return targ[0]; }


int main(){
    cin>>n;
    for(size_t i = 0; i < n; i++){
        cin>>aa[i];
        va.push_back(aa[i]);
    }
    C gcdt(va) E;
    
}


Measured memory_bytes: 2676
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		String[] t = scanner.nextLine().split(" ");
		long x = Math.abs(Long.parseLong(t[0]));
		long k = Long.parseLong(t[1]);
		long d = Long.parseLong(t[2]);
		long ans = 0;

		long sho   = Math.floorDiv(x, d);
		long amari = x - sho * d;

		if(sho > k) {

			ans = x - k * d;
		}else {
			ans = Math.abs(amari - d * (Math.abs(k - sho) % 2));
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 35580
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut s = s;
    for i in 0..s.len() {
        if let Some(b) = s.pop() {
            s.insert(0, b);
        }
        if s == t {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, bool>> c(n, {1, false});
  c[0] = {1, true};
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    c[x].first--;
    c[y].first++;
    if (c[x].second) {
      c[y].second = true;
      if (c[x].first == 0) {
        c[x].second = false;
      }
    }
    debug(c);
  }
  int ans = 0;
  for (auto&& [_, e] : c) {
    if (e) ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

ll cnt(ll h)
{
	if(h == 1) return 1;
	else return 2 * cnt(h/2) + 1;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	ll h;
	cin >> h;
	cout << cnt(h) << endl;
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string x;
  cin >> x;

  // スタックで左から順に処理
  stack<char> s;
  for (int i = 0; i < x.size(); i++) {
    if (s.empty()) {
      s.push(x[i]);
    } else {
      if (x[i] == 'S') {
        s.push(x[i]);
      } else {
        if (s.top() == 'S') {
          s.pop();
        } else {
          s.push(x[i]);
        }
      }
    }
  }

  // 解答
  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<ll> x(n),y(m);
    REP(i,n) cin>>x[i];
    REP(i,m) cin>>y[i];

    ll x_d = 0, y_d = 0;
    REP(i,n){
        x_d += i*x[i] - (n-1 - i)*x[i];
        x_d %= MOD;
    }
    REP(i,m){
        y_d += i*y[i] - (m-1 - i)*y[i];
        y_d %= MOD;
    }
    
    ll ans = x_d * y_d;
    ans %= MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main() {
	long long int a, b,c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if (a + b >= c) { printf("%lld", b + c); }
	else { printf("%lld",a+2*b+1); }
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int n;
vector<vector<pll>> G(111111);
vi ans(111111);

void dfs(int now, int par) {
  int par_c;
  vi cs;
  rep (i, G[now].size()) {
    if (G[now][i].first == par) {
      par_c = ans[G[now][i].second];
      break;
    }
  }
  int color = 0;
  rep (i, G[now].size()) {
    if (G[now][i].first == par) {
      continue;
    }
    while (color == par_c) color++;
    ans[G[now][i].second] = color;
    dfs(G[now][i].first, now);
    color++;
  }
}

signed main() {
  ll n, k;
  cin >> n >> k;
  vl a(n);
  rep (i, n) {
    cin >> a[i];
    a[i] %= k;
    a[i] = (a[i] - 1 + k) % k;
  }

  vl sum(n + 1);
  rep (i, n) {
    sum[i + 1] = (sum[i] + a[i]) % k;
  }

  //DEBUG_VEC(sum);

  map<ll, vi> mp;
  rep (i, n + 1) {
    mp[sum[i]].push_back(i);
  }

  ll ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    vi x = itr->second;
    rep (i, x.size()) {
      int j = x[i];
      auto itr = lower_bound(all(x), j + k);
      ans += itr - (x.begin() + i + 1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 28288
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll n = readInt(), x = readInt();
	cout << 3 * (n-__gcd(n, x));
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }

  int ans = h.at(0), x = h.at(0);
  for (int i = 0; i < n - 1; i++) {
    if (h.at(i) < h.at(i + 1)) {
      ans += h.at(i + 1) - h.at(i);
    }
    x = h.at(i + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n;
struct node
{
    int x,y,z;
    bool operator<(const node&o)const
    {
        return x<o.x;
    }
}a[N];
vector<pair<int,int> >v;
multiset<int>s;
multiset<int>::iterator it;
int top,q[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].y),a[i].z=0;
    for(int i=n+1;i<=n+n;i++)
        scanf("%d%d",&a[i].x,&a[i].y),a[i].z=1;
    n+=n;
    sort(a+1,a+1+n);
    int ans=0;
    for(int i=n;i>=1;i--)
    {
        if(a[i].y!=a[i+1].y)
        {
            sort(v.begin(),v.end());
            for(int j=v.size()-1;j>=0;j--)
            {
                int y=v[j].first,z=v[j].second;
                if(z) q[++top]=y;
                else
                {
                    it=s.lower_bound(y);
                    if(it!=s.end())
                    {
                        ans++;s.erase(s.find(*it));
                    }
                }
            }
            v.clear();
        }
        v.push_back({a[i].y,a[i].z});
        while(top)
            s.insert(q[top--]);
    }
    sort(v.begin(),v.end());
    for(int j=v.size()-1;j>=0;j--)
    {
        int y=v[j].first,z=v[j].second;
        if(z) q[++top]=y;
        else
        {
            it=s.lower_bound(y);
            if(it!=s.end())
            {
                ans++;s.erase(s.find(*it));
            }
        }
    }
    printf("%d\n",ans);
}


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

using namespace std;
typedef long long ll;

int N;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;

    ll t = 1;
    ll a = 1;

    ll T;
    ll A;

    for (int i = 0; i < N; ++i) {
        cin >> T >> A;

        if (t * A < a * T) {
            if (t % T != 0) {
                t += (T - (t % T));
            }
            if (a < t / T * A) {
                a = t / T * A;
            } else {
                if (a % A != 0) {
                    a += (A - (a % A));
                }
                t = a / A * T;
            }
        } else if (t * A > a * T) {
            if (a % A != 0) {
                a += (A - (a % A));
            }
            if (t < a / A * T) {
                t = a / A * T;
            } else {
                if (t % T != 0) {
                    t += (T - (t % T));
                }
                a = t / T * A;
            }
        }

        //cout << "t: " << t << ", a: " << a << endl;
    }

    cout << (t + a) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s.size()==2){
        cout<<s<<endl;
    }else{
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
 return 0;   
}

Measured memory_bytes: 256
#  Author: Amey Bhavsar
#  ID: bhavsar
#  IDE: Geany/Ubuntu
#  Platform: AtCoder Beginner Contest 174
from math import sqrt, floor, pi, cos, sin, log, log2



#  n=map(int,input().split())
n,m=map(int,input().split())
ans = 0
for i in range(n):
	x,y=map(int,input().split())
	if (sqrt(x*x + y*y) <= m):
		ans+=1
print(ans)
	

#  a=list(map(int,input().split()))
#  mat = []
#  for i in range(n):
	#  r = input()
	#  r = list(map(int,input().split()))
	#  mat.append(r)



Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;
int main(){
    ll h,w,n;
    cin >> h >> w >> n;
    if(n == 0){
        cout << (h-2)*(w-2) << endl;
        rep(i,9){
            cout << 0 << endl;
        }
        return 0;
    }
    map<P,ll> m;
    ll ans[10];
    rep(i,10) ans[i] = 0;
    
    ll a,b;
    rep(i,n){
        cin >> a >> b;
        a--;b--;
        if(a-2 >= 0 && b-2 >= 0 && a-2 < h-2 && b-2 < w-2) {
            ans[m[mp(a-2,b-2)]++]++;
        }
        if(a-2 >= 0 && b-1 >= 0 && a-2 < h-2 && b-1 < w-2) {
            ans[m[mp(a-2,b-1)]++]++;
        }
        if(a-2 >= 0 && a-2 < h-2 && b < w-2) {
            ans[m[mp(a-2,b)]++]++;
        }
        if(a-1 >= 0 && b-2 >= 0 && a-1 < h-2 && b-2 < w-2) {
            ans[m[mp(a-1,b-2)]++]++;
        }
        if(a-1 >= 0&&b-1 >= 0 && a-1 < h-2 &&b-1 < w-2) {
            ans[m[mp(a-1,b-1)]++]++;
        }
        if(a-1 >= 0 && a-1 < h-2 && b < w-2) {
            ans[m[mp(a-1,b)]++]++;
        }
        if(b-2 >= 0 && a < h-2 && b-2 < w-2) {
            ans[m[mp(a,b-2)]++]++;
        }
        if(b-1 >= 0 && a < h-2 && b-1 < w-2) {
            //sum[a][b-1]++;
            ans[m[mp(a,b-1)]++]++;
        }
        if(a >= 0 && b >= 0 && a < h-2 && b < w-2) {
            //sum[a][b]++;
            ans[m[mp(a,b)]++]++;
        }
    }
    //cout << ans[0] << endl;
    cout << (ll)(h-2)*(w-2) - ans[0] << endl;
    rep(i,9){
        cout << ans[i] - ans[i+1] << endl;
    }

    return 0;
}

Measured memory_bytes: 56448
package main
 
import (
	"fmt"
)

func main() {

  var S string
  var T string
  fmt.Scan(&S)
  fmt.Scan(&T)
  var result bool = false
  for i := 0 ;i < len(S); i++ {
    if S == T {
     result = true
      break
    }
    S= S[len(S)-1:] +S[:len(S)-1]
  }
  if result {
    fmt.Printf("Yes")
  } else {
    fmt.Printf("No")
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
# define mod 1000000007
typedef long long ll;
#include <cmath>
#include <limits>
#include <iostream>


int		main()
{
	ll x; cin >> x;
	//int ans = ((log10(x)-2)/(log10(1.01))) + 1;
	//cout << ans << endl;
	//cout << log10(2) << endl;
	ll y = 100;
	for (int i = 1; i < 1000000000; i++)
	{
		y = y*1.01;
		if (y >= x)
		{
			cout << i << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3592
#include<stdio.h>
int main(void)
{
    int n,i,m,t;
    double x[100],y[100],r,c;
    while(scanf("%d",&n)*n){
        for(i=0;i<n;i++)scanf("%lf,%lf",&x[i],&y[i]);
        for(t=0,r=0.;r<=10.;r+=.01){
            for(c=0.f;c<=10.;c+=.01){
                for(m=0,i=0;i<n;i++){
                    if((x[i]-c)*(x[i]-c)+(y[i]-r)*(y[i]-r)<=1.001)m++;
                }
                if(m>t)t=m;
            }
        }
        printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int mod = 1e5;
const int MAX = 1e6;

int main() {
    int n, k;
    cin >> n >> k;
    cout << min(1,n%k) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long A[3010][3010]; 
long long dp[3010][3010][4]; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int R, C, K; cin >> R >> C >> K; 
	for(int i = 0; i < K; i++){
		int r, c; long long v; cin >> r >> c >> v; 
		r--; c--; A[r][c] = v; 
	}
	if(A[0][0]) dp[0][0][1] = A[0][0]; 
	for(int i = 0; i < R; i++){
		for(int j = 0; j < C; j++){
			for(int k = 0; k <= 3; k++){
				dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
				if(A[i][j+1] && (k < 3)) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + A[i][j+1]); 
				dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]); 
				if(A[i+1][j]) dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + A[i+1][j]); 		 
			}
		}
	}
	long long ans = 0; 
	for(int i = 0; i <= 3; i++) ans = max(ans, dp[R-1][C-1][i]); 
	cout << ans << "\n"; 
}

Measured memory_bytes: 356240
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,c = LI()
    if a == b and b == c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = I()
    s = S()
    r = s.count("R")
    if r > n//2:
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n,q = LI()
    s = S()

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n, k, ans;
    cin >> n >> k;
    if(k == 0) {
        ans = n*n;
    }
    else {
        ans = (n-k)*(n-k+1)/2;  // a < b のパターンは(n-k)*(n-k+1)/2通り

        for(ll b = k+1; b < n; b++) {
            ll c = (n-b+1)/b;
            ll d = (n-b+1)%b;
            if(d <= k) {
                ans += c*(b-k);
            }
            else {
                ans += c*(b-k) + (d-k);
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  vector<pair<ll, ll>> v;

  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());

  ll sum = 0, ans = 0;
  REP(i, n) {
    ll mm = min(v[i].second, m - sum);
    sum += mm;
    ans += v[i].first * mm;
    if(sum >= m) break;
  }

  cout << ans << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

int N,X,D;
int M[55];
vint G[55];

vpint A;
int sumM[55],sz[55];
void dfs(int v){
    sumM[v]=M[v];
    sz[v]=1;
    for(auto u:G[v]){
        dfs(u);
        sumM[v]+=sumM[u];
        sz[v]+=sz[u];
    }
    A.pb({sumM[v],sz[v]});
}

int dp[55][55*55*55];
const int INF=1001001001001001001ll;

signed main(){
    cin>>N>>X>>D;
    cin>>M[0];
    for(int i=1;i<N;i++){
        cin>>M[i];
        int p;cin>>p;
        p--;
        G[p].pb(i);
    }

    dfs(0);

    rep(i,A.size()){
        for(int j=i+1;j<A.size();j++){
            if(A[i].fi*A[j].se>A[j].fi*A[i].se)swap(A[i],A[j]);
        }
    }

    fill_n(*dp,55*55*55*55,INF);
    dp[0][0]=0;
    rep(i,N){
        rep(j,55*55*55){
            for(int k=0;k<=50&&k<=D&&j+k*A[i].se<55*55*55;k++)chmin(dp[i+1][j+k*A[i].se],dp[i][j]+A[i].fi*k);
        }
    }

    int ans=0;
    for(int i=0;i<55*55*55;i++){
        int x=X-dp[N][i];
        if(x<0)continue;
        int sum=i;
        for(int j=0;j<N;j++){
            int w=x/A[j].fi;
            if(A[j].se!=N)chmin(w,max(0ll,D-50));
            sum+=A[j].se*w;
            x-=A[j].fi*w;
        }
        chmax(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


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

int foo[30000];
int main(){
  int n, k = 0, ans = 0;
  int a,b,c,d,e,f,g,h,i;
  const int data[4] = {0,3,5,7};
  int cnt[4] = {0,0,0,0};
  cin >> n;

  for(a = 0; a < 4; a++){
    cnt[a]++;
    for(b = a?1:0; b < 4; b++){
      cnt[b]++;
      for(c = b?1:0; c < 4; c++){
        cnt[c]++;
        for(d = c?1:0; d < 4; d++){
          cnt[d]++;
          for(e = d?1:0; e < 4; e++){
            cnt[e]++;
            for(f = e?1:0; f < 4; f++){
              cnt[f]++;
              for(g = 1; g < 4; g++){
                cnt[g]++;
                for(h = 1; h < 4; h++){
                  cnt[h]++;
                  for(i = 1; i < 4; i++){
                    cnt[i]++;
                    if( cnt[1] > 0 && cnt[2] > 0 && cnt[3] > 0){
                      foo[k] =  data[a]*1e8+data[b]*1e7
                               +data[c]*1e6+data[d]*1e5
                               +data[e]*1e4+data[f]*1e3
                               +data[g]*1e2+data[h]*1e1
                               +data[i];
                      //cout << foo[k] << "\n";
                      k++;
                    }
                    cnt[i]--;
                  }
                  cnt[h]--;
                }
                cnt[g]--;
              }
              cnt[f]--;
            }
            cnt[e]--;
          }
          cnt[d]--;
        }
        cnt[c]--;
      }
      cnt[b]--;
    }
    cnt[a]--;
  }
  for(k = 0; n >= foo[k] && foo[k] != 0; k++);
  cout << k << "\n";
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int const N = 200 * 1000 + 16;
 
int a[N];
int n, k;
mt19937 rd(time(0));
 
struct node {
  ll x;
  int s = 1;
  int y = rd();
 
  node* l = 0;
  node* r = 0;
 
  node(ll v) {
    x = v;
  }
 
  ~node() {
    delete l;
    delete r;
  }
 
  node* upd() {
    s = 1;
    s += l ? l->s : 0;
    s += r ? r->s : 0;
    return this;
  }
};
 
struct treap {
  node* root = 0;
 
  ~treap() {
    delete root;
  }
 
  node* join(node* l, node* r) {
    if(not l) return r;
    if(not r) return l;
 
    if(l->y < r->y) {
      l->r = join(l->r, r);
      return l->upd();
    } else {
      r->l = join(l, r->l);
      return r->upd();
    }
  }
 
  pair<node*,node*> split(node* p, ll x) {
    if(not p) return make_pair(nullptr,nullptr);
 
    if(x < p->x) {
      auto t = split(p->l, x);
      p->l = t.second;
      t.second = p->upd();
      return t;
    } else {
      auto t = split(p->r, x);
      p->r = t.first;
      t.first = p->upd();
      return t;
    }
  }
 
  void insert(ll x) {
    auto t = split(root, x);
    root = join(t.first, join(new node(x), t.second));
  }
 
  int query(ll x) {
    auto t = split(root, x);
    int cnt = t.first ? t.first->s : 0;
    root = join(t.first, t.second);
    return cnt;
  }
};
 
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
 
  cin >> n >> k;
  copy_n(istream_iterator<int>(cin), n, a);
 
  treap t;
  t.insert(0);
  ll ans = 0;
  ll sum = 0;
  for(int i = 0; i < n; ++i) {
    sum += a[i];
    ll v = sum - 1ll * i * k - k;
    ans += t.query(v);
    t.insert(sum - 1ll * (i+1) * k);
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll solve(ll h,ll w){
	ll res;
	if(h%3ll==0ll)return 0ll;
	else res = w;
	for(ll i=1;i<w;i++){
		ll a = (w-i)*h;
		ll b = i*(h/2);
		ll c = i*(h-h/2);
		res = min(res,max(max(a,b),c)-min(min(a,b),c));
	}
	return res;
}
int main(){
	ll H,W;
	cin >> H >> W;
	cout << min(solve(H,W),solve(W,H)) << endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int N, K; cin >> N >> K;
    vector<int> p(N);
    rep (i, 0, N) cin >> p[i];
    sort(p.begin(), p.end());

    int ans = 0;
    rep (i, 0, K) ans += p[i];

    cout << ans << endl;
}


Measured memory_bytes: 3640
program main
	implicit none
    character(10)::s,t,u
    integer::a,b
    read(*,*) s,t
    read(*,*)a,b
    read(*,*)u
    
    if(s==u)then
    	write(*,*) a-1,b
    else
    	write(*,*) a,b-1
    end if
    stop
end program main





Measured memory_bytes: 2788
#include "stdio.h"

int main(void)
{
    int a[1000001];
    int i;
    int j=1;
    for(i=1;i<1000001;i++)
    {
        if(i%5==0)
        {
            a[i] = 0;
        }
        else if(i%3==0)
        {
            a[i] = 0;
        }

        else
        {
            a[i] = i;
        }
        
    }

    long int N;
    long int kei=0;
    scanf("%ld",&N);
    for(i=1;i<=N;i++)
    {
        kei = kei + a[i];
    }
    printf("%ld",kei);
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
}a[100005],b[100005];
int p[10005];
int cmp1(node a,node b){
	return a.x>b.x;
}
int cmp2(node a,node b){
	return a.y<b.y;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i].x>>a[i].y;
	for(int i=0;i<n;i++)
		cin>>b[i].x>>b[i].y;
	sort(a,a+n,cmp1);
	sort(b,b+n,cmp2);
	int sum=0;
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i].x<b[j].x&&a[i].y<b[j].y&&p[j]==0){
				sum++;
				p[j]=1;
				break;
			}
		}
	}
	cout<<sum<<endl;
	
}

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

//#include <tuple>

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

int change_ten(int n){
  if (n%10 == 0) {
    return n;
  } else {
    int i = n/10;
    return (i+1)*10;
  }
}

int main() {
  int A[5];
  int ans = 0;
  rep(i, 5) {
    cin >> A[i];
    ans += change_ten(A[i]);
  }
  int diff = 10;
  rep(i, 5) {
    if (A[i]%10!=0)
      diff = min(A[i]%10, diff);
  }
  

  cout << ans - (10 - diff) << endl;

}


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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(int64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

signed main() {
  int64_t n;
  cin >> n;
  
  
  int64_t count = 0;
  FOR(i, 1, n+1){
	string iStr = std::to_string(i);
    char first = iStr.front();
    char last = iStr.back();
    if(last=='0') continue;
    
    string newStr = "";
    newStr += last;
    if(first != last ) newStr += first;
    while(true){
      int64_t newValue = stoi(newStr);
      if(newValue<=n){
        int digitCount = newStr.length()-2;
        if(digitCount >= 1) {
          int64_t tmpVal = 9;
          int64_t newNewValue = newValue;
          REP(j,digitCount){
            tmpVal *= 10;
            newNewValue += tmpVal;
          }
          if(n<newNewValue){
            count += (n-newValue)/10 + 1;
          }
          else{
            count += (newNewValue-newValue)/10 + 1;
          }
        }
        else{
          count++;
        }
      }
      else break;
      newStr = newStr.substr(0,newStr.length()-1);
      if(newStr.length()==0){
        newStr += last;
        newStr += first;
      } else {
      	newStr += '0';
      	newStr += first;
      }
    }
  }
  cout << count << endl;

  return 0;
}

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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 5e5 + 10;
const int mod = 998244353;
const double pi = acos(-1);

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

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
  int b = 1;
  while (n)
  {
    if (n & 1)
      b = a * b % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return b;
}

class Prime_Number
{
public:
  int prime[maxn], s, v[maxn];
  void prime_init(int n)
  {
    for (int i = 2; i <= n; i++)
    {
      if (!v[i])
      {
        prime[s++] = i;
        for (int j = 1; j * i <= n; j++)
          v[i * j] = 1;
      }
    }
  }
};

//**************************

void solve()
{
 string s;
 cin>>s;
 int len=s.length();
 int sum=0;
 for(int i=0;i<len;i++)
 sum+=(s[i]-'0');
 if(sum%9)
  cout<<"No";
  else 
  cout<<"Yes";
}
signed main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[5],b[5]={0};
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	int shijian=0;
	for(int i=0;i<5;i++){
		while(a[i]%10!=0){
			a[i]++;
			b[i]++;
		}
	}
	for(int i=0;i<5;i++){
		shijian+=a[i];
	}
	int sum=b[0];
	for(int i=0;i<5;i++){
		if(b[i]>sum){
			sum=b[i];
		}
	}
	shijian-=sum;
	cout<<shijian<<endl;
	return 0;
}

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

struct state
{
  int f;
  int i, j;
  unsigned s;
  state() : f(0), i(-1), j(-1), s(0) {}
  state(int a, int b, int c, unsigned d) : f(a), i(b), j(c), s(d) {}
};

struct dungeon
{
  vector<string> grid;
  vector<vector<string> > moves;

  inline static int initial_floor(char c)
  {
    return c == '^' || isupper(c);
  }

  char get(const state& s) const
  {
    const char c = grid[s.i][s.j];
    if (c == '#' || c == '|') {
      return c;
    }
    int f = initial_floor(c);
    const int S = moves.size();
    for (int i = 0; i < S; i++) {
      const vector<string>& g = moves[i];
      if ((s.s & (1<<i)) && g[s.i][s.j] == '*') {
        f ^= 1;
      }
    }
    if (f == s.f) {
      return tolower(c);
    } else {
      return '#';
    }
  }
};

int main()
{
  int H, W;
  dungeon d;
  cin >> W >> H;
  d.grid.resize(H);
  state start;
  for (int i = 0; i < H; i++) {
    cin >> d.grid[i];
    for (int j = 0; j < W; j++) {
      if (d.grid[i][j] == '%') {
        start.i = i;
        start.j = j;
      }
    }
  }
  int S;
  cin >> S;
  for (int k = 0; k < S; k++) {
    vector<string> v(H);
    for (int i = 0; i < H; i++) {
      cin >> v[i];
    }
    d.moves.push_back(v);
  }

  static const int INF = 10000000;
  static int dist[2][50][50][1<<10];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < H; j++) {
      for (int k = 0; k < W; k++) {
        fill_n(dist[i][j][k], 1<<S, INF);
      }
    }
  }
  dist[start.f][start.i][start.j][start.s] = 0;
  queue<state> q;
  q.push(start);
  while (!q.empty()) {
    const state s = q.front();
    q.pop();
    const int dd = dist[s.f][s.i][s.j][s.s] + 1;
    const char here = d.get(s);
    if (here == '&') {
      cout << dd-1 << endl;
      return 0;
    }

    for (int i = 0; i < 4; i++) {
      static const int di[] = {-1, 1, 0, 0}, dj[] = {0, 0, -1, 1};
      const state t(s.f, s.i + di[i], s.j + dj[i], s.s);
      int& next = dist[t.f][t.i][t.j][t.s];
      if (d.get(t) != '#' && dd < next) {
        next = dd;
        q.push(t);
      }
    }

    if (here == '|') {
      const state t(s.f ^ 1, s.i, s.j, s.s);
      int& next = dist[t.f][t.i][t.j][t.s];
      if (dd < next) {
        next = dd;
        q.push(t);
      }
    } else if (isalpha(here)) {
      const int sw = here - 'a';
      int f = s.f;
      if (d.moves[sw][s.i][s.j] == '*') {
        f ^= 1;
      }
      const state t(f, s.i, s.j, s.s ^ (1<<sw));
      int& next = dist[t.f][t.i][t.j][t.s];
      if (dd < next) {
        next = dd;
        q.push(t);
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

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

int main(){
  int N;
  int a,b,c,d;
  cin >> N;
  a = N / 1000;
  b = (N - a*1000) / 100;
  c = (N - a*1000 - b*100) / 10;
  d = N % 10;
  
  if(a == b && b == c){
    cout << "Yes" << endl;
  }else if(b == c && c == d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return(0);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint h(n);
    rep(i, n) cin >> h[i];
    int mx = 0;
    int ans = 0;
    rep(i, n) {
       if (h[i] >= mx) {
           ans++;
           mx = h[i];
       }
    }

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

Measured memory_bytes: 256
#import numpy as np
#import sys
#sys.setrecursionlimit(10**7)
#from functools import reduce
#from fractions import gcd

# input
N = int(input())
S = []
for _ in range(N):
    S.append(input())

# process
d = {S[0]:1,}
for i in range(1, N):
    s = S[i]
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

ans = []
mx = max(d.values())
for k, v in d.items():
    if v == mx:
        ans.append(k)

ans.sort()

# output
for a in ans:
    print(a)


Measured memory_bytes: 35216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            cin = new CommonInput();

            int n, m;
            string tmp;
            bool isOpen = false;

            HashSet<string> db;

            n = cin.GetNextToInt();

            db = new HashSet<string>();

            for (int i = 0; i < n; i++)
            {
                db.Add(cin.GetNext());
            }

            m = cin.GetNextToInt();

            for (int i = 0; i < m; i++)
            {
                tmp = cin.GetNext();
                if (db.Contains(tmp))
                {
                    if (isOpen)
                    {
                        Console.WriteLine("Closed by " + tmp);
                    }
                    else
                    {
                        Console.WriteLine("Opened by " + tmp);
                    }

                    // not
                    isOpen ^= true;
                }
                else
                {
                    Console.WriteLine("Unknown " + tmp);
                }
            }
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        public string Line { get; set; }
        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public void GetLine()
        {
            this._i = 0;
            do
            {
                this.Line = Console.ReadLine();
            } while (this.Line == "");

            if (this.Line != null)
                this._s = this.Line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);
        }

        public string GetNext()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            this.GetLine();

            return this._s[this._i++];
        }

        public int GetNextToInt()
        {
            return int.Parse(this.GetNext());
        }

        public long GetNextToLong()
        {
            return long.Parse(this.GetNext());
        }

        public double GetNextToDouble()
        {
            return double.Parse(this.GetNext());
        }
    }
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	while(b<=a)
	{
		b*=2;
		sum++;
	}
	while(c<=b)
	{
		c*=2;
		sum++;
	}
	if(k>=sum)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}




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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0) Alice += a[i];
    else Bob += a[i];
  }
  cout << Alice - Bob << endl;
}
    


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = dict([[int(input().rstrip('\n')), 0] for _ in range(m)])
    x = [0] * (n + 1)
    x[0] = 1 if 0 not in a else 0
    x[1] = 1 if 1 not in a else 0
    for i in range(2, n+1):
        if i not in a:
            x[i] = (x[i-1] + x[i-2]) % 1000000007
        else:
            x[i] = 0
    print(x[-1])


if __name__ == '__main__':
    slove()


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

int main(){
  int n;
  cin >> n;
  string s;
  map<char,int> mp[n];
  for ( int i = 0; i < n; i++){
    cin >> s;
    for ( int j = 0; j < s.length(); j++){
      mp[i][s[j]]++;
    }
  }

  string ans = "";
  for ( map<char,int>::iterator it=mp[0].begin(); it!=mp[0].end(); it++){
    char key = it->first;
    int minV = 100;
    for (int i = 0; i < n; i++){
      minV = min( mp[i][key], minV);
    }
    for(int i = 0; i < minV; i++){
      ans+=key;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int ans, ar[N], n;
map<int, int> m;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
		m[ar[i]] = i;
	}
	
	sort(ar + 1, ar + n + 1);

	for(int i = 1; i <= n; i++)
		if(m[ar[i]] % 2 != i % 2)
			ans++;
	cout << ans / 2;
}

Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256