akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, d, x;
    int ans = 0;
    cin >> n >> d >> x;
    imfor(i, n) {
        int a;
        cin >> a;
        int tmpday = 0;
        int tmpcnt = 0;
        while (true) {
            tmpday = tmpcnt * a + 1;
            if (tmpday > d) {
                break;
            }
            ans++;
            tmpcnt++;
        }
    }
    cout << ans + x << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
 int a[4];
 char c[4];
 char str[16];
 scanf("%s",c);
 for(int i=0;i<4;i++){
  a[i] = c[i] - 48;
 }
 if(a[0]+a[1]+a[2]+a[3] == 7){
  printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]-a[1]+a[2]+a[3] == 7){
  printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]+a[1]-a[2]+a[3] == 7){
  printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]+a[1]+a[2]-a[3] == 7){
  printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]-a[1]-a[2]+a[3] == 7){
  printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]-a[1]+a[2]-a[3] == 7){
  printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]+a[1]-a[2]-a[3] == 7){
  printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]);
 }else if(a[0]-a[1]-a[2]-a[3] == 7){
  printf("%d-%d-%d-%d=7",a[0],a[1],a[2],a[3]);
 }
 
 return 0;
}

Measured memory_bytes: 128
import java.util.*

fun check(x: Int, D: List<String>): Boolean {
    val xs = x.toString()
    return !D.any { s -> xs.contains(s) }
}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextInt()
    val D = (1..K).map { sc.next() }.toList()
    var ans = N
    while (true) {
        if (check(ans, D)) {
            println(ans)
            break
        }
        ans++
    }
}

Measured memory_bytes: 38872
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 998244353
#define N 200005
int n,rd,rl;
vector<int> g[N],r[N],eki[N];
int vis[N],vis2[N],ans[N];
set<int> s;
void dfs1(int u,int cnt)
{
    vis[u]=cnt;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(!vis[v]) dfs1(v,cnt);
    }
}
void dfs2(int u)
{
    vis2[u]=1;
    s.insert(vis[u]);
    eki[vis[u]].pb(u);
    for(int i=0;i<r[u].size();i++)
    {
        int v=r[u][i];
        if(!vis2[v]) dfs2(v);
    }
}
int main()
{
    fastio;
    cin>>n>>rd>>rl;
    for(int i=0;i<rd;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    for(int i=0;i<rl;i++)
    {
        int x,y;
        cin>>x>>y;
        r[x].pb(y);
        r[y].pb(x);
    }
    int cnt=1;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs1(i,cnt);
            cnt++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis2[i])
        {
            dfs2(i);
            for(auto it :s)
            {
                for(int j=0;j<eki[it].size();j++)
                {
                    ans[eki[it][j]]=eki[it].size();
                }
                eki[it].clear();
            }
            s.clear();
        }
    }
    for(int i=1;i<=n;i++) cout<<ans[i]<<gap;
}


Measured memory_bytes: 27520
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7


def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q = m // n
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, m - q * n

    return (x2, y2, n)

g1 = [1, 1]

for i in range(2, N+1):
    g1.append((g1[-1] * i) % mod)

a = [0]
for i in range(N):
    a.append(extended_euclid(i+1, mod)[0])

a = list(accumulate(a))
ans = 0
for i in range(N):
    tmp = (a[N-i]-a[1])+(a[i+1]-a[1])+1
    ans += tmp*g1[N] * A[i]
    ans %= mod
print(ans)


