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

int N;
string S[555];
vector<int> G[30];
vector<int> rG[30];
bool used[30];

void dfs(int v,vector<int>& vs){
  used[v] = true;
  for(int i=0;i<(int)G[v].size();i++){
    if( used[G[v][i]] ) continue;
    dfs( G[v][i] , vs );
  }
  vs.push_back( v );
  return ;
}
void rdfs(int v,int t){
  used[v] = true;
  for(int i=0;i<(int)rG[v].size();i++){
    if( used[rG[v][i]] ) continue;
    rdfs( rG[v][i], t );
  }  
}

int scc(){
  memset(used,0,sizeof(used));
  vector<int> vs;
  for(int i=0;i<26;i++)
    if( !used[i] ) dfs(i,vs);
  memset(used,0,sizeof(used));
  int t=0;
  for(int i=25;i>-1;i--)
    if( !used[vs[i]] ) rdfs( vs[i], t++ );
  return t;
}

void init(){
  for(int i=0;i<26;i++){
    G[i].clear(); rG[i].clear();
  }    
}

void add_edge(char u, char v){
  if( u == '#' || v == '#' ) return;
  G[u-'a'].push_back( v-'a' );
  rG[v-'a'].push_back( u-'a' );
}

void view(){
  for(int i=0;i<26;i++){
    char c = i+'a';
    cout << c << ": " << endl;
    for(int j=0;j<(int)G[i].size();j++){
      cout << " -> " << (char)(G[i][j]+'a') << endl;
    }
  }
}

bool makeg(int l,int h,int f){
  // cout << l<<" " << h << " " << f<< endl;
  if( l>=h ) return true;
  char c=S[l][f];
  int pd = l;
  if( c == '#' )
    return makeg(l+1,h,f);  
  for(int i=l+1;i<=h;i++){
    //cout << S[i] << endl;
    if( S[i][f] == '#' ){
      if( c != '#' ) return false;
      return makeg(i+1,h,f);
    }
    //    cout << c << "  "<< S[i][f] << endl;
    if( S[i][f] != c ){
      if( !makeg(pd,i-1,f+1) ) return false;
      add_edge( S[i][f], c );
      c = S[i][f];
      pd = i;
    }
  }
  return makeg(pd,h,f+1);
}

bool make_graph(){
  return makeg(0,N-1,0);
  view();
}

int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      cin >> S[i];
      S[i]+="#";
    }
    init();
    if( !make_graph() || scc() < 26 ) cout << "no" << endl;
    else cout << "yes" << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    string s,t; cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if(u == s) {
        a--;
    } else {
        b--;
    }

    cout << a << endl;
    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
module mod_radix_sort
  implicit none
  integer, private, parameter :: intkind = 8
  integer, private, parameter :: nbit = 8
  integer, private, parameter :: upper = lshift(1, nbit) - 1
contains
  subroutine radix_sort(a)
    integer(intkind), intent(inout) :: a(:)
    integer(intkind), allocatable :: queue(:, :)
    integer :: n, m, i, j, k, cnt(0:upper)
    n = size(a)
    m = 0
    do i = 0, 8 * intkind - 1, nbit
      cnt = 0
      do j = 1, n
        k = and(rshift(a(j), i), upper)
        cnt(k) = cnt(k) + 1
      end do
      m = max(m, maxval(cnt))
    end do
    allocate(queue(m, 0:upper))
    do i = 0, 8 * intkind - 1, nbit
      cnt = 0
      do j = 1, n
        k = and(rshift(a(j), i), upper)
        cnt(k) = cnt(k) + 1
        queue(cnt(k), k) = a(j)
      end do
      k = 0
      do j = 0, upper
        if (cnt(j) == 0) cycle
        a(k + 1:k + cnt(j)) = queue(1:cnt(j), j)
        k = k + cnt(j)
      end do
    end do
  end
end module mod_radix_sort
program voting_judges
  use mod_radix_sort
  integer :: n, v, p, i, l, r, x
  integer(8) :: m, s, a(100000) = 0, mv
  read(*,*) n, m, v, p
  read(*,*) a(1:n)
  call radix_sort(a(1:n))
  a(1:n) = a(n:1:-1)
  l = p
  r = n + 1
  do i = p + 1, n
    if (a(i) + m < a(p)) then
      r = i
      exit
    end if
  end do
  mv = m * v
  do while (r - l > 1)
    x = (l + r) / 2
    s = sum(a(x) + m - a(p:x - 1)) + m * (p + n - x)
    if (s < mv) then
      r = x
    else
      l = x
    end if
  end do
  write(*,'(i0)') l
