akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define endl "\n"
#define fi first
#define se second
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define pii pair<int, int>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template <typename T>
ostream &operator<<(ostream &out, set<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << (*i) << ' ';
    return out;
}
template <typename T, typename V>
ostream &operator<<(ostream &out, map<T, V> const &v) {
    for (auto i = v.begin(); i != v.end(); i++)
        out << "\n" << (i->first) <<  ":"  << (i->second);
    return out;
}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll
int solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

int32_t main(){ _
    int t;
    // cin >> t;
    t = 1;
    while (t--) solve();
}


Measured memory_bytes: 764
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

vector <int> Prime;

bool isPrime(int num){
  if (num == 1) return false;
  for (int i = 2; i * i <= num; i++){
    if (num % i == 0) return false;
  }
  return true;
}

int main(){
  for (int i = 1; i <= 55555; i+= 5){
    if (isPrime(i)) Prime.push_back(i);
  }

  int N; cin >> N;
  for (int i = 0; i < N; i++){
    cout << Prime[i];
    if (i == N - 1) cout << endl;
    else cout << " ";
  }
  return 0;
}


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

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

  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else if (s == "Rainy") {
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct mer{
    ll v,w;
};

mer item[101];
ll dp[101][10001];

int main() {
   

    ll n,w;
    cin >> n >> w;
    for (ll i=1;i<=n;i++){
        mer p;
        cin >> p.v >> p.w;
        item[i] = p;
    }
    for (ll i=0;i<=n;i++){
        for (ll j=0;j<=w;j++){
            if(i*j == 0){
                dp[i][j] = 0;
            }else{
                ll pre, post;
                pre = dp[i-1][j];
                if(j - item[i].w >= 0){
                    post = dp[i-1][j-item[i].w] + item[i].v;
                    dp[i][j] = max(pre, post);
                }else{
                    dp[i][j] = pre;
                }
            }
        }
    }
    
    cout << dp[n][w] << endl;
}





Measured memory_bytes: 10976
//for aizu
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

bool row[8] , col[8] , d1[15] , d2[15];
bool board[8][8];

bool Solve(int r , int c , int num)
{
    if (r == 8)
    {
        if (num == 0)
            return true;
        else
            return false;
    }
    int nextr , nextc;
    if(c == 7)
    {
        nextc = 0;
        nextr = r + 1;
    }
    else
    {
        nextc = c+1;
        nextr = r;
    }

    if(!board[r][c] && !row[r] && !col[c] && !d1[r+c] && !d2[c-r+7])
    {
        board[r][c] = 1;
        row[r] = 1;
        col[c] = 1;
        d1[r + c] = 1;
        d2[c - r + 7] = 1;

        if (Solve(nextr , nextc, num-1))
            return true;

        board[r][c] = 0;
        row[r] = 0;
        col[c] = 0;
        d1[r + c] = 0;
        d2[c - r + 7] = 0;
    }
    if (Solve(nextr, nextc , num))
        return true;
    return false;
}
int main()
{
    int n , i , j;
    scanf("%d" , &n);
    for (i = 0 ; i < n ; i++)
    {
        int r , c;
        scanf("%d %d" , &r , &c);
        board[r][c] = 1;
        row[r] = 1;
        col[c] = 1;
        d1[r + c] = 1;
        d2[c - r + 7] = 1;
    }
    Solve(0 , 0 , 8 - n);
    for (i = 0 ; i < 8 ; i++)
    {
        for (j = 0 ; j < 8 ; j++)
        {
            if (board[i][j])
                printf("Q");
            else
                printf(".");
        }
        printf("\n");
    }
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

const int N = 200005;

void solve() {
  string s;
  cin >> s;
  vector<char> v(N * 2);
  rep(i, s.size()) v[N + i] = s[i];
  int q;
  cin >> q;
  int l = N;
  int r = N + s.size() - 1;
  // for (int i = l; i <= r; i++)
  //   cout << v[i] << endl;
  int mode = 1;
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 1) {
      mode = mode == 1 ? 2 : 1;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f != mode) {
        v[++r] = c;
      }
      else {
        v[--l] = c;
      }
    }
    // dump(l, r, mode);
    // for (int i = l; i <= r; i++)
    //   cout << v[i] << endl;
  }
  string ans;
  if (mode == 1) {
    for (int i = l; i <= r; i++)
      ans += v[i];
  } else {
    for (int i = r; l <= i; i--)
      ans += v[i];
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1492
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
       int[][]u = new int [2][10]; 
    for(int i=0;i<2;i++){
       for(int k=0;k<10;k++){
    	u[i][k]=sc.nextInt();
       }
      }
    Arrays.sort(u[0]); Arrays.sort(u[1]);
    int w=u[0][9]+u[0][8]+u[0][7];
    int k=u[1][9]+u[1][8]+u[1][7];
    System.out.println(w+" "+k);
    }
    }

