akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int m, k;
    cin >> m >> k;
    int n = 1 << m;
    if(m == 1) {
        if(k == 0) {
            cout << "0 0 1 1" << endl;
        } else {
            cout << "-1" << endl;
        }
        return 0;
    } else if(k >= n) {
        cout << -1 << endl;
        return 0;
    } else if(k == 0) {
        rep(i, 0, n - 1) {
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }
    cout << 0 << " " << k << " " << 0 << " ";
    rep(i, 1, n - 1) {
        if(i == k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    rrep(i, 1, n - 1) {
        if(i == k) continue;
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}



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

using namespace std;

#define ll long long

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif // ONLINE_JUDGE
	int n,k;
	cin>>n>>k;
	int arr[n];
	int dp[n];
	for(int i=0;i<n;i++)
		dp[i]=1e9;
	dp[0]=0;
	for(int i=0;i<n;i++)
		cin>>arr[i];

	for(int i=0;i<n-1;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i+j<n)
				dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
		}
	}
	cout<<dp[n-1]<<"\n";
	// for(int i=0;i<n;i++)
	// 	cout<<dp[i]<<"\n";
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; cin >> N;
  std::unordered_map<int, int> mp;
  int mx = 0;
  rep(i, N) {
    int x; cin >> x;
    REP(y, x - 1, x + 2) {
      mp[y]++;
      mx = std::max(mx, mp[y]);
    }
  }

  std::cout << mx << std::endl;

  return 0;
}

