akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(100000000)

def main():
    n,p=map(int,input().split())
    s=list(map(int,list(input())))
    
    if p==2 or p==5:
        cnt=0
        for i in range(n):
            if s[i]%p==0:
                cnt+=i+1
        print(cnt)

    else:
        pmod=[0]*p
        cummod=0
        ten=1
        for i in range(n):
            cummod+=s[-i-1]*ten
            cummod%=p
            pmod[cummod]+=1
            ten*=10
            ten%=p
        
        ans=pmod[0]
        for i in range(p):
            k=pmod[i]
            if k >=2 :
                ans+=k*(k-1)//2
        print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 6560
// Problem : A - Libra
// Contest : AtCoder - AtCoder Beginner Contest 083
// URL : https://atcoder.jp/contests/abc083/tasks/abc083_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int a,b,c,d;cin>>a>>b>>c>>d;
	if(a+b>c+d)
	{
		cout<<"Left";
	}
	else if(a+b==c+d)
	cout<<"Balanced";
	else
	cout<<"Right";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3584
// ===========================================
// 20.02.25
// 
// 
// ===========================================

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ET "\n"
#define CLR(arr) memset(arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;



int main(){
    
    int N;                  //number of songs
    cin >> N;
    vector<string> S(N+1);  //name of song
    vector<int> T(N+1);     //time of song
    
    
    for(int i = 1; i <= N; i++){
        cin >> S[i] >> T[i];
    }
    
    
    string input;
    cin >> input;
    
    int start = 0;
    for(int i = 1; i <= N; i++){
        if(S[i] == input){
            start = i;
            break;
        }
    }
    
    int ans = 0;
    for(int i = start+1; i <= N; i++){
        ans += T[i];
    }
    
    cout << ans;
    
}



Measured memory_bytes: 256
def is_prime(i)
  # 1は素数ではない
  return false if i == 1

  # 2は素数
  return true if i == 2

  judge = true
  (2..i).each do |j|
      # root i までで十分
      break if j > i**0.5 
      if i % j == 0
        judge = false
        break
      end
   end
   return judge   
end

x = gets.to_i

loop do
  if is_prime(x)
    puts x
    break
  end
  x += 1
end


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

using namespace std;

#define int long long 
#define INF 21000000000



signed main(){
		int n,k,q;
		cin >> n >> k >> q;
		vector<int> a;
		for(int i=0;i<n;i++){
				a.push_back(k-q);
		}
		for(int i=0;i<q;i++){
				int tmp;
				cin >> tmp;
				a[tmp-1] += 1;
		}
		for(auto& A : a){
				if(A > 0) cout << "Yes" << endl;
				else cout << "No" << endl;
		}
}



Measured memory_bytes: 1524
import math
nums = [int(e) for e in input().split()]
a = nums[0]
b = nums[1]
x = nums[2]
if a * a * b < 2 * x:
    print(math.degrees(math.atan(2*b/a - 2*x/(a**3))))
else:
    print(math.degrees(math.atan(a*b*b/(2 * x))))

Measured memory_bytes: 3316
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	string s;cin>>s;
	int numB=0,ans=0;
	rep(i,s.size()){
		if(s[i]=='B') numB++;
		if(s[i]=='W') ans+=numB;
	}
	cout<<ans<<endl;
}

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

#define ll long long
const ll inf=2e18;

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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=-inf;
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;
    return 0;
}

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

int main()
{
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	sort(a,a+n);
	
	cout<<a[n-1]-a[0]<<endl;
	
	return 0;
}


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

int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  int g = __gcd(a, b);
  int g2 = __gcd(c, d);
  double mx;
  int mxw, mxs;
  bool can1[2][3001];
  bool can2[2][3001];
  memset(can1, 0, sizeof(can1));
  memset(can2, 0, sizeof(can2));
  for(int i = 0;i <= 3000;i += 100){
    if(i % (100 * a) == 0)
      can1[0][i] = 1;
  }
  for(int i = 0;i <= 3000;i += 100){
    if(i % (100 * b) == 0){
      for(int j = 0;j <= 3000;j += 100){
        if(can1[0][j] && i + j <= 3000)
          can1[1][j + i] = 1;
      }
    }
  }
  for(int i = 0;i <= 3000;i++){
    if(i % c == 0)
      can2[0][i] = 1;
  }
  for(int i = 0;i <= 3000;i ++){
    if(i % d == 0){
      for(int j = 0;j <= 3000;j++){
        if(can2[0][j] && i + j <= 3000)
          can2[1][j + i] = 1;
      }
    }
  }
  mx = -1;
  for(int i = 0;i <= f;i += 100){
    if(can1[1][i]){
      for(int j = f - i;j >= 0;j--){
        if(can2[1][j] && i / 100 * e >= j){
          double sol = 1.0 * j / (i + j);
          if(sol > mx){
            mx = sol;
            mxw = i, mxs = j;
          }
        }
      }
    }
  }
  cout << mxw + mxs << ' ' << mxs;
  return 0;
}


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