Measured memory_bytes: 17176
//2019.10.18 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define lowbit(x) (x&-x)
#define gc getchar
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//char sr[1<<21],z[20];
//int C=-1,Z=0;
//inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
//inline void print(res x){
//    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
//    while(z[++Z]=x%10+48,x/=10);
//    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
//}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
int kcz=1000000007;
inline void add(res &x,const res &y){
    x+=y,x>=kcz?x-=kcz:(x<0?x+=kcz:1);
}
inline int Add(const res &x,const res &y){
    return x+y>=kcz?x+y-kcz:(x+y<0?x+y+kcz:x+y);
}
inline int mul(const res &x,const res &y){
    return int(1LL*x*y%kcz);
}
inline int mul(const res &x,const res &y,const res &d){
    return int(1LL*x*y/d%kcz);
}
inline int qpow(res x,res y){
    res ret=1;
    while(y){
        if(y&1)ret=mul(ret,x);
        x=mul(x,x),y>>=1;
    }
    return ret;
}
inline LL Qpow(RG LL x,res y){
    RG LL ret=1;
    while(y){
        if(y&1)ret*=x;
        x*=x,y>>=1;
    }
    return ret;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    inline void MAIN(){
        res A=read(),B=read();
        printf("%d\n",max(A-2*B,0));
    }
}
int main(){
//    srand(19260817);
    MAIN::MAIN();
//    Ot();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    int g = 0;
    int ans = 0;
    rep(i, n) {
        if (g == 0) {
            g++;
            if (s[i] == 'p')
                ans--;
        }
        else {
            g--;
            if (s[i] == 'g')
                ans++;
        }
    }
    cout << ans << endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> e(n);
  vector<int> deg(n,0);
  int a,b;
  for(int i=0;i<n+m-1;i++){
    cin >> a >> b;
    a--,b--;
    e[a].push_back(b);
    deg[b]++;
  }
  queue<int> bfs;
  for(int i=0;i<n;i++){
    if(deg[i]==0) bfs.push(i);
  }
  vector<int> par(n,-1);
  int now;
  while(!bfs.empty()){
    now=bfs.front();
    bfs.pop();
    for(auto &t:e[now]){
      par[t]=now;
      deg[t]--;
      if(deg[t]==0) bfs.push(t);
    }
  }
  for(int i=0;i<n;i++){
    cout << par[i]+1 << endl;
  }
  return 0;
}


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

#define int long long

int N, M;
vector<int> G[100000];
bool flag = true;
int used[100000] = {};

void dfs(int u, int c) {
  if ( used[u] && used[u] != c ) {
    flag = false;
    return;    
  }
  if ( used[u] ) return;
  used[u] = c;  
  for ( int v : G[u] ) {
    dfs(v, 3-c);    
  }
}

signed main() {
  cin >> N >> M;
  for ( int i = 0; i < M; i++ ) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  dfs(0, 1);
  for ( int i = 0; i < N; i++ ) {
    if ( !used[i] ) {
      flag = true;
      break;
    }
  }
  if ( flag ) {
    cout << -1 << endl;
    return 0;
  }

  const int INF = 1e15;
  typedef pair<int, int> P;  
  int dp[N][2];
  fill_n(*dp, N*2, INF);  
  queue<P> q;
  q.push(P(0, 0));  
  while ( !q.empty() ) {
    P p = q.front(); q.pop();
    int u = p.first, c = p.second;

    // cout << u << " " << c << endl;
    
    if ( dp[u][c%2] != INF ) continue;
    dp[u][c%2] = c;    

    for ( int v : G[u] ) {
      q.push(P(v, c+1));      
    }
  }  

  int a = 0, b = 0;
  for ( int i = 0; i < N; i++ ) {
    a = max(a, dp[i][0]);
    b = max(b, dp[i][1]);    
  }

  cout << min(a, b) << endl;
  
  return 0;
}



