akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

int main()
{
  string s; cin >> s;
  int n=s.size();
  REP(i,n-1) if(s[i]==s[i+1])
  {
    printf("%d %d\n",i+1,i+2);
    return 0;
  }
  REP(i,n-2) if(s[i]==s[i+2])
  {
    printf("%d %d\n",i+1,i+3);
    return 0;
  }
  printf("-1 -1\n");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long INF=1e18,MOD=1e9+7;
int main(){
	ll n,m;
    cin>>n>>m;
    vector<ll>k(m),p(m);
    vector<vector<ll>>s(m);
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
			ll hoge;cin>>hoge;
			s[i].push_back(hoge);
        }
    }
	for(int i=0;i<m;i++)cin>>p[i];

	ll ans=0;
	ll num=pow(2,n);
	vector<int>d(m);
	for(ll i=0;i<num;i++){
		for(int ii=0;ii<m;ii++)d[ii]=0;
		for(ll j=0;j<n;j++){
			if (i & (1<<j)){
				for(int kk=0;kk<m;kk++){
					for(int l=0;l<k[kk];l++){
						if(j+1==s[kk][l]){
							d[kk]+=1;
							break;
						}
					}
				}
			}
		}
		bool flag=true;
		for(int k=0;k<m;k++){
			if(d[k]%2!=p[k]%2)flag=false;
		}
		if(flag)ans++;
		
	}
	cout<<ans<<endl;
}

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

