akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<LL,LL>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n,m;
    cin >> n >> m;
    LL a[n+5];
    for (LL i=1;i<=n;i++) cin >> a[i];
    LL jump = 1;
    for (LL i=1;i<=n;i++) {
        jump = jump/__gcd(jump, a[i])*a[i];
    }
    // cout << jump << endl;
    for (int i=1;i<=n;i++) {
        if (jump%a[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    LL g = a[1];
    for (LL i=1;i<=n;i++) {
        g = __gcd(g, a[i]);
    }
    // cout << g << endl;
    for (LL i=1;i<=n;i++) {
        a[i]/=g;
    }
    for (LL i=1;i<=n;i++) {
        if (a[i]%2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    LL start = jump/2;
    if (start > m) {
        cout << 0 << endl;
        return 0;
    }
    cout << (m-start)/jump+1 << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 1024
// Bismillahir Rahmanir Rahim  //
// Tanbir Ahmed  << RibNat >>  //
// University of Barisal       //



#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     Pnl             printf("\n")
#define     End             return 0
#define     ll              long long int
#define     Pair            pair<ll,ll>
#define     F               first
#define     S               second
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     Max             1000000000000000014
#define     Min             -1000000000000000014
#define     mod             1000000007
#define     range           10007

#define     pb              push_back
#define     Vector          vector<ll>
#define     mp              make_pair
#define     PI              3.1415926535897
#define     min_heap        priority_queue <ll, vector<ll>, greater<ll> >
#define     ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>  //*(x.find_by_order(k)),x.order_of_key(k)

/*************** #Template FUNCTIONS# **************/

// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
//  ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
 ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
// ll Check(ll n,ll i){return (n&(1LL<<i));}
// ll Set(ll n,ll i){return (n|(1LL<<i));}
// ll status[(ll)range/64+5];Vector primes;void sieve(){for(ll i=3;i<=sqrt(range);i+=2){if(Check(status[i/64],i%64)==0){for(ll j=i*i;j<range;j+=2*i){status[j/64]=Set(status[j/64],j%64);}}}primes.pb(2);for(ll i=3;i<range;i+=2)if(Check(status[i/64],i%64)==0)primes.pb(i);}

// ll dx[] = {-2, -1, 1, 2,  2,  1, -1, -2};
// ll dy[] = { 1,  2, 2, 1, -1, -2, -2, -1};

// ll X[]= {0,0,1,-1,1,1,-1,-1};
// ll Y[]= {1,-1,0,0,1,-1,1,-1};

/********************** START **********************/






int main(){
    // ll t;
    // cin>>t;
    // while(t--){
        string s,p;
        cin>>s>>p;
        string x=p;
        x.pop_back();

        if(x==s){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }

//    }
}






/*******      ALHAMDULILLAH     *********/  
/*******      Happy Coding      *********/


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

int main()
{
    int x;
    std::cin>>x;
    bool res = false;
    if(x>=2000)res = true;
    int shou = x / 100;
    int amari = x % 100;
    if(amari<=shou*5)res = true;
    std::cout<<(res)<<std::endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=((a_%MOD)+MOD)%MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}
modint fc[400010]={1};
modint fct(int n){
    if(fc[n].a) return fc[n];
    return fc[n]=modint(n)*fct(n-1);
}
modint ifc[400010]={1};
modint ifct(int n){
    if(fc[n].a) return ifc[n];
    return ifc[n]=modint(n).inv()*ifct(n-1);
}
void initfct(int n){
    ifct(n);
    ifr(i,n) ifc[i]=ifc[i+1]*(i+1);
}
modint cmb(int n,int r){
    if(n<0||r<0||n<r) return 0;
    return fct(n)*ifct(r)*ifct(n-r);
}

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    modint ans(1),c(n*m);
    ans=modint(6).inv()*(modint(n-1)*n*(n+1)*m*m+modint(m-1)*m*(m+1)*n*n);
    for(int i=3;i<=k;i++){
        ans*=(c-i+1)*modint(i-2).inv();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    int cnt=0;
    int a,b;
    cin >> N;
    for(int i=1;i<N;i++){
      for(int j=1;j*j<=N-i;j++){
         a = (N-i)%j;
         b = (N-i)/j;
        //cout << i <<" "<< j <<" " << (N-i)%j<< endl;
        if(a == 0){
          if(b == j){
            cnt+=1;
          }
          else{
            cnt+=2;
          }
       }
      }
    }

    cout << cnt << endl;
    return 0;
}


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

int digit(int n)
{
    int ret=0;
    while (n>0)
    {
        ret++;
        n/=10;
    }
    return ret;
}
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        if(digit(i)%2)
            ans ++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef deque<int> vi;
const int INF=1<<30;
int DP[1001][9];
int main() {
	int n;
	char s;
	cin >> n;
	DP[0][1]=1;
	FORE(i,1,n){
		cin >>s;
		int master;
		if(s=='J')
		master=1;
		if(s=='O')
		master=2;
		if(s=='I')
		master=4;
		REP(j,8){
		if(j&master)
			REP(k,8)
				if(j&k)
					DP[i][j]+=DP[i-1][k];
		DP[i][j]%=10007;
		}
	}
	int sum=0;
	REP(i,9)
	sum+=DP[n][i];
	cout << sum%10007 << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
int main() {
	int n,m;
	string s;
	string ans="No";
	cin >>n>> s;
	m=s.length()/2;
	if (!(s.length()%2)&&s.substr(0,m)==s.substr(m,2*m))ans="Yes";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
while gets
  n, r = $_.split.map(&:to_i)
  a = gets.split.map(&:to_i)
  deck_a = (n/2...n).to_a
  deck_b = (0...n/2).to_a
  deck_c = Array.new
  r.times do |i|
    deck_c.clear
    c = a.shift
    while !(deck_a.empty? && deck_b.empty?)
      deck_c.concat(deck_a.slice!(0...c))
      deck_c.concat(deck_b.slice!(0...c))
    end
    deck_a = deck_c[n/2...n]
    deck_b = deck_c[0...n/2]
  end
  p deck_c.pop
end

Measured memory_bytes: 9096
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  int n,x[105],ave=0,p=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
    ave+=x[i];
  }
  if((ave*10/n)%10<=5)ave/=n;
  else ave=ave/n+1;
  
  for(int i=0;i<n;i++){
    p+=pow(ave-x[i],2);
  }
  cout<<p<<endl;
  
  return 0;
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

constexpr unsigned ALPH_NUM = 26;

string shift(const string& line, int n);
bool judge(string& word);

int main()
{
    string line;
    while(getline(cin, line)) {
        bool is_solved = false;
        for (auto i = 0; i < ALPH_NUM && !is_solved; i++) {
            string shifted = shift(line, i);

            stringstream ss(shifted);
            string word;
            while (ss >> word) {
                if (judge(word)) {
                    cout << shifted << endl;
                    is_solved = true;
                    break;
                }
            }
        }
    }

    return 0;
}

string shift(const string& line, int n)
{
    string shifted = line;

    for (auto i = 0; i < line.size(); i++) {
        if (line.at(i) >= 'a' && line.at(i) <= 'z') {
            shifted.at(i) = static_cast<char>('a' + (line.at(i) - 'a' + n) % ('z' - 'a' + 1));
        } else {
            shifted.at(i) = line.at(i);
        }
    }

    return shifted;
}

bool judge(string& word)
{
    if (word.at(word.size() - 1) == '.') {
        word.erase(word.end() - 1);
    }

    return ((word == "the" || word == "this" || word == "that")? true: false);
}

Measured memory_bytes: 1200
import heapq
from itertools import permutations
n, m, r = map(int, input().split())
R = list(map(lambda x: int(x)-1, input().split()))
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((c, b))
    edges[b].append((c, a))


def dijkstra(init_v):
    next_v = [(0, init_v)]
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in edges[v]:
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


dists = []
for x in R:
    dist = dijkstra(x)
    dists.append(dist)

INF = 10**18
ans = INF
for subset in permutations(range(r)):
    d = 0
    for v, v2 in zip(subset, subset[1:]):
        d += dists[v][R[v2]]
    if d < ans:
        ans = d

print(ans)


Measured memory_bytes: 12712
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    map<int, int> m;
    for(int i = 0; i < N; ++i) {
        m[a[i]]++;
    }
    int ret = 0;
    for(int i = 0; i < 99998; ++i) {
        ret = max(ret, m[i] + m[i+1] + m[i+2]);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5376
/*1 1 1??§?????????????????????????????£???*/
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int dy[8] = {0, 1, -1, 0, 1, -1, 1, -1};

int a, d, n;

void slove(void){
	int cnt = 0;
	int now = a;

	while(cnt != n){
		bool flag = true;//?´???°?????????????????????flag
		for (int i = 2; i * i <= now ; ++i){
			if (now % i == 0){
				flag = false;//?´???°??§?????????
				break;
			}
		}
		/*1????´???°??§???????????????????´???°????????§???1???true??¨????????????????????§???now != 1???????????????*/
		if (flag == true && now != 1) cnt++;//?´???°??????
		now += d;//????????°???????????????
	}

	printf("%d\n", now - d);//?????????+d??????????????£???????????§????????????????????????
	return;
}

int main(void){
	rep(i, 1000){
		scanf("%d %d %d", &a, &d, &n);
		if (a == 0) break;
		slove();
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define bg begin()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)

int main(){
	string s,t; cin>>s>>t;
	set<string> se;
	ll S=sz(s),T=sz(t);
	if(S<T) cout<<"UNRESTORABLE";
	else{
		for(int i=S-T;i>=0;i--){//tの始点(s上)
			bool c=true;
			rep(j,T){
				if(s[i+j]=='?') continue;
				else if(s[i+j]==t[j]) continue;
				else c=false;
			}
			if(c){
				string tmp="";
				rep(j,i){
					if(s[j]=='?') tmp+="a";
					else tmp+=s[j];
				}
				tmp+=t;
				FOR(j,i+T,S){
					if(s[j]=='?') tmp+="a";
					else tmp+=s[j];
				}
				se.insert(tmp);
			}
		}
		if(se.empty()) cout<<"UNRESTORABLE";
		else cout<<*se.bg;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
   int n;
   cin>>n;
   int a[n+1];
   int b[n+1];
   int su=0;
   rep1(i,n){
       cin>>a[i];
       b[i]=0;
   }
   for (int i=n; i>0; --i){
       int p=2;
       int co = a[i];
       while (i*p<=n){
           co+=b[i*p];
           p++;
       }
       if (co%2==1){
           b[i]=1;
           su++;
       }
       
   }
   if (su==0){
       cout<<0<<endl;
   }
   else{
        cout<<su<<endl;
        rep1(i,n){
            if (b[i]==1){
                cout<<i;
                cout<<" ";
            }
        }
        cout<<endl;
   }
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main()
{

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dis;
    dis = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    printf("%f10\n",dis);

}


Measured memory_bytes: 3204
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

A=[]
for _ in range(H):
    A.append(list(input()))

dp=[[0 for j in range(W+1)] for i in range(H+1)]
dp[1][1]=1

for h in range(H):
    for w in range(W):
        if A[h][w]==".":
            dp[h+1][w+1]+=dp[h][w+1]+dp[h+1][w]
            dp[h+1][w+1]%=(10**9+7)

print(dp[-1][-1])





Measured memory_bytes: 52468
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const int BIG = 998244353;





int main() {

	int N;
	cin >> N;

	int d[200000];

	for (int i = 1; i <= N; i++) { cin >> d[i]; }

	sort(d + 1, d + N + 1);

	cout << d[N / 2 + 1] - d[N / 2];


	

	system("PAUSE");
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int dp[100010];

int main() {
	int N, K; cin >> N >> K;
	vector<int> H(N);
	rep(i, N) cin >> H[i];

	rep(i, 100010) dp[i] = INF;
	dp[0] = 0;

	// dp[足場i] 足場iまで辿り着くための最小コスト
	// dp[i+j] = min(dp[i]+abs(H[i+j]-H[i]))

	// FOR(j, 1, K+1) で、1, 2, ... , K個前の足場から跳んできたときのコストを見る
	rep(i, N) FOR(j, 1, K+1) {
		if (i-j>=0) dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]));
	}

	// 最初は足場1に居るので（1-indexed）、N-1を出力
	cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=5000;
const int MAXM=200;

int n,m;
int d[MAXN-1];
int x[MAXN][MAXM];

int stck[MAXM][MAXN],nstck[MAXM];

ll sval[4*MAXN];
ll slazy[4*MAXN];
void smod(int x,int l,int r,int L,int R,ll BY) {
	if(L<=l&&r<=R) {
		sval[x]+=BY;
		slazy[x]+=BY;
	} else {
		int m=l+(r-l)/2;
		if(L<=m) smod(2*x+1,l,m,L,R,BY);
		if(m+1<=R) smod(2*x+2,m+1,r,L,R,BY);
		sval[x]=slazy[x]+max(sval[2*x+1],sval[2*x+2]);
	}
	//printf("smod(%d..%d,%d..%d,%lld) -> %lld\n",l,r,L,R,BY,sval[x]);
}

void run() {
	scanf("%d%d",&n,&m);
	REP(i,n-1) scanf("%d",&d[i]);
	REP(i,n) REP(j,m) scanf("%d",&x[i][j]);
	//n=MAXN,m=MAXM; REP(i,n-1) d[i]=rand(); REP(i,n) REP(j,m) x[i][j]=rand();

	ll ret=0;
	REP(k,m) nstck[k]=0;
	memset(sval,0,sizeof(sval)); memset(slazy,0,sizeof(slazy));
	REP(i,n) {
		REP(k,m) {
			int was=0;
			while(nstck[k]>0) {
				int j=stck[k][nstck[k]-1];
				if(x[j][k]>x[i][k]) {
					smod(0,0,n-1,0,j,-(x[i][k]-was));
					break;
				} else {
					smod(0,0,n-1,0,j,-(x[j][k]-was));
					was=x[j][k];
					--nstck[k];
				}
			}
			stck[k][nstck[k]++]=i;
		}
		ll only=0; REP(k,m) only+=x[i][k]; smod(0,0,n-1,0,i,+only);
		ll cur=sval[0];
		if(cur>ret) ret=cur;
		if(i!=n-1) smod(0,0,n-1,0,i,-d[i]);
	}
	printf("%lld\n",ret);
}

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


Measured memory_bytes: 5248
N = int(input())
ls = list(map(int,input().split()))
i = 0
ls[0] -= 1
while i < N-1:
    if ls[i] < ls[i+1]:
        ls[i+1] -= 1
    if ls[i] > ls[i+1]:
        print("No")
        exit(0)
    i += 1
print("Yes")

Measured memory_bytes: 14396
#include<stdio.h>

//選択ソート
int selectionSort(int N, int A[]) {
    
    int i, j, min, cnt = 0, tmp;
    
    for (i = 0; i < N - 1; i++) {
        
        min = i;
        
        //最小値の位置決定
        for (j = i; j < N; j++){
            if (A[j] < A[min]) min = j;
        }
        
        tmp = A[i];
        A[i] = A[min];
        A[min] = tmp;
        
        if (i != min) cnt++;
    }
    return cnt;
}

int main(void) {
    int cnt, N, A[100];
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    
    cnt = selectionSort(N, A);
    
    for (int i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    
    printf("\n");
    printf("%d\n", cnt);

}
    


Measured memory_bytes: 2088
def dfs(v):
    visited[v] = True
    for v2 in range(N):
        if graph[v][v2] == False:
            continue
        if visited[v2] == True:
            continue
        dfs(v2)

global N, M, graph, visited
N, M = [int(i) for i in input().split()]
graph = [[False for _ in range(50)] for _ in range(50)]
visited = [False for _ in range(50)] 
a = [0 for _ in range(50)]
b = [0 for _ in range(50)]
for i in range(M):
    a[i], b[i] = [int(i) for i in input().split()]
    a[i] -= 1
    b[i] -= 1
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = True
    
ans = 0
for i in range(M):
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = False
    for j in range(N):
        visited[j] = False
    dfs(0)

    bridge = False
    for j in range(N):
        if visited[j] == False:
            bridge = True
    if bridge:
        ans += 1
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = True
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

        int N = scanner.nextInt();

        int[] counts = new int[100 + 1];

        for (int i = 0; i < N; i++) {
            counts[scanner.nextInt()]++;
        }

        int numUniqueNumbers = 0;
        for (int i = 1; i <= 100; i++) {
            if (counts[i] > 0) {
                numUniqueNumbers++;
            }
        }

        System.out.println(numUniqueNumbers);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
    int N;
    char s[10000];
    int i=0;
    scanf("%d", &N);
    scanf("%s", s);
    while(s[i]!='\0'){
        s[i]=(((s[i]-65)+N)%26)+65;
        i++;
    }

    printf("%s", s);
    return 0;

}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        int K = scan.nextInt();

        int[][] ar = new int[H][W];
        int[][] sum = new int[H+1][W];

        //read the value
        for (int i = 0; i < ar.length; i++) {
            String v = scan.next();
            for (int j = 0; j < v.length(); j++) {
                ar[i][j] = v.charAt(j) - '0';
            }
        }

        //calculate sum
        for (int i = 1; i <= H; i++) {
            for (int j = 0; j < W; j++) {
                sum[i][j] += sum[i-1][j] + ar[i-1][j];
            }
        }

        int ans = Integer.MAX_VALUE;
        //find the state and do the seperation
        loop:
        for (int i = 0; i < (1 << H - 1); i++) {

            //create all the seperations
            ArrayList<Integer> sep = new ArrayList<>();
            sep.add(0);
            for (int j = 0; j < H; j++) {
                if( (i & (1 << j)) != 0 ){
                    sep.add(j+1);
                }
            }
            sep.add(H);


            int count = Integer.bitCount(i); // count of all the horizontal lines

            int[] whites = new int[sep.size()-1];
            for (int j = 0; j < W; j++) {
                boolean sup = false;
                for (int k = 0; k < sep.size()-1; k++) {
                    if(whites[k] + sum[sep.get(k+1)][j] - sum[sep.get(k)][j] > K){
                        sup = true;
                    }
                }

                for (int k = 0; k < sep.size() - 1; k++) {
                    if(!sup){
                        whites[k] += sum[sep.get(k+1)][j] - sum[sep.get(k)][j];
                    }else{
                        whites[k] = sum[sep.get(k+1)][j] - sum[sep.get(k)][j];
                        if(whites[k] > K){
                            continue loop;
                        }
                    }
                }

                if(sup){
                    count++;
                }
            }

            ans = Math.min(ans,count);
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 26764
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string noteStr[] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
    map<string, int> noteMap;
    for(int i=0;i<12;i++){
        noteMap[noteStr[i]] = i;
    }

    int dN;
    cin >> dN;
    for(int di=0;di<dN;di++){
        int n, m;
        cin >> n >> m;
        vec stairs(n);
        for(int i=0;i<n;i++){
            string str;
            cin >> str;
            stairs[i] = noteMap[str];
        }
        vec music(m);
        for(int i=0;i<m;i++){
            string str;
            cin >> str;
            music[i] = noteMap[str];
        }

        bool able = false;
        for(int i=0;i<2;i++){
            int sv = n-1-i, mv = m - 1;
            while(sv>=0&&mv>=0){
                if(stairs[sv] == music[mv]){
                    sv -= 1;
                }else if(stairs[sv]+1 == music[mv] || (stairs[sv]==11&&music[mv]==0)){
                    sv -= 2;
                }else if(stairs[sv]-1 == music[mv] || (stairs[sv]==0&&music[mv]==11)){
                    if(sv==n-1)break;
                    sv += 1;
                }else{
                    break;
                }
                mv--;
            }
            if(sv==-1&&mv==-1){
                able = true;
                break;
            }
        }
        if(able) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1600
n,q = map(int,input().split())
s = input()
l = []
for i in range(q):
    l.append(tuple(map(int,input().split())))
x = [0]*n
a = 0
flag = False
for i in range(n):
    if s[i] == 'A':
        flag = True
    elif s[i] == 'C' and flag:
        a += 1
        flag = False
    else:
        flag = False
    x[i] = a
for i in range(q):
    print(x[l[i][1]-1]-x[l[i][0]-1])

Measured memory_bytes: 67160
/*input
16 4 3
ooxxoxoxxxoxoxxo
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld n,k,c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	vi v;
	rep(i,0,s.size()){
		if(s[i]=='o'){
			v.pb(i);
		}
	}
	lld cnt2[n+2],cnt[n+2];
	rep(i,0,n+2){
		cnt[i]=0;
		cnt2[i]=0;
	}
	rep(i,0,s.size()){
		if(s[i]=='o'){
			cnt[i]=1;
			cnt2[i]=1;
		}
	}
	rep(i,1,n){
		if(i-c-1>=0)
			cnt[i]+=cnt[i-c-1];
		cnt[i]=max(cnt[i],cnt[i-1]);
	}
	rrep(i,n-1,0){
		if(i+c+1<=n){
			cnt2[i]+=cnt2[i+c+1];
		}
		cnt2[i]=max(cnt2[i],cnt2[i+1]);
	}
	set <lld> s2;
	for(auto i:v){
		lld t=i;
		lld t2=0;
		lld t3=0;
		if(i-1>=0){
			t2=cnt[i-1];
		}
		if(i+1<=n){
			t3=cnt2[i+1];
		}
		if(t2+t3==k-1){
			s2.insert(i);
		}
	}
	for(auto i:s2){
		cout << i+1 << endl;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 15752
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int mx = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            if (map.containsKey(s)) {
                map.put(s, map.get(s) + 1);
            } else {
                map.put(s, 1);
            }
            mx = Math.max(mx, map.get(s));
        }

        final int max = mx;
        new ArrayList<>(map.entrySet())
                .stream()
                .filter(e -> e.getValue() == max)
                .sorted(Comparator.comparing(Map.Entry::getKey))
                .map(e -> e.getKey())
                .forEach(System.out::println);

        sc.close();

    }

}

Measured memory_bytes: 82964
#include<iostream>
using namespace std;
int main()
{
    char a;
    cin>>a;
    if(a=='S')
    {
        cout<<"Cloudy\n";
    }
    else if(a=='C')
    {
        cout<<"Rainy\n";
    }
    else
    {
        cout<<"Sunny\n";
    }
return 0;
}

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

namespace competition
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long sum = 0;
            for (int i = 1; i <= N; i++)
            {
            if (i%3!=0 && i%5!=0)
                {
                    sum = sum + i;
                }
            }
            Console.WriteLine(sum);
        }
            
                
             

        
    }
}


Measured memory_bytes: 27536
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
using namespace std;
 
int main(){
  while(true){
    int n;
    cin >> n;
    if(!n)break;
    vector<int> line(n);
    REP(i,n){
      int tmp;
      cin >> tmp;
      line[i] = tmp;
    }
    string s;
    cin >> s;
    int line_i;
    REP(i,s.size()){
       
      if(i >= n)line_i = i % n;
      else line_i = i;
      if(s[i] - line[line_i] - 'a' < -26 && s[i] >= 'a')
    s[i] = 'z' + 1 + (s[i] - line[line_i] + 26 - 'a');
      else if(s[i] - line[line_i] - 'A' < -26 && s[i] >= 'A'){
    s[i] = 'Z' + 1 +  (s[i] - line[line_i] + 26 - 'A');
      }else if(s[i] - line[line_i]  < 'a' && s[i] >= 'a'){
    s[i] = 'Z' + 1 + (s[i] -line[line_i] - 'a');
      }else if(s[i] - line[line_i] < 'A' && s[i] >='A'){
    s[i] = 'z' + 1  + (s[i] - line[line_i] - 'A');
      }else{
    s[i] = s[i] - line[line_i];
      }
    }
     
    cout << s <<endl;
  }
 
  return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  int ans=0;
  double d=100000000;
  for(int i=0;i<N;i++){
    double x=T-H.at(i)*0.006;
    if(min(abs(A-d),abs(A-x))==abs(A-x)){
      ans=i+1;
      d=x;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    unsigned long long cnt=0;
    for(int i=0;i<(n-k);i++) cnt+=arr[i];
    cout<<cnt;
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(){
	int s[105];
	int min=1000000001,max=0;
	int n;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)
	{
		scanf("%d",&s[i]);
		if(max<s[i])
		{
			max=s[i];
		}
		
		if(min>s[i])
		{
			min=s[i];
		}
	}
	printf("%d",max-min);
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,n) for(ll i=a;i<n;i++)
using namespace std;

int main()
{
    boost
   /* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
     ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll p[a], q[b];
    vector<ll> r(c);
    loop(i, 0, a)cin >> p[i];
    loop(j, 0, b)cin >> q[j];
    loop(i, 0, c)cin >> r[i];
    sort(p, p + a);
    sort(q, q + b);
    sort(r.begin(), r.end());
    ll ans = 0;
    vector<ll> v1;
    ll i = a - 1, j = x;
    while (j > 0 and i >= 0) {
        v1.push_back(p[i]);
        i--; j--;
    }

    if (j > 0) {
        i = c - 1;
        while (j > 0 and i >= 0) {
            v1.push_back(r[i]);
            r.pop_back(); i--, j--;
            c--;
        }
    }
    i = b - 1; j = y;
    while (j > 0 and i >= 0) {
        v1.push_back(q[i]);
        i--;
        j--;
    }
    if (j > 0) {
        i = c - 1;
        while (j > 0 and i >= 0) {
            v1.push_back(r[i]);
            r.pop_back(); i--; j--;

            c--;
        }
    }
    if (v1.size() < x + y) {
        i = c - 1;
        
        while (v1.size() < x + y and i >= 0)
        {
            v1.push_back(r[i]);
            i--;

        }
    }
    sort(v1.begin(), v1.end());

    sort(r.begin(), r.end());
    ll  k = 0;
    j = 0;
    if (r.size() > 0) {
        i = r.size() - 1;
        j = 0;
        while (i >= 0 and v1[j] < r[i]) {
            ans += r[i];
            i--;
            j++;
        }
    }
    for (i = j; i < v1.size(); i++)ans += v1[i];
    cout << ans;
   //for(int g:v1)cout<<g<<" ";


    return 0;
}


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

c = [0] * n
for _ in range(m):
    a, b = map(int, input().split())
    c[a-1] += 1
    c[b-1] += 1

for i in range(n):
    if c[i] % 2 == 1:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 3828
def main():

    A = input()
    n = len(A)
    ans = 1 + n*(n-1)//2 # +1 for unflipped case
    count = dict()
    for c in A:
        count[c] = count.get(c, 0) + 1
    for c in count:
        ans -= count[c] * (count[c] - 1) //2
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3500
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  vector<int> abc(3);
  REP(3) cin >> abc[i];

  int k;
  cin >> k;

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

  REP(k) {
    abc[2] *= 2;
  }
  
  cout << (abc[0] + abc[1] + abc[2]) << endl;

  return 0;
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

cnt = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in lr:
    cnt[l][r] += 1

acc = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(n):
        tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]
        acc[i + 1][j + 1] = tmp + cnt[i + 1][j + 1]

for p, q in pq:
    p -= 1
    ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]
    print(ans)


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

int main(){
  int n, sum = 0;
  cin >> n;
  int l[2 * n];
  for(int i = 0; i < 2 * n; i++) cin >> l[i];
  sort(l, l + 2 * n);
  for(int i = 0; i < 2 * n; i += 2) sum += l[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
def f(n)
  if n.even? then return n/2 end
  3*n+1
end

s = gets.to_i
a = [s]
an = 0
i = 2
  
while true
  an = f(a.last)
  if a.include?(an)
    puts i
    break
  end
  i+=1
  a.push an
end


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

const int mod = 1e9 + 7;
const int maxn = 55;
char nn[maxn][maxn];
char mm[maxn][maxn];
int n, m;


int main(){
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> nn[i];
	for (int j = 0; j < m; ++j)
		cin >> mm[j];

	for (int i = 0; i < n-m+1; ++i)
	for (int j = 0; j < n-m+1;++j)
	if (nn[i][j] == mm[0][0]){
		bool flag = 0;
		for (int k = 0; k < m; ++k){
			for (int h = 0; h < m; ++h)
			if (nn[i + k][j + h] != mm[k][h]){
				flag = 1; break;
			}
			if (flag)break;
		}
		if (!flag){ cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>

using namespace std;


int a[105];

int main() {
	int n,s=0,i;
	cin>>n;
	for(i=1;i<=n;i++) {
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(i=n;i>1;i-=2) {
		s+=a[i]-a[i-1];
	}
	if(n&1)	{
		s+=a[1];
	}
	cout<<s;
}

Measured memory_bytes: 256
m = int(input())

class Node:
    def __init__(self, key, left ,right):
        self.key = key
        self.left = left
        self.right = right


class BinaryTree():
    def __init__(self):
        self.root = None

    def getRoot(self):
        return self.root
    def setRoot(self, v):
        self.root = v

    def inorder(self, v=None):
        if v is None:
            v = self.root
        if v.left is not None:
            self.inorder(v.left)
        print(' ' + str(v.key), end='')
        if v.right is not None:
            self.inorder(v.right)
        
    def preorder(self, v=None):
        if v is None:
            v = self.root
        print(' ' + str(v.key), end='')
        if v.left is not None:
            self.preorder(v.left)
        if v.right is not None:
            self.preorder(v.right)

def insert(T, z):
    y = None
    x = T.getRoot()
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.p = y

    if y is None:
        T.setRoot(z)
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(T, k):
    x = T.getRoot()
    while x is not None:
        if x.key == k:
            print('yes')
            return
        elif x.key < k:
            x = x.right
        else:
            x = x.left
    print('no')


T = BinaryTree()

for i in range(m):
    inp = input().split()
    if inp[0] == 'print':
        T.inorder()
        print()
        T.preorder()
        print()
    elif inp[0] == 'find':
        find(T, int(inp[1]))
    else:
        v = Node(int(inp[1]), None, None)
        insert(T, v)

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

typedef long long int LL;

int main()
{
	LL k;
	static LL  group[100000+10];
	LL small=2, bic=3;

	LL i;

	cin >> k;

	for (i = 1; i <= k; i++)
	{
		cin >> group[i];
	}
	if (group[k] != 2)
	{
		k = 0;
	}

	for (i = k - 1; i >= 1; i--)
	{
		if (group[i] >= small)
		{
			if (group[i] > bic)
			{
				break;
			}

			small = group[i];
			bic = group[i] * (bic / group[i]) + group[i] - 1;
		}
		else
		{
			if (small % group[i] != 0)
			{
				if (group[i]*(small/group[i]+1) > bic)
				{
					break;
				}
				small = group[i] * (small / group[i] + 1);
			}

			bic = group[i] * (bic / group[i]) + group[i] - 1;

		}

		//cout << "A";
		//cout << small << " " << bic << endl;

	}
	if (i == 0)
	{
		cout << small << " " << bic << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        long ans = 0;
        for(int i=1;i<=n;++i){
            if(i%15==0||i%3==0||i%5==0)continue;
            ans+=i;
        }
        System.out.println(ans);
    }
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  if (n == 1) {
    cout << "Yes" << endl;
  } else {
    for (int i = n - 2; i >= 0; i--) {
      // if ((h[i] - h[i + 1]) >= 2) {
      //   cout << "No" << endl;
      //   return 0;
      // }
      if (h[i] > h[i + 1]) {
        h[i]--;
      }
    }
    // debug
    // for (int i = 0; i < n; i++) {
    //   printf("%d ", h[i]);
    // }
    // printf("\n");
    for (int i = 0; i < n - 1; i++) {
      if (h[i] > h[i + 1]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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 int MOD = 1000000007;
long long ruijo(int x, int n) {
    long long res = 1;
    rep(i, 0, n) { res *= x; }
    return res;
}
//約数を列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}
int main() {
    long long N, M;
    cin >> N >> M;
    long long fl[1010][3];
    rep(i, 0, N) { cin >> fl[i][0] >> fl[i][1] >> fl[i][2]; }
    long long res = 0;
    rep(a, 0, 2) {
        rep(b, 0, 2) {
            rep(c, 0, 2) {
                vector<long long> sum;
                rep(i, 0, N) {
                    long long x=fl[i][0];
                    long long y=fl[i][1];
                    long long z=fl[i][2];
                    if(a == 1) {
                        x = -x;
                    }
                    if(b == 1) {
                        y = -y;
                    }
                    if(c == 1) {
                        z = -z;
                    }
                    sum.push_back(x + y + z);
                }
                sort(sum.begin(), sum.end(), greater<long long>());
                long long Msum = 0;
                rep(i, 0, M) { Msum += sum[i]; }
                chmax(res, Msum);
            }
        }
    }

    cout << res << endl;
}

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


#define long long long int

using namespace std;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int, int> pi;


int main() {
    std::ios_base::sync_with_stdio(false);

    string s;

    cin >> s;

    map<string, int> m{{"SUN", 7},
                       {"MON",  6},
                       {"TUE",  5},
                       {"WED",  4},
                       {"THU",  3},
                       {"FRI",  2},
                       {"SAT",  1}};

    cout << m[s];
    return 0;
}

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


using namespace std;
using LLint = long long int;

LLint ModPow(LLint j,LLint k,LLint l){
	//(j^k)/mod l を計算
	if(k==0) return 1%l;
	else if(k%2==0){
		LLint t=ModPow(j,k/2,l);//k/2乗したもの
		return t*t%l;
	}
	else return (j%l)*ModPow(j,k-1,l)%l;
}

LLint Combi(LLint a,LLint b,LLint M){
	LLint UP,DOWN;
	UP=DOWN=1;
	for(int i=0;i<b;++i){
		UP = UP*((a-i)%M)%M;
		DOWN = DOWN*((i+1)%M)%M;
	}
	return (UP*ModPow(DOWN,M-2,M))%M;
}



const LLint Mod = 1000000007;

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	LLint ALL = ModPow(2,n,Mod);

	LLint A;
	A=Combi(n,a,Mod);

	LLint B;
	B=Combi(n,b,Mod);

	cout<< (((ALL-1-A-B)%Mod)+Mod)%Mod<<endl;

	return 0;
}


Measured memory_bytes: 256