Measured memory_bytes: 12540
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n; cin >> n;
  VVI vec;
  REP(i, n) {
    int w;
    cin >> w;
    VI v = {0, 1, 2};
    REP(j, w) {
      int a; cin >> a;
      if(a == 0) swap(v[0], v[1]);
      else swap(v[1], v[2]);
    }
    vec.PB(v);
  }

  if(n >= 6) {
    cout << "yes" << endl;
    return 0;
  }

  sort(ALL(vec));
  FOR(i, 1, 1<<vec.size()) {
    VVI v;
    REP(j, vec.size()) {
      if(i&1<<j) v.PB(vec[j]);
    }
    do {
      VI amida = {0, 1, 2};
      for(auto k: v) {
        amida[0] = k[amida[0]];
        amida[1] = k[amida[1]];
        amida[2] = k[amida[2]];
      }
      if(amida == VI{0, 1, 2}) {
        cout << "yes" << endl;
        return 0;
      }
    } while(next_permutation(ALL(v)));
  }
  cout << "no" << endl;

  return 0;
}



Measured memory_bytes: 3232
/* Kadai2_3
   nabe9393 */
 
#include <stdio.h>
 
int main(void) {
    int Neutral, White, Black;
 
    //入力受け取り
    scanf("%d", &Neutral);
    scanf("%d", &White);
    //Bの値が黒く塗ることになるマスの数
    //Nの二乗からAを引いた数
    Black = Neutral*Neutral - White;
    printf("%d\n", Black);
    return 0;
}

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    FAST;
    int ara[]={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 k;
    cin>>k;
    cout<<ara[k-1]<<endl;
    return 0;

}

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

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

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	int cnt[10][10]={};
	for(int x=1;x<=n;x++){
		string s=to_string(x);
		cnt[s[0]-'0'][s.back()-'0']++;
	}

	lint ans=0;
	for(int x=1;x<=n;x++){
		string s=to_string(x);
		ans+=cnt[s.back()-'0'][s[0]-'0'];
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i

sp = Array.new
n.times do |i|
	sp.push(gets.chomp.split.push(i))
end

sp.sort! do |sp1, sp2|
	sp2[1].to_i <=> sp1[1].to_i
end

sp.sort! do |sp1, sp2|
	sp1[0] <=> sp2[0]
end

n.times do |i|
	puts sp[i][2] + 1
end

Measured memory_bytes: 1788
#include<stdio.h>
    
int main(){
    int i,j,n,Max,key,key2,count=1;
    int A[200001];
        
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
    }
      count=0;
   Max=A[2]-A[1];
 key2=A[n];
for(i=n;i>=2;i--){
     
        if(key2<=A[i]){
    for(j=i;j>1;j--){
 if(Max<A[i]-A[j-1]){
           Max=A[i]-A[j-1];
            key=A[j-1];}
          
              
    else if(count==1){
    if(key>A[j-1]){
    if(Max<A[i]-A[j-1]){
    Max=A[i]-A[j-1];
    key=A[j-1];}}
 
        key2=A[i];
    }
          count=1; 
              
}
        }}
          
            printf("%d\n",Max);
            return 0;
        }
    

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

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

    long long ans = 1ll<<60;
    long long sum = 0;
    bool plus = true;
    long long b = 0;
    for (int i = 0; i < n; i++) {
        sum += a.at(i);
        if (plus) {
            if (sum <= 0) {
                b += 1 - sum;
                sum = 1;
            }
        }
        else {
            if (sum >= 0) {
                b += 1 + sum;
                sum = -1;
            }
        }
        plus ^= 1;
    }
    ans = min(ans, b);

    plus = false;
    b = 0;
    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a.at(i);
        if (plus) {
            if (sum <= 0) {
                b += 1 - sum;
                sum = 1;
            }
        }
        else {
            if (sum >= 0) {
                b += 1 + sum;
                sum = -1;
            }
        }
        plus ^= 1;
    }
    ans = min(ans, b);
    
    cout << ans << endl;
}   

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<cstdio>
#include<string>  
#include<algorithm>
#include<cmath>  
#include<iostream>
#include<queue>
#include<cstdlib>
#include<cstring>
#define maxn 2000001
#define ll long long
using namespace std;
/*
超时 
struct o
{
	int f;
	int l;
};
o a[maxn],b[maxn];
int  main()
{
	int n,m,i,j,x,y,w=0,s=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if(x==1)
		{
			a[++w].f =x;
			a[w].l =y;
		}
		if(y==n)	
		{
			b[++s].f =x;
			b[s].l =y;	
		}	
	}
	for(i=1;i<=w;i++)
		for(j=1;j<=s;j++)
		{
			if(a[i].l==b[j].f)
			{
				printf("POSSIBLE");
				return 0;				
			}
		}
	printf("IMPOSSIBLE");	
	return 0;
 }
*/
struct o
{
    int f;
    int l;
};
o a[maxn];
int cnt;
int h[maxn];
int n,m;
int v[maxn];
int flag=0;
void dfs(int s,int t)
{
    if(t>2)
		return ; 
	if(t==2)
	{   if(s==n)
      	{
        	flag=1;
       	}
        return ;
    }
    for(int e=h[s];e!=-1;e=a[e].f)
    {
	    if(v[e]==0)
        {
            v[e]=1;
            dfs(a[e].l,t+1);
            v[e]=0;
        }
        dfs(a[e].l,t+1);
    }
   
}
int main()
{
   scanf("%d%d",&n,&m);
   memset(v,0,sizeof(v));
   memset(h,-1,sizeof(h));
   cnt=0;
   for(int i=1;i<=m;i++)
   {
    	int x,y;
    	scanf("%d%d",&x,&y);
    	if(x==1 || y==1)
    	{
    		a[cnt].l=y;
   			a[cnt].f=h[x];
    		h[x]=cnt++;
	    	a[cnt].l=x;
    		a[cnt].f=h[y];
    		h[y]=cnt++;
		}
		if(x==n || y==n)
		{
			a[cnt].l=y;
	   		a[cnt].f=h[x];
    		h[x]=cnt++;
    		a[cnt].l=x;
	    	a[cnt].f=h[y];
    		h[y]=cnt++;
		}
   }
   dfs(1,0);
   if(flag==1)
   {
      printf("POSSIBLE");
   }
   else
   {
       printf("IMPOSSIBLE");
   }
}



