akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int[] A = new int[Q];
    int[] correct = new int[N];

    for (int i = 0; i < Q; i++) {
      A[i] = sc.nextInt() - 1;
      correct[A[i]]++;
    }

    sc.close();

    PrintWriter out = new PrintWriter(System.out);
    
    for (int i = 0; i < N; i++) {
      if (0 < correct[i] + K - Q) {
        out.println("Yes");
      } else {
        out.println("No");
      }
    }

    out.flush();

  }

}

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

int n, k;
int a[110];
int dp[100010];

int solve(int x){
  if(dp[x]>=0) return dp[x];
  dp[x] = 0;
  rep(i, n)if(x-a[i]>=0 && solve(x-a[i])==0){
    dp[x] = 1;
    break;
  }
  return dp[x];
}

int main(){
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  rep(i, k+1) dp[i] = -1;
  dp[0] = -1;
  cout << (solve(k)>0 ? "First" : "Second") << endl;
}

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

struct student
{
  int id;
  int record;
};


int main()
{
  int n;
  std::cin >> n;
  std::vector<student>a(n);
  for (int i = 0; i < n; i++)
  {
    student st;
    st.id = i;
    std::cin >> st.record;
    a[i]=st;
  }
  std::sort(a.begin(), a.end(), 
  [](student& left, student& right)
  {return left.record < right.record;});
  
  for (int i = 0; i < n; i++)
  {
    std::cout << a[i].id+1 << " ";
    // std::cout << a[i].record << " ";
  }
  
  
  return 0;
}


Measured memory_bytes: 1536
from itertools import groupby
s = input()
k = int(input())
ans = 0
count = []
for i, j in groupby(s):
    count.append(len(list(j)))
if len(set(s)) == 1:
    ans = (len(s)*k)//2
elif k > 1 and s[0] == s[-1]:
    f = count[0]
    e = count[-1]
    ans += f//2 + e//2 + (f+e)//2*(k-1)
    for n in count[1:-1]:
        ans += n//2 * k
else:
    for n in count:
        ans += n//2 * k
print(ans)


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n); REP(i, n) cin >> a[i];
  int comb = (1 << k) - 1;
  ll ans = LINF;
  while (comb < (1 << n)) {
    int prev = 0, cnt = 0;
    ll sum = 0;
    REP(i, n) {
      if (comb >> i & 1) {
        sum += max(prev + 1, a[i]) - a[i];
        prev = max(prev + 1, a[i]);
      } else {
        chmax(prev, a[i]);
      }
      if (cnt == k) break;
    }
    chmin(ans, sum);
    int x = comb & -comb, y = comb + x;
    comb = (((comb & ~y) / x) >> 1) | y;
  }
  cout << ans << '\n';
  return 0;
}


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