Measured memory_bytes: 19316
#include <stdio.h>
int main() {
  int x, y, z, r;
  scanf("%d %d", &x, &y);
  if(x < y) {
    z = y;
    y = x;
    x = z;
  }
  do {
    r = x % y;
    x = y;
    y = r;
  } while(y > 0);
  printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(){
    long long int t[5],a[5],n,max=0;
    cin>>n;
    for(int i=0;i<5;i++){
        t[i]=0;
        cin>>a[i];
    }
    for(int i=0;i<5;i++){
        t[i]+=n/a[i];
        if(n%a[i]) t[i]++;
        if(t[i]>max) max=t[i];
    }
    cout<<max+4<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[15],n,k;
int main(){
    a[0]=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    a[i]=min(a[i-1]+k,a[i-1]*2);
    cout<<a[n];
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  char T;
  bool bad = false;

  for (int i = 1; i < 4; i++) {
  	T = S[i - 1];
    if (S[i] == T) {
      bad = true;
    }
  }
  
  cout << (bad ? "Bad" : "Good") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
vector<P> ans;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    if(n%2==0){
        rep(i,n){
            rrep(j,i+1,n){
                if(i==n-j-1)continue;
                ans.push_back({i+1,j+1});
            }
        }
    }
    else{
        rep(i,n){
            rrep(j,i+1,n){
                if(i==n-j-2)continue;
                ans.push_back({i+1,j+1});
            }
        }
    }
    Cout(Size(ans));
    rep(i,Size(ans)){
        cout<<ans[i].fi<<" "<<ans[i].se<<"\n";
    }
    return 0;
}


Measured memory_bytes: 512
N, K = map(int, input().split())
cnt = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(lambda x : int(x)-1, input().split()))
    for a in A:
        cnt[a] += 1
ans = 0
for c in cnt:
    if c == 0:
        ans += 1
print(ans) 


Measured memory_bytes: 67708
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin >> s;
	cin >> t;
	int i,c=0;
	for(i=0;i<3;i++){
		if(s[i]==t[i]){
			c++;
		}
	}
	cout << c;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin>>n;
  std::vector<std::string> s;
  for(int i=0;i<n;i++){
    std::string tmp;
    cin>>tmp;
    std::sort(tmp.begin(), tmp.end());
    s.push_back(tmp);
  }
  std::sort(s.begin(), s.end());
  int64_t result=0;
  std::string target=s[0];
  int64_t count=0;


  for(int i=1;i<n;i++){

    if(target==s[i]){
      count++;
      result+=count;
    }
    else{
      count=0;
      target=s[i];
    }
  }
  cout<<result<<endl;


  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    vector<int> ans(n);
    for (int j = 0; j < n; j++) {
        ans.at(a.at(j) - 1) = j + 1;
    }
    for (auto k : ans) {
        cout << k << " ";
    }
    cout << endl;
}


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

const int N = 201010, MOD = 1e9 + 7;

int f[N], x[N], y[N], cnt, n, m, SZ, val[N];
pair<int, int> a[N];

void Add(int x, int y) {
  for(; x <= SZ; x += -x & x)
    val[x] = (val[x] + y) % MOD;
}

int Query(int x) {
  int ans = 0;
  for(; x; x -= x & -x)
    ans = (ans + val[x]) % MOD;
  return ans;
}

int main(void) {
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= n; i++)
    scanf("%d", &x[i]);
  for(int j = 1; j <= m; j++)
    scanf("%d", &y[j]);
  vector<int> tmp;
  for(int i = 1, j = 1; i <= n; i++) {
    while(j <= m && y[j] < x[i]) j++;
    if(j == 1 || j > m || x[i] == y[j]);
    else {
      a[++cnt] = {x[i] - y[j - 1], y[j] - x[i]};
      //cerr << i << " " << x[i] - y[j - 1] << " " << y[j] - x[i] << endl;
      tmp.push_back(a[cnt].first);
      tmp.push_back(a[cnt].second);
    }
  }
  sort(tmp.begin(), tmp.end());
  tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
  SZ = tmp.size();
  for(int i = 1; i <= cnt; i++) {
    a[i].first = lower_bound(tmp.begin(), tmp.end(), a[i].first) - tmp.begin() + 1;
    a[i].second = lower_bound(tmp.begin(), tmp.end(), a[i].second) - tmp.begin() + 1;
    //cerr << a[i].first << " " << a[i].second << endl;
  }
  sort(a + 1, a + cnt + 1);
  cnt = unique(a + 1, a + cnt + 1) - a - 1;
  int ans = 1;
  for(int i = 1; i <= cnt; i++) {
    int j = i;
    while(j + 1 <= cnt && a[j + 1].first == a[i].first) j++;
    for(int k = i; k <= j; k++) {
      f[k] = (Query(a[k].second - 1) + 1) % MOD;
      ans = (ans + f[k]) % MOD;
    }
    for(int k = i; k <= j; k++)
      Add(a[k].second, f[k]);
    i = j;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N),B(N);
    rep(n,0,N) cin>>A.at(n);
    rep(n,0,N) cin>>B.at(n);

    int ans=0;
    int64_t sumDiff=0;
    vector<int> plusDiff;
    rep(n,0,N){
        int diff=A.at(n)-B.at(n);
        if(diff<0){
            sumDiff+=abs(diff);
            ans++;
        }else if(diff>0){
            plusDiff.push_back(diff);
        }
    }

    sort(ToEnd(plusDiff));
    int64_t sum=0;
    _rep(i,plusDiff.size()-1,0){
        if(sum>=sumDiff) break;
        ans++;
        sum+=plusDiff.at(i);
    }
    if(sum<sumDiff) ans=-1;

    cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