using namespace std;

int main(){
	int n;
	int ans=0;
	
	cin >> n;
	
	vector<int> v(n);
	
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			ans += v[i]*v[j];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}
				

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define REP(i,begin,end) for(int i=begin;i<=end;i++)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

#define MAXN 100002

int n;
int a[MAXN], b[MAXN], c[MAXN];
int dp[MAXN][3];

int main(){
fio

cin >> n;
REP(i,1,n) cin >> a[i] >> b[i] >> c[i];

dp[1][0] = a[1];
dp[1][1] = b[1];
dp[1][2] = c[1];

REP(i,2,n){
	dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
	dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
	dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
}

cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
return 0;
}

Measured memory_bytes: 2560
n, m, c = map(int, input().split())
B = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    tmp = 0
    A = [int(i) for i in input().split()]
    for a, b in zip(A, B):
        tmp += a * b
    if tmp + c > 0:
        ans += 1
        
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; i++) cin >> w[i];
  int ans = 1e9;
  for(int i = 1; i < n; i++){
    int l = 0, r = 0;
    for(int j = 0; j < i; j++){
      l += w[j];
    }
    for(int j = i; j < n; j++){
      r += w[j];
    }
    ans = min(ans, abs(l - r));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){
  ll N;
  cin >> N;
  vector<ll> a(N);
  for(auto &&x:a)cin>>x;

  ll b = 0;
  for(auto x:a){
    b ^= x;
  }
  if(b==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int n,m; cin>>n>>m;
    vector<int> k(m); 
    vector<unsigned int> s(m,0);
    rep(i,m){
        cin>>k[i];
        rep(j,k[i]){
            int a;
            cin>>a;
            s[i]|=(1<<(a-1));
        }
    }
    vector<int> p(m);
    rep(i,m){
        cin>>p[i];
    }

    int cnt=0;
    for(int bit=0; bit<(1<<n); bit++){
        unsigned int check=0;
        rep(i,m){
            int kosuu=0;
            kosuu=__builtin_popcount(bit & s[i]);
            if(kosuu%2==p[i]){
                check|=(1<<i);
            }
        }
        if(check==((1<<m) -1)){
            cnt++;
        }
    }   
    cout<<cnt<<endl;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int> > ship_map(N - 1);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        ship_map[a].push_back(b);
    }
    bool ans = false;
    rep(i,ship_map[0].size()){
        rep(j,ship_map[ship_map[0][i]].size()){
            if (ship_map[ship_map[0][i]][j] == N - 1){
                ans = true;
            }
        }
    }
    if (ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 8576
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int dp[1010][20010];

int main() {
    int h, n, a[1010], b[1010];
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        //dp[i][0] = 0;
        for (int j = 1; j <= h + 10000; j++) dp[i][j] = 1e9;
    }
    dp[0][0] = 0;
    for (int j = 1; j <= h + 10000; j++) dp[n][j] = 1e9;


    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= h + 10000; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            if (j >= a[i]) dp[i + 1][j] = min(dp[i + 1][j], dp[i + 1][j - a[i]] + b[i]);
        }
    }

    int ans = 1e9;
    for (int i = h; i <= h + 10000; i++) ans = min(ans, dp[n][i]);
    cout << ans << endl;