end program voting_judges

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    if(n % 10 == 9 || n / 10 == 9)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{
int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}

	vec(T);
	fx(D) {
		pb(T, x % 26 + 1);
	}
	ll sum = 0;

	fx(200000) {
		int d, q;
		d = rand() % D + 1, q = rand() % 26 + 1;
		int pre = T[d - 1];
		T[d - 1] = q;
		ll ans = 0;

		fy(26) {
			Las[y] = 0;
		}
		fw(D) {

			ans += table[w][T[w] - 1];
			Las[T[w] - 1] = w + 1;
			fz(26) {
				ans -= C[z] * (w + 1 - Las[z]);
			}
		}
		if (ans>sum) {
			sum = ans;
		}
		else {
			T[d - 1] = pre;
		}
	}

	fx(D) {
		ce(T[x])
	}

	
    return 0;
}



Measured memory_bytes: 3648
/**************************************************
  Solution to: 175ABC C - Walking Takahashi
  Writer: InvisibleCyclist
  By/Based on:
**************************************************/
#include<bits/stdc++.h>
using namespace std;
long long x;
long long k;
long long d;
int main(){
	cin>>x>>k>>d;
	long long cnt=abs(x)/d;
	if(k<=cnt) printf("%lld\n",abs(x)-k*d);
	else{
		long long a=cnt%2;
        long long b=k%2;
        if(a==b) printf("%lld\n",abs(x)-abs(x)/d*d);
        else printf("%lld\n",(cnt+1)*d-abs(x));
	}
	return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
main() {
  int count,flag=0;
  char str[100];
  scanf("%d",&count);
  scanf("%s",str);
  
  for(int i = 0; i < (count/2); i++) {
    if(str[i] == str[count/2 + i])
      flag++;
  }
  if(count%2 == 0&& flag == count/2 )
    printf("Yes");
  else printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
ll n;

ll ans = INFLONG;
//void calc(){
//  vector<ll> vec(n);
//}
int main(){
  ll h,w,n;
  cin >> h >> w >> n;
  ll m = max(h,w);
  ll ans = n / m;
  if(n % m != 0){ans++;}
  cout << ans << endl;
}

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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  cout << ((n & 1) == 0 and s.substr(0, n >> 1) == s.substr(n >> 1) ? "Yes" : "No");

  return 0;
}

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

// 
int main() {
    long long A;
    double B;
    cin >> A >> B;
    cout << (long long)((A * (long long)(B * 100 + 0.5)) / 100);
}
// 9990000000000000
// 90000000000000


Measured memory_bytes: 3712
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;
	
long long gcd(long long a, long long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main(){
	long long a,b,c,d;
	long long x,y,z,ans;
	cin >> a >> b >> c >> d;
	//最小公約数
	x=lcm(c,d);
	//大小
	long long lrg,sml;
	lrg=max(a,b);
	sml=min(a,b);
	//aの約数の数
	y=(lrg/c)+(lrg/d)-(lrg/x);
	//bの約数の数
	z=(sml/c)+(sml/d)-(sml/x);
	
	if(a%c==0 || a%d==0){
		z=z-1;
	}
	
	ans=(lrg-sml+1)-(y-z);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

const int MAX_V = 105;
ll d[MAX_V][MAX_V];
int V;

void warshall_floyd(){
	rep(k,V)rep(i,V)rep(j,V) chmin(d[i][j],d[i][k]+d[k][j]);
}

signed main(){
	int n,m; cin>>n>>m;	V=n;
	int a[m], b[m]; ll c[m];
	memset(d,INF,sizeof(d));
	rep(i,n) d[i][i]=0LL;
	rep(i,m){
		cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--;
		chmin(d[a[i]][b[i]],c[i]); chmin(d[b[i]][a[i]],c[i]);
	}
	warshall_floyd();
	int ans=m;
	rep(i,m){
		bool flg=false;
		rep(j,n){
			if(d[j][a[i]]+c[i]==d[j][b[i]]) flg=true;
		}
		if(flg) ans--;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n, k; cin >> n >> k;
  Vll a(n); cin >> a;


  auto f = [&] (ll x) {
    if (x == 0) return false;
    int cnt = 0;
    rep(i, n) cnt += (a[i] + x - 1) / x - 1;
    return (cnt <= k);
  };

  ll ok = ll(2e10) + 5;
  ll ng = 0;
  while (llabs(ok - ng) > 1) {
    ll md = (ok + ng) >> 1;
    if (f(md)) ok = md;
    else ng = md;
  }

  cout << ok << '\n';
  return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    B=LI()
    A=[0]*N
    A[0]=B[0]
    A[-1]=B[-1]
    for i in range(N-2):
        A[i+1]=min(B[i],B[i+1])
        
    print(sum(A))

main()


Measured memory_bytes: 61812
import math
mod = 10**9+7
n,k = map(int,input().split())
b = math.factorial(k-1)%mod
fact = [0]*(n-k+1)
a = math.factorial(k-1)%mod
c = 1
for i in range(k-1, n):
    if i == k-1:
        fact[0] = (a*pow(b*c, mod-2, mod))%mod
    else:
        a = a*i%mod
        c = c*(i-k+1)%mod
        fact[i-k+1] = (a*pow(b*c, mod-2, mod))%mod
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(k-1,n):
    ans += fact[i-k+1]*(A[i]-A[n-i-1])
    ans %= mod
print(ans)


Measured memory_bytes: 72924
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n, k;
  cin >> n >> k;
  vi v(n);
  rep(i, n) cin >> v[i];
  sort(all(v), greater<int>());

  int res = 0;
  rep(i, k) {
    res += v[i];
  }
  print(res);
}


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

int main(){
    int q,x;
    char com[20];

    list<int> v;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&x);
            v.push_front(x);
        }
        else if(com[6]=='F'){
            v.pop_front();
        }
        else if(com[6]=='L'){
            v.pop_back();
        }
        else{
            scanf("%d",&x);
            for(list<int>::iterator it=v.begin();it!=v.end();it++){
                if(*it==x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    

    list<int>::iterator itr1=v.begin();
    
    for(int i=v.size()-1;itr1!=v.end();i--){
        printf("%d",*itr1);
        if(i)printf(" ");
        itr1++;
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 34448
n, m = [int(_) for _ in input().split()]
c = []
flag = True
g = [[-1, -1] for _ in range(n)]
g_num = 0
for i in range(m):
    l, r, d = [int(_) for _ in input().split()]
    l -= 1
    r -= 1
    if g[l][0] != -1 and g[r][0] != -1 and g[l][0] == g[r][0]:
        if c[g[l][0]][g[r][1]][1] - c[g[l][0]][g[l][1]][1] != d:
            flag = False
            break
    elif g[l][0] != -1 and g[r][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        r_pos = c[g[r][0]][g[r][1]][1]
        if r_pos > l_pos+d:
            for j in c[g[l][0]]:
                j[1] += r_pos - d - l_pos
                if j[1] > 10**9:
                    flag = False
                    break
                g[j[0]][1] += g[c[g[r][0]][-1][0]][1] + 1
            c[g[r][0]].extend(c[g[l][0]])
            for j in c[g[l][0]]:
                g[j[0]][0] = g[r][0]

        else:
            for j in c[g[r][0]]:
                j[1] += l_pos + d - r_pos
                if j[1] > 10**9:
                    flag = False
                    break
                g[j[0]][1] += g[c[g[l][0]][-1][0]][1] + 1
            c[g[l][0]].extend(c[g[r][0]])
            for j in c[g[r][0]]:
                g[j[0]][0] = g[l][0]

    elif g[l][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        c[g[l][0]].append([r, l_pos+d])
        g[r][0] = g[l][0]
        g[r][1] = g[c[g[l][0]][-2][0]][1]+1
    elif g[r][0] != -1:
        r_pos = c[g[r][0]][g[r][1]][1]
        c[g[r][0]].append([l, r_pos-d])
        g[l][0] = g[r][0]
        g[l][1] = g[c[g[r][0]][-2][0]][1]+1
    else:
        c.append([[l, 0], [r, d]])
        g[l][0] = g_num
        g[r][0] = g[l][0]
        g[l][1] = 0
        g[r][1] = 1
        g_num += 1
    if not flag:
        break
if flag:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int startMAX = max(A,C);
	int endMIN = min(B, D);

	cout << max(0, endMIN-startMAX) << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
L=[0]
R=[0]
cnt = 0

for i in range(n):
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0
    L.append(cnt)
cnt = 0
s = s[::-1]
for i in range(n):
    if s[i]  == '>':
        cnt += 1
    else:
        cnt = 0
    R.append(cnt)

R = R[::-1]
ans = 0
for i in range(n+1):
    ans += max(R[i], L[i])

print(ans)

Measured memory_bytes: 36900
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;


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

    int a,b,c;
    cin >> a >> b >> c;
    int ans = a%b;
    bool ok = false;
    rep(i,150){
        int x = ans * i;
        x %= b;
        if(x == c){
            ok = true;
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long hey;
#define hi string
#define pi 3.141592653589793238
#define fi first
#define mod 1000000007
#define se second
#define pb push_back 
#define pop pop_back 
#define bs binary_search
#define mp make_pair
#define ma map< hey,hey >
#define vi vector < hey > 
#define all(v) v.begin(),v.end()
#define qu priority_queue< hey >
#define endl '\n'
#define forn(i, n) for (hey i = 0; i <hey(n); ++i)
#define yorn(i, n) for (hey i = 1; i <=hey(n); ++i)
#define vp vector< pair<hey,hey> >
// lower bound - first element equal to or greater than given value.
// upper bound - first element greater than given value.
hey frog(hey n,hey a[][3])
{
    
    hey dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
void hellogadhi()
{
    hey n;
    cin>>n;
    hey a[n][3];
    forn(i,n)
    forn(j,3)
    cin>>a[i][j];
    cout<<frog(n,a);
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	    hellogadhi();
	}
	return 0;
}


Measured memory_bytes: 4992
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int, read().split())
UV = tuple(zip(m, m))

ans = 0
for n in range(1, N + 1):
    ans += n * (N - n + 1)
for a, b in UV:
    if a > b:
        a, b = b, a
    ans -= a * (N - b + 1)
print(ans)

Measured memory_bytes: 59320
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define fi first
#define se second
#define reset(n,k) memset((n),k,sizeof(n))
#define all(n) n.begin(),n.end()
#define pb push_back
using namespace std;
using ll=long long;
using pii=pair<int,int>;
int arr[5];
int main(){
	IOS;
	int n,m,a,b;
	cin>>n>>m;
	memset(arr,-1,sizeof(arr));
	bool ok = 1;
	while(m--){
		cin>>a>>b;
		if(arr[a]!=-1 && arr[a]!=b){
			ok = 0;
			break;
		}
		arr[a] = b;
	}
	
	if(n>1 && arr[1] == 0){
		ok = 0;
	}
	for(int i=2;i<=n;i++){
		if(arr[i] == -1){
			arr[i] = 0;
		} 
	}
	if(arr[1] == -1){
		if(n==1) arr[1] = 0;
		else arr[1] = 1;
	}
	if(ok){
		for(int i=1;i<=n;i++){
			cout<<arr[i];
		}
		cout<<'\n';
	}
	else{
		cout<<-1<<'\n';
	}


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
#define INF 10000000000 //10^10
#define PI 3.141592
#define pb push_back

int main(){
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    int r=0;
    ll ret=0;
    int base=0;
    rep(l,n){
        while(r<n && (base&a[r])==0){
            base|=a[r++];
        }
        ret+=r-l;
        base^=a[l];
    }
    cout << ret << endl;
}


Measured memory_bytes: 1024
/* Coached by Dukkha */
#include <stdio.h>
#include <string.h>

#define N 50
#define M 50

int dsu[N], ii[M], jj[M], n, m;

int find(int i) {
	return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
}

void join(int i, int j) {
	i = find(i);
	j = find(j);
	if (i == j)
		return;
	if (dsu[i] > dsu[j])
		dsu[i] = j;
	else {
		if (dsu[i] == dsu[j])
			dsu[i]--;
		dsu[j] = i;
	}
}

int bridge(int h_) {
	int h;

	memset(dsu, -1, n * sizeof *dsu);
	for (h = 0; h < m; h++) {
		if (h == h_)
			continue;
		join(ii[h], jj[h]);
	}
	return find(ii[h_]) != find(jj[h_]);
}

int main() {
	int h, cnt;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++)
		scanf("%d%d", &ii[h], &jj[h]), ii[h]--, jj[h]--;
	cnt = 0;
	for (h = 0; h < m; h++)
		if (bridge(h))
			cnt++;
	printf("%d\n", cnt);
	return 0;
}


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

int main(){
 int n, k;
 cin >> n >> k;
 int v;
 vector<int> vs;
 for(int i=0;i<n;i++) {
    cin >> v;
    vs.push_back(v);
 }
 sort(vs.begin(), vs.end());
 cout << accumulate(vs.begin(), vs.begin()+k, 0);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int>x(n) ;
    for(int i=0;i<n;i++)cin >> x[i];
    
    int hp = 12345678;
    for(int p=1;p<=100;p++){
        int hp_v = 0;
        for(int j=0;j<n;j++){
            hp_v += pow(x[j]-p,2);
        }
        if(hp_v < hp) hp = hp_v; 
    }
    
    cout << hp;
    
    return 0;
}


Measured memory_bytes: 3584
s=input()
n=len(s)
if n==4:
    x=s[2]
else:
    x=s[2:n-1]
    
if s[0]!='A':
    print('WA')
    
elif x.count('C')!=1:
    print('WA')
    
else:
    i=x.find('C')
    s=list(s)
    s.pop(i+2)
    s.pop(0)
    s=''.join(s)
    if s.islower()==True:
        print('AC')
    else:
        print('WA')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc") cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.1415926535897932;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

vector<int> ans;

void solve (int r, int a, int b, int x) {
    a %= (1<<(r+1));
    b %= (1<<(r+1));
    if (r == 0) {
        ans.push_back(b+x);
        return;
    }

    if ((a&(1<<r)) == (b&(1<<r))) {
        if (r == 1) {
            if (a&(1<<r)) {
                ans.push_back(a-(1<<r)+x);
                ans.push_back(b-(1<<r)+x);
                ans.push_back(b+x);
            } else {
                ans.push_back(a+(1<<r)+x);
                ans.push_back(b+(1<<r)+x);
                ans.push_back(b+x);
            }
        } else {
            if (a&(1<<r)) solve(r-1, a, b, x+(1<<r));
            else solve(r-1, a, b, x);
            ans.pop_back();
            int tmp = ans.back();
            tmp %= (1<<r);
            if (a&(1<<r)) {
                ans.push_back(tmp+x);
                solve(r-1, tmp, b, x);
                ans.push_back(b+x);
            } else {
                ans.push_back(tmp+(1<<r)+x);
                solve(r-1, tmp, b, x+(1<<r));
                ans.push_back(b+x);
            }
        }
    } else {
        int t = 0;
        rep(i,r) {
            t = a^(1<<i);
            if (t%(1<<r) != t) break;
        }
        if (a < b) {
            solve(r-1, a, t, x);
            ans.push_back(t+(1<<r)+x);
            solve(r-1, t, b, x+(1<<r));
        } else {
            solve(r-1, a, t, x+(1<<r));
            ans.push_back(t-(1<<r)+x);
            solve(r-1, t, b, x);
        }
    }
}

int n, a, b;

int main() {
    cin >> n >> a >> b;
    int cnt = 0;
    rep(i,n) if ((a&(1<<i)) != (b&(1<<i))) cnt++;
    if (cnt%2 == 0) {
        cout << "NO" << endl;
        return 0;
    }
    ans.push_back(a);
    solve(n-1, a, b, 0);
    cout << "YES" << endl;
    rep(i,ans.size()) {
        cout << ans[i];
        if (i == (int)ans.size()-1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 1656
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	string Str => ReadLine();
	public K()
	{
		var N = F;
		var g = new string[N];
		for (var i = 0; i < N; i++) g[i] = Str;
		var M = F;
		var b = new string[M];
		for (var i = 0; i < M; i++) b[i] = Str;
		var d = new Dictionary<string, int> { [""] = 0 };
		foreach (var s in g) if (d.ContainsKey(s)) d[s]++; else d[s] = 1;
		foreach (var s in b) if (d.ContainsKey(s)) d[s]--; else d[s] = 1;
		WriteLine(d.Values.Max());
	}
}


Measured memory_bytes: 13280
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int mans = 0;
    int sequence = 0;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if(a == b){
            sequence++;
            mans = max(mans, sequence);
        }else{
            sequence = 0;
        }
    }

    if(mans >= 3){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}

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

int min(int a, int b){
    if(a < b){
      return a;
    }else{
      return b;
    }
}
int abs(int a){
    if(a<0){
      a=a*(-1);
    }
    return a;
}
int main(){
  int N,K;
  cin>>N>>K;

  
  long long h[100100];
  for(long long i=0;i<N;i++){
    cin>>h[i];
  }
  if(N==2){
    cout<<h[1]-h[0]<<endl;
    return 0;
  }
  
  long long dp[100100];
  for(long long i=0;i<N;i++){
    dp[i]=1e13;
  }
  dp[0]=0;
  
  for(int i=1;i<N;i++){
    for(int j=max(0,i-K);j<=i;j++){
      dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
  }
  cout<<dp[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()

  t=x=y=f=0
  for _ in range(n):
    _t,_x,_y=LI()
    
    _t-=t
    _t-=abs(x-_x)
    _t-=abs(y-_y)

    if _t<0:
      f=1
    elif _t%2!=0:
      f=1

  if f==1:
    return 'No'
  else:
    return 'Yes'

print(main())


Measured memory_bytes: 5412
#include<iostream>
using namespace std;
int main()
{
string h;
  getline(cin,h);
 if (h.compare("Sunny")==0)
    cout<<"Cloudy";
  else if (h.compare("Cloudy")==0)
    cout<<"Rainy";
  else 
    cout<<"Sunny";




return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    string s, t, ans = "";
    cin >> s >> t;
    vector< vector<ll> > dp(s.size() + 1, vector<ll>(t.size() + 1, 0));
    ll i, j;
    for (i = 0; i < s.size(); ++i) for (j = 0; j < t.size(); ++j) dp.at(i + 1).at(j + 1) = (s.at(i) == t.at(j) ? dp.at(i).at(j) + 1 : max(dp.at(i).at(j + 1), dp.at(i + 1).at(j)));
    while (i && j) {
        if (s.at(i - 1) == t.at(j - 1)) {
            ans += s.at(i - 1);
            --i, --j;
        } else (dp.at(i).at(j - 1) < dp.at(i - 1).at(j) ? --i : --j);
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 72832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vl>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

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

  bitset<64> s(N);
  vl start(65);

  int p = 63;
  while (!s[p]) --p;

  start[p] = 1;
  vl tmp(1, 1);
  rep(i,p-1) {
    ll x = tmp.back() * 3 - tmp.front() + 1;
    (x += x < 0 ? MOD : 0) %= MOD;
    tmp.push_back(x);
  }

  ll ans = accumulate(all(tmp), 1LL) % MOD;
  ll pre = 1;

  for (int i=p-1; i>=0; --i) {
    start[i] = (start[i+1] + (s[i] ? 0 : pre)) % MOD;

    if (s[i]) {
      tmp.assign(1, (pre + start[i+1]) % MOD);
      rep(j,i) {
        ll x = tmp.back() * 3 - tmp.front() + pre;
        (x += x < 0 ? MOD : 0) %= MOD;
        tmp.push_back(x);
      }

      (ans += tmp.back()) %= MOD;
      pre = (pre + start[i+1]) % MOD;
    }
  }

  if (p != 0) (ans += start[0]) %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())

    minRes = 10 ** 10

    for a in range(1, 10** 5 + 1):
        if n % a == 0:
            b = int(n / a)

            res = max(len(str(a)), len(str(b)))

            if res < minRes:
                minRes = res
    
    print(minRes)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int A1, A2, A3;
    std::cin >> A1 >> A2 >> A3;
    
    std::cout << std::max(A1, std::max(A2, A3)) - std::min(A1, std::min(A2, A3)) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef complex<int> P;
int main(){
	int m,n,tx,ty; P a[200],b[1000];
	while(cin>>m,m){
		rep(i,m)cin>>tx>>ty,a[i]=P(tx,ty);
		cin>>n; rep(i,n)cin>>tx>>ty,b[i]=P(tx,ty);
		rep(i,n){
			P cp=b[i];
			rep(j,m-1){
				int f=0;
				rep(k,n)if(b[k]-cp==a[j+1]-a[j]){
					f=1;
					cp=b[k]; break;
				}
				if(!f)goto NEXT;
			}
			cout<<real(b[i]-a[0])<<" "<<imag(b[i]-a[0])<<endl; break;
			NEXT:;
		}
	}
	return 0;
}

Measured memory_bytes: 872
class Node(object):
    def __init__(self, parent, left, right):
        self.parent = parent  # ????????????
        self.left = left      # ??????????????????????????????????????????
        self.right = right    # ??????????????????????????????????????´?????????

    def get_depth(self):
        if self.parent == -1:
            return 0
        else:
            depth = 1
            t = Nodes[self.parent]
            while t.parent != -1:
                t = Nodes[t.parent]
                depth += 1
            return depth

    def get_type(self):
        if self.parent == -1:
            return 'root'
        elif self.left == None:
            return 'leaf'
        else:
            return 'internal node'


def decode_node_data(n):
    global Nodes
    num_of_elem = len(n)
    if num_of_elem < 2:
        raise ValueError
    elif num_of_elem == 2:  # leaf
        pass
    else:
        id, num_of_children = int(n[0]), int(n[1])
        children = n[2:]
        Nodes[id].left = int(children[0])
        prev_child = None
        for c in children:
            Nodes[int(c)].parent = id
            if prev_child != None:
                Nodes[prev_child].right = int(c)
            prev_child = int(c)


MAX_NODES = 100001
Nodes = [Node(-1, None, None) for _ in range(MAX_NODES)]
if __name__ == '__main__':
    # ??????????????\???
    num_of_nodes = int(input())
    node_data = []
    for _ in range(num_of_nodes):
        node_data.append(input().split(' '))

    # ??¨????§£???
    for n in node_data:
        decode_node_data(n)


    # ???????????¨???
    for node_id in range(num_of_nodes):
        type = Nodes[node_id].get_type()
        children = []
        if type != 'leaf':
            if Nodes[node_id].left != None:
                c = Nodes[node_id].left
                children.append(c)
                while Nodes[c].right != None:
                    c = Nodes[c].right
                    children.append(c)
        print('node {0}: parent = {1}, depth = {2}, {3}, [{4}]'.format(node_id, Nodes[node_id].parent, Nodes[node_id].get_depth(), type,
                                                                       ', '.join(map(str, children))))

Measured memory_bytes: 65992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  int cnt = 0;
  if(s == "RRR") cout << 3 << endl;
  else if(s=="RRS" || s=="SRR") cout << 2 << endl;
  else if(s=="RSS" || s == "SRS" || s == "SSR" || s == "RSR") cout << 1 << endl;
  else if(s == "SSS") cout << 0 << endl;
}


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

//#define DEBUG

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int N = 1e5+5;
int arr[N], arr2[N];


int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll ans = 0;
	int n, m, idx;
	cin >> n >> m;
	idx = m-2;
	lp(i, m)
		cin >> arr[i];
	sort(arr, arr+m);
	lp(i, m-1){
		arr2[i] = arr[i+1] - arr[i];
		ans += 0ll + arr2[i];
	}
	sort(arr2, arr2+m-1);
	--n;
	while((n--) && (idx >= 0)){
		ans = ans - arr2[idx];
		--idx;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    string s;
    cin>>s;
    sort(all(s));
    char c=s[0];
    for(int i=1;i<s.size();i++) {
        if(c==s[i]) {cout<<"no\n";exit(0);} 
        c=s[i];
    }
    cout<<"yes\n";
    return 0;
}

Measured memory_bytes: 256
s = input()
s = s[:-1]
for i in range(len(s)):
    r = len(s)
    if r %2 == 0:
        if s[:r//2] == s[r//2:]: #同じ配列の繰り返しだから半分ずつも同じものになっている
            print(len(s))
            break
        else:
            s = s[:-1]
    else:
        s = s[:-1]
      
      


Measured memory_bytes: 2940
H,W=map(int,input().split())
S = [list(input()) for _ in range(H)]
result = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      result[i][j] = '#'
      if i+1 < H and result[i+1][j]!='#': result[i+1][j] += 1
      if i-1 >= 0 and result[i-1][j]!='#': result[i-1][j] += 1
      if j+1 < W and result[i][j+1]!='#': result[i][j+1] += 1
      if j-1 >= 0 and result[i][j-1]!='#': result[i][j-1] += 1
      if i+1 < H and j+1 < W and result[i+1][j+1]!='#': result[i+1][j+1] += 1
      if i+1 < H and j-1 >= 0 and result[i+1][j-1]!='#': result[i+1][j-1] += 1
      if i-1 >= 0 and j+1 < W and result[i-1][j+1]!='#': result[i-1][j+1] += 1
      if i-1 >= 0 and j-1 >= 0 and result[i-1][j-1]!='#': result[i-1][j-1] += 1
[[print(result[i][j]) if j==W-1 else print(result[i][j],end='') for j in range(W)] for i in range(H)]

Measured memory_bytes: 3572
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Queue<Integer> q = new PriorityQueue<>();
        SortedMap<Integer, Integer> map = new TreeMap<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            q.add(Integer.parseInt(sc.next()));
        }
        for (int i = 0; i < m; i++) {
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            map.merge(c, b, (v1, v2) -> v1 + v2);
        }
        while (map.size() > 0) {
            int val = map.firstKey();
            int cnt = map.get(val);
            if (q.peek() >= val) {
                break;
            } else {
                q.poll();
                q.add(val);
                if (cnt == 1) {
                    map.remove(val);
                } else {
                    map.replace(val, --cnt);
                }
            }
        }
        long ans = 0;
        for (int a : q) {
            ans += a;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 73232
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

// AtCoder Beginner Contest 139
int main(){

    ll n;
    cin >> n;

    cout << n * (n - 1) / 2 << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int a;
    int b[3];
    string s;
    
    cin >> s;
    a = s[0] - '0';
    for (int i = 1;i <= 3;i++){
        b[i-1] = s[i] - '0';
    }
    
    int f[3];
    int c[3];
    for (int i = 0;i < (1<<3);i++){
        for (int j = 0;j < 3;j++){
            if ((i>>j)%2){
                f[2-j] = 1;
                c[2-j] = b[2-j];
            }
            else {
                f[2-j] = 0;
                c[2-j] = -b[2-j];
            }
        }
        if (a+c[0]+c[1]+c[2] == 7){
            break;
        }
    }
    cout << a;
    for (int i = 0;i < 3;i++){
        if (f[i]){
            cout << "+" << b[i];
        }
        else {
            cout << "-" << b[i];
        }
    }
    cout << "=7" << endl;
}


Measured memory_bytes: 3636
def main():
    n, kk = map(int, input().split())

    mod = 10**9+7
    fact = [1, 1]
    for i in range(2, 2*10**5+1):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r, mod=10**9+7):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    ans = [1]

    for k in range(1, n):
        ans.append(nCr(n-1, k)*nCr(n, k) % mod)

    print(sum(ans[:min(kk+1, n)]) % mod)


main()


Measured memory_bytes: 57124
#include <bits/stdc++.h>
using namespace std;
int main () {
    string S, T;
    cin >> S >> T;
    for (int i = 0; i <= 100; i++) {
        if (S == T) {
            puts("Yes");
            return 0;
        }
        S = S.back() + S;
        S.erase(S.length()-1);
    }
    puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int 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 INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
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;
}
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;
}
void init_fact(int n){
	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){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
//int g(int x){
//	x=modpow(x,MOD-2);
//	return x;
//}
int n,ans=1;
string s;
signed main(){
	cin>>n>>s;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll x; cin >> x;
    if(1<=x && x<=6) cout << 1 << endl;
    else if(x<=11) cout << 2 << endl;
    else{
        if(x%11==0) cout <<  2*(x/11) << endl;
        else if(1<=x%11 && x%11<=6) cout << 2*(x/11) + 1 << endl;
        else if(x%11 == 7) cout <<  2*(x/11) + 2 << endl;
        else cout <<  2*(x/11) + 2 << endl;
    }
}

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

Measured memory_bytes: 256
N=int(input())
a=map(int,input().split())
A=list(a)
B=0
for i in range(N):
 if A[i]%2==0:
  if A[i]%6==0 or A[i]%10==0:
   B+=1
 else:
  B+=1
if B==N:
 print("APPROVED")
else:
 print("DENIED")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String str = sc.next();
            if (str.equals("-"))
                break;
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                String left = str.substring(0, h);
                String right = str.substring(h);
                str = right + left;
            }
            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26492