double d;

int main(){
    cin >> d;
    double ans = max<double>(sqrt(2)*d,1+(int)d);
    cout << Double(ans) << endl;
}

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

int main(){
  int N,M;
  cin >>N>>M;
  
  vector<int> a(M);
  vector<int> b(M);
  rep(i,0,M) cin >>a[i]>>b[i];
  
  map<int,int> mp;
  rep(i,0,M){
    int A = a[i];
    int B = b[i];
    mp[A]++;
    mp[B]++;
  }
  rep(i,0,N){
    cout <<mp[i+1]<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int arr[nax];
ll dp[110][nax];
ll dp2[110][nax];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  int n,k;
  sd2(n, k);
  for(int i = 1 ; i <= n; i++)
    sd(arr[i]);

  dp[0][0] = dp2[0][1] = 1;

  for(int i = 0;i <= k; i++)
    dp2[0][i] = dp2[0][i - 1] + dp[0][i];

  for(int i = 1; i <= n; i++)
  {
      int cur = arr[i];
      for(int j = 0; j <= k; j++)
      {
          dp[i][j] = (dp2[i - 1][j] - (j - cur > 0 ? dp2[i - 1][max(0,j - cur - 1)] : 0) + MOD) % MOD;
          if(j > 0)
            dp2[i][j] = (dp2[i][j - 1] + dp[i][j]) % MOD;
          else
            dp2[i][j] = dp[i][j];
          //cout << i << " " << j << " " <<  dp[i][j] << " " << dp2[i][j] << "\n"; 
      }
  }
  printf("%lld\n", dp[n][k]);
  return 0;
}

Measured memory_bytes: 164224
#include <stdio.h>

int main(void)
{
    int N, K;
    int b;
    int tower;
    int use;
    
    scanf("%d%d", &N, &K);

    tower = 1;  // 塔の高さ
    use = 1;    // 使用済みのブロック数
    b = 1;      // 一段あたりのブロック数
    while ((N - use) >= b){
        if (use <= K * b){
            tower++;
            use += b;
        }
        else {
            b++;
        }
    }
    printf("%d\n", tower);
    
    return (0);
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
 
using boost::multiprecision::cpp_int;
using namespace std;
 
#if __has_include("print.hpp")
  #include "print.hpp"
#endif
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<ll, ll> p;
 
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> mp;
 
  ll res = 0;
  rep(i, n){
    cin >> v[i];
  }
 
  rep(i, n){
    int sa = i - v[i];
    int wa = i + v[i];
    res += mp[sa];
    mp[wa]++;
  }
 
  cout << res << endl;
 
 
}

Measured memory_bytes: 21108
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def mi(): return map(int, input().split())


def li(): return list(mi())


def li_(): return [int(x) - 1 for x in input().split()]


def lin(n: int): return [input() for _ in range(n)]


def llin(n: int): return [li() for _ in range(n)]


def llin_(n: int): return [li_() for _ in range(n)]


def lli(): return [list(map(int, l.split())) for l in input()]


def i(): return int(input())


def f(): return float(input())


def s(): return input().replace('\n', '')


def main():
    N, W = mi()
    WV = llin(N)
    dp = [[0] * (W + 1) for _ in range(N)]
    dp[0] = [WV[0][1] if WV[0][0] <= i else 0 for i in range(W+1)]
    for i in range(1, N):
        for j in range(W + 1):
            if j >= WV[i][0]:
                dp[i][j] = dp[i - 1][j - WV[i][0]] + WV[i][1]
            dp[i][j] = max(0, dp[i][j], dp[i - 1][j])
    print(dp[N-1][W])


if __name__ == '__main__':
    main()


Measured memory_bytes: 119148
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

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

    int ans = -1;
    if(a == b && b == c){
        ans = 1;
    }
    else if(a != b && b != c && c != a){
        ans = 3;
    }
    else{
        ans = 2;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,b,sum=0;
 sc(n);
 vector<ll>a;
 rep(i,0,n){
  sc(b);push(a,b);sum+=b;
 }
  
 ll ans=2000000000;
 ll suma=0;
 ans=2*llpow(10,9);
 rep(i,0,n-1){
  suma+=a[i];
  ans=min(ans,abs(sum-2*suma));
  //cout<<i<<" "<<sum<<" "<<suma<<" "<<ans<<endl;
 }
 pr(ans);  
return 0;}

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

using namespace std;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

// #define DEBUG
#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main()
{
    ios::sync_with_stdio(false);
#ifndef DEBUG
    cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (auto &x : a)
        cin >> x;
    int count = 0;
    bool found = false;
    for (int i = 0; i < 2 * n; i += 2)
    {
        if (a[i] == a[i + 1])
        {
            count++;
        }
        else
        {
            count = 0;
        }
        if (count >= 3)
        {
            found = true;
            break;
        }
    }
    cout << (found ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

ll dp[100011];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)cin>>arr[i];
	dp[1]=abs(arr[1]-arr[0]);
	for(ll i=2;i<n;i++)dp[i]=min(abs(arr[i-1]-arr[i])+dp[i-1],abs(arr[i-2]-arr[i])+dp[i-2]);
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long 
using namespace std; 
inline char get(){
	const int TOP=1000000;
	static char T[TOP],*x=T,*y=T;
	return x==y&&(y=(x=T)+fread(T,1,TOP,stdin),x==y)?EOF:*x++;
}
inline ll read (){
	register ll num;int sign=1;register char c;
	while (((c=get())<'0'||c>'9')&&c!='-');c=='-'?num=sign=0:num=c-48;
	while ((c=get())>='0'&&c<='9')num=(num<<3)+(num<<1)+(c-48);
	return sign?num:-num;
}
ll n,m,ans=1;
int main(){
	n=read();m=read();
	for(ll i=2;i*i<=m;++i){
		if(m%i==0){
			int s=0;
			while(m%i==0){m/=i;s++;}
			for(int j=1;j<=s/n;++j)ans*=i;
		}
	}
	if(m>1)if(n==1)ans*=m;
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int flag=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			flag=1;
		}
	}
	if(flag==1)
	{
		printf("NO");
	}
	else
	{
		printf("YES");
	}
}

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