bool check(vector<P> s)
{
    int h = 0;
    for (P p : s)
    {
        int b = h + p.first;
        if (b < 0)
            return false;
        h += p.second;
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    string s;
    vector<P> ls, rs;
    int total = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (char c : s)
        {
            if (c == '(')
                ++h;
            else
                --h;
            b = min(b, h);
        }
        if (h > 0)
            ls.emplace_back(b, h);
        else
            rs.emplace_back(b - h, -h);
        total += h;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());
    if (check(ls) && check(rs) && total == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 18748
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int n;
  cin >> n;
  if(n==7||n==5||n==3){cout << "YES" << endl;}else{cout << "NO" << endl;}
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())

k=[]
l=[]
ans=0
for i in range(m):
    input_l = sorted(list(map(int,input().split())))
    if input_l[0]==1:
        k.append(input_l[1])
    if input_l[1]==n:
        l.append(input_l[0])
print('IMPOSSIBLE' if len(set(k)&set(l))==0 else 'POSSIBLE')
    

Measured memory_bytes: 21840
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    int N;string S;cin>>N>>S;
    int count=0;
    rep(i,N-2)if(S.substr(i,3)=="ABC")count++;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  long a = -2;
  string S;
  while(N != 0){
    if(N % abs(a) == 0) S.push_back('0');
    else {
      S.push_back('1');
      N -= (a / -2);
    }
    
    if(N == 0)break;
    a *= -2;
  }
  reverse(S.begin(), S.end());
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
//*
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll h, w;
	ll d[10][10];
	ll count[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

	cin >> h >> w;

	REP(i, 10) {
		REP(j, 10) {
			ll x;
			cin >> x;
			d[i][j] = x;
		}
	}

	REP(i, h) {
		REP(j, w) {
			ll y;
			cin >> y;
			if (y != -1) {
				count[y]++;
			}
		}
	}

	REP(k, 10) {
		REP(i, 10) {
			REP(j, 10) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	ll ans = 0;

	REP(i, 10) {
		if (i != 1) {
			ans += d[i][1] * count[i];
		}
	}

	cout << ans << endl;
}
//*/

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int startMax = Math.max(a, c);
    int stopMin = Math.min(b,d);
    if(startMax > stopMin) {
      System.out.println(0);
    }else {
      System.out.println(stopMin - startMax);
    }
  }
}


Measured memory_bytes: 23892
/*Author - sambhu show(jgec) */
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define PI 3.141592653589793238
//ang=(PI*ang)/180.0 in radian
#define Max(a,b,c) max(a,max(b,c));
#define Min(a,b,c) min(a,min(b,c));
#define all(v) v.begin(),v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define endl "\n"
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int XX[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int main()
{

	int l, r, d;
	cin >> l >> r >> d;

	int a = (l - 1) / d;
	int b = r / d;
	cout << b - a << endl;

	return 0;
}

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

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

    int A, B, C;
    cin >> A >> B >> C;

    if(C <= A + B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# ABC145C

import itertools
import math

N=int(input())
r=[tuple(map(int,input().split())) for i in range(N)]

lensum=0
for i in itertools.permutations(r):
    for j in range(N-1):
        length=((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2)**0.5
        lensum+=length
        
print(lensum/math.factorial(N))

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

void Main() {
  int T, X;
  cin >> T >> X;
  cout << (double)T / (double)X << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	map<char, lli>m;
	for (int i = 0; i < N; i++) {
		m[s[i]]++;
	}
	lli ans = 1;
	for (auto i = m.begin(); i != m.end();i++) {
		ans *= ((*i).second + 1);
		ans %= MOD;
	}
	cout << ans - 1 << endl;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    string s,t; cin >> s >> t;
    int len_s = s.size();
    int len_t = t.size();
    s = ' '+s;
    t = ' '+t;
    vector<vector<int>> dp(len_s+1,vector<int>(len_t+1,0));
    for(int i = 1; i <= len_s; i++){
        for(int j = 1; j <= len_t; j++){
            if(s.at(i) == t.at(j)) dp.at(i).at(j) = dp.at(i-1).at(j-1) +1;
            else dp.at(i).at(j) = max(dp.at(i).at(j-1),dp.at(i-1).at(j));
        }
    }
    string ans = "";
    
    int i = len_s;
    int j = len_t;
    while(i > 0 && j > 0){
        if(dp.at(i).at(j) == dp.at(i).at(j-1)) j--;
        else if(dp.at(i).at(j) == dp.at(i-1).at(j)) i--;
        else{
            ans = s.at(i) + ans;
            i--;
            j--;
        } 
    }

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


Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
    int n;
    int ans = 0;

    cin >> n;
    vector<int> vec(n);

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

    for (int i = 1; i < n-1; i++)
    {
        if ((vec.at(i-1) > vec.at(i) && vec.at(i) > vec.at(i+1))||((vec.at(i-1) < vec.at(i) && vec.at(i) < vec.at(i+1))))
        {
            ans++;
        }
    }
    
    cout << ans << endl;
    
}


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

using namespace std;

long long A[101010];

int main() {
    int N;

    cin >> N;    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N);
    int id;
    while (A[N - 2] != 0) {
        for (int i = 0; i < N; i++) {
            if (A[i] > 0) {
                id = i;
                break;
            }
        }
        if (id == N - 1) break;
        for (int i = id + 1; i < N; i++) {
            A[i] %= A[id];
        }
        sort(A, A + N);
    }
    cout << A[N - 1] << endl;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    while (true)
    {
        ++ans;
        N = N / K;
        if (N == 0)
        {
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

class Coin
{
public:
  int n, m;
  vector<int> c;
  vector<vector<int>> dp;
  Coin(){}
  Coin( int n, int m ) : n(n), m(m), c(m), dp(m, vector<int>(n+1)) {}
  int solve();
};

int Coin::solve()
{
  for ( auto i = 0; i <= n; ++i )
    dp[0][i] = i;

  for ( auto i = 0; i < m; ++i )
    dp[i][0] = 0;

  sort( c.begin(), c.end() );

  for ( auto i = 1; i < m; ++i )
    {
      for ( auto j = 1; j <= n; ++j )
        {
          int mc = dp[i-1][j];

          if ( j >= c[i] )
            {
              mc = min( mc, dp[i-1][j-c[i]] + 1 );
              mc = min( mc, dp[i][j-c[i]] + 1 );
            }

          dp[i][j] = mc;
        }
    }
  
  cout << dp[m-1][n] << endl;
  
  return 0;
}

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

  Coin c(n, m);

  for ( auto i = 0; i < m; ++i )
    cin >> c.c[i];

  c.solve();

  return 0;
}

Measured memory_bytes: 5224
#include<stdio.h>
int main(void)
{
  int n1,n2,n3;
  scanf("%d",&n1);
  scanf("%d",&n2);
  scanf("%d",&n3);
  if(n1==n2&&n1==n3){
    printf("No");
  }
  else if(n1==n2||n1==n3||n2==n3){
    printf("Yes");
  }
  else {printf("No");}
  return 0;
}

Measured memory_bytes: 1732
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
namespace Solve
{
	typedef long long LL;
	inline LL mymax(LL a,LL b){return a>b?a:b;}
	const int MAXN=3005;
	int v[MAXN][MAXN],N,M,K;
	LL F[MAXN][MAXN][4];
	void work()
	{
		while(scanf("%d%d%d",&N,&M,&K)!=EOF)
		{
			memset(v,0,sizeof(v));
			for(int i=1;i<=K;i++)
			{
				int x,y,w;
				scanf("%d%d%d",&x,&y,&w);
				v[x][y]=w>v[x][y]?w:v[x][y];
			}
			memset(F,0,sizeof(F));
			for(int i=1;i<=N;i++)
			{
				for(int j=1;j<=M;j++)
				{
					F[i][j][0]=mymax(F[i][j][0],F[i-1][j][0]);
					F[i][j][0]=mymax(F[i][j][0],F[i][j-1][0]);
					for(int t=1;t<=3;t++)
					{
						F[i][j][t]=mymax(F[i][j][t],F[i-1][j][t]);
						F[i][j][t]=mymax(F[i][j][t],F[i][j-1][t]);
						F[i][j][t]=mymax(F[i][j][t],F[i][j-1][t-1]+v[i][j]);
						for(int nt=0;nt<=3;nt++)
							F[i][j][t]=mymax(F[i][j][t],F[i-1][j][nt]+v[i][j]);
					}
				}
			}
			LL ans=F[N][M][0];
			for(int t=1;t<=3;t++)
				if(F[N][M][t]>ans)
					ans=F[N][M][t];
			cout<<ans<<endl;
		}
		return;
	}
}
int main()
{
	#ifdef LOCAL
	freopen("00test.in","r",stdin);
	freopen("00test.out","w",stdout);
	#endif
	Solve::work(); 
	return 0;
}

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

int main(){
  long long N,M,ans;
  long long mod=1000000007;
  cin>>N>>M;
  if(N==M){
    long long ans=1;
    for(long long i=N;i>=1;i--){
      ans=(ans*i)%mod;
    }
    ans=(ans*ans*2)%mod;
    cout<<ans<<endl;
    return 0;
  }
  if((N==M+1)||(M==N+1)){
    long long ans=1;
    for(long long i=N;i>=1;i--){
       ans=(ans*i)%mod;
    }
    for(long long i=M;i>=1;i--){
       ans=(ans*i)%mod;
    }
    cout<<ans<<endl;
    return 0;
  }    
  cout<<0<<endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

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

	int N,M=0;	cin>>N;
	map<string, int> mp;
	vector<string>	data;
	FOR(i,0,N){
	string S;
	cin>>S;
	mp[S]++;
	M=max(M,mp[S]);
	}
	
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if(itr->second==M)	cout<<itr->first<<endl;
    }
	
    return 0;
}

Measured memory_bytes: 23936
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;

    vector<vector<int>> G(N);
    rep(i,N){
      for(int d=-1; d<=1; d++){
        int nx = i + d;
        if(d==0 || nx<0 || nx>=N) continue;
        G[i].pb(nx);
      }
    }
    G[X].pb(Y);
    G[Y].pb(X);

    // rep(i,N){
    //   cout << i << ": ";
    //   rep(j,G[i].size()){
    //     cout << G[i][j] << " ";
    //   }cout << endl;
    // }

    vector<int> ans(N,0);

    rep(i,N){
      vector<int> dis(N+1,-1);
      queue<int> que;

      int s = i;
      //if(s==2)break;
      dis[s] = 0;
      que.push(s);

      while(!que.empty()){
        int p = que.front();
        que.pop();
        //cout << "step: " << p << endl;
        
        //cout << "size: " << G[p].size() << endl;
        rep(j,G[p].size()){
          int nx = G[p][j];
          if(dis[nx]==-1){
            que.push(nx);
            dis[nx] = dis[p]+1;
            //cout << "step: " << dis[p] << endl;
          }
        }
      }

      for(int k=s; k<N; k++){
        int index = dis[k];
        ans[index]++;
        //cout << index << " ";
      }//cout << endl;

    }

    for(int i = 1; i < N; i++){
      cout << ans[i] << endl;
    }
}

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

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    int product, i;
    cin >> product;

    if(product <= 9)
    	cout << "Yes" << endl;
    else
    {
    	for(i = 2; i <= sqrt(product); i++)
    	{
    		if(product % i == 0)
    		{
    			if(product/i < 10)
    			{
    				break;
    			}
    		}
    	}
    	if(i <= sqrt(product))
    		cout << "Yes" << endl;
    	else
    		cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int a = N / 10;
	int b = N % 10;

	if (a == 9 || b == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3608
#include<utility>
#include<vector>
#include<functional>
#include<algorithm>
#include<iostream>

using namespace std;

struct Edge{
	int from,to; //if you want cost, etc., you should care //aboutthe"emplace_back(line36,line118).
	Edge(int f,int t){
		from=f;
		to=t;
	}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

pair<vector<int>,Edges> bridge(const Graph& g){
	const int n=g.size();
	int idx=0,s=0,t=0,k=0;
	vector<int>ord(n,-1),onS(n),stk(n),roots(n),cmp(n);
	Edges brdg;
	function<void(int,int)> dfs = [&](int v,int u){
		ord[v]=idx++;
		stk[s++]=v;
		onS[v]=true;
		roots[t++]=v;
		for(auto& e:g[v]){
			int w=e.to;
			if(ord[w]==-1)dfs(w,v);
			else if(u != w && onS[w])
			       while(ord[roots[t-1]]>ord[w])-t;
		}
		if(v==roots[t-1]){
			brdg.emplace_back(u,v);
			while(true){
				int w=stk[--s];
				onS[w]=false;
				cmp[w]=k;
				if(v==w)break;
			}
			--t;
			++k;
		}
	};
	for(int u=0;u<n;++u){
		if(ord[u]==-1){
			dfs(u,n);
			brdg.pop_back();
		}
	}
	return make_pair(cmp,brdg);
}

vector<int>ArticulationPoint(const Graph& g){
	int n=g.size(),idx;
	vector<int>low(n),ord(n),art;
	function<void(int)>dfs=[&](int v){
		low[v]=ord[v]=++idx;
		for(auto& e:g[v]){
			int w=e.to;
			if(ord[w]==0){
				dfs(w);
				low[w]=min(low[v],low[w]);
				if((ord[v]==1 && ord[w]!=2)||(ord[v]!=1 && low[w]>=ord[v]))
					art.push_back(v);
			}else
				low[v]=min(low[v],ord[w]);
		}
	};
	for(int u=0;u<n;++u){
		if(ord[u]==0){
			idx=0;
			dfs(u);
		}
	}
	return art;
}

vector<int> tarjan(const Graph& g){
	int n=g.size(),idx=0,k=0,s=0;
	vector<int>ord(n,-1),low(n),onS(n),cmp(n),stk(n);
	function<void(int)>dfs;
	dfs=[&](int v){
		ord[v]=low[v]=idx++;
		stk[s++]=v;
		onS[v]=true;
		for(auto &e:g[v]){
			int w=e.to;
			if(ord[w]==-1){
				dfs(w);
				low[v]=min(low[v],low[w]);
			}else if(onS[w]){
				low[v]=min(low[v],ord[w]);
			}
		}
		if(low[v]==ord[v]){
			while(1){
				int w=stk[--s];
				onS[w]=false;
				cmp[w]=k;
				if(w==v)break;
			}
			++k;
		}
	};
	for(int v=0;v<n;++v)
		if(ord[v]==-1)dfs(v);
	return cmp;
}

vector<int> kosaraju(const Graph& g){
	int n=g.size(),sz=0;
	Graph rg(n);
	vector<int>stk,cmp(n,-1),added(n),visited(n),ord(n);
	for(auto &es:g){
		for(auto &e:es)rg[e.to].emplace_back(e.to,e.from);
		sz+=es.size();
	}
	stk.resize(n+sz);
	sz=0;
	for(int i=0;i<n;++i){
		if(visited[i])continue;
		int s=0;
		stk[s++]=i;
		while(s!=0){
			int v=stk[s-1];
			visited[v]=true;
			bool pushed=false;
			for(auto &e:g[v]){
				int to=e.to;
				if(!visited[to]){
					stk[s++]=to;
					pushed=true;
				}
			}
			if(pushed)continue;
			int t=stk[s-1];
			if(!added[t]){
				added[t]=true;
				ord[n-++sz]=t;
			}
			--s;
		}
	}
	int k=0;
	for(int &u:ord){
		if(cmp[u]!=-1)continue;
		int s=0;
		stk[s++]=u;
		while(s!=0){
			int v=stk[--s];
			cmp[v]=k;
			for(auto &e:rg[v]){
				int t=e.to;
				if(cmp[t]==-1)stk[s++]=t;
			}
		}
		++k;
	}
	return cmp;
}

int main(){
	int V,E;
	cin>>V>>E;
	Graph g(V);
	for(int i=0;i<E;++i){
		int s,t;cin>>s>>t;
		g[s].emplace_back(s,t);
	}
	int Q;cin>>Q;
	vector<int>SCC=kosaraju(g);
	for(int i=0;i<Q;++i){
		int u,v;cin>>u>>v;
		cout<<(SCC[u]==SCC[v])<<endl;
	}
}

Measured memory_bytes: 4296
import Control.Applicative

main = interact $ unlines . map show' . kagisys . read' . lines
 where
  read' (n:xs) = let (reg,(_:uids)) = splitAt (read n) xs in (reg,uids)
  show' (stats,uid) = case stats of
   Nothing -> "Unknown "++ uid
   (Just True) -> "Opened by " ++ uid
   (Just False) -> "Closed by " ++ uid

kagisys (reg,uids) = transit (Just False) uids
 where
  transit _ [] = []
  transit stats (u:uids)
   | elem u reg = (not <$> stats, u) : transit (not <$> stats) uids
   | otherwise = (Nothing, u) : transit stats uids

Measured memory_bytes: 4204
#include <stdio.h>

int main()
{
    long long int x, p, r;
    scanf("%lld %lld", &x, &p);

    if(x>p)
    {
        r = x-p;
        printf("%lld", r);
    }
    else
    {
        r = 0;
        printf("%lld", r);
    }

    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define F first
#define S second
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define one(x) cout<<#x<<" : "<<x<<endl;
#define two(x,y) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<endl;
#define three(x,y,z) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<" , "<<#z<<" : "<<z<<endl;
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5+5;


signed main()
{
    string s;
    cin >> s;
    string a , b;
    int n = s.length();
    a = s.substr(0, (n-1)/2 );
    b = s.substr((n+3)/2 -1 );
    
    string sr , ar , br ;
    sr = s;
    ar = a;
    br = b;
//    cout<<a << " "<<ar <<endl;
//    cout<< b << " "<<br<<endl;
reverse(all(sr));
    reverse(all(br));
    reverse(all(ar));
    if(a == ar && b == br && sr == s){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}




Measured memory_bytes: 256
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
l=A[0]
for i in range(n-1):
	l=(l*A[i+1])//gcd(l,A[i+1])
r=0
for i in range(n):
	r+=(l-1)%A[i]
print(r)

Measured memory_bytes: 5344
#include<stdio.h>
int main()
{
    int A,B,C,p,r;
    scanf("%d%d%d",&A,&B,&C);

    p=A-B;
    r=C-p;
    if(p<C)
    {
    printf("%d",r);
    }
    else
    {
       printf("0");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<atcoder/all>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
#pragma intrinsic(_umul128)
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//--------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, Q;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q;

	dsu uf(N);
	rep(q, 0, Q) {
		int t, u, v; cin >> t >> u >> v;
		if (t == 0) uf.merge(u, v);
		else {
			printf("%d\n", uf.same(u, v) ? 1 : 0);
		}
	}
}







Measured memory_bytes: 3956
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_to_string(&mut buf);
    let mut it = buf.split_whitespace();
    let a: i32 = it.next().unwrap().parse().unwrap();
    let b: i32 = it.next().unwrap().parse().unwrap();
    let c: i32 = it.next().unwrap().parse().unwrap();
    if a+b>=c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static String EVEN = "Even";
	public static String ODD = "Odd";

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a1 = s.nextInt();
		int a2 = s.nextInt();

		String ret;
		if (a1 * a2 % 2 == 0) {
			ret = EVEN;
		} else {
			ret = ODD;
		}

		System.out.println(ret);
	}

}


Measured memory_bytes: 21716
k, n = map(int, input().split())
a = list(map(int, input().split()))

# print(k)
# print(n)
# print(a)

minmin = k
for i in range(n):
    start = i
    end = -1 + i
    if i == 0:
        end = n - 1
    # print("{} -> {}".format(start, end))
    
    result = k
    if i == 0:
        result = a[end] - a[start]
        # print(result)
    else:
        result = (a[end] + k) - a[start]
        # print(result)
        
    if result < minmin:
        minmin = result
        
    # print(minmin)
        
print(minmin)

Measured memory_bytes: 26420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int high = 0;
  int n;
  int h[101];
  int ans = 0;
  
  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> h[i];
    high += h[i];
  }
  
  while(high != 0)
    {
      // cout << high << endl;
      
      int l;
      int r;
      int mini;
      l = -1;
      r = -1;
      mini = 1000;
      
      for(int i = 0;i < n;i++)
	{
	  if(mini != 1000 && h[i] == 0)
	    {
	      r = i - 1;
	      break;
	    }
	  
	  if(l == -1 && h[i] != 0)
	    {
	      l = i;
	    }

	  if(h[i] != 0)
	    {
	      mini = min(mini, h[i]);
	    }
	}

      if(r == -1)
	{
	  r = n - 1;
	}
      
      for(int i = l;i <= r;i++)
	{
	  h[i] -= mini;
	  high -= mini;
	}
      ans += mini;
    }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/

int main(){
  string s; cin >> s;
  int ans = 0;
  rep(i,s.size()){
    if(s[i] == '1') ans++;
  }
  cout << ans << endl;
}


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

struct Inputs
{
    int *inputK;
    int *inputA;
    int *inputB;
};

void * GiveMemory()
{
    return malloc(sizeof(int));
}

int CountMultiplicationB(int *inputK, int *inputB)
{
   return *inputB / *inputK;
}

int CountMultiplicationA(int *inputK, int *inputA)
{
   return *inputA / *inputK;
}

void PrintOutput(int *inputK,int multiplyA,int multiplyB, int *inputA, int *inputB)
{
    if(*inputK * multiplyA  == *inputA)
    {
        printf("OK \n");
    }
    else if(*inputK * (multiplyA + 1) <= *inputB)
    {
        printf("OK \n");
    }
    else
    {
        printf("NG \n");
    }
}

void ReadInput(int *inputK, int *inputA, int *inputB)
{
    //printf("Enter the value of K: \n");
    scanf("%d", inputK);
    //printf("Enter the value of A and B: \n");
    scanf("%d %d", inputA, inputB);

}

int main(int argc, const char * argv[])
{
    struct Inputs Golf;
    Golf.inputA = GiveMemory();
    Golf.inputB = GiveMemory();
    Golf.inputK = GiveMemory();
    
    ReadInput(Golf.inputK, Golf.inputA, Golf.inputB);
    
    int multiplyA = CountMultiplicationA(Golf.inputK, Golf.inputA);
    int multiplyB = CountMultiplicationB(Golf.inputK, Golf.inputB);
    
    PrintOutput(Golf.inputK, multiplyA, multiplyB,  Golf.inputA, Golf.inputB);
    
    return 0;
}


Measured memory_bytes: 1644
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    const int range = 4;
    int count = 0, tmp;
    int i;
    int x[range];
    string n;
    cin >> n;
    for(i=0;i<range;i++) x[i] = n[i];
    sort(x, x + range);
    tmp = x[0];
    for(i=0;i<range;i++){
        if(tmp == x[i]) count++;
        else count = 0;
        if(count>=3) break;
    }
    cout << (count >= 3? "Yes": "No") << endl;
}

Measured memory_bytes: 760
k = int(input())
mod = 7 % k
counter = 1
memo = 1
mod_map = set()
mod_map.add(mod)
while mod != 0:
    mod = ((mod * 10) % k + 7) % k
    if mod not in mod_map:
        mod_map.add(mod)
    else:
        counter = -1
        break
    counter += 1
    if mod == 0:
        break
print(counter)


Measured memory_bytes: 156932
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//===========================================================

int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}

//===========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897932384626433832795;
const ll mod = 1000000007LL;
const int INF = 1000000000;

int main() {
	TEZ;

	int n;
	cin >> n;

	int ac, wa, tl, re;
	ac = wa = tl = re = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;

		if (s == "AC")
			ac++;
		else if (s == "WA")
			wa++;
		else if (s == "TLE")
			tl++;
		else
			re++;
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tl, re);

	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
const int N = 1000001;


// array to store inverse of 1 to N
ll factorialNumInverse[N + 1];

// array to precompute inverse of 1! to N!
ll naturalNumInverse[N + 1];

// array to store factorial of first N numbers
ll fact[N + 1];

// Function to precompute inverse of numbers
void InverseofNumber(ll p)
{
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (int i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
// Function to precompute inverse of factorials
void InverseofFactorial(ll p)
{
    factorialNumInverse[0] = factorialNumInverse[1] = 1;

    // precompute inverse of natural numbers
    for (int i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}

// Function to calculate factorial of 1 to N
void factorial(ll p)
{
    fact[0] = 1;

    // precompute factorials
    for (int i = 1; i <= N; i++) {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

// Function to return nCr % p in O(1) time
ll Binomial(ll N, ll R, ll p)
{
    // n C r = n!*inverse(r!)*inverse((n-r)!)
    ll ans = ((fact[N] * factorialNumInverse[R])
              % p * factorialNumInverse[N - R])
             % p;
    return ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n,m,k;
cin>>n>>m>>k;
int c=m;
int mod=998244353;
InverseofNumber(mod);
    InverseofFactorial(mod);
    factorial(mod);
int ans=0;
for(int i=1;i<=n;i++)
{
    int val=Binomial(n-1,n-i,mod);
    val=val*c;
    val%=mod;

    if(n-i<=k)
    {
        ans+=val;
        ans%=mod;

    }

    c*=(m-1);
    c%=mod;

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


Measured memory_bytes: 27092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7

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

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

ll dp[50];

ll fib(int n) {
    if (dp[n] >= 0) return dp[n];
    if (n == 0) return dp[n] = 1;
    if (n == 1) return dp[n] = 1;
    return dp[n] = fib(n-1)+fib(n-2);
}

int main() {
    int n;
    cin >> n;
    REP(i, n+1) dp[i] = -1; 
    cout << fib(n) << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    int n, q;
    scanf("%d%d", &n, &q);
    string s;
    cin >> s;
    int check[s.length()] = {0};
    int tmp1 = 0;
    for (int i = 1; i < s.length(); i++)
    {
        if (s[i - 1] == 'A' && s[i] == 'C')
        {
            tmp1++;
        }
        check[i] = tmp1;
    }
    int l, r, tmp[q] = {0};
    for (int i = 0; i < q; i++)
    {
        scanf("%d%d", &l, &r);
        tmp[i] = check[r - 1] - check[l - 1];
        /*
        for (int j = l; j < r; j++)
        {
            tmp[i] += check[j];
        }*/
    }
    for (int i = 0; i < q; i++)
    {
        printf("%d\n", max(tmp[i], 0));
    }
    return 0;
}


Measured memory_bytes: 1792
N = int(input())

C = [[0 for _ in range(10)] for _ in range(10)]
for k in range(1, N + 1):
    k = str(k)
    r = int(k[-1])
    l = int(k[0])
    C[l][r] += 1

a = 0
for l in range(10):
    for r in range(10):
        a += C[l][r] * C[r][l]

print(a)


Measured memory_bytes: 40428
#include <iostream>

using namespace std;

int main()
{
    int a , b ;
    cin >> a >> b ;
    a = a * b ;
    if((a%2) == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }

    return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 200100;

int n, m;
int a[maxn + 5];

int col[maxn + 5];

set<pair<int, int> > all;

int ri[maxn + 5];
int pre[maxn + 5];

int fa[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d", a + i), --a[i];
	all.insert(mp(-1, 0));
	m = 0;
	REP(i, 0, n)
	{
		auto u = --all.lower_bound(mp(a[i], 0));
		pair<int, int> to_add = mp(a[i], u->y);
		int nxt = -1;
		if (!~u->x) nxt = u->y + 1, ++m;
		ri[u->y] = a[i];
		pre[a[i]] = u->x;
		col[a[i]] = u->y;
		all.erase(u);
		all.insert(to_add);
		if (~nxt) all.insert(mp(-1, nxt));
	}
	queue<int> q;
	REP(i, 0, m) q.push(i);
	int ans = 0;
	int lst = n - 1;
	vector<int> seq;
	for (int i = n - 2; i >= 0; --i)
	{
		if (col[i] != col[i + 1] && (col[i] - col[i + 1] + m) % m + (col[i + 1] - col[lst] + m) % m <= m)
		{
			++ans;
			lst = i + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int ans = 0;
  if (S == "RRR") {
    cout << 3 << endl;
  } else if (S == "SSS") {
    cout << 0 << endl;
  } else if (S == "RRS" || S == "SRR") {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3636
def run():
    N=int(input())
    T,A=input().split()
    T=int(T)
    A=int(A)
    H=input().split()
    for i in range(N):
        H[i]=float(H[i])
    ans=0
    for i in range(N):
        for j in range(N):
            if(abs(T-0.006*H[ans] - A)>abs(T-0.006*H[i] - A)):
                ans=i
    print(ans+1)

run()

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

bool f(string& s, int x) {
    int res = s.front() - '0';
    for (int i = 0; i < s.size() - 1; ++i) {
        if ((x >> i) & 1) {
            res += s[i + 1] - '0';
        } else {
            res -= s[i + 1] - '0';
        }
    } 

    return res == 7;
}

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

    int N = S.size() - 1;

    for (ll i = 0; i < (1 << N); ++i) {
        if (f(S, i)) {
            rep(j, N) {
                cout << S[j] << (((i >> j) & 1)? '+' : '-');
            }
            cout << S.back() << "=7" << endl;
            return 0;
        }
    }
}

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

int main(){
  int th, ta, ah, aa;
  cin>>th >>ta >>ah >>aa;
  
  while(th>0 && ah>0){
    ah-=ta;
    if(ah<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    th-=aa;
  }
  
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int mn=min(a,b),mx=max(a,b);
    for(int i=0;i<mx;i++)
        cout<<mn;
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3636
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys

# import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def Hershad(n):
    if n == 0:
        return 0
    return n % 10 + Hershad(n // 10)


N = int(readline())
print('Yes' if N % Hershad(N) == 0 else 'No')


Measured memory_bytes: 12472
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

int main()
{
    int n, in;
    std::cin >> n;
    std::vector<int> v;
    for(int i = 0; i < n; i++){
        std::cin >> in;
        v.push_back(in);
    }   
    sort(v.begin(), v.end(), std::greater<int>());
    int answer = 0;
    for(int i = 0; i < n; i++){
        answer = answer + pow(-1, i) * v[i];
    }
    std::cout << answer << std::endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <ll> > &v) {
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main() {
	ll n;
	cin>>n;
	ll b[110];
	rep(i,0,n) cin>>b[i];
	int ans[110]={0};
	int pt=n-1;
	int pp=0;
	bool x=true;
	rep(i,0,n) if(b[i]>i+1) x=false;
	while(x && pp<n){
			irep(i,pt,0){
				if(b[i]==i+1){
					ans[pp]=i+1;
					//cout<<ans[pp]<<endl;
					pp++;
					rep(k,i,n-1) b[k]=b[k+1];
					if(pp==n) break;
					if(pt==-1) break;
					pt--;
					break;
				}
			}
	}

	if(x ) irep(i,n-1,0)cout<<ans[i]<<endl;
	else cout<<"-1";
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#include <limits>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
#define setp(n) setprecision(n)<<fixed
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=1000000;




main(){
    int n=in();
    double now=0.0;
    rep(i,n){
       double a; cin>>a;
       now+=1.0/a;
    }
    cout<<setp(10)<<1.0/now;
}

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

int H, W;
vector<string> S;
vector<vector<int> > odd;
vector<vector<int> > odd2;

int histMaxRect(vector<int> &histogram)
{
    int N = histogram.size();
    int maxS = 0;
    std::stack<pair<int, int> > st;
    st.push(make_pair(1, 0));
    for (int i=0; i<histogram.size(); i++)
    {
        if (st.top().first == histogram[i])
        {
            st.pop();
            st.push(make_pair(histogram[i], i));
            continue;
        }
        while(st.top().first > histogram[i])
        {
            pair<int, int> p_tmp = st.top();
            st.pop();
            maxS = max(maxS, (i-st.top().second) * p_tmp.first);
        }
        st.push(make_pair(histogram[i], i));
    }
    // for (auto h : histogram) cout << h << " ";
    // cout << endl;
    while (st.size() > 1)
    {
        pair<int, int> p_tmp = st.top();
        st.pop();
        maxS = max(maxS, (N - st.top().second) * p_tmp.first);
    }
    // cout << maxS << endl;
    return maxS;
}

int main()
{
    cin >> H >> W;
    S.resize(H);
    for (int i=0; i<H; i++) cin >> S[i];
    odd = vector<vector<int> >(H, vector<int>(W, 1));
    for (int i=1; i<H; i++)
    {
        for (int j=1; j<W; j++)
        {
            int tmp = 0;
            if (S[i][j] == '#') tmp++;
            if (S[i][j-1] == '#') tmp++;
            if (S[i-1][j] == '#') tmp++;
            if (S[i-1][j-1] == '#') tmp++;
            if (tmp%2 == 0) odd[i][j] = 0;
        }
    }
    odd2 = vector<vector<int> >(H, vector<int>(W, 1));
    for (int i=1; i<H; i++)
    {
        for (int j=0; j<W; j++)
        {
            if (odd[i][j]) odd2[i][j] = 1;
            else odd2[i][j] = odd2[i-1][j] + 1;
        }
    }

    int maxs = max(H, W);
    for (int h=1; h<H; h++)
    {
        maxs = max(maxs, histMaxRect(odd2[h]));
    }
    cout << maxs << endl;
    return 0;
}

Measured memory_bytes: 35712