Measured memory_bytes: 4260
#include <stdio.h>
int main(void){
  int N,i,count=0;
  scanf("%d",&N);
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    if(i % 2 == 0 && a[i] % 2 != 0){
      count++;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1724
m, d = list(map(int, input().split()))
count = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        d1 = j // 10
        d2 = j % 10
        if (d1 >= 2) and (d2 >= 2):
            if i == d1 * d2:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a, c=1;
  c(a);
  while(1){
    if(a>=c*c) c++;
    else{
      co((c-1)*(c-1));
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 2147483647;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

int dy[4]{1,0};
int dx[4]{0,1};

int H,W;
int table[100][100];
int R[100][100];
int B[100][100];
bool dp[100][100][40000];

int main(){
    cin >> H >> W;
    rep(i,H) rep(j,W) cin >> R[i][j];
    rep(i,H) rep(j,W) cin >> B[i][j];
    rep(i,H)rep(j,W) table[i][j] = abs(R[i][j]-B[i][j]);
    dp[0][0][20000+table[0][0]] = true;
    dp[0][0][20000-table[0][0]] = true;
    rep(i,H){
        rep(j,W){
            rep(k,40000){
                if(i){
                    if(dp[i-1][j][k])dp[i][j][k+table[i][j]] = dp[i][j][k-table[i][j]] = true;
                }
                if(j){
                    if(dp[i][j-1][k])dp[i][j][k+table[i][j]] = dp[i][j][k-table[i][j]] = true;
                }
            }
        }
    }
    int ans = 100000000;
    rep(i,40000){
        if(dp[H-1][W-1][i]){
            ans = min((ll)ans,abs(i-20000));
        }
    }
    cout << ans << endl;
}

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

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

    int A, B, C;
    cin >> A >> B >> C;
    if(A + B >= C){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
// A - Can't Wait for Holiday
#include <stdio.h>

int main(void){
    char s[4];
    scanf("%s", s);
    int day=0;
    if(s[0] == 'S'){
        if(s[1] == 'U'){day=7;}
        else{day=1;}
    }else if(s[0] == 'T'){
        if(s[1] == 'U'){day=5;}
        else{day=3;}
    }else if(s[0] == 'M'){day=6;}
    else if(s[0] == 'W'){day=4;}
    else{day=2;}

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

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

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

def main():
    mod=10**9+7
    N,K=MI()
    A=LI()
    if N==1:
        if K%2==0:
            ans=[]
            print(' '.join(map(str, ans)))
        else:
            print(A[0])
    else:
        #有向グラフ
        #i番目からスタートした時，次の週のときにどこからスタートしたものと同様になるか，を追えば良い
        #例えば，12323ならば2週目の最初に1が出たときに実質リセットされるので2323をみるのと同じになる
        #これは結局，次に自分と同じ番号が出てくるところの次，なければループ
        M=2*(10**5)
        L=[[]for _ in range(M+1)]#各数字がどこに出てくるか記録
        
        A=A+A+A
        for i in range(N*3):
            L[A[i]].append(i)
            
        nxt=[0]*(N+1)
        
        import bisect
        for i in range(N-1,-1,-1):
            num=bisect.bisect_right(L[A[i]],i)
            nxt_st=L[A[i]][num]
            if nxt_st>=N:
                if nxt_st==2*N-1:
                    nxt[i]=N
                else:
                    nxt[i]=nxt_st+1-N
            else:
                if nxt_st==N-1:
                    nxt[i]=N
                nxt[i]=nxt[(nxt_st+1)%N]
            # print(A[i])
            # print(L[A[i]])
            # print(num)
            # print(nxt_st)
            # print(nxt[i])
            # print("----")
            
        #nxtがわかればあとはダブリング
        N2=50
        dub=[[0]*(N+1) for _ in range(N2)]#最後に注意．1,2,3で3から始めたら次は無
        for i in range(N):#最後はどうせ０なので無視
            dub[0][i]=i
            dub[1][i]=nxt[i]

        
        for j in range(1,N2-1):
            for i in range(N+1):
                dub[j+1][i]=dub[j][dub[j][i]]
                
        # for j in range(10):
        #     print(dub[j])
        
        st=0
        K-=1#このdubやnxtは，次の時にどこから始まるかなので-1
        for j in range(1,N2):#0の時はいらない
            if K&1:
                st=dub[j][st]
            K=K>>1
            
        if st==N:
            ans=[]
            print(' '.join(map(str, ans)))
        else:

            
            ans=[]
            from collections import defaultdict
            dd = defaultdict(int)
            
            for i in range(st,N):
                if dd[A[i]]:
                    x=-1
                    while x!=A[i]:
                        x=ans.pop()
                        dd[x]=0
                else:
                    ans.append(A[i])
                    dd[A[i]]=1
                    
            print(' '.join(map(str, ans)))
        
    
    
    

main()


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

int main() {
    long long l[87];
    l[0] = 2;
    l[1] = 1;
    for(int i = 0; i < 85; i++) {
        l[i+2] = l[i+1] + l[i];
    }
    int n;
    cin >> n;
    cout << l[n] <<endl;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  "use strict";
	const lines = input.split("\n");
  let nums = lines.map(s => parseInt(s, 10));
  nums.pop()

  const smallest_digit1 = nums.reduce((acc, n) => {
    const x1 = acc%10 || 10;
    const x2 = n%10 || 10;
    return x1 <= x2 ? acc : n
  }, 10);
  let find = false;
  const rest = nums.filter(n => {
    if (n === smallest_digit1  && !find) {
      find = true;
      return false
    }
    return true

  })
  const answer = rest.reduce((acc, n) => {
    return acc + n + ( n%10 === 0 ? 0 : 10 - n%10)
  }, 0) + smallest_digit1;
	//出力
  console.log(answer)
}
// Exec
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
 
int main()
{
   int n;
   cin>>n;
   int k;
   cin>>k;
   int h[n+1];
   for(int i=1;i<=n;i++)
   {
     cin>>h[i];
   }
  int dp[n+1]={INT_MAX};
  for(int i=0;i<(n+1);i++)
  {
    dp[i]=INT_MAX;
  }
  dp[n]=0;
  //cout<<dp[n]<<" ";
  for(int i=n-1;i>=0;i--)
  {
     for(int j=1;((j<=k)&&(i+j<=n));j++)
     dp[i]=min(dp[i+j]+abs(h[i]-h[i+j]),dp[i]);
    //cout<<dp[i]<<" ";
  }
  cout<<dp[1]<<"\n";
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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;
}

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);




ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}


ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //ll N=262144;
  //vll segtree(2*N-1);
  ll h,w;
    cin>>h>>w;
  FOR(i,0,h){
    FOR(j,0,w){
      st s;
        cin>>s;
      if(s=="snuke"){
        char c='A';
        c+=j;
        cout<<c<<i+1<<"\n";
      }
    }
  }
}

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

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

    if (S.length() == 2) {
        cout << S << endl;
    } else {
        for (int i = 2; i >= 0; i--) {
            cout << S[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0;i < n;i++)
using namespace std;
typedef long long ll;
 
int main() {
  int n, x; cin >> n >> x;
  vector<int> l(n);
  vector<int> sum(n + 1);
  rep(i,n){
    cin >> l.at(i);
  }
  rep(i,n){
    sum.at(i + 1) = sum.at(i) + l.at(i);
  }
  int ans = 0;
  rep(i,n + 1){
    if(sum.at(i) <= x){
      ans++;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
//by Top
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 111;
     
using namespace std;

int n, q, a[maxn], dp[maxn], k, mn = inf;
                           
void solve(){
	cin >> n >> k;

    for (int i = 1; i <= n; i++){
    	cin >> a[i];
    	mn = min(mn, a[i]);
    }

    sort(a + 1, a + n + 1);

   	for (int i = mn; i <= k; i++){
   		for (int j = 1; j <= n; j++){
   			if (i - a[j] >= 0){
   				if (dp[i - a[j]] == 0)
   					dp[i] = 1;
   			}
   			else
   				break;
   		}
   	}

   	if (dp[k] == 1)
   		cout << "First";
   	else
   		cout << "Second";
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}


Measured memory_bytes: 1024
#include <iostream>
 
typedef long long int int64;
using namespace std ;
 
int main () {
  int64 K, A, B;
  cin >> K >> A >> B;
 
  if(K-A-1<0){
    cout << K+1 << endl;
    return 0;
  }
 
  if(B-A<3){
    cout << K+1 << endl;
    return 0;
  }
 
  int64 ans = 1;
  ans += A-1;
  if((K-A+1)%2==0){
    ans += (B-A)*((K-A+1)/2);
  }else{
    ans += (B-A)*((K-A+1)/2)+1;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int X;
  cin >> X;
  int amari = X % 100;
  int div = X/100;
  if (div > ((amari-1)/5)){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }


}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a,b,c,x,cout=0;

	scanf("%d %d %d",&a,&b,&c);

	for(x = a; x <= b; x++){

		if(c%x==0){
			cout++;
		}

	}
	printf("%d\n",cout);

	return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  ll ans=0,tmp=0;;
  rep(i,n-1){
    if(a[i]>=a[i+1])tmp++;
    else{
      chmax(ans,tmp);
      tmp=0;
    }
  }
  chmax(ans,tmp);
  cout<<(ans)<<endl;
  
  
  
}


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

long long n, C1, h[200005], dp[200005];
deque<long long> M;
deque<long long> C;

bool bad(int l1, int l2, int l3)
{
    return (C[l3]-C[l1])*(M[l1]-M[l2]) < (C[l2]-C[l1])*(M[l1]-M[l3]);
}

void add(long long m, long long c)
{
	M.push_back(m);
	C.push_back(c);

	while(M.size()>=3 && bad(M.size()-3,M.size()-2,M.size()-1))
	{
		M.erase(M.end()-2);
		C.erase(C.end()-2);
	}
}

long long query(long long x)
{
    while(M.size()>=2) {
        long long now = M[0]*x+C[0], next = M[1]*x+C[1];
        if(next < now) { //if query maximum value then next > now
            M.pop_front();
            C.pop_front();
        }
        else break;
    }

    return M[0]*x + C[0];
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> C1;
    for(int i=1; i<=n; i++) cin >> h[i];

    dp[1] = 0;
    add(-2*h[1], h[1]*h[1]+C1);

    for(int i=2; i<=n; i++) {
        dp[i] = query(h[i]) + h[i]*h[i];
        add(-2*h[i], h[i]*h[i]+C1+dp[i]);
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<vector>

using namespace std;
typedef unsigned long long ll;

class DisjoitSet{
    public:
        vector<ll> rank, p,size;
        DisjoitSet(){}
        DisjoitSet(int n){
            rank.resize(n, 0);
            p.resize(n, 0);
            size.resize(n, 0);
            for (int i = 0; i < n; i++)
            {
                makeSet(i);
            }
        }
        void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
        size[x] = 1;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if (rank[x] > rank[y]){
                p[y] = x;
                size[x] += size[y];
            }
            else
            {
                p[x] = y;
                size[y] += size[x];
                if (rank[x] == rank[y])
                {
                    rank[y]++;
                }
            }
        }
        ll sized(int x)
        {
           int p = findSet(x);
           return size[p];
        }
        int findSet(int x){
            if (x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main(){
    int n, m;
    cin >> n >> m;
    DisjoitSet ds = DisjoitSet(n + 1);
    vector<pair<int, int>> v;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    vector<ll> ans(m+1, 0);
    ans[m] = (ll)n * (n - 1) / 2;
    for (int i = m-1; i > -1 ; i--)
    {
        int a = v[i].first;
        int b = v[i].second;
        if(!ds.same(a,b))
        {
            ans[i] = ans[i + 1] - (ll)ds.sized(a) * (ll)ds.sized(b);
            ds.unite(a, b);
        }
        else
        {
            ans[i] = ans[i + 1];
        }
        
    }
    for (int i = 1; i < m+1; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

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

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

  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  vector<int64_t> cost(n);
  cost[0] = 0;
  cost[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {
    cost[i] = min(cost[i - 2] + abs(h[i] - h[i - 2]), cost[i - 1] + abs(h[i] - h[i - 1]));
  }

  cout << cost[n - 1] << "\n";
  return 0;
}

Measured memory_bytes: 1408
import itertools
N = int(input())
MARCH = [0, 0, 0, 0, 0]
final_ans = 0
for i in range(N):
    a = input()
    if a[0] =='M':
        MARCH[0] += 1
    elif a[0] =='A':
        MARCH[1] += 1
    elif a[0] =='R':
        MARCH[2] += 1
    elif a[0] =='C':
        MARCH[3] += 1
    elif a[0] =='H':
        MARCH[4] += 1

MARCH = list(itertools.combinations(MARCH,3))

for i in MARCH:
    final_ans += i[0]*i[1]*i[2]
print(final_ans)

Measured memory_bytes: 3064
n = int(input())
d,x = map(int, input().split())
a = [0] * n
for i in range(n):
    a[i] = int(input())

eat = 0
for i in range(n):
    for k in range(10**7):
        if 1 + a[i] * k <= d:
            eat += 1
        else:
            break
        
print(x+eat)


Measured memory_bytes: 3060
n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()

sub = 10 ** 9
for i in range(n-k+1):
    hmax = h[i+k-1]
    hmin = h[i]
    sub = min(hmax - hmin, sub)
print(sub)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main()
{
    int n;
    cin>>n;
    ll ans=1;
    ll a[3]={0};
    for(int i=0;i<n;i++)
    {
        ll c;
        cin>>c;
        ll cnt=0;
        for(int j=0;j<3;j++)
        {
            if(a[j]==c)cnt++;
        }
        ans=(ans*cnt)%MOD;
        for(int j=0;j<3;j++)
        {
            if(a[j]==c)
            {
                a[j]++;
                break;
            }
        }
    }
    cout<<ans<<'\n';
}


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

int main(){

    int n,q; cin >> n >> q;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);

    rep(i,q){
        ll x; cin >> x;
        int right = 0;
        ll sum = 0;
        ll ans = 0;

        for(int left = 0; left < n; left++){
            while(right < n && sum + a.at(right) <= x){
                sum += a.at(right);
                right++;
            }
            ans += right - left;
            if(left == right) right++;
            else sum -= a.at(left);
        }
        cout << ans << endl;
    }
    return 0;
}


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

namespace C_ABC130
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            double ans = (double)(s[0]) * (double)(s[1]) / 2;
            int ans2 = 0;
            if(s[2]==(double)s[0]/2&&s[3]==(double)s[1]/2){
                ans2 = 1;
            }
            Console.WriteLine("{0} {1}", ans,ans2);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int c = 0;
    if (s.at(0) == 'o') c++;
    if (s.at(1) == 'o') c++;
    if (s.at(2) == 'o') c++;
    cout << 700 + (100 * c) << endl;
}

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

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int ans = a[0];
    for (int i = 1; i < n; i++) ans = gcd(ans, a[i]);

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C; cin >> A >> B >> C;
    int ans = 0;
    while(C > 0)
    {
        int res = 0;
        if(C >= 7 * A)
        {
            C -= 7 * A + B;
            res += 7;
        }
        else
        {
            res += (C + A - 1) / A;
            C = 0;
        }
        ans += res;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
unsigned long gcd(unsigned long x, unsigned long y){
if(y){ return gcd(y,x%y); }else{ return x; }
}
int main(){
unsigned long A, B, M, ans=1; cin >> A >> B; M=gcd(A,B);
if(M%2==0){ans++; while(M%2==0){M=M/2;}}
for(int i=3; i<=sqrt(M); i+=2){ if(M%i==0){ans++; while(M%i==0){M=M/i;}} }
if(M>1){ ans++; }
cout << ans << "\n";
}

Measured memory_bytes: 256
n, k = map(int, input().split())
count = 0

if k == 0:
    count += n * n

else:
    for b in range(k + 1, n + 1):
        q, r = n // b, n % b
        count += q * (b - k) + max((r + 1 - k), 0)
        
print(count)

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

#include <bits/stdc++.h>

#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl

using namespace std;

class ANextAlphabet {
public:
    void solve(std::istream &in, std::ostream &out) {
        char ch;
        in >> ch;
        out << char(ch + 1);
    }
};


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

    ANextAlphabet solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);

    return 0;
}


Measured memory_bytes: 3560
def main():
    N = int(input())
    S = input()
    ls = []
    for i in range(N-2):
        if S[i]=="A":
            ls.append(i)

    ans = 0
    for i in ls:
        if S[i:i+3]=="ABC":
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

int gettime(const int orders[]) {
  int i = 0;
  int t = 0;
  while (i < 4) {
    int order = orders[i];
    if (order % 10 > 0 ){
      order = (order/10) * 10 + 10;
    }
    t += order;
    i ++;
  }
  t += orders[4];
  return t;
}

int main() {
  int orders[5];
  for (int i = 0; i < 5; i ++) cin >> orders[i];

  sort(orders, orders+5);

  int Min = 1e9;
  do {
    Min = min(Min, gettime(orders));
  } while (next_permutation(orders, orders+5));

  cout << Min << endl;

  return 0;
}



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

struct node {
  int id;
  struct node *next;
};
struct node **list;
int *seq, *art, counter;

void Insert(int, int);
int Biconnected(int);
int main(void)
{
  int i, v, e, s, t;
  scanf("%d %d", &v, &e);
  list = (struct node**)malloc(sizeof(struct node*) * v);
  art = (int*)calloc(v, sizeof(int));
  seq = (int*)calloc(v, sizeof(int));
  for (i = 0; i < v; i++) {
    list[i] = NULL;
  }
  for (i = 0; i < e; i++) {
    scanf("%d %d", &s, &t);
    Insert(s,t);
  }
  Biconnected(0);
  for (i = 0; i < v; i++) {
    if (art[i]) printf("%d\n", i);
    free(list[i]);
  }
  free(list);
  free(seq);
  free(art);
}
void Insert(int a, int b)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->id = a;
  p->next = list[b];
  list[b] = p;
}
int Biconnected(int point)
{
  int min;
  struct node *n;
  counter++;
  seq[point] = counter;
  min = counter;
  for(n = list[point]; n != NULL; n = n->next) {
    if (!seq[n->id]) {
      int m;
      m = Biconnected(n->id);
      if (m < min) min = m;
      if (seq[point] == 1) {
        if (seq[n->id] != 2) {
          art[point] = 1;
        }
      }else {
        if (m >= seq[point]) {
          art[point] = 1;
        }
      }
    } else if (seq[n->id] < min) {
      min = seq[n->id];
    }
  }
  return min;
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int x = c-a;
    int y = d-b;
    for(int i=0; i<x; i++) cout << "R";
    for(int i=0; i<y; i++) cout << "U";
    
    for(int i=0; i<x; i++) cout << "L";
    for(int i=0; i<y; i++) cout << "D";
    
    cout << "D";
    for(int i=0; i<=x; i++) cout << "R";
    for(int i=0; i<=y; i++) cout << "U";
    cout << "L";
    
    cout << "U";
    for(int i=0; i<=x; i++) cout << "L";
    for(int i=0; i<=y; i++) cout << "D";
    cout << "R";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N1=1100;
const int N2=5100;
vi e[N1];
int n,x[N1];
pii best[N1];
vector<vi> dp(N1,vi(N2,0));
bool dfs(int v,int p) {
	int siz=0;
	for(auto a:e[v]) {
		if(a!=p) {
			if(!dfs(a,v)) return 0;
		}
	}
	for(auto a:e[v]) {
		if(a!=p) {
			siz+=best[a].fi+best[a].se;
		}
	}
	dp[v][0]=1;
	for(auto a:e[v]) {
		if(a!=p) {
			per(i,0,x[v]+1) {
				if(dp[v][i]) {
					dp[v][i]=0;
					if(i+best[a].fi<x[v]+1) {
						dp[v][i+best[a].fi]=1;
					}
					if(i+best[a].se<=x[v]) {
						dp[v][i+best[a].se]=1;
					}
				}
			}
		}
	}
	per(i,0,x[v]+1) {
		if(dp[v][i]) {
			best[v].fi=x[v];
			int add=x[v]-i;
			siz+=add;
			best[v].se=siz-x[v];
			//cout<<v<<' '<<best[v].fi<<' '<<best[v].se<<endl;
			return 1;
		}
	}
	return 0;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	rep(i,2,n+1) {
		int a;cin>>a;
		e[a].pb(i);
		e[i].pb(a);
	}
	rep(i,0,n) cin>>x[i+1];
	//cout<<dfs(1,0)<<endl;
	if(dfs(1,0)) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 25656
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    auto n = lread();
    auto a = aryread();
    long x = 3 ^^ n;
    long y = 1;
    foreach (i; 0 .. n)
    {
        if (a[i] % 2 == 0)
        {
            y *= 2;
        }
    }
    writeln(x - y);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3616
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
         
         
         ll a,b,c,k;
         
         cin>>a>>b>>c>>k;
         ll s=0;
         if(k<=a)
         {
               s=k;
         }
         
        else if(k>=a)
         {
               s+=a;
               k-=a;
               
               
               while(k>0&&b>0)
               {
                     b--;
                     k--;
               }
               
               
               while(k>0)
               {
                     s--;
                     k--;
               }
               
               
         }
         


             o(s)



        
	re
}

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

int n,a,b,c,ans=INF;
vector<int> l;
/*方針*/
/*
    l[0]        l[1]       l[2]      l[3]   ......   l[n-1]
  　aに使う     aに使う     aに使う    aに使う         aに使う
  　bに使う     bに使う     bに使う    bに使う　　　　　bに使う
  　cに使う     cに使う     cに使う    cに使う         cに使う
  　使わない    使わない    使わない    使わない        使わない

  上のように竹1本につき、a,b,cに使うか、どこにも使わないという4つの選択肢があるので
  上のパターンを全探索する(dfs) O(4^n)で間に合う
  ただし、a,b,cには少なくとも1本を使わなければならないので、a,b,cのいずれか少なくとも
  1本に対して、使用本数が0となる場合は除く
*/

void dfs(int A,int B,int C,int number,int MP){//A:今のaの長さ　B:今のbの長さ　C:今のcの長さ 
    if(number==n){
        if(!(A==0 || B==0 || C==0)){//少なくとも1本は使わなければならない
            ans=min(ans,MP+abs(A-a)+abs(B-b)+abs(C-c));//MP:合成魔法のMP　abs:長さ調節魔法のMP
        }
        return;
    }
        
    dfs(A+l[number],B,C,number+1,MP+10);//l[number]をaに使う
    dfs(A,B+l[number],C,number+1,MP+10);//l[number]をbに使う
    dfs(A,B,C+l[number],number+1,MP+10);//l[number]をcに使う
    dfs(A,B,C,number+1,MP);//l[number]を使わない
    
    return;
}


int main(){
    cin>>n>>a>>b>>c;//a,b,cの長さの竹を3本作りたい
    l.resize(n);
    for(int i=0;i<n;i++){cin>>l[i];}
    dfs(0,0,0,0,0);

    cout<<ans-30<<endl;
    //最初、必ずA==0 B==0 C==0に対して合成をするが、問題文では無に合成できないので、余計な合成分を除く
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

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

  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }

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

  double ans = v[0];
  for(auto v_: v){
    ans = (ans + v_) / 2;
  }
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;
typedef pair < ll, ll > pl;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)3e5 + 5;
const int mod = (int)1e9 + 7;

int n, x;
int a[MAX_N], b[MAX_N];

ll ans;

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d%d", &n, &x);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        b[i] = a[i];
    }
    ans = infl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++)
            b[j] = min(b[j], a[(j - i + n) % n]);
        ll now = 1ll * i * x;
        for (int j = 0; j < n; j++)
            now += b[j];
        ans = min(ans, now);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=705;
int n,m,ans=2e9,col[N],sum[2];
bool s[N],s2[N],mat[N][N];
void dfs(int u,int p){
	col[u]=p;
	sum[p==1]++;
	for(int i=1;i<=n;i++){
		if(i==u||mat[u][i])continue;
		if(!col[i])dfs(i,-p);
		else if(col[i]==p){
			puts("-1");
			exit(0);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		mat[x][y]=mat[y][x]=1;
	}
	s[0]=1;
	for(int i=1;i<=n;i++){
		if(col[i])continue;
		sum[0]=sum[1]=0;
		dfs(i,1);
		memset(s2,0,sizeof(s2));
		for(int j=0;j<=n;j++){
			s2[j+sum[0]]|=s[j];
			s2[j+sum[1]]|=s[j];
		}
		for(int j=0;j<=n;j++)s[j]=s2[j];
	}
	for(int i=0;i<=n;i++)
		if(s[i])ans=min(ans,i*(i-1)/2+(n-i-1)*(n-i)/2);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    char a, b; cin >> a >> b;
    if ('H' == a and 'H' == b) cout << 'H' << endl;
    if ('H' == a and 'D' == b) cout << 'D' << endl;
    if ('D' == a and 'H' == b) cout << 'D' << endl;
    if ('D' == a and 'D' == b) cout << 'H' << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
	for (;;){
		string first;
		cin >> first;
		if (first == "-"){ break; }
		int m;
		cin >> m;
		for (; m > 0; m--)
		{
			int h;
			cin >> h;
			string a = first.substr(0, h);
			first.erase(first.begin(), first.begin()+h);
			first += a;
		}
		cout << first<<endl;
	}
	return 0;

}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    string s; cin>>s;
    if(s.back()=='s') s+="es";
    else s+="s";
    cout<<s<<endl;

}

Measured memory_bytes: 3648
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
s = list(s)

if len(s)%2 == 1:
	print('No')
	exit()

for i in range(0,len(s)//2,2):
	if s[i] != 'h' or s[i+1] != 'i':
		print('No')
		exit()

print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932384626433832795028841971
using namespace std;

int main(){
    int n,a;
    cin >> n;
    a = 1;
    while(true){
        if(a > n){
            break;
        }
        if(a % 3 == 0){
            cout << " " << a;
        }
        else{
            int tmp = a;
            while(true){
                if(tmp % 10 == 3){
                    cout << " " << a;
                    break;
                }
                
                tmp /= 10;
                
                if(tmp == 0){
                    break;
                }
            }
        }
        a++;
    }
    cout << endl;
    return 0;
}
               

Measured memory_bytes: 1164
import math

# Sieve of Eratosthenes
is_prime = [1] * (10 ** 5)
is_prime[0:2] = 0, 0
for i in range(2, int(math.sqrt(len(is_prime)))):
    if is_prime[i]:
        for j in range(i * 2, len(is_prime), i):
            is_prime[j] = 0

# Similar to 2017
a = [0] * (10 ** 5)
for i in range(1, len(a), 2):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        a[i] = 1

# Cumulative sum
s = [0] * (10 ** 5 + 1)
for i in range(len(a)):
    s[i + 1] = s[i] + a[i]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(s[r + 1] - s[l])

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

#include <utility>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

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

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> hs(H), ws(W);
    set<P> s;  // 爆破対象がある座標
    rep(i, M) {
        int r, c;
        cin >> r >> c;
        r--;
        c--;
        hs[r]++;
        ws[c]++;
        s.emplace(r, c);
    }
    int mh = 0, mw = 0;
    rep(i, H) mh = max(mh, hs[i]);  // 縦向きに爆破対象が置かれている数の最大値
    rep(i, W) mw = max(mw, ws[i]);  // 横向きに爆破対象が置かれている数の最大値
    vector<int> is, js;
    rep(i, H) if (mh == hs[i]) is.push_back(i);  // 最大値の場所
    rep(i, W) if (mw == ws[i]) js.push_back(i);  // 最大値の場所
    int ans = mh + mw;                           // ありえる最大値
    for (int i : is) {
        for (int j : js) {
            if (s.count(P(i, j)))  // 2回数えてしまっているので、ありえる最大値が出せない
                continue;
            cout << ans << endl;  // 最大値が出せる
            return 0;
        }
    }
    // 最大値が出せない
    ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23760
from collections import Counter
from functools import reduce
import bisect
import copy
import fractions
import math
# import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]

n, a = II(), LI()
a_abs = [abs(i) for i in a]
print(sum(a_abs)) if sum(x < 0 for x in a) % 2 == 0 else print(sum(a_abs) - 2 * min(a_abs))


Measured memory_bytes: 16428
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

long long int inf=1e9;

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

    vector<long long int> cost(M, 0);
    vector<pair<long long int, vector<int> > > dp((1<<N), make_pair(inf, vector<int>()));
    dp[0].first=0;
    for(int m=0; m<M; m++) {
        int B;
        cin >> cost[m] >> B;
        long long int Tsum=0;
        for(int b=0; b<B; b++) {
            int T;
            cin >> T;
            Tsum += 1<<(T-1);
        }
        for(int bit=0; bit<(1<<N); bit++) {
            dp[Tsum | bit].first = min(dp[Tsum | bit].first, dp[bit].first+cost[m]);
            
            // bool flag=true;
            // for(int flg=0; flg<N; flg++) {
            //     if(~Tsum&(1<<flg) && bit&(1<<flg)) {
            //         flag=false;
            //         break;
            //     }
            // }
            // if(flag) {
            //     if(dp[bit].first==0) {
            //         // cout << bit << ", " << cost[m] << endl;
            //         dp[bit].first = cost[m];
            //         dp[bit].second = vector<int>(1, m);
            //     } else if(dp[bit].first>cost[m]) {
            //         dp[bit].first = cost[m];
            //         dp[bit].second = vector<int>(1, m);
            //     }
            // }
        }
    }
    // for(int bit=0; bit<(1<<N); bit++) {
    //     cout << bit << ", " << dp[bit].first << endl;
    // }
    
    bool ans_flag=true;
    // for(int bit=3; bit<(1<<N); bit++) {
    //     for(int n=0; n<N; n++) {
    //         if(bit & (1<<n)) {
    //             int cur=bit & ~(1<<n);
    //             if(dp[1<<n].first==0) {
    //                 ans_flag=false;
    //                 break;
    //             } else {
    //                 if(dp[bit].first==0) {
    //                     dp[bit].first = dp[1<<n].first + dp[cur].first;
    //                 } else if (dp[bit].first>dp[1<<n].first+dp[cur].first) {
    //                     dp[bit].first = dp[1<<n].first + dp[cur].first;
    //                 }
    //             }
    //         }
    //     }
    //     if(!ans_flag) break;
    // }
    
    if(dp[(1<<N)-1].first==inf) {
        ans_flag = false;
    }

    if(ans_flag) {
        cout << dp[(1<<N)-1].first << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
    
}

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

int main()
{
  double x1, x2, y1, y2;
  double x_dis, y_dis;

  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  x_dis = x1 - x2;
  y_dis = y1 - y2;

  printf("%lf\n", sqrt(x_dis * x_dis + y_dis * y_dis));

  return 0;
}



Measured memory_bytes: 2108
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, l int
	fmt.Scanf("%d %d", &n, &l)

	var s string
	stringSlice := []string{}
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &s)
		stringSlice = append(stringSlice, s)
	}

	sort.Strings(stringSlice)
	fmt.Println(strings.Join(stringSlice[:], ""))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define INF 1e12
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> v(n+1);
	For(i,0,n) cin>>v[i];
	sort(all(v));
	int g=v[1]-v[0];
	For(i,2,n)
	{
		g=gcd(g,v[i]-v[i-1]);
	}
	cout<<g<<"\n";
	return 0;
}

Measured memory_bytes: 640