akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,b) for(int i=1;i<=b;i++)
#define drep(i,b) for(int i=b;i>=1;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pr pair<int,int>
#define ff first
#define ss second
#define int long long
#define endl '\n'
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,k,t,x,y,z;

vector<int> ve[N];

void bfs() {
    queue<int> que;
    vector<int> fa(n+1);
    que.push(1);fa[1]=1;
    while(!que.empty()) {
        int u=que.front();
        que.pop();
        for(int v:ve[u]) {
            if(!fa[v]) fa[v]=u,que.push(v);
        }
    }
    rep(i,n) if(!fa[i]) {
        cout<<"No"<<endl;
        return ;
    }
    cout<<"Yes"<<endl;
    rep(i,n) if(i>1) cout<<fa[i]<<endl;
}

void solve(int ans=0) {
    cin>>n>>m;
    rep(i,m) {
        cin>>x>>y;
        ve[x].push_back(y);
        ve[y].push_back(x);
    }
    bfs();
}

#undef int
int main() {
    ios::sync_with_stdio(false);
    //int T;cin>>T;
    //while(T--)
        solve();
}


Measured memory_bytes: 15404
n = int(input())
s = []
for i in range(n):
    s.append(input())

dictS = {}
for new_st in s:
    new_st = "".join(sorted([x for x in new_st]))
    if new_st in dictS:
        dictS[new_st] += 1
    else:
        dictS[new_st] = 1

ans = sum([int(x * (x - 1) / 2) for x in dictS.values()])
print(ans)

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