Measured memory_bytes: 20736
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
ar1 = list(range(102))
ar2 = list(set(ar1) - set(p))
ar3 = sorted(ar2, reverse = True)
diff = 100
for i in ar3:
  if abs(x - i) <= diff:
    diff = abs(x - i)
    ans = i
  else:
    break

print(ans)

Measured memory_bytes: 9216
n,m=map(int, input().split())
h=list(map(int, input().split()))
a=[0]*(n+1)
num={0:1}
for i in range(n):
    a[i+1]=(a[i]+h[i])%m
    if a[i+1] in num:
        num[a[i+1]]+=1
    else:
        num[a[i+1]]=1

ans=0
for i in num.values():
    if i>1:
        ans+=(i*(i-1))//2
print(ans)

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

double cross(double x1, double y1, double x2, double y2, double x3, double y3) {
	double xx1 = x2-x1, yy1 = y2-y1;
	double xx2 = x3-x1, yy2 = y3-y1;
	return (xx1*yy2 - xx2*yy1);
}

int main() {
	double xa,xb,xc,xd,ya,yb,yc,yd;
	while (scanf(
			"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
			&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) == 8) {
		double p = cross(xa, ya, xb, yb, xc, yc);
		bool convex = true;
		if (p*cross(xb, yb, xc, yc, xd, yd) < 0.0) convex = false;
		if (p*cross(xc, yc, xd, yd, xa, ya) < 0.0) convex = false;
		if (p*cross(xd, yd, xa, ya, xb, yb) < 0.0) convex = false;

		cout << (convex ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll mem[404][404]={};
ll a[MAX];

ll rec(ll l, ll r) {
    if(r-l<=1) return 0;
    if(mem[l][r]!=-1) return mem[l][r];
    
    ll res=INF;
    ll sum=0;
    
    for(ll i=l; i<r; i++) sum+=a[i];
    
    for(ll mid=l+1; mid<r; mid++) {
        res=min(res, rec(l, mid)+rec(mid, r)+sum);
    }
    
    return mem[l][r]=res;
}

int main(void) {
    cin >> N;
    ll i;
    
    for(i=0; i<N; i++) cin >> a[i];
    
    memset(mem, -1, sizeof(mem));
    pt(rec(0, N));
    
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

void Primefactorization(int n, set<lli> &fac) {
	for (int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			fac.insert(i);;
			n = n / i;
		}
	}
	if (n != 1) fac.insert(n);
	return;
}

int main() {
	lli n; cin >> n;
	set<lli> set;
	Primefactorization(n,set);
	
	lli  ans = n;
	lli sub_ans = 1;
	for (auto itr = set.begin(); itr != set.end(); itr++) {
		ans *= (*itr - 1);	
		sub_ans *= *itr;
	}
	cout << ans / sub_ans<< endl;

	return 0;
}

Measured memory_bytes: 3076
n, k, *aa = map(int, open(0).read().split())

imp_length = 0
psbl_length = max(aa)

while psbl_length - imp_length > 1:
    mid = (psbl_length + imp_length) // 2
    cost = sum(0 - -a // mid - 1 for a in aa)
    if cost <= k:
        psbl_length = mid
    else:
        imp_length = mid

print(psbl_length)

Measured memory_bytes: 109104
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;
 
int main(){
 
string s;
int A=-1,Z;
  
  cin >> s;

for(int i = 0; i < s.size() && A==-1; i++){
  if(s[i] == 'A') A = i;
}

for(int i = A+1; i < s.size(); i++){
  if(s[i] == 'Z') Z = i;
}
  
  cout << Z - A + 1<< endl;
  
return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using namespace std;

int main(void)
{
  long int x;
  cin>>x;
  
  long double a=100;
  long int b=100;
  
  int i=1;
  while(1){
    a=b*1.01;
    b=(long int)a;
    if(b>=x){
      cout<<i<<endl;
      break;
    }
      
    i++;
  }
  
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>

#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < double,double> pt;
typedef pair < int,int> pii;

const int N = 1e5 + 500;
const int M = 1e6 + 500;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int BASE = 31337;

int n,m,l,r,bad,d;
int pos[N],calc[N],bio[N];
vector < pii > v[N];

void dfs(int x){
    if(bio[x] || bad) return;
    bio[x]  = 1;
    for(int i = 0;i<v[x].size();i++){
        if(bio[v[x][i].X] && pos[x] - pos[v[x][i].X] != v[x][i].Y){
            bad = 1;return;
        }
        if(bio[v[x][i].X]) continue;
        pos[v[x][i].X] = pos[x] - v[x][i].Y;
        dfs(v[x][i].X);
    }
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i = 0;i<m;i++){
        scanf("%d%d%d",&l,&r,&d);
        v[l].push_back(make_pair(r, -d));
        v[r].push_back(make_pair(l, d));
    }

    for(int i = 1;i<=n;i++)
        dfs(i);
    if(bad) printf("No\n");
    else printf("Yes\n");
}


Measured memory_bytes: 12416
import sys, math, itertools, bisect, copy, re

from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

# 10倍速いらしい
input = sys.stdin.readline

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

M, D = [int(x) for x in input().split()]

cnt = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        if d > 10 and d // 10 >= 2 and d % 10 >= 2:
            if (d // 10) * (d % 10) == m:
                cnt += 1
                # print(f"{m}: {d}")

print(cnt)


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m; scanf("%d%d", &n, &m);
	i64 tmp = 0;
	while(n--) {
		int a; scanf("%d", &a);
		
		tmp += a;
	}
	i64 ans = 0;
	while(m--) {
		i64 a; scanf("%lld", &a);
		
		ans += a * tmp;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3220
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  20 - 6 - 2020 +   20 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int,int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pdi pair<double,int>
#define pb push_back
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <array>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <errno.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const double pi = acos(-1.0);
int main()
{
    int y;
    int e;
    scanf("%d%d",&y,&e);
    if (500*y >= e){
        puts("Yes\n");
    }
    else{
        puts("No\n");
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int INF = 1001001001;


int main() {

    int n;
    cin >> n;
    double sum = 0.0;

    rep (i, n) {
        int a;
        cin >> a;

        sum += (1.0 / a);

    }

    printf("%.10f", 1.0 / sum);


}


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

int main() {
  constexpr int kInfinity = 1000000;
  int H, W;
  std::cin >> H >> W;
  std::vector<int> A(H), B(H);
  for (int i = 0; i < H; ++i) {
    std::cin >> A[i] >> B[i];
    --A[i];
  }

  std::map<int, int> costs;
  for (int i = 0; i < W; ++i) {
    costs[i] = 0;
  }
  std::map<int, int> counts;
  counts[0] = W;
  for (int i = 0; i < H; ++i) {
    if (counts.empty()) {
      std::cout << -1 << std::endl;
      continue;
    }
    const auto begin = costs.lower_bound(A[i]);
    const auto end = costs.upper_bound(B[i]);
    int best_cost = kInfinity;
    for (auto iter = begin; iter != end; ++iter) {
      const auto [x, cost] = *iter;
      best_cost = cost + B[i] - x;
      if (--counts[cost] == 0) {
        counts.erase(cost);
      }
    }
    costs.erase(begin, end);
    if (best_cost < kInfinity && B[i] < W) {
      ++counts[best_cost];
      costs[B[i]] = best_cost;
    }
    if (counts.empty()) {
      std::cout << -1 << std::endl;
    } else {
      std::cout << (counts.begin()->first + i + 1) << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 13920
r = "yuiophjklnm"

p (x0:[]) = [x0]
p (x0:x1:xs) = if x0 == x1
               then p (x1:xs)
               else (x0:(p (x1:xs)))

ans s = 
    let l = length $ p $ map (\a -> elem a r) s
    in
        l - 1

main = do
    c <- getContents
    let i = takeWhile (/= "#") $ lines c
        o = map ans i
    mapM_ print o



Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define LL long long int
#define Max(x, y) (x > y ? x : y)
#define Min(x, y) (x < y ? x : y)
#define Abs(x) ( (x) > 0 ? (x) : -(x) )
#define Swap(x,y) do{x = x ^ y; y = x ^ y; x = x ^ y;}while(0)
#define IO_BOOST                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0)
#define setp(x) fixed << setprecision(x)
#define INF 0x3f3f3f3f
#define Lowbit(x) ((x) & (-x))
#define Pii pair<int, int>
#define x first
#define y second
#define MOD ((int)1e9+7)
using namespace std;
 
int a[(int)2e5+5], n;
void solve(){
    int dp[(int)2e5+5] = {0};
    for(int i = 2 ; i <= n ; i++){
        dp[i] = INF;
        for(int j = Max(i-2, 1) ; j < i ; j++){
            dp[i] = Min( dp[i], dp[j] + Abs( a[i]-a[j] ) );
        }
    }
    cout << dp[n] << '\n';
}
int main(){
    IO_BOOST;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i];
    solve();

}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];

  map<pair<int, int>, int> m;

  REP(i, N) REP(j, N){
    if(i == j) continue;
    m[{A[i]-A[j], B[i]-B[j]}]++;
  }

  int ans = 0;
  for(auto p : m) chmax(ans, p.second);

  cout << N-ans << "\n";

  return 0;
}

Measured memory_bytes: 384
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

let a = Int(split[0])!
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
let b = Int(split[1])!


if a*b % 2 == 0{
    print("Even")
}else{
    print("Odd")
}


Measured memory_bytes: 14068
import bisect

N = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        p = l[:i]
        a, b = l[i], l[j]
        low = b - a + 1
        high = a + b
        ans += bisect.bisect_left(p, high) - bisect.bisect_left(p, low)
print(ans)

Measured memory_bytes: 80268
from collections import Counter
s = input()
t = input()

cs = Counter(s)
ct = Counter(t)

ok = 1
for k in ct:
    if k not in cs:
        ok = 0
if not ok:
    print("-1")
    exit(0)

N = len(s)
D = [-1]*26
E = [None]*(N+1)
cA = ord('a')
for i in range(N-1, -1, -1):
    E[i+1] = D[:]
    D[ord(s[i])-cA] = i
E[0] = D

ans = 0
p = -1
for c in t:
    v = ord(c) - cA
    q = E[p+1][v]
    if q == -1:
        q = E[0][v]
        ans += q + (N - p)
    else:
        ans += (q - p)
    p = q
print(ans)

Measured memory_bytes: 70876
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

type pair struct {
	i, j int
}

func solve() {
	N := nextInt() * 2
	L := make([]int, N)
	for i := 0; i < N; i++ {
		L[i] = nextInt()
	}
	sort.Ints(L)
	ans := 0
	for i := 0; i < N; i += 2 {
		ans += L[i]
	}
	out(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	int ans = 0;
	cin >> s;

		for (int i = 0; i < s.size() / 2; i++) {
			if (s[i] != s[s.size() - i-1])ans++;
		}
		cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k = I()
s = input()
n = len(s)

fact = [1] * (n + k + 1)
for i in range(1, n+k+1):
    fact[i] = i * fact[i-1]
    fact[i] %= mod
ans = 0
for i in range(n, n + k + 1):
    ret = fact[i-1] * pow(fact[n-1], mod-2, mod) * pow(fact[i-n], mod-2, mod) % mod
    ret *= pow(25, i-n, mod)
    ret *= pow(26, k + n - i, mod)
    ans += ret
    ans %= mod
print(ans)

Measured memory_bytes: 101880
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;
void add (ll &a, ll &b){
    a += b;
    if(a >= MOD) a-= MOD;
}
int main(){
    int n; cin >> n;
    vector<ll> c(n);
    rep(i,n) cin >> c[i];
    vector<ll> dp(220000, 0);
    vector<int> place[210000];
    rep(i,n){
        place[c[i]].push_back(i);
    }
    dp[0] = 1;
    rep(i,n+1){
        if(!i)continue;
        
        add(dp[i], dp[i-1]);

        int color = c[i-1];
        int it = lower_bound(place[color].begin(), place[color].end(), i-1) - place[color].begin();
        if(it > 0){
            int j = place[color][it-1];
            if((i-1) - j > 1)add(dp[i], dp[j+1]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

int main() {
  int r, d, x;
  cin >> r >> d >> x;
  for(int i = 0; i < 10; i++) {
    x = r*x - d;
    cout << x << endl;
  }
}

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << ", ";
  }
  cout << "]" << endl;
}

int main()
{
  int a, b;
  cin >> a >> b;
  string op;

  if (a < b)
  {
    op = "<";
  }
  else if (a > b)
  {
    op = ">";
  }
  else
  {
    op = "==";
  }

  printf("a %s b\n", op.c_str());
}



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

int main(){
    int n = 0;
    cin >> n;
    
    int flag=0;
    int ans=0;

    if(n%2==0)cout << n << endl;
    else cout << 2*n << endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long cnt = 0;
void insertionSort(int a[], int n, int g){
	int i,j,k,v;

	for(i=g; i<n; i++){
		v = a[i];
		j = i-g;
		while(j>=0 && a[j]>v){
			a[j+g] = a[j];
			j = j-g;
			cnt++;
		}
		a[j+g] = v;
	}
}

void shellSort(int a[], int n){
	int i,j,m,x;
	int G[10000];
	m=0;
	x = 1;
	for(j=0; x<=n;j++){
		G[j] = x;
		x = 3*x+1;
		m++;
	}
	printf("%d\n",m);

	/*ここがおかしい(1 行目に整数 m、2 行目に m 個の整数 Gi(i=0,1,...,m−1) を空白区切りで出力してください。
3 行目に、G を用いた場合のプログラムが終了した直後の cnt　の値を出力してください)*/

	for(i=m-1; i>=0; i--){
		if(i==0){
			printf("%d\n",G[i]);
			break;
		}
		printf("%d ",G[i]);
	}

	for(i=m-1; i>=0; i--){
		insertionSort(a,n,G[i]);
	}
	printf("%d\n",cnt);

	for(i=0; i<n; i++){
		printf("%d\n",a[i]);
	}
}

int main(void){
	int i,n;

  scanf("%d",&n);

  int z[n];

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

  shellSort(z,n);

  return 0;
}



Measured memory_bytes: 5700
def resolve():
    A, B, C, D = list(map(int, input()))
    for op1 in ["+", "-"]:
        AB = A+B if op1 == "+" else A-B
        for op2 in ["+", "-"]:
            ABC = AB+C if op2 == "+" else AB-C
            for op3 in ["+", "-"]:
                ABCD = ABC+D if op3 == "+" else ABC-D
                if ABCD == 7:
                    print("{A}{op1}{B}{op2}{C}{op3}{D}=7".format(A=A,
                                                                 op1=op1,
                                                                 B=B,
                                                                 op2=op2,
                                                                 C=C,
                                                                 op3=op3,
                                                                 D=D))
                    return
    raise Exception("Not found")

    




if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38256
T = gets.to_i

T.times do
  ary = Array.new(9)
  num = gets.chomp.split(' ').map(&:to_i)
  color = gets.chomp.split(' ')

  for i in 0..8
    ary[i] = [num[i], color[i]]
  end

  ary.sort!
  set = 0
  while true
    break if ary.size < 3
    card1 = ary.shift
    for i in 0...ary.size-1
      next if ary[i][1] != card1[1]
      end_flag = 0
      equal = 1
      snum = 1
      case ary[i][0] - card1[0]
      when 0
        equal += 1
      when 1
        snum += 1
      else
        break
      end

      for j in i+1...ary.size
        next if ary[j][1] != ary[i][1]
        case ary[j][0] - card1[0]
        when 0
          equal += 1
        when 2
          snum += 1
        else
          break
        end
        if equal == 3 || snum == 3
          set += 1
          ary.delete_at(ary.find_index(ary[i]))
          ary.delete_at(ary.find_index(ary[j-1]))
          end_flag = 1
          break
        end
      end
      break if end_flag == 1
    end
  end
  case set
    when 3
      puts 1
    else
      puts 0
  end
end

Measured memory_bytes: 8676
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var d = Enumerable.Range(0, 5).Select(_ => int.Parse(ReadLine())).ToArray();
    var k = int.Parse(ReadLine());

    var ans = (d.Last() - d.First()) <= k ? "Yay!" : ":(";
    WriteLine(ans);
  }
}

Measured memory_bytes: 13396
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int dp[1000000];
int main(){
	while(cin>>n,n){
		memset(dp, 0, sizeof(dp));
		dp[0]=1;
		for(int i =1;i <=17;i++){
			for(int k =1;k <=n;k++){
				if(k-i*i<0)continue;
				dp[k]+=dp[k-i*i];
			}
		}
		cout <<dp[n]<<endl;
	}
	return 0;
}

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

int main(){
    int n , q; cin >> n >> q;
    vector<priority_queue<int>> a(n);
    rep(i , q){
        int s , t , value;
        cin >> s;
        if( s == 0 ){
            cin >> t >> value;
            a[t].push(value);
        } else if ( s == 1 ){
            cin >> t;
            if(a[t].empty()) continue;
            cout << a[t].top() << endl;
        } else {
            cin >> t;
            if(a[t].empty()) continue;
            a[t].pop();
        }
    }
}


Measured memory_bytes: 4108
import math
def gcd(a, b):
  while b > 0:
    a, b = b, a % b
  return a
def div(a):
  r = []
  i = 2
  k = int(math.sqrt(a))
  while i <= k:
    if a % i == 0:
      r.append(i)
      while a % i == 0:
        a //= i
      k = math.sqrt(a)
    i += 1
  if a > 1:
    r.append(a)
  return r

a, b = map(int, input().split())
if a > b:
  a, b = b, a
c = gcd(a,b)
print(len(div(c))+1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int main() { 
  int n;
  vector<int> a;
  vector<int>::iterator it; 
  while(cin >> n) {  
    if(n==0) {    
      it=a.end();  
      it--;   
      cout << *it << endl;  
      a.erase(it); 
    } else {    
      a.push_back(n); 
    } 
  } 
  return 0;
}


Measured memory_bytes: 1212