bool is_ok(const string& s, const string& t)
{
  for (int i = 0; i < (int)s.size(); i++) {
    if (s.at(i) != t.at(i)) {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  string t;
  cin >> s;
  cin >> t;
  if (is_ok(s, t)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int ans=0,sum=0,flag=0,a,b,c,s;
	vector<int> v(100,0);
	cin>>a;
b=a;
	for(int i=0;i<100;i++){
	    v[i]=a%10;
	    a=a/10;
sum+=v[i];
	    if(a==0)
	    break;
	}
	if(b%sum==0){
	    cout<<"Yes"<<'\n';
	}
	else{
	    cout<<"No"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int MAX=200000;



int main(){
  int i;
  int R[MAX],N;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&R[i]);
  int minv=R[0];
  int ans=-2000000000;
  for(i=1;i<N;i++){
    if(ans < R[i]-minv){
      ans=R[i]-minv;
    }
    if(minv > R[i]){
      minv = R[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2572
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
signed main(){
    int n,s[(1<<18)];
    cin>>n;
    rep(i,(1<<n))cin>>s[i];
    sort(s,s+(1<<n));
    vector<int>v;
    v.pb(s[(1<<n)-1]);
    multiset<int>st;
    rep(i,(1<<n)-1)st.insert(s[i]);
    rep(_,n){
        vector<int>w=v;
        for(int i:v){
            auto it=st.lower_bound(i);
            if(it==st.begin()){
                puts("No");
                return 0;
            }
            it--;
            w.pb(*it);
            st.erase(it);
        }
        sort(all(w));
        reverse(all(w));
        v=w;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 16624
#include<bits/stdc++.h>
using namespace std;
int n, m, c, b[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10009];
vector<int> v;

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d", &c); v.push_back(c);
  }
  for(int i = 0; i <= n; i++){
    if(i && dp[i] == "") continue;
    for(int j : v){
      string tm = dp[i] + to_string(j);
      int s = dp[i+b[j]].size(), t = tm.size();
      if(s < t || (s == t && dp[i+b[j]] < tm)) dp[i+b[j]] = tm;
    }
  }
  cout << dp[n] << "\n";
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;
typedef vector<int> vec;

int main(){
  string s;
  cin >> s;
  while(s.size()){
    if(s.substr(0,2) == "hi"){
      s = s.substr(2);
    }
    else{
      cout << "No" << endl;
      return 0;
    } 
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  char x; cin >> x;
  if(islower(x)) cout << 'a' << endl;
  else cout << 'A' << endl;
  return 0;
}


Measured memory_bytes: 3580
import fractions

N = int(input())
a = list(map(int,input().split()))

ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
ans=ans-1
b=0

for i in a:
    b=b+ans%i
print(b)

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

int main()
{
    string N;
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N.size(); i++)
    {
        sum += int(N[i]) - int('0');
    }
    // cout << sum << endl;
    // cout << sum % 9 << endl;
    if ((sum % 9 == 0) || (sum == 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e6 + 5;
const int inf = 1e16 + 2;

int A[N];
void solve(int ze) {
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0 ; i < n ; i ++) {
        int a;
        cin >> a;
        arr[i] = a;
        A[a] ++;
    }
    for(int i = 1 ; i < N ; i ++) {
        if(A[i]) {
            for(int j = i + i ; j < N ; j += i) {
                A[j] += A[j - i];
            }
        }
    }
    int cnt = 0;
    for(int i = 0 ; i < n ; i ++) {
        if((A[arr[i]] - 1) == 0) cnt ++;
    }
    cout << cnt << '\n';
}
    
    


/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    return 0;
}
 



Measured memory_bytes: 12884
#include <iostream>
#include <functional>
#include <vector>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,finv;
public:
    combination(int N){
        fact = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            finv[i] = fact[i].inv();
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    int N,M;
    string S;
    cin >> N >> M >> S;
    vector<int> L(M+1),R(M+1);
    vector<int> mi(N+1,N+1),ma(N+1,0);
    for(int i=1;i<=M;i++){
        cin >> L[i] >> R[i];
        for(int j=L[i];j<=R[i];j++){
            mi[j] = min(mi[j],i);
            ma[j] = max(ma[j],i);
        }
    }
    vector<int> get1(N+2,0),getc(N+2,0),remove(N+2,0);
    for(int i=1;i<=N;i++){
        get1[mi[i]] += (S[i-1]=='1');
        getc[mi[i]]++;
        remove[ma[i]]++;
    }
    vector<mint> dp(N+1,0);
    combination c(N);
    dp[0] = 1;
    int now = 0;
    for(int i=1;i<=M;i++){
 //       cerr << i << " " << getc[i] << " " << remove[i] << endl;
        for(int j=now;j>=0;j--) dp[j+get1[i]] = dp[j];
        for(int j=get1[i]-1;j>=0;j--) dp[j] = 0;
        now += getc[i];
        if(!remove[i]) continue;
        vector<mint> ndp(N+1,0);
        for(int j=0;j<=now;j++){
            for(int k=0;k<=min(j,remove[i]);k++){
                if(0<=j-k && j-k<=now-remove[i]) ndp[j-k] += dp[j]*c.comb(remove[i],k);
            }
        }
        now -= remove[i];
        swap(dp,ndp);
//        for(int j=0;j<=N;j++) cerr << dp[j].x << (j!=N? " ":"\n");
    }
    cout << dp[0].x << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
string a,b,c;
cin >>a>>b>>c;
int numa,numb,numc;
numa=a.size();
numb=b.size();
numc=c.size();
int lena=1;
int lenb=0;
int lenc=0;
char who=a[0];
while(1){
if(lena>numa||lenb>numb||lenc>numc){
break;
}
if(who=='a'){
if(lena<numa)
who=a[lena];
lena++;
}
else if(who=='b'){
if(lenb<numb)
who=b[lenb];
lenb++;
}
else{
if(lenc<numc)
who=c[lenc];
lenc++;
}
}
if(lena>numa)
cout << "A";
else if(lenb>numb)
cout << "B";
else
cout << "C";
return 0;
}

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

struct node {
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x) {
  while(x -> left != NIL) {
    x = x -> left;
  }
  return x;
}

Node treeSearch(Node u, int k) {
  if(u == NIL || k == u -> key) {
    return u;
  }
  if(k < u -> key) {
    return treeSearch(u -> left, k);
  }
  else {
    return treeSearch(u -> right, k);
  }
}

Node treeSuccessor(Node x) {
  Node y;
  if(x -> right != NIL) {
    return treeMinimum(x -> right);
  }
  y = x -> parent;
  while(y != NIL && x == y -> right) {
    x = y;
    y = y -> parent;
  }
  return y;
}

void treeDelete(Node z) {
  Node y;
  Node x;
  
  if(z -> left == NIL || z -> right == NIL) {
    y = z;
  }
  else {
    y = treeSuccessor(z);
  }
  
  if(y -> left != NIL) {
    x = y -> left;
  }
  else {
    x = y -> right;
  }
  
  if(x != NIL) {
    x -> parent = y -> parent;
  }
  
  if(y -> parent == NIL) {
    root = x;
  }
  else if(y == y -> parent -> left) {
    y -> parent -> left = x;
  }
  else {
    y -> parent -> right = x;
  }
  
  if(y != z) {
    z -> key = y -> key;
  }
} 

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z -> key < x -> key) {
      x = x -> left;
    }
    else {
      x = x -> right;
    }
  }
  z -> parent = y;
  if(y == NIL) {
    root = z;
  }
  else if(z -> key < y -> key) {
    y -> left = z;
  }
  else {
    y -> right = z;
  }
}

void inorder(Node u) {
  if(u != NIL) {
    inorder(u -> left);
    printf(" %d", u -> key);
    inorder(u -> right);
  }
}

void preorder(Node u) {
  printf(" %d", u -> key);
  if(u != NIL) {
    if(u -> left != NIL) {
      preorder(u -> left);
    }
    if(u -> right != NIL) {
      preorder(u -> right);
    }
  }
}

main() {
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for(i = 0; i < n; i++) {
    scanf("%s", com);
    if(com[0] == 'f') {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'i') {
      scanf("%d", &x);
      insert(x);
    }
    else if(com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0] == 'd') {
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  rep(i, R) cin >> r[i];
  vector<vector<ll>> g(N+1, vector<ll>(N+1, INF64));
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = g[b][a] = c;
  }

  for(int k = 1; k <= N; ++k) {
    for(int i = 1; i <= N; ++i) {
      for(int j = 1; j <= N; ++j) chmin(g[i][j], g[i][k]+g[k][j]);
    }
  }

  sort(ALL(r));
  ll ans = INF64;
  do {
    ll tmp = 0;
    rep(i, R-1) tmp += g[r[i]][r[i+1]];
    chmin(ans, tmp);
  } while(next_permutation(ALL(r)));

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;
int n, A[20], q, m;
bool conta[200][20]={};

bool solve(int i, int m){
  //if(conta[i][m])return true;
  if(m==0)return /*conta[i][m]=*/true;
  if(i>=n)return /*conta[i][m]=*/false;
  return /*conta[i][m]=*/(solve(i+1,m) || solve(i+1,m-A[i]));
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  cin>>q;
    for(int i=0;i<q;i++){
    cin>>m;
    if(solve(0,m))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    int ans = 0;
    auto bfs = [&](int i, int j) {
        int ret = 0;
        vector<vector<int>> dis(h,vector<int>(w,-1));
        queue<P> q;
        q.push({i,j});
        dis[i][j] = 0;
        while(!q.empty()) {
            int ni = q.front().first;
            int nj = q.front().second;
            q.pop();
            ret = max(ret,dis[ni][nj]);
            rep(k,4) {
                int ci = ni+dx[k];
                int cj = nj+dy[k];
                if(ci < 0 || ci >= h || cj < 0 || cj >= w) continue;
                if(field[ci][cj] == '#') continue;
                if(dis[ci][cj] != -1) continue;
                dis[ci][cj] = dis[ni][nj]+1;
                q.push({ci,cj});
            }
        }
        return ret;
    };
    rep(i,h) {
        rep(j,w) {
            if(field[i][j] == '#') continue;
            ans = max(ans,bfs(i,j));
        }
    }
    cout << ans << endl;
}

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

int main(void) {
	int A,B,C,ans;
  	scanf("%d %d",&A,&B);
  	if(A<=B){
      	ans += B;
      	B--;
    }else{
      	ans += A;
      	A--;
    }
  	if(A<=B){
      	ans += B;
      	B--;
    }else{
      	ans += A;
      	A--;
    }
  	printf("%d",ans);
  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> S(h+2, vector<char>(w+2));
  int black = 0;
  for(int i=0;i<h+2;i++) {
    if(i == 0 || i == h+1) for(int j=0;j<w+2;j++) S[i][j] = '#';
    else {
      for(int j=0;j<w+2;j++) {
        if(j == 0 || j == w+1) S[i][j] = '#';
        else {
          cin >> S[i][j];
          if(S[i][j] == '#') black++;
        }
      }
    }
  }

  vector<vector<int>> root(h+2, vector<int>(w+2, -1));

  root[1][1] = 1;
  
  queue<pair<int, int>> que;

  map<pair<int, int>, int> used;

  que.push(make_pair(1, 1));

  while(!que.empty()) {
    pair<int, int> p = que.front();que.pop();
    if(used[p]) continue;
    int a = root[p.first][p.second] + 1;
    if(S[p.first+1][p.second] == '.' && !used[make_pair(p.first+1, p.second)]) {
      root[p.first+1][p.second] = a;
      que.push(make_pair(p.first+1, p.second));
    }
    if(S[p.first-1][p.second] == '.' && !used[make_pair(p.first-1, p.second)]) {
      root[p.first-1][p.second] = a;
      que.push(make_pair(p.first-1, p.second));
    }
    if(S[p.first][p.second+1] == '.' && !used[make_pair(p.first, p.second+1)]) {
      root[p.first][p.second+1] = a;
      que.push(make_pair(p.first, p.second+1));
    }
    if(S[p.first][p.second-1] == '.' && !used[make_pair(p.first, p.second-1)]) {
      root[p.first][p.second-1] = a;
      que.push(make_pair(p.first, p.second-1));
    }

    used[p] = 1;
  }

  if(root[h][w] == -1) cout << -1 << endl;
  else cout << h * w - root[h][w] - black << endl;

  return 0;
}

Measured memory_bytes: 384
S=list(input())
T=list(input())

def replacer():
	m = {}
	i = ord("A")

	def replace(c):
		nonlocal i
		if c not in m:
			m[c] = chr(i)
			i += 1
		return m[c]

	return replace

rs="".join(map(replacer(), S))
rt="".join(map(replacer(), T))

print("Yes" if rs == rt else "No")


Measured memory_bytes: 8332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  string s = "";
  ll l = 26LL;
  ll cnt = 1LL;
  while(n-l>0) {
    n -= l;
    l *= 26LL;
    cnt++;
  }
  n--;
  rep(j,cnt) {
    for(int i = (int)'a'; i<=(int)'z'; i++) {
      if(n%26 == i-(int)'a') s += (char)i;
    }
    n /= 26;
  }
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    vll L(100);
    L[0] = 2; L[1] = 1;
    FOR(i, 2, 100)L[i] = L[i - 1] + L[i - 2];
    int N;
    while (cin >> N) {
        cout << L[N] << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100001;
int nt,x[N],y[N],t[N],n;

bool hantei(){
	int sax,say,sat,saxy;
	sax=abs(x[nt+1]-x[nt]);
	say=abs(y[nt+1]-y[nt]);
	sat=abs(t[nt+1]-t[nt]);
	saxy=sax+say;
	if(sat>=saxy && (sat-saxy)%2==0){
		return true;
	}else{
		return false;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	t[0]=x[0]=y[0]=0;
	nt=0;

	while(nt<n){
		if(!hantei()){
			cout<<"No"<<endl;
			return 0;
		}
		nt++;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1408
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

// from std
pub use std::cmp::{max, min};
pub use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        n: i64, k: i64
    }

    let ans = min(
        (n - (k * (n / k))).abs(),
        (n - (k * ((n / k) + 1))).abs()
    );
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct node{
  int key;
  struct node *next,*prev;
};
node *Nordepointer;


void insert(int key){
  node *temp=(node *)malloc(sizeof(node));
  temp->key=key;
  temp->next=Nordepointer->next;
  Nordepointer->next->prev=temp;
  Nordepointer->next =temp;
  temp->prev = Nordepointer;
}

void freenode(node *temp){
  temp->prev->next=temp->next;
  temp->next->prev=temp->prev;
  free(temp);
}
void searchdelete(int key){
  node *temp;
  bool flag=0;
  for(temp=Nordepointer->next;temp!=Nordepointer;temp=temp->next){
    if(key==temp->key){
      flag=1;
      break;
    }
    //cout<<temp->key<<endl;
  }
  if(flag){
    freenode(temp);
  }
}

void deleteFirst(){
  freenode(Nordepointer->next);
}
void deleteLast(){
  freenode(Nordepointer->prev);

}
int main(){
  int n,key;
  char c[20];
  node *temp;
  Nordepointer =(node *)malloc(sizeof(node));
  Nordepointer->next = Nordepointer;
  Nordepointer->prev = Nordepointer;
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%s%d",c,&key);
    if(strcmp(c,"insert")==0){
      insert(key);
    }
    else if(strcmp(c,"delete")==0){
      searchdelete(key);
    }
    else if(strcmp(c,"deleteFirst")==0){
      deleteFirst();
    }
    else if(strcmp(c,"deleteLast")==0){
      deleteLast();
    }
  }
  for(temp=Nordepointer->next;temp!=Nordepointer->prev;temp=temp->next){  
    cout<<temp->key<<" ";
  }
  cout<<temp->key<<endl;
  return 0;
}



Measured memory_bytes: 34300
C = [list(map(int, input().split())) for i in range(3)]


A1 = [C[0][0] - C[1][0], C[0][1] - C[1][1],C[0][2] - C[1][2]]
A1.sort()
A2 = [C[1][0] - C[2][0], C[1][1] - C[2][1],C[1][2] - C[2][2]]
A2.sort()
B1 = [C[0][0] - C[0][1], C[1][0] - C[1][1],C[2][0] - C[2][1]]
B1.sort()
B2 = [C[0][1] - C[0][2], C[1][1] - C[1][2],C[2][1] - C[2][2]]
B2.sort()
if A1[0] == A1[2] and A2[0] == A2[2] and B1[0] == B1[2] and B2[0] == B2[2]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
n = int(input())
taro_point = 0
hanako_point = 0

for i in range(n):
    taro_card, hanako_card = input().split()
    if taro_card > hanako_card:
        taro_point += 3
    elif taro_card < hanako_card:
        hanako_point += 3
    else:
        taro_point += 1
        hanako_point += 1

print(str(taro_point) + ' ' + str(hanako_point))


Measured memory_bytes: 5592
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N)cin >> A[i];

  map<int,int> cnt;
  for(int i = 1;i <= N;i++){
    cnt[i+A[i-1]]++;
  }
  ll ans=0;
  for(int i = 1;i <= N;i++){
    if(cnt[i-A[i-1]]!=0)ans+=cnt[i-A[i-1]];
  }
  cout << ans << endl;



 }


Measured memory_bytes: 20984
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//#define _USE_MATH_DEFINES
#include <math.h>  /* M_PI */

int main(){

    double r;
    cin >> r;
    double pi = 3.14159265358979;
     // double型定数2
    // double a = std::numbers::pi;
    // std::cout << 2 * r * a << std::endl;


    printf("%.5f\n", 2* r * pi);
}

Measured memory_bytes: 3260
#include<stdio.h>
int main()
{
	int n,i,t=1,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&b);
		if(b==t)
			t++;
	}
	if(t==1)printf("-1");
	else
	printf("%d",n-t+1);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
SN = []
for i in range(N):
  s, n =input().split()
  SN.append([s, int(n), i])

SN.sort()
#print(SN)

start = 0
while (start < N-1):
  for i in range(start, N):
    search = SN[start][0]
    while(SN[i][0] == search):
      end = i
      if(i<N-1):
        i = i+1
      else:
        end = i
        break
        
  SNpart = SN[start:min(end+1, N)]
  #print(SNpart)
  SNpart.sort(key=lambda x:-x[1])
  SN[start:min(end+1, N)] = SNpart

  #print(SN[start:end+1])
  start = end+1

for i in range(N):
  print(SN[i][2]+1)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class CWelcomeToAtCoder {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,m;
        s2(n,m);
        set<int> ac;
        map<int,int> wa;
        f(i,0,m){
            int p;
            string v;
            s2(p,v);
            if(v == "AC"){
                ac.insert(p);
            }else{
                if(!ac.count(p)){
                    if(wa.count(p)){
                        wa[p]++;
                    }else{
                        wa[p] = 1;
                    }
                }
            }

        }
        int total = 0;
        for(auto p: wa){
            if(ac.count(p.first))total+=p.second;
        }
        out<<ac.size()<<" "<<total<<endl;
	}
};


integer main() {
	CWelcomeToAtCoder solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 6016
# ARC062D - AtCoDeerくんと変なじゃんけん / AtCoDeer and Rock-Paper (ABC046D)
def main():
    # p as much as possible (len(S) // 2)
    S = input().rstrip()
    ans = len(S) // 2 - S.count("p")
    print(ans)


if __name__ == "__main__":
    main()

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> x >> y >> n;
    for(i=x; i<=y; i++)
    {
        if(i%n==0)
            s++;
    }
    cout << s << endl;
}


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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ
#define all(v) v.begin(), v.end() // sort等の関数呼び出しを簡潔にする

using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int main() {
    int N, Y;
    cin >> N >> Y;

    bool flag = false;
    vi ans(3, 0);

    for(int a = 0; 10000*a <= Y; a++){
        for(int b = 0; ((10000*a + 5000*b) <= Y) && (N-a-b >= 0); b++){
            if(10000*a + 5000*b + 1000*(N-a-b) == Y){
                flag = true;
                ans.at(0) = a;
                ans.at(1) = b;
                ans.at(2) = N - a - b;
                break;
            }
        }
        if(flag) break;
    }

    if(flag == false){
    ans.at(0) = -1;
    ans.at(1) = -1;
    ans.at(2) = -1;
    }

    cout << ans.at(0) << ' ' << ans.at(1) << ' ' << ans.at(2) << endl;
return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
int W[110];
int acc[110];

void input() {
  cin >> N;
  loop(n,0,N) cin >> W[n];
}

void solve() {
  acc[0] = 0;
  for (int n=0; n<N; n++) {
    acc[n+1] = acc[n] + W[n];
  }

  int min_ = 900000;
  for (int k=2; k<N; k++) {
    chmin(min_, abs(acc[k] - (acc[N] - acc[k])));
  }
  cout << min_ << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

void solve(){
    int n, r;

    cin >> n >> r;

    if(n >= 10){
        cout << r << endl;
        return;
    }
    else
        cout << r + ((10 - n) * 100) << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


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

int main() {
	int N;
	cin >> N;
  vector<string> S(N);
	rep(i,N) cin >> S[i];
	map<string,int> mp;
	int mx = 0;
	rep(i,N){
		mp[S[i]]++;
		mx = max(mx,mp[S[i]]);
	}
	vector<string> ans;
	for(auto e:mp){
		if(e.second == mx) ans.push_back(e.first);
	}
	sort(all(ans));
	for(auto e:ans) cout << e << endl;
}

Measured memory_bytes: 30448
s = input()
i = 1
ans = 'Yes'
l1 = ('R', 'U', 'D')
l2 = ('L', 'U', 'D')
for c in s:
    if i % 2 == 1:
        if c not in l1:
            ans = 'No'
            break
    else:
        if c not in l2:
            ans = 'No'
            break
    i += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    int w,h;
    int ichi[101][101]={0};
    while(1){
        int i=0,j=0;
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }
        char map[w][h];
        for(int n=0;n<w;n++){
            for(int k=0;k<h;k++){
                cin >> map[n][k];
            }
        }
        for(int n=0;n<w;n++){
            memset(ichi[n],0,sizeof(ichi[i]));
        }
        while(1){
            if(ichi[i][j] == 1){
                cout << "LOOP" << endl;
                break;
            }
            else if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                ichi[i][j] = 1;
                j++;
            }
            else if(map[i][j] == '<'){
                ichi[i][j] = 1;
                j--;
            }
            else if(map[i][j] == '^'){
                ichi[i][j] = 1;
                i--;
            }
            else if(map[i][j] == 'v'){
                ichi[i][j] = 1;
                i++;
            }
        }
    }
}

Measured memory_bytes: 1216
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(int[]);
    auto A = ab[0];
    auto B = ab[1];
    foreach (n; 1..20000) {
        if ((n*0.08).to!int == A && (n*0.1).to!int == B) {
            writeln(n);
            return;
        }
    }
    writeln(-1);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			long n = in.nextLong();
			List<Integer> a = construct(n + 1);
			out.println(2 * a.size());
			for (int i = 0; i < a.size(); i++) {
				if (i > 0) {
					out.print(" ");
				}
				out.print(a.get(i));
			}
			for (int i = 0; i < a.size(); i++) {
				out.print(" " + (i + 1));
			}
			out.println();
		}

		private List<Integer> construct(long n) {
			List<Integer> res = new ArrayList<>();
			if (n == 1) {
				return res;
			}
			if (n % 2 == 1) {
				List<Integer> a = construct(n - 1);
				res.add(a.size() + 1);
				res.addAll(a);
			} else {
				List<Integer> a = construct(n / 2);
				res.addAll(a);
				res.add(a.size() + 1);
			}
			return res;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}



Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
string s;
int opn[222],stz[222];
vector<int>pr;
bool flag;
int f(int L,int R,int st)
{
	int mi=-1;
	for(int i=L;i<R;i++)
	{
		if(opn[i]<0||stz[i]!=st)continue;
		if(mi<0)mi=i;
		else if(pr[opn[i]]<pr[opn[mi]])mi=i;
	}
	if(mi>=0)
	{
		int A=f(L,mi,st),B=f(mi+1,R,st);
		if(s[mi]=='+')return A+B;
		else if(s[mi]=='-')return A-B;
		else if(s[mi]=='*')return A*B;
		else if(s[mi]=='/')
		{
			if(B)return A/B;
			else
			{
				flag=false;
				return 0;
			}
		}
	}
	if(s[L]=='('&&s[R-1]==')')return f(L+1,R-1,st+1);
	else
	{
		int now=0;
		for(int i=L;i<R;i++)now=now*10+s[i]-'0';
		return now;
	}
}
main()
{
	while(cin>>s,s!="#")
	{
		int sz=0,c=0;
		pr.clear();
		for(int i=0;i<s.size();i++)
		{
			opn[i]=stz[i]=-1;
			if(s[i]=='+'||s[i]=='-'||s[i]=='*'||s[i]=='/')
			{
				opn[i]=sz++;
				stz[i]=c;
				pr.push_back(pr.size());
			}
			if(s[i]=='(')c++;
			if(s[i]==')')c--;
		}
		set<int>S;
		do{
			flag=true;
			int ans=f(0,s.size(),0);
			if(flag)S.insert(ans);
		}while(next_permutation(pr.begin(),pr.end()));
		cout<<S.size()<<endl;
	}
}



Measured memory_bytes: 3204
import fractions
a,b,k=map(int,input().split())
n=fractions.gcd(a,b)
l=[]
ld=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        ld.append(n//i)
if ld[-1]==l[-1]:del ld[-1]
l+=ld[::-1]
print(l[-k])

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MOD=1e9+7;
int dp[10005][105][2];

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

    string K;
    int D;
    cin>>K>>D;
    int n = K.length();

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

    FOR(i,n) {
        FOR(d, 10) {
            FOR(m,D) {
                int nm=(((m-d)%D)+D)%D;
                dp[i+1][nm][0] += dp[i][m][0];
                if(d<K[i]-'0')
                    dp[i+1][nm][0] += dp[i][m][1];
                if(d==K[i]-'0')
                    dp[i+1][nm][1] += dp[i][m][1];
                dp[i+1][nm][0] %= MOD;
            }
        }
    }

    ll ans =dp[n][0][0]+dp[n][0][1]-1+MOD;
    cout<<ans%MOD<<endl;


    return 0;
}



Measured memory_bytes: 8448
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, T;
  int ans = INF;

  cin >> n >> T;

  for(int i=0;i<n;i++){
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans, c);
  }

  if (ans == INF)
    cout << "TLE" << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    vint ans(n,0);
    int mode = 0; //0R  1L
    int rnow=0,lnow=0;
    int rl=0,ll=0;
    REP(i,n){
        if(mode==0){
            if(s[i]=='R'){
                rl++;
            }else{
                ll=1;
                rnow=i-1;
                lnow=i;
                mode=1;
            }
        }else{
             if(s[i]=='R'){
                 //cout << rl << " " << ll << endl;
                 ans[rnow]+=rl/2;
                 ans[rnow]+=rl%2;
                 ans[rnow]+=ll/2;
                 ans[lnow]+=ll/2;
                 ans[lnow]+=ll%2;
                 ans[lnow]+=rl/2; 
                 rnow=0;
                 lnow=0;
                 rl=1;
                 ll=0;
                 mode=0;
             }else{
                 ll++;
             }
        }
    }
    ans[rnow]+=rl/2;
    ans[rnow]+=rl%2;
    ans[rnow]+=ll/2;
    ans[lnow]+=ll/2;
    ans[lnow]+=ll%2;
    ans[lnow]+=rl/2; 
    REP(i,n-1){
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1104
#include <iostream>

using namespace std;

int main() {
	int x, a ,b; cin >> x >> a >> b;
	if(b - a <= 0)
	    cout << "delicious" << endl;
	else if(b - a <= x)
	    cout << "safe" << endl;
	else
	    cout << "dangerous" << endl;
}


Measured memory_bytes: 256
def even(n):
    count = 0
    i = 10
    while(n/i>=1):
        count += n//i
        i *= 5
    return int(count) 

def main():
    N = int(input())

    if N < 2:
        print(0)

    # even
    elif N % 2 == 0:
        print(even(N))
    # odd
    elif N % 2 == 1:
        print(0)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	if (nextInt()*nextInt())%2 == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640