akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
#include<algorithm>

int main()
{
    int N;
    std::cin>>N;
    std::vector<std::string> s(N);
    for(int i=0;i<N;i++)std::cin>>s[i];
    std::unordered_map<std::string,int> um(N);

    long long ans = 0;

    for(int i=0;i<N;i++){
        std::sort(s[i].begin(),s[i].end());
        um[s[i]]++;
        ans += um[s[i]]-1;
    }
    std::cout<<ans<<std::endl;
}

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

int main () {
  string S;
  cin >> S;
  int N = S.size();
  long long sum = 0;
  long long A = 0;
  long long B = 0;
  
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '<'){
      A++;
    }
    else if (S.at(i) == '>'){
      B++;
    }
    if (i == N-1 || S.at(i) == '>' && S.at(i+1) == '<'){
      for (int i = 1; i <= max(A,B); i++) {
        sum += i;
        if (min(A,B) > i){
          sum += i;
        }
      }
      A = 0;
      B = 0;
    }
  }
  cout << sum << endl;
}
    
      
   
   

Measured memory_bytes: 4160
a, b, c = map(int, input().split())
if a <= b and b <= c:
    print(int(str(c) + str(b)) + a)
elif c <= b and b <= a:
    print(int(str(a) + str(b)) + c)
elif a <= c and c <= b:
    print(int(str(b) + str(c)) + a)
elif b <= c and c <= a:
    print(int(str(a) + str(c)) + b)
elif b <= a and a <= c:
    print(int(str(c) + str(a)) + b)
else:
    print(int(str(b) + str(a)) + c)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

const ll mod = (ll) 1e9 + 7;

ll modpow(ll x, ll d) {
    if (d == 0) {
        return 1ll;
    }
    ll  y = modpow(x, d / 2);
    ll ret = (y * y) % mod;
    if (d & 1) {
        ret = (ret * x) % mod;
    }
    return ret;
};

ll modinv(ll k) {
    ll fact = 1;
    for (ll i = 1; i <= k; i++) {
        fact *= i;
        fact %= mod;
    }
    return modpow(fact, mod - 2);
}