int main() {
  int x;
  int i = 1;
  while (1) {
    cin >> x;
    if (x == 0) {
      break;
    }
    cout << "Case " << i << ": " << x << endl;
    i++;
  }
  return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;

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

    map<char, int> m[55];
    rep(i,n){
        string s;
        cin >> s;
        rep(j,s.size()){
            m[i][s[j]]++;
        }
    }

    rep(i,'z' - 'a' + 1){
        int mini = INF;
        rep(j,n){
            mini = min(m[j][i + 'a'], mini);
        }
        rep(j,mini){
            cout << static_cast<char>('a' + i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
def solve():
    from heapq import heappush, heappop
    from sys import stdin
    f_i = stdin
    
    while True:
        c, n, m, s, d = map(int, f_i.readline().split())
        if c == 0:
            break
        s -= 1
        d -= 1
        
        adj = [[] for i in range(n)]
        for i in range(m):
            a, b, f = map(int, f_i.readline().split())
            a -= 1
            b -= 1
            adj[a].append((b, f))
            adj[b].append((a, f))
        
        # Dijkstra's algorithm
        fare = [[1000000] * (c + 1) for i in range(n)]
        fare[s][c] = 0
        hq = [(0, s, c)]
        while hq:
            f1, u, rc = heappop(hq) # rc: number of remaining coupons
            
            if u == d:
                print(f1)
                break
            
            for v, f2 in adj[u]:
                f3 = f1 + f2
                if f3 < fare[v][rc]: # not using coupon
                    fare[v][rc] = f3
                    heappush(hq, (f3, v, rc))
                f4 = f1 + f2 // 2
                if rc and f4 < fare[v][rc-1]: # using coupon
                    fare[v][rc-1] = f4
                    heappush(hq, (f4, v, rc - 1))

solve()


Measured memory_bytes: 5828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int H,W;
    cin >> H >> W;
    ve<vi> A(H,vi(W,0)),B(H,vi(W,0)),C(H,vi(W,0));
    rep(i,H) rep(j,W) cin >> A[i][j];
    rep(i,H) rep(j,W) cin >> B[i][j];
    rep(i,H) rep(j,W) C[i][j] = abs(A[i][j]-B[i][j]);
    int s = 12900;
    ve<ve<ve<bool>>> F(H,ve<ve<bool>>(W,ve<bool>(s+1,false)));
    
    F[0][0][C[0][0]] = true;
    
    
    reps(i,1,H){
        rep(j,s+1){
            if(F[i-1][0][j]){
                if(abs(j-C[i][0]) <= s) F[i][0][abs(j-C[i][0])] = true;
                if(j+C[i][0] <= s) F[i][0][j+C[i][0]] = true;
            }
        }
    }
    reps(i,1,W){
        rep(j,s+1){
            if(F[0][i-1][j]){
                if(abs(j-C[0][i]) <= s) F[0][i][abs(j-C[0][i])] = true;
                if(j+C[0][i] <= s) F[0][i][j+C[0][i]] = true;
            }
        }
    }
    reps(i,1,H){
        reps(j,1,W){
            
            rep(k,s+1){
                if(F[i-1][j][k]){
                    if(abs(k-C[i][j]) <= s) F[i][j][abs(k-C[i][j])] = true;
                    if(k+C[i][j] <= s) F[i][j][k+C[i][j]] = true;
                }
                if(F[i][j-1][k]){
                    if(abs(k-C[i][j]) <= s) F[i][j][abs(k-C[i][j])] = true;
                    if(k+C[i][j] <= s) F[i][j][k+C[i][j]] = true;
                }
            }

            
        }
    }
    
    
    rep(k,s+1){
        
        if(F[H-1][W-1][k]){
            out(k);
            return 0;
        }
    }
    
    

    return 0;
}


Measured memory_bytes: 10880
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
#define INF 10000000000;

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N+1), C(N+1);
  H[0] = 0;
  C[1] = 0;
  for(ll i=1; i<N+1; ++i){
    cin >> H[i];
  }

  for(ll i=2; i<N+1; ++i) {
    ll m = INF;
    for(ll j=1; j<min(K+1, i); ++j) { m = min<ll>(C[i-j]+abs(H[i-j]-H[i]), m); }
    C[i] = m;
  }

  cout << C[N] << endl;

  return 0;
}

Measured memory_bytes: 1792
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
def cal(y,x,datum,height):
  return max(height-(abs(y-datum[1])+abs(x-datum[0])),0)==datum[2]
for i in range(101):
  for j in range(101):
    height=abs(i-data[0][1])+abs(j-data[0][0])+data[0][2]
    flag=0
    for k in data[1:]:
      if not cal(i,j,k,height):
        flag=1
        break
    if flag:pass
    else:print(j,i,height);exit()


Measured memory_bytes: 42732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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


  int n;
  cin >> n;
  pair<string,ll> s[n];
  
  rep(i,n){
    string t;
    int time;
    cin >> t >> time;
    s[i] = mp(t,time);
  }
  string st;
  cin >> st;
  ll ans=0;
  
  bool ok=false;
  rep(i,n){
    if(ok){
      ans += s[i].second;
    }
    if(!ok){
      if(s[i].first==st) ok=true;
    }
    
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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

//////////////////////////////////////////////////

int main() {
    ll n, p; cin >> n >> p;
    if (n==1) {
        cout << p << endl;
        return 0;
    }
    // 素因数分解
    map<ll, ll> m;
    auto prime_factrize = [&](ll a) -> void {
        for (ll i = 2; i*i <= a; i++)
        {
            if (a%i != 0) continue;
            ll cnt = 0;
            while (a%i == 0) {
                cnt++;
                a /= i;
            }
            m[i] += cnt;
        }
        if (a > 1) m[a]++;
    };

    prime_factrize(p);
    ll ans = 1;
    for (auto v : m) {
        while (v.second >= n) {
            ans *= v.first;
            v.second -= n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
	N = int(input())
	dp = [False]*(101)
	dp[0] = True
	dp[4] = True
	dp[7] = True
	for i in range(4, 101):
		if i + 7 <= 100:
			dp[i+7] = dp[i+7] or dp[i]
		if i + 4 <= 100:
			dp[i+4] = dp[i+4] or dp[i]

	if dp[N]:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int hoge(string s){
    int ans = 0;
    rep(i,s.size()){
        ans += s[i]-'0';
    }
    return ans;
}
int main(){
    int n;
    cin >> n;
    int ans = INT_MAX;
    for(int i = 1; i < n; i++){
        ans = min(ans, hoge(to_string(i)+to_string(n-i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll x[n][2];
  rep(i,n){
    cin>>x[i][0]>>x[i][1];
  }
  ll s[n],e[n];
  vector<pair<ll,ll>> p(n);
  rep(i,n){
    p[i].first=x[i][0]+x[i][1];
    p[i].second=x[i][0]-x[i][1];
  }
  sort(all(p));
  ll ans=1,t=p[0].first;
  REP(i,1,n){
    if(t<=p[i].second){
      ans++;
      t=p[i].first;
    }
  }
  cout<<ans<<endl;
}

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

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

#define MOD 1000000007

int n,k;
vi divisor;
vl vals;

ll modpow(ll a, ll b){
	ll r = 1;
	while(b){
		if(b&1)r=r*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return r;
}

int main(){
	scanf("%d%d",&n,&k);
	for(int x=1;x*x<=n;x++)if(n%x==0){
		divisor.push_back(x);
		if(x*x==n)continue;
		divisor.push_back(n/x);
	}
	sort(divisor.begin(), divisor.end());
	int m = divisor.size();
	ll ans = 0;
	REP(i,m){
		int d = divisor[i];
		ll val = modpow(k,(d+1)/2);
		REP(j,i)if(d % divisor[j] == 0)(val += MOD - vals[j]) %= MOD;
		vals.push_back(val);
		if(d%2==0)d/=2;
		ans += val * d % MOD;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int n;
    cin >> n;
    vector<P> seg;
    rep(i, n){
        ll x, l;
        cin >> x >> l;
        seg.push_back(make_pair(x + l, x - l));
    }

    sort(seg.begin(), seg.end());
    ll wall = INT64_MIN, cnt=0LL;
    rep(i, n){
        // cout << seg[i].first << endl;
        if(wall <= seg[i].second){
            cnt++;
            wall = seg[i].first;
        }
    }

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

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c < 22) cout << "win" << endl;
    else cout << "bust" << endl;
}


Measured memory_bytes: 256
from math import sqrt

while True:
	input_data =[] # ????´??????????
	alpha = 0 # ??????
	num = int(input())
	if num == 0:
		break
	input_data = [float(i) for i in input().split()]
	m = sum(input_data) / float(num)
	for i in range(num):
		alpha += (input_data[i] - m)**2
	print(sqrt(alpha/num))

Measured memory_bytes: 7820
haiku = input()
x = haiku.split()
num_5 = 0
num_7 = 0

for v in x:
    v = int(v)
    if v == 5:
        num_5 += 1
    elif v == 7:
        num_7 += 1

if num_5 == 2 and num_7 == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int c[3][3];
        for(int i =0;i<3;i++){
                cin>> c[0][i]>>c[1][i]>>c[2][i];
        }
        int x=0;
        
        for(int i =0;i <=c[0][0];i++){
                for(int j=0;j<=c[1][0];j++){
                        for(int k=0;k<=c[2][0];k++){
                                if(((c[0][0]-i)==(c[1][0]-j))&&((c[1][0]-j)==(c[2][0]-k))){
if(((c[0][1]-i)==(c[1][1]-j))&&((c[1][1]-j)==(c[2][1]-k))){
if(((c[0][2]-i)==(c[1][2]-j))&&((c[1][2]-j)==(c[2][2]-k))){
                                           x=1;
                                           break;
                                 } } }
                         }
                }
        }
        if(x==1){
                cout<<"Yes";
        }
        else{
                cout<<"No";
        }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,k,ans=0;
	cin>>a>>b>>c>>k;
	ans+=(min(a,k));
	k-=min(k,a);
	k-=min(k,b);
	ans-=(min(c,k));
	k-=min(k,c);
	puta(ans);
}


Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[100];
int main()
{
    scanf("%s", s);
    int flag = 1, len = strlen(s);
    for (int i = 0; s[i] != '\0'; i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] != 'h')
            {
                flag = 0;
                break;
            }
        }
        else
        {
            if (s[i] != 'i')
            {
                flag = 0;
                break;
            }
        }
    }
    if (len % 2)
        flag = 0;
    if (flag)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	string S;
	cin >> N >> S;
	int sz = 2 * N;

	map<pair<string,string>,int>mp;
	for (int i = 0; i < (1 << N); i++) {
		string R, B;
		for (int j = 0; j < N; j++) {
			if(i & (1 << j))R += S[j+N];
			else B += S[j + N];
		}
		reverse(all(B));
		auto p = make_pair(R,B);
		mp[p]++;
	}

	ll ans = 0;
	for (int i = 0; i < (1 << N); i++) {
		string R, B;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j))R += S[j];
			else B += S[j];
		}
		reverse(all(B));
		ans += mp[{B,R}];
	}
	puts(ans);

	return 0;
}



Measured memory_bytes: 87040
# Problem:
# Python  Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
intm1 = lambda x: int(x) - 1
intp1 = lambda x: int(x) + 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(intm1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(limitno, giventotal):
    result = 0
    for x in range(0, limitno+1):
        for y in range(0, limitno+1):
            z = giventotal - x - y
            if ( 0 <= z ) and (z <= limitno):
#                print("{} + {} + {} = {}".format(x,y,z,giventotal))
                result = intp1(result)
    return result


if __name__ == "__main__":
    K, S = MI()
    print("{}".format(solver(K, S)))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m;
	string t = "IO";
	while(cin >> n , n){
		cin >> m;
		int ret = 0;
		
		int w = 0;
		bool f = 0;
		rep(i,m){
			char c; cin >> c;
			if(t[f] == c)w++ , f^=1;
			else if(c == 'I') w = 1 , f = 1;
			else if(c == 'O') w = 0 , f = 0;
			
			if(w >= n*2+1 ){ if(w%2)ret++; }
		}
		
		cout << ret << endl;
	}
}

Measured memory_bytes: 916
def readinput():
    n=int(input())
    return n

def main(n):
    fk=[1]*(n+1)
    for i in range(2,n+1):
        j=i
        while(j<=n):
            fk[j]+=1
            j+=i
    sum=0
    for i in range(1,n+1):
        sum+=i*fk[i]
    return sum

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)


Measured memory_bytes: 145580
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T=1;
	//cin >> T;
	ll t=0;
	while(t++<T){
		string s;
		cin>>s;
		ll k=0;
		ll n=s.length();
		fo(i,n){
			k+=s[i]-'0';
		}
		if(k%9==0)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		
	}
return 0;
}


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

vector<int> v(100000);
vector<int> prime;

void erast(){
	for(int i=0;i<100000;i++){
		v[i] = 1;
	}
	for(int i=2;i*i<=100000;i++){
		if(v[i]){
			for(int j=0;i*(j+2)<100000;j++){
				v[i*(j+2)]=0;
			}
		}
	}
	for(int i=2;i<100000;i++){
		if(v[i]){
			prime.push_back(i);
		}
	}
}

int N;
int main(){
	cin >> N;
	erast();
	int count = 0,i = 0;
	while(count<N){
		if(prime[i]%5==1 && count!=N-1){
			cout << prime[i] << " ";
			count++;
		}else if(prime[i]%5==1 && count==N-1){
			cout << prime[i] << endl;
			count++;
		}
		i++;
	}
}

Measured memory_bytes: 768
fun main(args : Array<String>) {
    val (h1, m1, h2, m2, k) = readLine()!!.split(" ").map { it.toInt() }

    var h = h2-h1
    var m = m2-m1
    if (m < 0) {
        h -= 1
        m += 60
    }

    println(60*h + m - k)
}

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

int main(){
  int h, w;
  cin >> h >> w;
  string s[110];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  char c[110][110];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> c[i][j];
    }
  }
  char d[220][110];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      d[2*i][j] = c[i][j];
      d[2*i+1][j] = c[i][j];
      
    }
  }
  for(int i=0; i<2*h; i++){
    for(int j=0; j<w; j++){
      cout << d[i][j];
      if(j==w-1) cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

int main (void)
{
	string s,p;
	
	cin >> s;
	cin >> p;
	
	s = s + s;
	
	if (s.find(p) == -1)
	{
		cout << "No" << endl;
	}else {
		cout << "Yes" << endl;
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll X=in<ll>();
	ll V=100;
	int i=0;
	while(V<X){
		V = V*1.01;
		i++;
	}

	out(i);
	return 0;
}


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

#define MAX_A 1000
#define MIN_A 0

int main()
{
  int n, max = MIN_A, min = MAX_A, a;
  cin >> n;
  while (n--) {
    cin >> a;
    if (a > max)
      max = a;
    if (a < min)
      min = a;
  }
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
  int N,ans=0;
  cin>>N;
  vector<vector<pair<int,int>>> p(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    for(int j=0;j<a;j++){
      int pf,ps;
      cin>>pf>>ps;
      p[i].push_back(pair<int,int>(pf,ps));
    }
  }
for(int i=0;i<(1<<N);i++){
    bool f=true;
    bitset<15> b(i);
    int cnt=b.count();
    for(int j=0;j<N&&f;j++){
      if(!(i&(1<<j))) continue;
      for(int k=0;k<p[j].size()&&f;k++){
        if(b[j]==1){
          if(b[p[j][k].first-1]!=p[j][k].second) f=false;
        }
      }
    }
    if(f) ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

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

int main() {
	long long n,count=0,ans=0;cin>>n;
	long long a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	
	for(i=1;i<n;i++)
	{
	    if(a[i]>a[i-1])
	    {
	        count=0; 
	    }
	    else
	    {
	        count++;
	        ans=max(ans,count);
	    }
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();

        ArrayList<Integer> arr = new ArrayList<>();
        int sum = 0;
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        for (int i = 1; i<n; i++){
            sum += arr.get(i) - arr.get(i-1);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35820
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
    l[i]-=i+1
l.sort()
m=l[n//2]
ans=0
ans1=0
ans2=0
for i in range(n):
    ans+=abs(l[i]-m)
    ans1+=abs(l[i]-m-1)
    ans2+=abs(l[i]-m+1)
print(min(ans,ans1,ans2))


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef vector<vector<int>> graph;


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int n; cin>>n; int a[n],b[n];
    for (int i = 0; i < n+1; i++)cin>>a[i];
    for (int i = 0; i < n; i++)cin>>b[i];
    Int ans=0;
    for (int i = 0; i < n; i++){
        if(b[i]>a[i]+a[i+1]){
            ans+=a[i]+a[i+1];a[i+1]=0;
        }else{
            ans+=b[i];
            if(b[i]>a[i]){
                a[i+1]-=(b[i]-a[i]);
            }
        }
    }
    cout<<ans<<endl;
}
   

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline int read() {
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int main() {
	int n,a=0,b=0;
	char str[200005];
	n=read();
	scanf("%s",str);
	for(int i=0;i<n;i++) {
		if(str[i]=='#')a++;
		if(str[i]=='.'&&a>0)b++,a--;
	}
	printf("%d",b);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsgned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=105;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,a[MAXN],Mx,Mn;
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)a[read()]++;
	for(Mx=n;!a[Mx];Mx--);for(Mn=1;!a[Mn];Mn++);
	if(a[Mx]==1)return puts("Impossible"),0;
	if(Mn!=(Mx+1)/2)return puts("Impossible"),0;
	Rep(i,Mn+1,Mx)if(a[i]<2)return puts("Impossible"),0;
	if(a[Mn]>2||(Mx%2==0&&a[Mn]==2))return puts("Impossible"),0;
	puts("Possible");
	return 0;
}





Measured memory_bytes: 3596
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100010;
int H[maxn];
int main(){
    int n;
    scanf("%d",&n);
    int dp[n+1];
    memset(dp,-1, sizeof(dp));
    for(int i=1;i<=n;i++){
        scanf("%d",&H[i]);
    }
    dp[1]=0;
    dp[2]=abs(H[2]-H[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(abs(H[i]-H[i-2])+dp[i-2],abs(H[i]-H[i-1])+dp[i-1]);
    }
    printf("%d",dp[n]);
    return 0;

}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです(p.s. 過去問対応もありがとうございます)
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::usize::{MAX, MIN};
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize
    }

    let factors = trial_division(n);
    // println!("done")

    let mut ans = 0usize;
    for (_, e) in factors {
        ans += (1usize..).take_while(|x| (*x * (*x + 1)) / 2 <= e).count();
    }

    println!("{}", ans);
}

fn trial_division(mut n :usize) -> HashMap<usize, usize>{
    let mut primes = HashMap::new();
    let mut i = 2;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            if primes.contains_key(&i) {
                let mut x = primes.get_mut(&i).unwrap();
                *x += 1;
            } else {
                primes.insert(i, 1);
            }
        }
        i+=1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    if n > 1 {
        if primes.contains_key(&n) {
            let mut x = primes.get_mut(&n).unwrap();
            *x += 1;
        } else {
            primes.insert(n, 1);
        }
    }
    primes
}


Measured memory_bytes: 2164
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        Enumerable.Range(1, 9)
            .SelectMany(i => Enumerable.Range(1, 9)
                .Select(j => string.Format($"{i}x{j}={i * j}")))
            .ToList()
            .ForEach(Console.WriteLine);
    }
}


Measured memory_bytes: 16328
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n; string s;
    cin>>n>>s;
    int ans=0;
    int cnt=0;
    rep(i,n){
        if(s[i]=='I'){
            cnt++;
        }
        else{
            cnt--;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

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

int main() {
	long double a,b,c;
	long double eps = 1.0E-14;
	cin>>a>>b>>c;
	if(sqrt(a)+sqrt(b)+eps<sqrt(c)) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<functional>

using namespace std;

template <typename T>
struct SegmentTree
{
    using F = function<T(T, T)>;
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f, T ti) : f(f), ti(ti) {}
    void init(int n_)
    {
        n = 1;
        while (n < n_)
            n <<= 1;
        dat.assign(n << 1, ti);
    }

    void build(const vector<T> &v)
    {
        int n_ = v.size();
        init(n_);
        for (int i = 0; i < n_; i++)
            dat[n + i] = v[i];
        for (int i = n - 1; i; i--)
            dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }

    // v[k] = x (0-indexed)
    void set(int k, T x)
    {
        dat[k += n] = x;
        while (k >>= 1)
            dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }

    // get F(v[a], v[a + 1], ... , v[b - 1]) (0-indexed)
    T query(int a, int b)
    {
        T vl = ti, vr = ti;
        for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1)
        {
            if (l & 1)
                vl = f(vl, dat[l++]);
            if (r & 1)
                vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
};

using ll = long long;

int n;
vector<int> h, a;
int main()
{
    SegmentTree<ll> dp([](ll a, ll b){return max(a, b);}, 0);
    cin >> n;
    h.resize(n);
    a.resize(n);
    dp.init(n);
    REP(i, n) {cin >> h[i]; h[i]--;}
    REP(i, n) cin >> a[i];
    REP(i, n) {
        dp.set(h[i], dp.query(0, h[i]) + a[i]);
    }
    cout << dp.query(0, n) << endl;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int progress = 0;
    rep(i, S.length()) {
        if (S[i] == 'C' && progress == 0) progress++;
        if (S[i] == 'F' && progress == 1) {
            cout << "Yes" << endl;
            return 0;
        } 
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#B
S=input()
T=input()

M= len(S)
N = len(T)
ans=0

for i in range(M-N+1):
    tmp=S[i:i+N]
    #print(tmp)
    cnt=0
    for j in range(N):
        if tmp[j]==T[j]:
            cnt +=1
    ans = max(ans,cnt)

print(N-ans)

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  vector<bool> f(b, false);
  for(int i = 1;;++i) {
    if(a*i%b == c) {
      cout << "YES" << endl;
      return 0;
    }
    if(f[a*i%b]) {
      cout << "NO" << endl;
      return 0;
    }
    f[a*i%b] = true;
  }
}

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

const int maxn = 1e5;
int n, a[maxn + 3];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	int x = n, y = 1;
	while (x > 1 && y + 1 <= a[x - 1]) {
		x--, y++;
	}
	if (y > a[x - 1]) {
		puts((a[x] - y) & 1 ? "First" : "Second");
	} else {
		int p = (a[x] - y - 1) & 1, z = x - 1;
		while (z > 1 && a[z - 1] == a[z]) z--;
		int q = (x - 1 - z) & 1;
		puts(p && q ? "Second" : "First");
	}
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
double dmax(double a,double b){
    return a>b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
#define N 55555
int p[N+1];

void eratosthenes(void){
    int i,j;
    for(i=2;i<N;i++)
        p[i]=1;
    for(i=2;i*i<N;i++){
        if(p[i]){
            for(j=2*i;j<=N;j=j+i){
                p[j]=0;
            }
        }
    }
}

// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n=in(),i=2,c=0;
    eratosthenes();
    while(c<n){
        if(p[i]&&i%10==3){
            if(c)printf(" ");
            printf("%d",i);
            c++;
        }
        i++;
    }
    puts("");
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int n,b=0,w=0;
  long long count=0;
  char s[200005];
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<n;i++){
    if(s[i]=='W') w++;
  }
    for(int i=n-1;i>=0;i--){
      if(s[i]=='W'){
        count+=i+1-w;
        w--;
        if(w==0) break;
      }
    }
    printf("%lld",count);



  return 0;
}

Measured memory_bytes: 1928
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var k = sc.nextInt();
		sc.close();

		var sum = 0L;
		for (var a = 0; a < k; a++) {
			for (var b = 0; b < k; b++) {
				for (var c = 0; c < k; c++) {
					sum += gcd(a + 1, b + 1, c + 1);
				}
			}
		}

		System.out.println(sum);
	}

	public static int gcd(int a, int b, int c) {
		return gcd(gcd(a, b), c);
	}

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

		return gcd(b, a % b);
	}
}

Measured memory_bytes: 35828
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int ret = 0;
  for (int i = 1; i * i <= m; ++i) {
    if (m % i == 0) {
      if (m / i >= n) ret = max(ret, i);
      if (i >= n) ret = max(ret, m / i);
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int a, b;
	string ans;
	cin >> a >> b;
	if ((a > 0 && b > 0)||((a < 0 && b < 0) && abs(a + b) % 2 == 1))
		ans = "Positive";
	if (BETWEEN(0,a,b))
		ans = "Zero";
	if ((a < 0 && b < 0) && abs(a + b) % 2 == 0)
		ans = "Negative";
	cout << ans;		
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if(b - a == c - b)
    	cout << "YES" << endl;
    else
    	cout << "NO" << endl;
}

Measured memory_bytes: 256
temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.append([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i][x]-points[j][x], 2) for x in range(D)]), 1/2)
    if l.is_integer():
      counter+=1
      
print(counter)

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

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

int main(){
  int N,W; cin >> N >> W;
  vector<int>weight(N+1);
  vector<int>value(N+1);
  for(int i=1;i<=N;i++){
    cin >> weight.at(i) >> value.at(i);
  }

  vector<vector<long long> >dp(N+1,vector<long long>(W+1,0));
  for(int i=1;i<=N;i++){
    for(int j=1;j<=W;j++){
      if(j - weight.at(i) >=0){
        chmax(dp.at(i).at(j),dp.at(i-1).at(j-weight.at(i)) + value.at(i));
      }
      chmax(dp.at(i).at(j),dp.at(i-1).at(j));
    }
  }
  cout << dp.at(N).at(W) << endl;
}


Measured memory_bytes: 80256
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF   = LL(1e18) + LL(1e17);
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    LL K;
    cin >> K;
    vector<LL> A(N);
    REP0 (i, N)
        cin >> A[i];
    sort(A.begin(), A.end());

    // x -> 積が x 以下であるようなペアは K 未満であるかどうか
    auto isok = [&](LL x) {
        LL total = 0;
        REP0 (i, N)
        {  // A[i]とのペアのうち, 積がKを超えない最大の値を見つける
            if (A[i] < 0)
            {  // A[i] が負だと, 後ろから何番目かまでが条件を満たす
                int ng = -1, ok = N;
                while (abs(ng - ok) > 1)
                {
                    int c = (ng + ok) / 2;
                    if (A[c] * A[i] < x)
                        ok = c;
                    else
                        ng = c;
                }
                total += N - (ng + 1);
            }
            else
            {  // A[i]が正ならば, 前から何番目かまでが条件を満たす
                int ok = -1, ng = N;
                while (abs(ng - ok) > 1)
                {
                    int c = (ng + ok) / 2;
                    if (A[c] * A[i] < x)
                        ok = c;
                    else
                        ng = c;
                }
                total += ok + 1;
            }
            // この計算は重複をカウントしているので, あれば外す
            if (A[i] * A[i] < x)
                total--;
        }
        // 同じペアの逆もカウントしているので, それも外す
        total /= 2;
        return total < K;
    };

    LL ok = -LLINF, ng = LLINF;

    while (abs(ng - ok) > 1)
    {
        LL x = (ok + ng) / 2;
        if (isok(x))
            ok = x;
        else
            ng = x;
    }
    cout << ok << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,d,x,y,s=0;
cin>>n>>d;
for(int i=0;i<n;i++){
	cin>>x>>y;
	if(x*x+y*y<=d*d)s++;
}
cout<<s;
return 0;
}

Measured memory_bytes: 3636