using namespace std;

int main(){
    int n,k;
    double total=0;
    cin >>n >>k;
    for(int i=1;i<n+1;i++){
        double count=1;
        double a =i;
        for(int j=0;j<100000000;j++){
            if(a>=k){
                break;
            }
            count= count/2;
            a=a*2;
        }
        total= total+count;
        // cout << count << endl;

    }
     cout <<setprecision(13) << total/n <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n+x-1) / x * t << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define esraa ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);

using namespace std;
const int N = 1e6+10, INF=9e9;

int main()
{
    esraa;
    string s,t,st;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    long long dp[n+1][m+1];
    memset(dp,0,sizeof dp);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    for(int i=n,j=m; i>0 && j>0; )
    {
        if(s[i-1]==t[j-1])
        {
           st.push_back(s[i-1]);
           i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    for(int i=st.size()-1; i>=0; i--)
    {
        cout<<st[i];
    }
    cout<<"\n";

//cout<<dp[n][m]<<" "<<n<<" "<<m;


	return 0;
}


Measured memory_bytes: 70656
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(input())
a = []
xy = []
for _ in range(n):
    tmp_a = int(input())
    tmp_xy = [[int(i) for i in readline().split()] for _ in range(tmp_a)]
    a.append(tmp_a)
    xy.append(tmp_xy)
    
from itertools import product

ans_list = []

for comb in product([1,0], repeat=n):
    lie_list = [-1]*n
    flag = True
    for i in range(n):
        if comb[i] == 1:
            if lie_list[i] == -1:
                lie_list[i] = 1
            elif lie_list[i] == 1:
                pass
            elif lie_list[i] != 1:
                flag = False
                break
            for x,y in xy[i]:
                if lie_list[x-1] == -1:
                    lie_list[x-1] = y
                elif lie_list[x-1] == y:
                    pass
                elif lie_list[x-1] != y:
                    flag = False
                    break
        else:
            if lie_list[i] == -1:
                lie_list[i] = 0
            elif lie_list[i] == 0:
                pass
            elif lie_list[i] != 0:
                flag = False
                break
    if flag:
        ans_list.append(sum(comb))

if ans_list:
    print(max(ans_list))
else:
    print(0)

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

void push(int);
int pop (void);

int top=0;
int stack[100];

int main(){

  int x,y,z;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    
    else if(s[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }
    
    else if(s[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    
    else{
     z=atoi(s);
      push(z);
    }
  }

  printf("%d\n",stack[top]);

  return 0;
}

void push(int i){
  top++;
  stack[top]=i;
}

int pop(void){
  top--;
  return stack[top+1];
}



Measured memory_bytes: 2052
import Control.Applicative
import Control.Monad
import Data.List
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  [n, k, s] <- map read <$> words <$> getLine
  unless (n == 0 && k == 0 && s == 0) $ do
    print $ solve n k s
    main

solve :: Int -> Int -> Int -> Int
solve n k s = dp ! (idx (k, s))
  where idx (i, j) = i*(s+1)+j
        iv = V.replicate ((k+1)*(s+1)) 0 // [(0,1)] :: Vector Int
        dp = foldl' f iv [1..n]
        f v x = V.accum (+) v $ do
          i <- [0..k-1]
          j <- [0..s]
          let y = v ! (idx (i,j))
          guard $ y > 0
          guard $ j + x <= s
          return (idx (i+1, j+x), y)



Measured memory_bytes: 6112
// In God We Trust


# include <bits/stdc++.h>
using namespace std;

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
signed main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  for (int i = 0 ; i < n ; i ++)
    cin >> a[i] >> b[i] >> c[i] ;
  long long aa[n], bb[n], cc[n];
  aa[0] = a[0], bb[0] = b[0], cc[0] = c[0];
  for (int i = 1; i < n; i++)
    aa[i] = max(bb[i - 1] + a[i], cc[i - 1] + a[i]),
      bb[i] = max(aa[i - 1] + b[i], cc[i - 1] + b[i]),
      cc[i] = max(aa[i - 1] + c[i],bb[i - 1] + c[i]);
  cout << max(aa[n - 1], max(bb[n - 1], cc[n - 1])) << endl;
  
    
  
}


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const ll INF=2e18;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

ll gcd(ll a,ll b)
{
	return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
	if(a==INF || b==INF) return INF;
	if(a/gcd(a,b)>INF/b) return INF;
	return a/gcd(a,b)*b;
}

inline int clz(uint x)
{
	int i=0;
	if(!(x&0xffff0000)) i+=16,x<<=16;
	if(!(x&0xff000000)) i+=8,x<<=8;
	if(!(x&0xf0000000)) i+=4,x<<=4;
	if(!(x&0xc0000000)) i+=2,x<<=2;
	if(!(x&0x80000000)) i+=1,x<<=1;
	return i+!x;
}

template<typename T>
vector<T> Zeta(const vector<T>& g)
{
	int n=31-clz(g.size());
	vector<T> f=g;
	rep(i,n) rep(s,1<<n)
		if(s>>i&1) f[s]+=f[s^1<<i];
	return f;
}

template<typename T>
vector<T> Moebius(const vector<T>& f)
{
	int n=31-clz(f.size());
	vector<T> g=f;
	rep(i,n) rep(s,1<<n)
		if(s>>i&1) g[s]-=g[s^1<<i];
	return g;
}

int main()
{
	for(ll n,m;cin>>n>>m && n|m;){
		vl as(n);
		rep(i,n) cin>>as[i];
		vd ps(n);
		rep(i,n) cin>>ps[i],ps[i]/=100;
		
		// f(S): -1^|S| × (Sのどの要素でも割り切れる1<=x<=mの個数)
		// g(S): Sのいずれかの要素で割り切れる1<=x<=mの個数
		vl f(1<<n);
		repi(i,1,1<<n){
			ll l=1;
			rep(j,n) if(i>>j&1)
				l=lcm(l,as[j]);
			if(l==INF) continue;
			f[i]+=m/l;
		}
		vl g=Moebius(f);
		
		double res=0;
		repi(i,1,1<<n){
			double p=1;
			rep(j,n) p*=i>>j&1?ps[j]:1-ps[j];
			res+=p*abs(g[i]);
		}
		printf("%.10f\n",res);
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

int main() {
	ll n, m; cin >> n >> m;

	vector<int>a(n);
	vector<int>b(n);
	rep(i, n)cin >> a[i] >> b[i];

	vector<int>c(m);
	vector<int>d(m);
	rep(i, m)cin >> c[i] >> d[i];

	ll now = 0;
	vector<int>flg(n);

	for (int i = 0; i < n; i++) {
		ll ans = INF;
		for (int j = 0; j < m; j++) {
			now = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (now < ans) {
				flg[i] = j;
				ans = now;
			}
		}
	}
	rep(i, n)cout << flg[i] + 1 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        ArrayList<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        TreeSet<String> hs = new TreeSet<String>();
        String s = mylist.get(0);
        int k = Integer.valueOf(mylist.get(1));

        int cnt = 1;

        while (cnt <= k) {
            int sposi = 0;
            while (sposi < s.length() - cnt + 1) {
                String stemp = s.substring(sposi, sposi + cnt);
                hs.add(stemp);
                //                System.out.println(stemp);
                sposi += 1;
            }
            cnt += 1;
        }

        int counter = 1;
        for (String v : hs) {
            if (counter == k) {
                System.out.println(v);
                break;
            }
            counter += 1;
            

        }

    }

}


Measured memory_bytes: 24148
#include <iostream>

using namespace std;

int main(){
  int n;
  char s[100];
  int l=0;
  int r=0;
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> s[i];
    if (s[i] == '(') {
      l++;
    } else if (s[i]==')') {
      if (l>0) {
	l--;
      } else {
	r++;
      }
    }
  }
  for (int i=0;i<r;i++) {
    cout << '(';
  }
  for (int i=0;i<n;i++) {
    cout << s[i];
  }
  for (int i=0;i<l;i++) {
    cout << ')';
  }
  cout << endl;
}



Measured memory_bytes: 256
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
if X > Y:
    X, Y = Y, X

ans = [0] * (N - 1)
for i in range(N - 1):
    for j in range(i + 1, N):
        ij = j - i
        ix = abs(i - X)
        iy = abs(i - Y)
        jx = abs(j - X)
        jy = abs(j - Y)

        minn = ij
        minn = min(minn, ix + 1 + jy)
        minn = min(minn, iy + 1 + jx)

        ans[minn - 1] += 1

for i in ans:
    print(i)

Measured memory_bytes: 50140
#include <iostream>
#include <vector>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int n, m, q;
int a[51], b[51], c[51], d[51];
int v[11];
 
long long gcd(long long a, long long b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}
 
int main() {
    int N;
    cin >> N;
    long long* A = new long long[N];
    vector<long long> lgcds(N);
    vector<long long> rgcds(N);
    rep(i, 0, N){
        cin >> A[i];
    }
    rep(i, 0, N-1){
        lgcds[i+1] = gcd(lgcds[i], A[i]);
    }
    for (int i = N-1; i>0; i--){
        rgcds[i-1] = gcd(rgcds[i], A[i]);
    }
    long long ans = 1;
    rep(i, 0, N){
        ans = max(ans, gcd(lgcds[i], rgcds[i]));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
# colorful slimes
class SegTree():
    # 1-indexed
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*(2**(self.K+1)+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X] = v
        for i in range(X-1, 0, -1):
            self.seg[i] = self.f(self.seg[i << 1], self.seg[i << 1 | 1])

    def update(self, k, value):
        X = 2**self.K
        k += X
        self.seg[k] = value
        while k:
            k = k >> 1
            self.seg[k] = self.f(self.seg[k << 1], self.seg[(k << 1) | 1])

    def query(self, L, R):
        num = 2**self.K
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)


N, X = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(3*N)]
for i in range(N):
    B[i] = B[i+N] = B[i+2*N] = A[i]

T = SegTree(B, min, 10**10)
ans = 10**30
# ちょうどN回の要素増加が必要。
# セグメント木を利用した解答
for cnt in range(N+1):
    # cnt回数だけループ操作を行うとする。
    # N回以上のループを伴う解答は自明回より不最適なのでのぞいて良い。
    sub = X*cnt
    for i in range(1+N, 2*N+1):
        sub += T.query(i, i+1+cnt)
    ans = min(sub, ans)
print(ans)

Measured memory_bytes: 70244
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

template<typename T> 
T dig_sum(T n){
   if(n < 10)  return n;
   return dig_sum(n/10) + n%10;
}
int main(){
    int N;
    cin >> N;
    int S = dig_sum(N);
    if(N % S) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n, h;
    static int[] a, b;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        int cnt = 0;
        int maxA = Arrays.stream(a).max().getAsInt();
        Arrays.sort(b);

        for(int i = n-1; i >= 0 && maxA <= b[i]; i--) {
            cnt++;
            h -= b[i];
            if (h <= 0) {
                print(cnt);
                return;
            }
        }

        if(h > 0) {
            cnt += h / maxA;
            if((h % maxA) > 0) cnt++;
        }

        print(cnt);
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        h = in.nextInt();
        a = new int[n];
        b = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

Measured memory_bytes: 87064
N, L = map(int, input().split())
s = sum(L + i - 1 for i in range(1, N + 1))
ans = sum(L + i - 1 for i in range(2, N + 1))
for i in range(1, N + 1):
    s1 = s - (L + i - 1)
    if abs(s - ans) > abs(s - s1):
        ans = s1
print(ans)

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


void solver() {
  int n, m;
  cin >> n >> m;
  vector<int> hs;

  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    hs.push_back(h);
  }

  vector<vector<int> > mp(n, vector<int>(0));
  for (int i = 0; i < m; i++) {
    int wa, wb;
    cin >> wa >> wb;
    wa = wa - 1;
    wb = wb - 1;
    mp[wa].push_back(wb);
    mp[wb].push_back(wa);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int ha = hs[i];
    bool f = true;
    for (int j = 0; j < mp[i].size(); j++){
      int hb = hs[mp[i][j]];
      if (ha <= hb) {
        f = false;
        break;
      }
    }
    if (f) {
      ans++;
    }
  }

  cout << ans << "\n";
}

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


Measured memory_bytes: 8804
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  ll cnt = 0;
  ll two = 0;
  rep(i, N) {
    ll tmp; cin >> tmp;
    if(tmp%4==0) ++cnt;
    else if(tmp%2==0) ++two;
  }
  if(two >= 2) N = N-two+1;
  printf("%s\n", cnt>=N/2?"Yes":"No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
#define pi pair<int, int>
#define vi vector<int>
#define REP(a,b)  for (int i = int(a); i < int(b); i++)
#define endl "\n"
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define w(tc) int tc; cin>>tc; while(tc--)
using namespace std;


int main() {
	IOS
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s;
	getline(cin, s);
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum += (s[i] - '0');
	}
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}



Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a, b, x;
    cin >> a >> b >> x;
    double v = a*a*b;
    double nokori = a*a*b - x;
    double ans;
    if(nokori <= a*a*b/2.0)
    {
        double teihen = 2*nokori/(a*a);
        ans = atan2(teihen,a);
    }
    else
    {
        double teihen2 = 2*x/(a*b);
        ans = atan2(b,teihen2);
    }
    cout << setprecision(16) << 180*ans/M_PI<< endl;
    return 0;
}


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

int main(){
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  --A,--B,--C,--D;
  if(A > B) swap(A,B), swap(C,D);
  if(C > D){
    bool f = false;
    for(int i = B; i <= D; ++i){
      if(S[i] == '.' and S[i-1] == '.' and S[i+1] == '.')
        f = true;
    }
    if(not f){
      cout << "No" << endl;
      return 0;
    }
  }
  auto f = [&S,N](int A, int B, int C, int D){
             vector<bool> visited(N,false);
             visited[A] = true;
             for(int i = A+1; i < N; ++i){
               if(S[i] != '.') continue;
               if(i > 0) visited[i] = visited[i]|visited[i-1];
               if(i > 1) visited[i] = visited[i]|visited[i-2];
             }
             if(not visited[C]) return false;
             visited = vector<bool>(N,false);
             visited[B] = true;
             S[C] = '#';
             for(int i = B+1; i < N; ++i){
               if(S[i] != '.') continue;
               if(i > 0) visited[i] = visited[i]|visited[i-1];
               if(i > 1) visited[i] = visited[i]|visited[i-2];
             }
             S[C] = '.';
             if(not visited[D]) return false;
             return true;
           };
  if(f(A,B,C,D) or f(B,A,D,C)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n,q,ok=0;

    cin>>n;
    ll s[n];

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

    cin>>q;
    ll t[q];

    for(int i=0;i<q;i++)
        cin>>t[i];

        for(int i=0;i<q;i++){
            ll item=t[i];

            for(int j=0;j<n;j++){

                if(item==s[j]){
                    ok++;
                    break;
                }
            }
        }

        cout<<ok<<"\n";
        return 0;
}



Measured memory_bytes: 3148
import sys
x=50000
sys.setrecursionlimit(x)

n=int(input())
arr = list(map(float,input().split()))
dp = [[-1]*(3001) for i in range(3001)]

def func(n,x):
    if x==0:
        return 1
    if dp[n][x]>-0.9:
        return dp[n][x]  
    if n==0:
        return 0
    
    dp[n][x] = (arr[n-1])*func(n-1,x-1) + (1-arr[n-1])*func(n-1,x)
    return dp[n][x]

print("%0.10f"%func(n,(n+1)//2))


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

int main(){
    int n;
    long sum = 0;
    long i = 1;
    cin >> n;

    while(i <= n){
        if(i%3 !=0){
            if(i%5 !=0){
                sum += i;
            }
        }
        i++;
    }
    cout << sum;

}

Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int result = 0;
        for(int i = 0;i<3;i++){
            char c1 = s.charAt(i);
            char c2 = t.charAt(i);
            if(c1 == c2){result++;}
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};



int main(void){
    int x;
    cin >> x;
    int b = x % 100;
    int a = x / 100;
    
    bool ya = 0;
    if(1 <= a && a <= 12){
        ya = 1;
    }
    
    bool yb = 0;
    if(1 <= b && b <= 12){
        yb = 1;
    }
    if(ya && yb){
        cout << "AMBIGUOUS" << endl;
    }else if(ya){
        cout << "MMYY" << endl;
    }else if(yb){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    
    
}


Measured memory_bytes: 256
import math

def leng(ax,ay,bx,by):
    aa=ax-bx
    bb=ay-by
    return (aa*aa+bb*bb)**0.5

def main():
    n=int(input())
    x = [0] * n
    y = [0] * n
    for i in range(n):
        x[i], y[i] = map(int, input().split())
        cnt=0.0
    for i in range(0,n):
        for j in range(i+1,n):
            cnt+=leng(x[i],y[i],x[j],y[j])
    cnt/=n
    print(cnt*2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long K = sc.nextLong();
		long count = 0;
		long check = 1;
		int l = S.length();
		int first = 1;
		int last = 1;
		int oddCheck = 1;
		if(l > 2 && S.substring(0,1).equals(S.substring(l-1,l))) {
			for(int i = 0; i < l-1; i++) {
				if(S.substring(i,i+1).equals(S.substring(i+1,i+2))) {
					first++;
				}else {
					break;
				}
			}
			for(int i = l; i >= 2; i--) {
				if(S.substring(i-1,i).equals(S.substring(i-2,i-1))) {
					last++;
				}else {
					break;
				}
			}
			for(int i = first; i <= l-last-1; i++) {
				if(S.substring(i, i+1).equals(S.substring(i+1, i+2))) {
					check++;
				}else {
					count += (check / 2) * K;
					check = 1;
				}
			}
			count += first/2 + (first+last)/2 * (K-1) + last/2;
			for(int i = 0; i < l-1; i++) {
				if(S.substring(i,i+1).equals(S.substring(i+1,i+2))) {
					oddCheck++;
				}else
				break;
			}
			if(oddCheck == l) {
				count = l*K / 2;
			}
		}else if(l > 2 && !(S.substring(0,1).equals(S.substring(l-1,l)))) {
			for(int i = 0; i < l-1; i++) {
				if(S.substring(i,i+1).equals(S.substring(i+1,i+2))) {
					first++;
				}else {
					break;
				}
			}
			for(int i = l; i > 1; i--) {
				if(S.substring(i-1,i).equals(S.substring(i-2,i-1))) {
					last++;
				}else {
					break;
				}
			}
			for(int i = first; i <= l-last-1; i++) {
				if(S.substring(i, i+1).equals(S.substring(i+1, i+2))) {
					check++;
				}else {
					count += (check / 2) * K;
					check = 1;
				}
			}
			count += first/2 * K + last/2 * K;
		}else if(l == 2 && S.substring(0,1).equals(S.substring(1,2))) {
			count += K;
		}else if(l == 2 && !(S.substring(0,1).equals(S.substring(1,2)))) {
			count = 0;
		}else{	//|S|=1
			count += K /2 ;
		}
		System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n+1);
    vector<int>moto(n+1);
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=n;i++){
        moto[a[i]]=i;
    }
     for(int i=1;i<=n;i++){
         cout << moto[i] << endl;
     }
}

Measured memory_bytes: 1664