ll ways(ll n, ll k) {
    ll ret = 1;
    for (ll i = n; i > n - k; i--) {
        ret *= i;
        ret %= mod;
    }
    return ret * modinv(k);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll n, a, b; cin >> n >> a >> b;
    ll tot = modpow(2ll, n);
    tot--;
    tot += mod;
    tot %= mod;
    tot -= ways(n, a);
    tot -= ways(n, b);
    while (tot < 0) {
        tot += mod;
    }
    cout << tot;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define INF 1000000000

int main(int argc, const char * argv[]) {

  int N, K; cin >> N >> K;
  vector<int> xpos, xneg;
  
  int x;
  for (int i=0; i<N; i++){
    cin >> x;
    if (x<0)
      xneg.push_back(-x);
    else
      xpos.push_back(x);
  }
  
  ll time, timemin = INF;
  
  for (int i=0; i<=K; i++){
    if (i > xneg.size() || K-i > xpos.size())
      continue;
    
    if (i == 0)
      time = xpos[K-1];
    else if (i == K)
      time = xneg[xneg.size()-K];
    else
      time = min(2*xneg[xneg.size()-i]+xpos[K-i-1], xneg[xneg.size()-i]+2*xpos[K-i-1]);
    
    timemin = min(time, timemin);
  }
  
  cout << timemin << endl;
  return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <cstring>
#include <cstdio>

#define M 1000030
#define NIL -1
#define L 14

using namespace std;

char H[M][L];
int getchar(char c){

  if(c == 'A') return 1;
  else if(c == 'C') return 2;
  else if(c == 'G') return 3;
  else if(c == 'C') return 4;
  else return 0;
}


long long getkey(char str[]){

  long long sum = 0,p = 1;

  for(int i = 0;i < strlen(str); i++){
    sum += p * (getchar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) {return key % M;}
int h2(int key) {return 1 + (key % (M - 1));}

int find(char str[]){
  long long key,i,h;
  key = getkey(str);

  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getkey(str);
  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){

  int i,n,h;

  char str[L],com[9];
  for(i = 0;i < M;i++) H[i][0] = '\0';
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%s %s",com,str);
    if(com[0] == 'i'){
      insert(str);
    }
    else {
      if(find(str) == 1){
        printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    ll a,b;cin>>a>>b;
    if(abs(a-b)==0||abs(a-b)==1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dist[2][100005];
vector<int>edge[100005];
void dfs(int v,int u,int d,int p){
	dist[p][v] += d;
	rep(i,edge[v].size()){
		if(edge[v][i]==u) continue;
		dfs(edge[v][i],v,d+1,p);
	}
}
int n;
int main(){
	int a,b;
	cin >> n >> a >> b;
	rep(i,n-1){
		int a,b; cin >> a >> b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs(a,-1,0,0);
	dfs(b,-1,0,1);
	
	int ans = 0;
	repn(i,n){
		if(dist[0][i] >= dist[1][i]) continue;
		ans = max(ans,dist[1][i]-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
main() {
	int n;
	cin >> n;
	for (int i=1; i<=n; i++) {
		if (i%3==0) cout << " " << i;
		else {
			int x = i;
			while (x) {
				if (x%10==3) {
					cout << " " << i;
					break;
				} else x /= 10;
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int d, t, s;
	cin >> d >> t >> s;
	if (t*s >= d)cout << "Yes"; else cout << "No";
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int nth_bit(ll x, ll n){
    return (x>>n) & 1;
}

void add(ll & a, ll b) { a = (a+b) % mod; }

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

    ll N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    vector<ll> bit_cnt(41, 0);
    rep(d, 40){
        int cnt = 0;
        rep(i, N) if(nth_bit(a[i], d) == 1) ++cnt;
        bit_cnt[d] = cnt;
    }

    ll inf = 1LL<<59;
    ll dp[41][2] = {};
    rep(i, 41) rep(j, 2) dp[i][j] = -inf;
    dp[40][0] = 0;
    reprev(i, 40) rep(j, 2) if(dp[i+1][j] != -inf) {
        int lim = j? 1:nth_bit(K, i);
        rep(k, lim+1){
            if(k == 0){
                chmax(dp[i][j || k<lim ], dp[i+1][j] + (1LL<<i)*bit_cnt[i]);
            }
            else{
                chmax(dp[i][j], dp[i+1][j] + (1LL<<i)*(N-bit_cnt[i]));
            }
        }
    }

    cout << max(dp[0][0], dp[0][1]) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

int solve(const int N, const vector<int> &d) {
    int a = d[N / 2 - 1];
    int b = d[N / 2];

    return b - a;
}

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

    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    cout << solve(N, d) << endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	int m = 1000, M = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		m = min(m, a);
		M = max(M, a);
	}

	cout << M - m << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=n;i<=999;i++)
	{
		if(i/100==(i/10)%10&&i/100==i%10)
	 	{
		 	cout<<i<<endl;
		 	break;
    	}
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  
  int N; cin >> N;
  set<char> color;

  for(int rep = 0; rep < N; ++rep){
    char c; cin >> c;
    color.insert(c);
  }

  if(SZ(color) == 4) cout << "Four\n";
  else cout << "Three\n";

  return 0;
}

Measured memory_bytes: 256
s = input()
p = input()

for i in range(len(s)):
  string = ""
  if (len(s)-((i+1)+len(p)) < 0):
    string = s[i:] + s[:(i+1)+len(p)]
  else:
    string = s[i:]
  if string.startswith(p):
    print("Yes")
    break
  if i == len(s)-1:
    print("No")


Measured memory_bytes: 5560
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int n;
   cin >> n;
   int a[n];
   for(int i = 0 ; i < n ; i++ ){
      cin >> a[i];
   }
   int M = 1e6+5;
   bitset<1000005>mp,cnt;
   for(int i = 0 ; i < n ; i++ ){
      if(mp[a[i]]){
        cnt[a[i]]=1;
        continue;
      }
      mp[a[i]]=1;
      for(int j = a[i]*2 ; j<M;j+=a[i]){
        cnt[j]=1;
      }
   }
   int ans = 0;
   for(int i = 0 ; i < n ; i++ ){
    ans+=(cnt[a[i]]==0);
   }
   cout << ans;
 }

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

int main()
{
  int n;
  cin>>n;
  int x,hash[n+1]={0};
  for(int i=2;i<=n;i++)
  {
    cin>>x;
    hash[x]++;
  }
  for(int i=1;i<=n;i++)
    cout<<hash[i]<<"\n";


  return 0;
}


Measured memory_bytes: 4348
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#define ll long long
#define length 100000   //10万
int compare(const int*a,const int *b);
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これ移動
*/
int main(){
    int array[length],N=1,K,A,B;
    int *aryp;
    ll sum=0;
    char chara[20];
    scanf("%d%d",&A,&B);
    while(N<B){
    N +=A-1;
    sum++;
    }
  printf("%d",sum);
    return 0;
}
int compare(const int*a,const int *b){
    if(*a<*b)
      return -1;
    else if(*a>*b)
      return 1;
    return 0;
}

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

// 辺の値の和 - P*辺の本数
// 辺の値から予めPを引いておいて，そのグラフ上での最長経路問題
// 辺の正負を逆転させて最短経路問題に帰着させる -> bellman ford法
// 不閉路に入り込んだ後，ゴールに到達できないケースもある
// 頂点の数だけループして収束しないなら不閉路があると判定する
// 始点から到達できる && 終点に到達できる ような閉路があるかどうか
// 始点から到達できない | 終点に到達できない 頂点たちは削除する < BFS/DFSを両端からやる

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

const int INF = 1001001001;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<tuple<int,int,int>> edges;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c -= p;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
  { // bellman-ford
    vector<int> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      rep(i,m) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        int newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("-1");
        return 0;
      }
    }
    int ans = -d[n-1];
    ans = max(ans, 0);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll x1=a*c,x2=a*d,x3=b*c,x4=b*d;
  cout<<max(x1,max(x2,max(x3,x4)))<<endl;
  
  
}



Measured memory_bytes: 3628
a,b=map(int,input().split())
s=input()
if '-' not in s or s.count('-')>1 or s[0]=='-' or s[-1]=='-':
    print('No')
    exit()

p=s.split('-')
print('No' if s[a]!='-' or len(p[0])!=a or len(p[1])!=b else 'Yes')

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

vector<string> subst;
string s;
ll k;

void dfs(ll dp, string st){
    subst.push_back(st);

    if(dp + 1 == s.size() || st.size() >= k){
        return;
    }
    st += s[dp + 1];
    dfs(dp + 1, st);
}

int main(void){
    cin >> s >> k;

    for(ll i = 0; i < s.size(); i++){
        string tmp{s[i]};
        dfs(i, tmp);
    }

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

    string pre = "";
    ll count = 0;
    for(ll i = 0; i < subst.size(); i++){
        if(pre != subst[i]){
            count++;
            pre = subst[i];
        }
        if(count == k){
            cout << subst[i] << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q, W, H, R, C, L;
string S;

int main() {
    cin >> N >> K >> L >> R;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    vector<ll> back[41];
    for (int bit = 0; bit < (1 << (N - N / 2)); bit++) {
        ll sum = 0;
        for (int i = 0; i < (N - N / 2); i++) {
            int mask = 1 << i;
            if (bit & mask) {
                sum += a[N - 1 - i];
            }
        }
        back[__builtin_popcount(bit)].push_back(sum);
    }
    for (int i = 0; i <= 20; i++) {
        sort(back[i].begin(), back[i].end());
    }

    ll ans = 0;
    for (int bit = 0; bit < (1 << (N / 2)); bit++) {
        ll sum = 0;
        for (int i = 0; i < N / 2; i++) {
            int mask = 1 << i;
            if (bit & mask) {
                sum += a[i];
            }
        }
        int cnt = K - __builtin_popcount(bit);
        if (cnt >= 0) {
            ans += upper_bound(back[cnt].begin(), back[cnt].end(), R - sum) - lower_bound(back[cnt].begin(), back[cnt].end(), L - sum);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 12328
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n,t;
  scanf("%d%d",&n,&t);
  int ans = 0;
  int pre = -INF;
  rep(i,n) {
    int a;
    scanf("%d",&a);
    if (pre+t <= a) {
      ans += t;
    } else {
      ans += a-pre;
    }
    pre = a;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
string s;
map<char,int>a;
int main()
{
	cin>>s;
	if(s[3]==s[2]&&s[4]==s[5])
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC176C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Ainput = Console.ReadLine().Split(' ');
            long[] A = new long[N];
            for(int i = 0; i < N; i++)
            {
                A[i] = long.Parse(Ainput[i]);
            }
            long fumi = 0;
            long max = 0;
            for(int i = 0; i < N; i++)
            {
                if (A[i] == max)
                {
                }
                else if (A[i] < max)
                {
                    fumi += max - A[i];
                }
                else
                {
                    max = A[i];
                }
            }
            Console.WriteLine(fumi);

        }
    }
}


Measured memory_bytes: 46724
n = int(input())
data = [int(s) for s in input().split()]

change = 0
new = []
for idx in range(n):
	idx_min = data[idx:].index(min(data[idx:])) + idx
	if idx_min > idx:
		data[idx],data[idx_min] = data[idx_min],data[idx]
		change += 1

print(' '.join([str(d) for d in data]))
print(change)

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;
struct Timer {
    unsigned long long begin_cycle;
    double cycle_per_sec = 2.8e9;
    unsigned long long getCycle() {
        unsigned low, high;
        __asm__ volatile("rdtsc":"=a"(low), "=d"(high));
        return ((unsigned long long) low) | ((unsigned long long) high << 32);
    }
    double getTime() { return (getCycle() - begin_cycle) / cycle_per_sec; }
    void init() { begin_cycle = getCycle(); }
};
long long xor64(long long range) {
    static unsigned long long x = 88172645463325252ULL;
    x ^= x << 13;
    x ^= x >> 7;
    return (x ^= x << 17) % range;
}

int N;
int x[110], y[110];
vector<bool> ans;
double best_score;
void SA(double start_temp) {
    Timer timer;
    timer.init();
    double end_temp = 1e-5;
    double T = 0.485;
    int it = 0;
    int xsum = 0, ysum = 0;
    vector<bool> cur(N);
    double time;
    while ((time = timer.getTime()) < T) {
        double temp = start_temp + (end_temp - start_temp) * time / T;
        int i = xor64(N);
        int dx = x[i], dy = y[i];
        if (cur[i]) { dx *= -1, dy *= -1; }
        double cur_score = sqrt((xsum + dx) * (xsum + dx) + (ysum + dy) * (ysum + dy));
        double prev_score = sqrt(xsum * xsum + ysum * ysum);
        double prob = exp((cur_score - prev_score) / temp);
        if (prob > (double) xor64(10000000) / 10000000) { cur[i] = !cur[i], xsum += dx, ysum += dy;}
        if (cur_score >= best_score) { ans = cur, best_score = cur_score; }
    }
}
signed main() {
    cin >> N;
    double sum = 0;
    for (int i = 0; i < N; i++) { cin >> x[i] >> y[i], sum += sqrt(x[i] * x[i] + y[i] * y[i]); }
    SA(sum / N / 10);
    SA(sum / N / 20);
    SA(sum / N / 40);
    SA(sum / N / 80);
    int xsum = 0, ysum = 0;
    for (int i = 0; i < N; i++) { if (ans[i]) { xsum += x[i], ysum += y[i]; }}
    cout << sqrt(xsum * xsum + ysum * ysum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t;
    t=1;
   while(t--)
   {
       ll n,i,j=0,d;
       std::cin >> n;
       string s;
       std::cin >> s;
       string t=s;
       sort(s.begin(),s.end());
       fr(i,0,n)
       {
           if(s[i]==t[i])
           continue;
           else
           j++;
       }
       cout<<j/2<<"\n";
       
   }
}

Measured memory_bytes: 3884
#include <stdio.h>
#include <math.h>

//  ????°?????????????
#ifndef min
#define min(a, b)            (((a) < (b)) ? (a) : (b))
#endif
//  ?????§????????????
#ifndef max
#define max(a, b)            (((a) > (b)) ? (a) : (b))
#endif

#define DEF_ELM_MAX 200000

	int R[DEF_ELM_MAX];

int MAXDIFF(int *Array, int num)
{
	int maxv = Array[1] - Array[0];
	int minv = Array[0];
	int i;

	for ( i = 1 ; i < num ; i++ ) {
		maxv = max(maxv, (Array[i]-minv));
		minv = min(minv, Array[i]);
	}
	return maxv;
}

int main(void)
{
	int N;
	int i;

	int ans;

	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &R[i]);
	}

	ans = MAXDIFF(R, N);

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    set<string> colors;
    int over3200cnt = 0;
    REP(i,N) {
        int rate;
        cin >> rate;

        string color;
        if (rate < 400) color = "gray";
        else if (rate < 800) color = "brawn";
        else if (rate < 1200) color = "green";
        else if (rate < 1600) color = "light blue";
        else if (rate < 2000) color = "blue";
        else if (rate < 2400) color = "yellow";
        else if (rate < 2800) color = "orange";
        else if (rate < 3200) color = "red";
        else over3200cnt++;

        if ( !color.empty() ) colors.insert(color);
    }

    if ( colors.empty()) {
        if (over3200cnt > 0) cout << 1;
        else cout << 0;

        cout << " " << over3200cnt;
        return 0;
    }

    cout << colors.size() << " " << colors.size()+over3200cnt << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class a{
 static void Main(){

char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
string a = Console.ReadLine();
for (int i =0;i<az.Length;i++)
{
  if(az[i].ToString()==a){
    Console.WriteLine(az[i+1]);
  }
}
 }
}


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

int main() {

    ll N;
    cin >> N;

    vl A(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll sum = 0;
    FOR(i, 1, N) {
        sum += (max(A[i-1], A[i]) - A[i]);
        A[i] = max(A[i-1], A[i]);
    }

    cout << sum << endl;

    return 0;
}


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

struct Data{
  int num,id;
  char ch;
};

int Partition(Data A[],int p,int r){
  Data x = A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j].num<=x.num){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

void Quicksort(Data A[],int p,int r){
  if(p<r){
    int q = Partition(A,p,r);
    Quicksort(A,p,q-1);
    Quicksort(A,q+1,r);
  }
}

void check(Data A[],int n){
  for(int i=1;i<n;i++){
    if(A[i-1].num<A[i].num)continue;
    if(A[i-1].id<A[i].id)continue;
    cout<<"Not stable"<<endl;
    return;
  }
  cout<<"Stable"<<endl;
}

int main(){
  int n;
  Data A[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i].ch>>A[i].num;
    A[i].id=i;
  }
  
  Quicksort(A,0,n-1);
  check(A,n); 
  for(int i=0;i<n;i++){
    cout<<A[i].ch<<' '<<A[i].num<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 2332
s = input()
l = len(s)
while len(s)>0:
    l=len(s)
    if s[l-5:]=='dream' or s[l-5:]=='erase':
        s=s[:l-5]
    elif s[l-6:]=='eraser':
        s=s[:l-6]
    elif s[l-7:]=='dreamer':
        s=s[:l-7]
    else:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 3188
import std.stdio, std.string, std.conv;
int n, x, k;
int[300999] C, U;
void main(){
	readf("%d\n", &n);
	foreach(a; readln.split) C[a.to!int] ++;
	foreach(c; C) for(x = 0; c; ) U[x++] += c --;
	for(x = n; k < n; ) k * x + x > n - U[x] && x -- || (k++, x.writeln);
}


Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,k;
    cin>>a>>b>>k;
    if(b-a<=2*k-1){
        for(ll i=a;i<=b;i++) cout<<i<<endl;
    }
    else{
        for(ll i=0;i<k;i++) cout<<a+i<<endl;
        for(ll i=k-1;i>=0;i--) cout<<b-i<<endl;
    }
}

Measured memory_bytes: 3648
import itertools
import math

def dist(x1, y1, x2, y2):
  return math.sqrt((x1-x2)**2 + (y1-y2)**2)

n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]

ans = 0
for p in itertools.permutations(xy):
  for i in range(n-1):
    ans += dist(*p[i], *p[i+1])

print(ans/math.factorial(n))

Measured memory_bytes: 9156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
struct point
{
	int w, h;
};
void PracticalSkillTest() {
	int H, W,D;
	cin >> H >> W >> D;
	point p[301 * 301];
	int M = H * W;
	for (size_t i = 1; i <= H; i++)
	{
		for (size_t j = 1; j <= W; j++)
		{
			int a;
			cin >> a;
			p[a].h = i;
			p[a].w = j;
		}
	}
	bool use[301 * 301];
	fill(use, use + M, false);
	ll sums[301 * 301];
	fill(sums, sums + M, 0);
	for (int i = 1; i <= M; i++)
	{
		if (use[i]) continue;
		use[i] = true;
		int ti = i;
		point f = p[ti];
		ll sum = 0;
		while (ti + D <= M)
		{
			ti += D;
			use[ti] = true;
			sum += abs(p[ti].h - f.h) + abs(p[ti].w - f.w);
			sums[ti] = sum;
			f = p[ti];
		}
	}

	int Q;
	cin >> Q;
	for (size_t i = 0; i < Q; i++)
	{
		ll res = 0;
		int L, R;
		cin >> L >> R;
		cout << (sums[R] - sums[L]) << endl;
	}
}

int main() {
	PracticalSkillTest();
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static int cnt = 0;
    static void InsertionSort(int[] A, int g)
    {
        for (int i = g; i < A.Length; i++)
        {
            int v = A[i];
            int j;
            for (j = i - g; j >= 0 && A[j] > v; j -= g)
            {
                A[j + g] = A[j];
                cnt++;
            }
            A[j + g] = v;
        }
    }

    static int[] ShellSort(int[] A)
    {
        cnt = 0;
        int m = (int) Math.Sqrt(A.Length);
        m = Math.Min(100, m);
        int[] G = new int[m];
        for (int i = 0; i < m; i++)
        {
            G[i] = (m - i) * (m - i);
            InsertionSort(A, G[i]);
        }
        return G;
    }

    static void OutputArray(int[] A)
    {
        for (int i = 0; i < A.Length - 1; i++) Console.Write("{0} ", A[i]);
        Console.WriteLine(A[A.Length - 1]);
    }

    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] A = new int[n];
        for (int i = 0; i < n; i++) A[i] = int.Parse(Console.ReadLine());
        int[] G = ShellSort(A);
        Console.WriteLine(G.Length);
        OutputArray(G);
        Console.WriteLine(cnt);
        for (int i = 0; i < n; i++) Console.WriteLine(A[i]);
    }
}


Measured memory_bytes: 25492
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://apc001.contest.atcoder.jp/tasks/apc001_d>
問題文============================================================
 N 頂点 M 辺の森が与えられます。頂点には 0 から N−1 の番号がついています。
 辺は (xi,yi) の形で与えられます。これは頂点 xi と yi が辺でつながっていることを意味します。
 
 各頂点 i には ai という値が定まっています。 あなたは与えられた森に辺を追加して連結にしたいです。
 辺を追加するときには、まず異なる頂点二つを選択し( i , j とする)、 i と j の間に辺を張ります。
 この時コストが ai+aj かかります。そしてこれ以降，頂点 i と j は永遠に選択できなくなります。
 
 森を連結にする最小コストを求めてください。 連結にするのが不可能な場合はImpossibleと出力してください。
=================================================================

解説=============================================================

 まず、 N頂点中でM辺の森がいくつに分割されるかを考える。
 
 実験等として考えると
 N - M 個に分割される

 M == N - 1の時　すなわち 1個に分割は　すでに木になっていることを示すので
 
 M < N - 1 として,
 N - M 個に分割されたものを木にするには N - M 個の頂点として考えれば良いので
 N - M - 1 個の辺があれば良い。
 よって 2*(N-M-1)個の頂点が必要である。
 ここで、選べる全頂点は N 個なので  N < 2*(N-M-1) であれば Impossibleとなる
 
 次に、木への復元を考える
 N-Mの分割された成分から 木にするには　必ず、それぞれから少なくとも１頂点を選ぶ必要がある
 また、2*(N-M-1)の頂点を選択してしまえば都合よく辺を引くことで木にすることができるので、
 
 それぞれの連結成分から 一番小さいコストの頂点を1つ選んでおき、
 残りの足りない分を残った全体から小さい順に選んでいけばよい
 
================================================================
*/

void dfs(ll n,vector<int>& color,vector<vector<ll>>& G,int color_idx){
    color[n] = color_idx;
    for(auto next:G[n]){
        if(color[next]==-1)dfs(next,color,G,color_idx);
    }
}

ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    vector<ll> a(N); for(auto &in:a) cin >> in;
    vector<ll> x(M),y(M);
    for(int i = 0; i < M;i++) cin >> x[i] >> y[i];
    if(M == N-1)return res;
    if(N < 2*(N-1-M)) return -1;
    vector<vector<ll>> G(N);
    for(int i = 0; i < M;i++){
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }
    vector<int> color(N,-1);
    int color_idx = 0;
    for(int i = 0;i < N;i++){
        if(color[i]==-1) dfs(i,color,G,color_idx++);
    }
    
    vector<vector<ll>> color_cost(color_idx);
    for(int i = 0; i < N;i++){
        color_cost[color[i]].push_back(a[i]);
    }
    for(auto& array:color_cost)sort(array.begin(),array.end());
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    ll cnt = 2*(N-M-1);
    for(auto& array:color_cost){
        res += array[0]; cnt--;
        for(int i = 1; i < array.size();i++){
            pq.push(array[i]);
        }
    }
    while(cnt--){
        res += pq.top();pq.pop();
    }
    return res;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll ans = solve();
    if(ans == -1) cout << "Impossible" << endl;
    else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11384
#include <iostream>
#include <list>
#include <map>
using namespace std;

int main()
{
	int N, M, Q;
	list<int> circle;
	map<int, bool> data;

	cin >> N >> M >> Q;

	for (int i = 0; i < N; i++) circle.push_back(i);

	auto pos = circle.begin();
	for (int i = 0; i < M; i++)
	{
		int a;
		cin >> a;
		if (a % 2 == 0)
		{
			for (int j = 0; j < a; j++)
			{
				pos++;
				if (pos == circle.end()) pos = circle.begin();
			}
		}
		else
		{
			for (int j = 0; j < a; j++)
			{
				if (pos == circle.begin()) pos = circle.end();
				pos--;
			}
		}
		data[*pos] = true;
		pos = circle.erase(pos);
		if (pos == circle.end()) pos = circle.begin();
	}

	for (int i = 0; i < Q; i++)
	{
		int q;
		cin >> q;
		if (data.count(q)) cout << 0 << endl;
		else cout << 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 13840
using System;
﻿﻿﻿﻿﻿using System.Globalization;
﻿﻿﻿﻿﻿using System.IO;
﻿﻿﻿﻿﻿using System.Linq;

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader("input.txt"));
            var task = new Task();
            using (var sw = Console.Out)
            //using (var sw = new StreamWriter("output.txt"))
            {
                task.Solve(sr, sw);
                //Console.ReadKey();
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var s = sr.NextString();
            var splitted = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            sw.WriteLine(String.Join(" ", splitted));
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

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

int main(){
    int r, c, a[1000][1000];
    
    cin >> r >> c;
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            cin >> a[i][j];
            a[i][c+1] += a[i][j];
        }
    }
    for(int j = 1; j <= c+1; j++){
        for(int i = 1; i <= r; i++){
            a[r+1][j] += a[i][j];
        }
    }
    
    for(int i = 1; i <= r+1; i++){
        for(int j = 1; j <= c+1; j++){
            if(j == 1)  cout << a[i][j];
            else    cout << " " << a[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3416
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std; 
 


int main() {
    double n,t;
    cin>>n>>t;
    t/=1000;
    // cout<<t<<endl;
    float y=-1;
    float x=-1;
    bool flag=false;
    for(x=0;x<=n;x++){
        y=(t-n-(4*x))/9;
        // cout<<y<<endl;
        if(floor(y)==ceil(y)){
            flag=true;
            break;
        }
    }
    float z=n-(x+y);
    if((x>=0 && y>=0 && z>=0)) cout<<y<<" "<<x<<" "<<z;
    else cout<<-1<<" "<<-1<<" "<<-1;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3644
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    vvl dp(N + MGN, vl(2,0));
    // dp[i][0] : max of sum in [0,i) not flipped Ai-1 and Ai
    // dp[i][1] ; max of sum in [0,i) flipped Ai_1 and Ai        
    dp[1][0] = A[0];
    dp[1][1] = -A[0];

    FOR(i, 1, N){
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
    }

    ll ans = max(dp[N-1][0] + A[N-1], dp[N-1][1] -A[N-1]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6144
c = [list(map(int,input().split())) for _ in range(3)]
x = [0] * 3
y = [0] * 3
state=True
for i in range(3):
    y[i] = c[0][i] - x[0]
for i in range(3):
    x[i] = c[i][0] - y[0]
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i] + y[j]:
            print('No')
            state = False
            break
    if state == False:
        break
if state == True:
    print('Yes')

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    int max = 0;
    for (int i = 0; i < N; i++) {
      int[] a = zalgorithm(s, i, N);
      for (int j = 0; j < a.length; j++) max = Math.max(max, Math.min(a[j], j));
    }
    System.out.println(max);
  }

  public static int[] zalgorithm(char[] s, int offset, int N) {
    int[] a = new int[N - offset];
    a[0] = N;
    int i = 1;
    int j = 0;
    while (i < N - offset) {
      while (i + j + offset < N && s[i + j + offset] == s[j + offset]) j++;
      a[i] = j;
      if (j == 0) {
        i++;
        continue;
      }
      int k = 1;
      for (; i + k < N && k + a[k] < j; k++) a[i + k] = a[k];
      i += k;
      j -= k;
    }
    return a;
  }
}


Measured memory_bytes: 44464
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}
ll A, B, X;
bool isOK(ll g,ll X) {
	if (g > X) return true;
	else return false;
}
ll keta(ll a) {
	ll k = 0;
	a = abs(a);
	if (a == 0)return 1;
	while (a > 0) {
		k++;
		a /= 10;
	}
	return k;
}
ll binary_search(ll key,ll A,ll B,ll X) {
	int left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = 1000000000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(A*mid+B*keta(mid),X)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return left;
}

int main() {
	ll N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << 5 + (N-1) / (Min(Min(A, B, C), D, E)) << endl;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int n, m;
vector<vector<pair<int, int>>> p;
vector<int> col;

void dfs(int i, int c) {
  if (col[i] >= 0) return;
  col[i] = c;
  for (auto &v : p[i]) {
    if (v.second) {
      dfs(v.first, 1 - c);
    } else {
      dfs(v.first, c);
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  p.resize(n);
  col.resize(n);
  for (int i = 0; i < n; i++) col[i] = -1;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    p[x].emplace_back(y, z % 2);
    p[y].emplace_back(x, z % 2);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (col[i] < 0) {
      ans++;
      dfs(i, 0);
    }
  }
  cout << ans << endl;

  return 0;
}


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

class Program
{
    static void Main()
    {
        int[] list =
        {
            1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
        };
        int n = int.Parse(Console.ReadLine()) - 1;
        Console.WriteLine($"{list[n]}");
    }
}

Measured memory_bytes: 13140