/*
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < 20; j++) cout << dp[i][j] << " ";
        cout << endl;
    }*/
    





}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int gcd(ll a, ll b){
    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

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

bool isin(int x, int y) {
    return 0<=x && x<w && 0<=y && y<h;
}

int main(){
    cin >> h >> w;
    string iro[h];
    REP(i, h) cin >> iro[i];

    REP(i, h) REP(j, w) {
        bool isok = false;
        if(iro[i][j] == '#') {
            REP(k, 4) {
                int y = i + dy[k];
                int x = j + dx[k];
                if(isin(x, y)) if(iro[y][x] == '#') isok = true;
            }
            if(!isok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;

char a_grouping_sub(int n) {
	if (n == 2) return 'C';
	else if ((n == 4) || (n == 6) || (n == 9) || (n == 11)) return 'B';
	else return 'A';
}

void a_grouping(void) {
	int x, y;
	cin >> x >> y;

	if (a_grouping_sub(x) == a_grouping_sub(y)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main() {
  ll N;
  cin >> N;
  P p[MAX];
  ll i;
  
  for(i=0; i<N; i++) {
    ll x, l;
    cin >> x >> l;
    p[i].sc=x-l;
    p[i].ft=x+l;
  }
  sort(p, p+N);
  
  
  ll ans=N;
  ll r=p[0].ft;
  for(i=1; i<N; i++) {
    if(r>p[i].sc) ans--;
    else r=p[i].ft;
  }
  
  pt(ans);
}




















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

int main(){
//srandom((unsigned long)time(NULL));

//maxの数かそのひとつ大きい数字でいけそう
//とりあえず下二つをそろえたらあとはこのふたつを1ずつあげてmaxに一致させる
//maxと2ndmaxが等しければ注意が必要
vector<int> v;
for(int i=0;i<3;i++){
    int x;
    cin>>x;
    v.emplace_back(x);
}
sort(v.begin(),v.end());
int a=v[0];
int b=v[1];
int c=v[2];
//a<=b<=c;
int cnt=0;
//05
//25
//45
if((b-a)%2==0){
        cnt+=(b-a)/2+(c-b);
}else{
    if(b-a==1){
    cnt+=c-b+2;
    }else{
        cnt+=(b-1-a)/2+c-b+2;
    }
}
cout<<cnt<<endl;

//0 33

return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = 1
b = n-1
print((n-1)//2)


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

int main()
{
	int a[100],b[100],c[100];
	int n,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	cin>>b[i];
	for(int i=1;i<=n-1;i++)
	cin>>c[i];
	for(int i=1;i<=n;i++)
	{
		if(i==1){
			s=s+b[a[i]];
		}
		else{
			if(a[i]-1==a[i-1])
			s=s+b[a[i]]+c[a[i]-1];
			else
			s=s+b[a[i]];
		}
	}
	cout<<s<<endl;
} 

Measured memory_bytes: 256
/* 
 * File:   main.c
 * Author: s1252006
 *
 * Created on June 15, 2018, 11:19 AM
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int countPrime(int array[], int length) {
    int nop = 0;
    int isComposite;
    for (int i = 0; i < length; i++) {
        isComposite = 0;
        for (int j = 2; j <= sqrt(array[i]); j++) {
            if (array[i] % j == 0) {
                isComposite = 1;
                break;
            }
        }
//        printf("%d, isComposite: %d", array[i], isComposite);
        if (!isComposite) nop++;
    }
    return nop;
}


int main(int argc, char** argv) {
    int length;
    scanf("%d", &length);
    
    const int nxArray = length;
    int array[nxArray];
    for (int ixArray = 0; ixArray < nxArray; ixArray++)
        scanf("%d", &array[ixArray]);
//    for (int ixArray = 0; ixArray < nxArray; ixArray++)
//        printf("%d ", array[ixArray]);
    
    printf("%d\n", countPrime(array, nxArray));
    

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2124
from fractions import gcd
def f(a):
  res=0
  while a%2==0:
    a//=2
    res+=1
  return res
n,m=map(int,input().split())
a=list(map(int,input().split()))
t=f(a[0])
for i in range(n):
  if t!=f(a[i]):
    print(0)
    exit()
l=1
for i in range(n):
  b=a[i]//2
  l=b*l//gcd(l,b)
print(int(((m/l)+1)//2))

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

int main() {
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(r<=x&&x<=w-r&&r<=y&&y<=h-r) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def main():
    n = int(input())
    a = list(map(int, input().split()))     # 出席番号順
    turn = [0]*(n+1)

    for index, j in enumerate(a, 1):
        turn[j] = index
    print(*turn[1:], sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 56620
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1<<29
#define LLINF 1LL<<60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}

ll N;
ll fact[100010];

ll modcomb(ll n, ll k){
    if(k < 0 || k > n) return 0;
    ll ans = fact[n];
    ans = ans * modpow(fact[k],MOD-2) % MOD;
    ans = ans * modpow(fact[n-k],MOD-2) % MOD;
    return ans;
}

int main() {
    cin >> N;
    vector<ll> cnt(N+1, -1);
    ll a, d1, d2;
    REP(i, N) {
        scanf("%llu", &a);
        if(cnt[a] != -1) {
            d1 = min(cnt[a], ll(i));
            d2 = max(cnt[a], ll(i));
            break;
        }
        cnt[a] = i;
    }
    fact[0] = 1;
    FOR(i, 1, N+2) fact[i] = fact[i-1] * i % MOD;

    ll ans;
    printf("%lld\n", N);
    FOR(k, 2, N) {
        ans = modcomb(N-1, k) % MOD;
        ans = (ans + 2 * modcomb(N-1, k-1)) % MOD;        
        ans = (ans - modcomb(N-1-(d2-d1-1), k-1) + MOD) % MOD;
        ans = (ans + modcomb(N-1, k-2)) % MOD;
        printf("%llu\n", ans);
    }
    printf("1\n");
 	return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int [][]a = new int [n][3];
		
		for(int i = 0; i < n ;i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
			a[i][2] = sc.nextInt();
			
			}
		int [][]dp = new int [n+1][3];
		
		for(int i = 1; i <= n ;i++) {
			for(int j = 0; j < 3 ;j++) {
				dp[i][j] = Math.max(dp[i-1][(j+1)%3] + a[i-1][(j+1)%3], dp[i-1][(j+2)%3] + a[i-1][(j+2)%3]);
			}
		}
		int temp = Math.max(dp[n][0], dp[n][1]);
		int ans = Math.max(dp[n][2], temp);
		
		System.out.println(ans);
	}
		
}


Measured memory_bytes: 98324
#include<stdio.h>
int main(void){
  int N,i,key=0,count=1,sum=0;
  int a[100];
  scanf("%d",&N);
  for(int j=0;j<N;j++){
    scanf("%d",&a[j]);
  }
  key=a[0];
  for(i=1;i<N;i++){
    if(a[i]==key){
      count++;
    }else{
      sum+=count/2;
      count=1;
      key=a[i];
    }
  }
  sum+=count/2;
  printf("%d\n",sum);
  return 0;
}

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

int main() {
  int N, M, a;
  cin >> N >> M;
  vector<int> vec(N, 0);

  for (int i = 0; i < 2 * M; i++) {
  	cin >> a;
    vec.at(a -1)++;
  }
  
  for (int i = 0; i < N; i++) cout << vec.at(i) << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) (a).size() 
#define rep(i,n) for(int i=0;i<n;i++)
#define fors(i,s) for(int i=0;i<s.size();i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	int b[n-1];
	rep(i,n-1){
		cin>>b[i];
	}
	int a[n];
	memset(a,0,sizeof(a));
	rep(i,n){
		if(i==0){
			a[i]=b[i];
		}
		else if(i==n-1){
			a[i]=b[i-1];
		}
		else{
			a[i]=min(b[i-1],b[i]);
		}
	}
	int ans=0;
	rep(i,n){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

   int cnt=0;
   while(b<=a){
      b*=2;
      cnt++;
   }
   while(c<=b){
      c*=2;
      cnt++;
   }

   if(cnt<=k) cout << "Yes" << endl;
   else cout<<"No"<<endl;
   return 0;
}


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

using namespace std;
typedef long long int lli;

const int MAXN = 100010;

int n;

lli A, B;

lli v[MAXN];

bool test(lli k)
{
	lli qtd = 0;

	for(int i = 1 ; i <= n ; i++)
	{
		if( v[i] <= B*k ) continue;

		lli remain = v[i] - B*k;

		qtd += remain/A;
		if( remain%A != 0 ) qtd++;
	}

	return ( qtd <= k );
}

int bs()
{
	int l = 0;
	int r = 1000000010;

	while( l < r )
	{
		int m = ( l + r )/2;

		if( test( m ) ) r = m;
		else l = m + 1;
	}

	return r;
}

int main()
{
	scanf("%d %lld %lld",&n,&A,&B);

	A -= B;

	for(int i = 1 ; i <= n ; i++)
		scanf("%lld",&v[i]);

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

Measured memory_bytes: 1024
fun memorizedRecursive(state: IntArray, memo: Array<IntArray>, current: Int = 0, borderBarrier:Int = 0): Int {
    if (current >= state.size) return 0
    if (memo[current][borderBarrier] >= 0) return memo[current][borderBarrier]
    memo[current][borderBarrier] = when(state[current]){
        0 -> memorizedRecursive(state, memo, current + 1, (borderBarrier - 1).let{if (it >= 0) it else 0})
        1 -> maxOf(memorizedRecursive(state, memo, current + 1, 2) + 1, memorizedRecursive(state, memo, current + 1, (borderBarrier - 1).let{if (it >= 0) it else 0}))
        2 -> if (borderBarrier > 0) memorizedRecursive(state, memo, current + 1, borderBarrier - 1) else memorizedRecursive(state, memo, current + 1, 0) + 1
        else -> if (borderBarrier > 0) maxOf(memorizedRecursive(state, memo, current + 1, 2) + 1, memorizedRecursive(state, memo, current + 1, borderBarrier - 1)) else (memorizedRecursive(state, memo, current + 1, 0) + 1)
    }
    return memo[current][borderBarrier]
}
fun calState(state: Array<String>, x: Int, y: Int): Int {
    return (if (x + 2 < state[y].length && state[y][x] == 'R' && state[y][x + 1] == 'G' && state[y][x + 2] == 'W') 2 else 0) +
            (if (y + 2 < state.size && state[y][x] == 'R' && state[y + 1][x] == 'G' && state[y + 2][x] == 'W') 1 else 0)
}
fun main(args:Array<String>): Unit {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val state = Array(n){readLine()!!.trim()}
    println(
            (0 until m).map{x ->
                if (x < n){
                    //println((0 .. x).map{y -> "(${x - y}, $y)"}.joinToString(","))
                    memorizedRecursive(IntArray(x + 1){y -> calState(state, x - y, y)}, Array(x + 1){IntArray(3){-1}})
                }else {
                    //println((0 until n).map{y -> "(${x - y}, $y)"}.joinToString(","))
                    memorizedRecursive(IntArray(n){ y -> calState(state, x - y, y)}, Array(n){IntArray(3){-1}})
                }
            }.sum() +
                    (1 until n).map{y ->
                        if (m + y < n){
                            //println((0 until m).map{x -> "(${m - x - 1}, ${y + x})"}.joinToString(","))
                            memorizedRecursive(IntArray(m){x -> calState(state, m - x - 1, y + x)}, Array(m){IntArray(3){-1}})
                        }else {
                            //println((0 until n - y).map{x -> "(${m - x - 1}, ${y + x})"}.joinToString(","))
                            memorizedRecursive(IntArray(n - y){ x -> calState(state, m - x - 1, y + x)}, Array(n - y){IntArray(3){-1}})
                        }
                    }.sum()
    )
}


Measured memory_bytes: 183956
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
//#define rem 1000000007
#define cont continue
#define PI 3.141592653589793238462643383279502
#define debug(n1) cout<<"debug... "<<n1<<"\n"
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
/////////////////////////

int main() {
	//code
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
	    int n;
        cin>>n;
        if( n>=30 )
        cout<<"Yes\n";
        else 
        cout<<"No\n";
	}
	return 0;
}


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

using namespace std;

int cum[100005];

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

    int n,k;
    string s;
    cin>>n>>k>>s;
    bool allone=true;
    for(auto x:s){
        if(x=='0'){ allone=false;break;}
    }
    if(allone){ cout<<n<<endl;return 0;}
    vector<pair<int,pair<int,int>>> zero;
    vector<int> ones;
    if(s.back()=='1'){
        s.push_back('0');
    }else 
        s.push_back('1');
    char cur='2';
    ++n;
    for(int i=0;i<n;++i){
        if(s[i]!=cur){
            if(s[i]=='1'){
                if(!ones.empty()&&!zero.empty()){
                    zero.back().second.first=ones.back();
                }
                cur='1';
                ones.push_back(1);
            }else{
                if(!zero.empty()){
                    zero.back().second.second=ones.back();
                }
                cur='0';
                zero.push_back({1,{0,0}});
            }
        }else if(cur=='0') {
            ++zero.back().first;
        }
        else {
            ++ones.back(); 
        }
    }
    if(s.back()=='0'){
        zero.pop_back();
    }else 
        ones.pop_back();
    if(k>=(int)zero.size()){
        cout<<n-1<<endl;
        return 0;
    }
//    for(auto x:zero){ cout<<x.first<<" "<<x.second.first<<" "<<x.second.second<<endl; }

    cum[0]=zero[0].second.first;
    for(int i=1;i<=(int)zero.size();++i){
        cum[i]=zero[i-1].first+zero[i-1].second.second+cum[i-1];
    }
//    for(int i=1;i<=(int)zero.size();++i) cout<<cum[i]<<endl;
    int ans=0;
    cum[0]=0;
    for(int i=1;i<=(int)zero.size()-k+1;++i){
        auto val=cum[i+k-1]-cum[i-1];
        if(i-2>=0){
            val+=zero[i-2].second.second;
        }
        ans=max(ans,val);
    }
   cout<<ans<<endl; 

}


Measured memory_bytes: 1576
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main()
{
	string S = readln.chomp;
    long n;
    char prev = '#';
    foreach(c;S)
    {
        if(c != prev)
        {
            prev = c;
            n++;
        }
    }
    writeln(n-1);
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
 ll d ; cin>> d ;
 ll c[26] ; rep(i,26) cin>>c[i] ;
 ll s[d][26] ;
 rep(i,d){
     rep(j,26){
        cin>> s[i][j] ;
     }
 }
ll t[d] ; 
rep(i,d){
    cin >> t[i] ;
    t[i]-- ;
}
ll ans=0 ;
ll last[26] ; rep(i,26) last[i]=0 ;
rep(i,d){
  ans+= s[i][t[i]] ;
  rep(i,26) last[i] ++ ;
  last[t[i]]=0 ;
  ll sum=0 ;
  rep(i,26) sum+= c[i]*last[i] ;
  ans-= sum ;
  cout<< ans<<endl ;
}
 return 0 ; 
}



Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

ll f[200005],finv[200005];

ll p(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=(res*x)%M;
        x=(x*x)%M;
        n/=2;
    }
    return res;
}

ll nCr(ll n,ll r)
{
    return (((f[n]*finv[r])%M)*finv[n-r])%M;
}

void freak__()
{
    ll h,w,a,b,sum=0,i;
    cin >> h >> w >> a >> b;
    vector<ll> v1,v2;
    f[0]=f[1]=1;
    for(i=2;i<200005;i++) f[i]=(f[i-1]*i)%M;
    finv[0]=finv[1]=1;
    for(i=2;i<200005;i++) finv[i]=(finv[i-1]*p(i,M-2))%M;
    for(i=1;i<=h-a;i++) v1.push_back(nCr(i+b-2,b-1));
    for(i=0;i<h-a;i++) v2.push_back(nCr(h-i+w-b-2,h-i-1));
    for(i=0;i<v1.size();i++) sum=(sum+(v1[i]*v2[i])%M)%M;
    cout << sum << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

Measured memory_bytes: 5620
#include<stdio.h>
int main ()
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	if(a<10)
    {
        c=b+1000-(100*a);
    }
    else
    {
        c=b;
    }
    printf("%d\n",c);

	return 0;
}


Measured memory_bytes: 128
n,m,l = gets.split.map(&:to_i)
a=Array.new(n,0).map{Array.new(m,0)}
b=Array.new(m,0).map{Array.new(l,0)}
c=Array.new(n,0).map{Array.new(l,0)}
n.times do |i|
  a[i] = gets.split.map(&:to_i)
end
m.times do |i|
  b[i] = gets.split.map(&:to_i)
end

n.times do |i|
  l.times do |j|
    m.times do |k|
      c[i][j]=c[i][j]+a[i][k] * b[k][j]
    end
  end
end

n.times do |i|
  puts c[i].map(&:to_s).join(" ")
end



Measured memory_bytes: 7416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
const ll MOD = 1e9+7;
signed main(){
    int n; cin >> n;
    string s; cin >> s;
    if(s[0]=='W'){
        cout << 0 << endl;
        return 0;
    }
    vector<bool> r(2*n,0);
    rep(i,2*n){
        if(i==0){
            r[0]=0;
        }
        else if(s[i-1]==s[i]){
            if(r[i-1]) r[i]=0;
            else r[i]=1;
        }else{
            r[i]=r[i-1];
        }
    }
    int cnt=0;
    rep(i,2*n) if(r[i]) cnt++;
    if(cnt!=n){
        cout << 0 << endl;
        return 0;
    }
    int res=0;
    ll ans=1;
    rrep(i,2*n){
        if(r[i]) res++;
        else{
            ans*=res;
            res--;
        }
        ans%=MOD;
    }
    for(ll i=1;i<=n;i++){
        ans*=i;
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
struct stu{
	int id;
	int t;
}sz[100005];
int n;
inline bool cmp(stu cp1,stu cp2){
	return cp1.t<cp2.t;
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)	scanf("%d",&sz[i].t),sz[i].id=i;
	sort(sz+1,sz+n+1,cmp);
	for(register int i=1;i<=n;i++){
		printf("%d",sz[i].id);
		if(i!=n)	printf(" ");
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> a(N,-1);
    bool flag=true;

    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector<int> dist(N, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while (!que.empty()) {
        int v = que.front();
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
            
            a[nv]= v+1;
        }
        que.pop();
    }

    cout << "Yes" << endl;
    for(int i=1;i<N;i++){
        cout << a[i] << endl;
    }
}

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

int main(){
  string s;
  cin >> s;
  int ans1 = 0, ans2 = 0; 
  rep(i,s.size()){
    if(i%2 == 0 && s[i] == '0') ans1++;
    else if(i%2 == 1 && s[i] == '1') ans1++;
  }
  rep(i,s.size()){
    if(i%2 == 0 && s[i] == '1') ans2++;
    else if(i%2 == 1 && s[i] == '0') ans2++;
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 3756
def main():
    NM = list(map(int,input().split()))
    H = list(map(int,input().split()))

    # AB = [list(map(int,input().split())) for i in range(NM[1])]

    Judge = [True] * NM[0]

    for i in range(NM[1]):
        ABi = list(map(int,input().split()))


        if H[ABi[0]-1] > H[ABi[1]-1]:
            if Judge[ABi[0]-1]:
                Judge[ABi[0]-1] = True
            Judge[ABi[1]-1] = False

        elif H[ABi[0]-1] == H[ABi[1]-1]:
            Judge[ABi[0] - 1] = False
            Judge[ABi[1] - 1] = False

        else:
            Judge[ABi[0] - 1] = False
            if Judge[ABi[1]-1]:
                Judge[ABi[1] - 1] = True

    # print(Judge)
    print(Judge.count(True))











if __name__ == '__main__':
    main()



Measured memory_bytes: 20140
N=int(input())
L=[input() for i in range(N)]
L.sort()
c=1
memo=0
ans=[]
for i in range(1,N):
  if L[i]==L[i-1]:
    c+=1
  else:
    if c==memo:
      ans.append(L[i-1])
    elif c>memo:
      ans.clear()
      ans.append(L[i-1])
      memo=c
    c=1
if c==memo:
  ans.append(L[N-1])
elif c>memo:
  ans.clear()
  ans.append(L[N-1])
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 20680
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
x=800*n
y=200*int(n/15)
print(x-y)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h=1,w=1;
        while(h!=0 && w!=0){
            h = sc.nextInt();
            w = sc.nextInt();
            if(h==0 && w==0){
              break;
            }
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i%2==0){
                        if(j%2==0){
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    } else {
                        if(j%2==0){
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}



Measured memory_bytes: 34832
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
    string S;
    std::cin >> S;
    int keta=S.size()-1;
    ll origin=0;
    int ww=0;
    while (true) {
        if(keta>=0){
            origin+=(S[ww]-48)*pow(10,keta);
            ++ww;--keta;
        }else{
            break;
        }
    }
    ll sum=0;
    for (size_t i = 0; i < S.size(); i++) {
        sum+=S[i]-48;
    }
    if(origin%sum==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
function main(input) {
  const lines = input.trim().split("\n");
  const nums = lines[0].split(' ').map(Number);

  let k = nums.pop();
  let res = 0;
  nums.forEach((n, i) => {
    if (k == 0) return;
    if (k < n) {
      res += k * (1 - i);
      k = 0;
    } else {
      res += n * (1 - i);
      k -= n;
    }
  });
  
  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29860
require 'set'
CARD = 3.times.map{gets.split.map(&:to_i)}.flatten
N = gets.to_i
DECRALE = N.times.map { gets.to_i }

DECRALE.each do |i| 
    CARD.map!{|x| x==i ? 0 : x}
end

zero_index = CARD.each_with_index.map { |x,i| x==0 ? i : nil }.compact.to_set
BINGO = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
ans = "No"
BINGO.each.with_index do |x,i|
    if x.to_set.subset?(zero_index) then
        ans = "Yes"
        break
    end
end

puts ans

Measured memory_bytes: 14500
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  int i,m,r=1e9,n;
  char s[11];
  scanf("%s",s);
  m=strlen(s);
  for(i=0;i<m-2;i++){
    n=100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0';
    if(abs(753-n)<r)r=abs(753-n);
  }
  printf("%d",r);
  return 0;
}


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


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

const long long mx = pow(10, 18);

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  long long ans = 1;
  for(auto now : a){
    if(now == 0){
      cout << 0 << endl;
      return 0;
    }
    if(mx/ans < now){
      cout << -1 << endl;
      return 0;
    }
    ans *= now;
    if(ans > mx){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3980
while True:
    n = int(raw_input())
    if n == 0:
        break

    a = [[] for i in range(n + 1)]
    for i in range(n + 1):
        if i < n:
            a[i] = map(int, raw_input().split())
            a[i].append(sum(a[i]))
        else:
            a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)]

    for i in range(n + 1):
        print "".join(map(lambda x: str(x).rjust(5, " "), a[i])) + "\n",

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1 == M2)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int getIndex(int old)
{
	if( old >= 60 )return (6);
	return (old / 10);
}

int main()
{
	int n;
	int num[7];
	
	while(true)
	{
		n = in();
		if( n == 0 )break;
		for(int i = 0; i < 7; i++)num[i] = 0;
		
		for(int i = 0; i < n; i++)
		{
			num[getIndex(in())]++;
		}
		for(int i = 0; i < 7; i++)
		{
			printf("%d\n", num[i]);
		}
	}
	return (0);
}

Measured memory_bytes: 1188
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register int i = (a); i <= (b); ++i)
#define per(i, a, b) for (register int i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 1e6 + 100 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-5 ;

ll n;

ll f[maxn][10];

char s[maxn];

ll tr[10][2] = {{0, 0}, {2, 3}, {4, 5}, {6, 7}, {2, 2}, {2, 3}, {8, 3}, {7, 7}, {6, 6}, {0, 0}};

signed main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	f[0][1] = 1;
	rep(i, 0, n - 1)
	{
		rep(j, 1, 8)
		{
			if(s[i + 1] != '1') (f[i + 1][tr[j][0]] += f[i][j]) %= mod;
			if(s[i + 1] != '0') (f[i + 1][tr[j][1]] += f[i][j]) %= mod;
		}
	}
	printf("%lld\n", (f[n][3] + f[n][7]) % mod);
	return 0;
}

Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,w,i,j;
  cin>>n>>w;
  ll ww[n+1],cc[n+1],dp[n+1][w+1];
  for(i=1;i<=n;i++)
    cin>>ww[i]>>cc[i];
  for(i=0;i<=w;i++)
  dp[0][i]=0;
  for(i=1;i<=n;i++)
    dp[i][0]=0;
  for(i=1;i<=n;i++)
    for(j=1;j<=w;j++)
      if(j>=ww[i])
      dp[i][j]=max(cc[i]+dp[i-1][j-ww[i]],dp[i-1][j]);
  else
    dp[i][j]=dp[i-1][j];
	j=0;  
  	for(i=1;i<=w;i++)
  	j=max(dp[n][i],j);
  cout<<j;
  
}

Measured memory_bytes: 79104
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Q;
	cin >> N >> Q;

	string S;
	cin >> S;

	vector<pair<char, char>> spell(Q);
	for (int i = 0; i < Q; i++) cin >> spell[i].first >> spell[i].second;

	auto dead = [&](int idx, int key) {

		for (int i = 0; i < Q; i++) {
			if (spell[i].first == S[idx]) idx += spell[i].second == 'L' ? -1 : 1;
			if (idx < 0 || idx >= S.size()) break;
		}

		return idx >= key;
	};

	auto biSearch = [&](auto f, int key) {
		int ng = -1;
		int ok = (int)S.size();

		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;

			if (f(mid, key)) ok = mid;
			else ng = mid;
		}

		return ok;
	};

	int L = biSearch(dead, 0);
	int R = biSearch(dead, S.size());
	if (L < R) cout << R - L << "\n";
	else cout << 0 << "\n";

	return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

ll n,m;
ll ans;

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

  n-=2;
  m-=2;

  if(n<0) n=1;
  if(m<0) m=1;

  cout<<n*m<<endl;

  return 0;
}


Measured memory_bytes: 256