akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define pii pair<ll,ll>
#define forn(i,n) for(int i=0;i<n;i++)
int main()
{
    boost;
    map<char,int> m1;
    string s;
    cin>>s;
    int f=0;
    forn(i,s.size())
    {
        m1[s[i]]=1;
    }
    vector<char> ans;
    string A="abcdefghijklmnopqrstuvwxyz";
    forn(i,A.size())
    {
        if(m1[A[i]]==0)
        {
            ans.pb(A[i]);
            f=1;
        }
    }
    if(!f)
    {
        cout<<"None"<<endl;
        return 0;
    }
    sort(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (a*b >= c*d) {
		printf("%d\n", a*b);
	} else {
		printf("%d\n", c*d);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sum = 0;
	REP(i,n){
		int a;
		cin >> a;
		sum += a-1;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
main = getLine >>= putStrLn . f . map read . words
f [x, y, x', y'] =
  r dx
    ++ u dy
    ++ l dx
    ++ d (dy + 1)
    ++ r (dx + 1)
    ++ u (dy + 1)
    ++ l 1
    ++ u 1
    ++ l (dx + 1)
    ++ d (dy + 1)
    ++ r 1
 where
  [l, r, d, u] = map (flip replicate) "LRDU"
  (dy, dx)     = (y' - y, x' - x)



Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = str.indexOf("A");
		int y = str.lastIndexOf("Z");

		System.out.println(y-x+1);

	}

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
struct ed {
    double x; 
    double y;  
    double l; 
    double a;
};

int main() {
  int n,m,x;
  cin >> n >> m;
  vvi s(m);
  vi p(m),k(m);
  REP(i,m) {
    cin >> k[i];
    REP(j,k[i]) {
      cin >> x;
      x--;
      s[i].push_back(x);
    }
  }
  REP(i,m) cin >> p[i];
  int cnt=0;
  REP(i,pow(2,n)) {
    int c=0;
    REP(j,m) {
      int ktemp=0;
      REP(l,k[j]) {
        if((1&i>>s[j][l])==1) ktemp++;
      }
      if(ktemp%2==p[j]) c++;
    }
    if(c==m) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll h,a;
cin>>h>>a;
ll cnt=0;
while(h>0)
{
    h=h-a;
    cnt++;
}
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()

if n == 1 or m == 1:
    if n*m == 1:
        print(1)
    else:
        print(n*m-2)
else:
    print((n-2)*(m-2))

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
ans = 0
 
for xx in range(a+1):
    A = 500*xx
    for y in range(b+1):
        B = 100*y
        for z in range(c+1):
            C = 50*z
            if x == A+B+C:
                ans += 1
            else:
                continue
 
 
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  long long N,ans=1LL;
  cin>>N;
  string S;
  cin>>S;
  for(char t='a';t<='z';t++){
    long long cnt=1LL;
    for(int i=0;i<N;i++){
      if(S[i]==t){
        cnt++;
      }
    }
    ans*=cnt;
    ans%=1000000007;
  }

  cout<< ans-1LL <<endl;
}



Measured memory_bytes: 512
-- Character - Counting Characters

import Data.List
import Data.Char

main :: IO ()
main = do
  xs <- getContents
  let ys = group . dropWhile (/= 'a') . sort . map toLower $ xs ++ ['a' .. 'z']
  mapM_ putStrLn $ map format [(a, length x - 1) | x@(a : _) <- ys]
    where format (a, b) = (a : " : ") ++ show b



Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  string s,t; cin>>s>>t;
  bool ok=true;
  rep(i,0,s.size()){
    if(s[i]!=t[i]) ok=false;
  }
  if(ok){
    cout<<"Yes"<<endl;
    return 0;
  }
  rep(i,0,s.size()){
    if(s[i]!=t[1+i]) ok=false;
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3624
///////////////////////////
///////////////////////////
//WORD
/////////////////////////

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        //???
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


vector<ll> prime_fact(ll n){
    vector<ll> ret;ll k=n;bool flag;
    while(k>1)
    {
        ll s=sqrt(k)+1;flag=false;ll i=2;
        while(k%i!=0){
            if(i>=s){
                flag=1;break;
            }
            i++;
        }
        if(flag){
            ret.push_back(k);  k=1;
        }
        else{
            k/=i;  ret.push_back(i);
        }
    }
    return ret;
}
//問題やばいのは素数きても{1,1,1,1,p}{1,1,1,p,1}みたいな場合があり得る
//だから足りない分は1で埋めるし、
//普通に{2,3,4}の順列数えた後に{24,1,1}とかも数えに行かなきゃいけない
int main(){
    COMinit();
    ll n,m;
    cin>>n>>m;
    vector<ll> p=prime_fact(m);//O(log(m))
    ll el=p.size();//要素数
    map<ll,ll> ma;
    for(ll x:p){
        ma[x]++;
    }
    //これでダブリカウントできるなぁ
    //重複組み合わせ蟻本P67
    ll ans=1;
    for(auto x:ma){
        ll num=x.second;
        //(N+r)Cr=(N+r)CNなので2引数目はnumでもn-1でもいいや
        ll tmp=COM(num+n-1,n-1);
        ans=(ans*tmp)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const ll mod=1000000007;
    int n,c;
    cin >> n >> c;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    const int N=400;
    vector<vector<ll>> pw(N+1,vector<ll>(N+1,1));
    for(ll p=1;p<=N;p++) for(int i=1;i<=N;i++) pw[p][i]=(pw[p][i-1]*p)%mod;
    vector<ll> now(c+1,0);
    now[0]=1;
    for(int i=0;i<n;i++)
    {
        vector<ll> nxt(c+1,0);
        vector<ll> sum(c+1,0);
        for(ll x=a[i];x<=b[i];x++) for(int k=0;k<=c;k++) sum[k]=(sum[k]+pw[x][k])%mod;
        for(int k=0;k<=c;k++) for(int j=c-k;j>=0;j--) nxt[j+k]=(nxt[j+k]+now[j]*sum[k])%mod;
        now=nxt;
    }
    cout << now[c] << "\n";
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n,i,j,count=0;
    n=s.size();
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
            if(s[i]==s[j])
            count++;
    }
  if(count==2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = b; i >= (a); --i)
#define repdl(i, a, b) for(ll i = b; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif

using namespace std;

ll cnt[19][19];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n; read(n);
  rep(i, 0, n) {
    string s; read(s);
    char a[15], b[15];
    if (find(all(s), '.') != s.end())
      sscanf(s.c_str(), "%[^.].%s", a, b);
    else
      sscanf(s.c_str(), "%s", a), sscanf("0", "%s", b);
    string sa(a), sb(b);
    while (sb.size() < 9) sb += '0';
    ll va = stoll(sa), vb = stoll(sb);
    ll r = va * 1'000'000'000ll + vb;
    //write(r);
    ll c2 = 0, c5 = 0;
    while (r % 2 == 0 && c2 < 18) r /= 2, c2++;
    while (r % 5 == 0 && c5 < 18) r /= 5, c5++;
    //write(c2, c5);
    cnt[c2][c5]++;
  }

  ll ans = 0;
  rep(i, 0, 19) rep(j, 0, 19) rep(k, 0, 19) rep(l, 0, 19) 
    if (i + k >= 18 && j + l >= 18) {
      if (i != k || j != l) ans += cnt[i][j] * cnt[k][l];
      else ans += cnt[i][j] * (cnt[i][j] - 1);
    }
  write(ans / 2);
}



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

#define MAX 100009
#define INF 99999999
#define MIN -99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()
#define mp       make_pair
#define ll	long long
#define FI	first
#define SE second

using namespace std;
int q;
int l,r;
vector<bool> prime(MAX,true);
vector<int> primeSum(MAX,0);
void init(){
  prime[0] = prime[1] = false;

  for(int i=2; i*i<MAX-2; i++){
    if(prime[i]){
      for(int j=i*2; j<MAX-2; j+=i){
        prime[j] = false;
      }
    }
  }
}
int main() {
  init();
  for(int i=1; i<MAX-2;i++){
    if(prime[i]) {
      if (prime[i] && prime[(i + 1) / 2]) {
        primeSum[i]++;
      }
    }
  }
  for(int i=1; i<MAX-2; i++){
    primeSum[i] += primeSum[i-1];
  }
  cin >> q;
  while(q--){
    cin >> l >> r;
    cout << abs(primeSum[r+1] - primeSum[l-1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	set<int>s;
	int a,b,c;
	cin >> a >> b >> c;
	s.insert({a,b,c});
	s.size()==2?cout <<"Yes" : cout << "No";
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

void solve(){
    int N;
    cin >> N;

    int T, A;
    cin >> T >> A;
    vector<double> Hs(N);
    for (int i = 0; i < N; i++) {
        cin >> Hs[i];
    }

    int ans=0;
    double mindiff=1000000.0;
    for (int i = 0; i < N; i++) {
        if (mindiff > abs(A - T + Hs[i]*0.006)) {
            mindiff = abs(A - T + Hs[i]*0.006);
            ans = i;
        }
    }

    cout << ans+1 << endl;


    
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){

	int r,c,buf;

	cin >> r >> c;

	vector < vector < int> > table(r+1, vector <int>(c+1, 0));


	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> buf;
			table[i][j] = buf;
			cout << buf << " ";
			table[i][c] += buf;
			table[r][j] += buf;
			table[r][c] += buf;
		}
		cout << table[i][c] << endl;
	}

	for (int j = 0; j < c; j++){
		cout << table[r][j] << " ";
	}
	cout << table[r][c] << endl;


	return 0;
}

Measured memory_bytes: 1256
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int m = in.nextInt();
    for(int i=0;i<m;i++)
    {
      int x = in.nextInt();
      n-=x;
    }
    if(n>=0)
    System.out.println(n);
    else
      System.out.println("-1");
  }
}
    


Measured memory_bytes: 46252
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
bool judge[101];

signed main(void) {

   cin >> N;
    rep(i,101){
        judge[i] = false;
    }

    int f = 0;
    int s = 0;
    while(s*7 <= 100){
        while(s*7 + f*4 <= 100){
            judge[s*7 + f*4] = true;
            f++;
        }
        s++;
        f=0;
    }

    if(judge[N]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define puts(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;

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

void solve(void){
	ll N, X;
	cin >> N >> X;
	putln((N - gcd(N, X)) * 3);
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 384
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ
 
    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]
 
    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
 
    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)
 
    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]

def kruskal(max_vertex,edges):
    edges.sort(key=lambda x:x[2])#costでソート
    uf=UnionFind(max_vertex)
    mst=[]
    for edge_cost in edges:
        es,ee,cost=edge_cost
        if not uf.is_same(es,ee):
            uf.unite(es,ee)
            mst.append([(es,ee),cost])
    return mst
         


#costでソートするから[頂点,頂点,重み]でもったほうがいいのでは
v,e=map(int,input().split())#v: 頂点の数 e:辺の数
graph=[]
for i in range(e):
    f,s,cost=map(int,input().split())
    graph.append([f,s,cost])#頂点0スタート

ans=0
for i in kruskal(v,graph):
    ans+=i[1]
print(ans)




Measured memory_bytes: 26368
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

const int MAXN = 13;
const double inf = 1e10;
int N;
int W;
int R[MAXN];
double dp[1<<MAXN][MAXN];

int main() {
  string line;
  while(getline(cin, line)) {
    stringstream ss(line);
    ss >> W;
    N = 0;
    while(ss >> R[N]) ++N;
    fill(dp[0], dp[1<<MAXN], inf);
    for(int i = 0; i < N; ++i) {
      dp[1<<i][i] = R[i];
    }
    for(int b = 0; b < (1<<N); ++b) {
      for(int i = 0; i < N; ++i) {
        for(int k = 0; k < N; ++k) {
          if(b&(1<<k)) continue;
          int d = (R[i]+R[k])*(R[i]+R[k]) - (R[i]-R[k])*(R[i]-R[k]);
          dp[b|(1<<k)][k] = min(dp[b|(1<<k)][k], dp[b][i] + sqrt(d));
        }
      }
    }
    double res = inf;
    for(int i = 0; i < N; ++i) {
      res = min(res, dp[(1<<N)-1][i]+R[i]);
    }
    if(res <= W) cout << "OK" << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 2048
#

N, M = list(map(int,input().split()))
if N == M == 1:
    print('1')
elif N == 1 and M > 1:
    print(M - 2)
elif M == 1 and N > 1:
    print(N - 2)
else:
    print((N - 2)*(M - 2))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll A, B; cin>>A>>B;
    cout<<max({A+B, A-B, A*B}) <<endl;
    return 0;
}

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

int main(void){
  string s;
  cin >> s;
  int flg=0;
  for(int i=0;i<s.size();++i){
    char c = s[i];
    for(int j=i+1;j<s.size();++j){
      if(s[j]==c) flg=1;
    }
  }
  if(flg==1) cout << "no\n";
  else cout << "yes\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


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

    int N;
    cin >> N;
    pair<int, int> A[100000] = {};

    for0(i, N){
        cin >> A[i].first;
        A[i].second = i;
    }

    sort(A, A + N, [](pair<int, int> a, pair<int, int> b)
                   {return a.first < b.first;});

    for0(i, N){
        cout << A[i].second + 1;
        cout << (i == N - 1 ? "" : " ");
    }

    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
  ll x=1;
  ll a,b;cin>>a>>b;
  for(ll i=1;i<=30;i++){
    if(x*a+1-x>=b)
      break;
    x++;
  }
  if(b==1)
    cout<<"0";
  else cout<<x;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long x = sc.nextLong();
		long num500 = 0;
		long num5 = 0;
		long n = (x / 500);
		num500 += n * 1000;
		x = x - (500 * n);
		num5 = (x / 5) * 5;
		
		out.println(num500 + num5);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int load[5][5]={0};
    rep(i,0,3){
        int a,b;
        cin>>a>>b;
        a--;b--;
        load[a][b]=1;
        load[b][a]=1;
    }

    bool ok=false;
    rep(i,0,4){
        rep(j,0,2){
            if(load[i][j]==load[3-i][3-j])ok=true;
            else {ok=false;break;}
        }
    }
    cout<<(ok?"YES":"NO")<<endl;
    return 0;
}

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

bool has3(int x){
    while(x){
        if ( x % 10 == 3 ) return true;
        x /= 10;
    }
    return false;
}

void call(int n){
    for ( int x = 1; x <= n; x++ ){
        if ( x % 3 == 0 || has3(x) ){
            cout << " " << x;
        }
    }
    cout << endl;
}

int main(){
    int n;
    cin >> n;
    call(n);
    
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
  int n;
  char c;
}member;

void selectionSort(member *,int);
void bubbleSort(member *,int);
void swap(member *,member *);
int main(){
  int i,n,flag=0;
  member *buble,*selection;
  scanf("%d",&n);
  buble = (member *)malloc(n * sizeof(member));
  selection = (member *)malloc(n * sizeof(member));
  for(i=0;i<n;i++){
    scanf(" %c",&buble[i].c);
    scanf("%d",&buble[i].n);
  }
  for(i=0;i<n;i++){
    selection[i]=buble[i];
  }
  bubbleSort(buble,n);
  for(i=0;i<n;i++){
    printf("%c%d",buble[i].c,buble[i].n);
    if(i!=n-1){
      printf(" ");
    }
    else printf("\n");
  }
  printf("Stable\n");

  selectionSort(selection,n);
  for(i=0;i<n;i++){
    printf("%c%d",selection[i].c,selection[i].n);
    if(i!=n-1){
      printf(" ");
    }
    else printf("\n");
  }
  for(i=0;i<n;i++){
    if(buble[i].n==selection[i].n && buble[i].c!=selection[i].c){
      flag=1;
      break;
    }
  }
  if(flag==0)printf("Stable\n");
  else printf("Not stable\n");


  
  return 0;
}

void bubbleSort(member *m,int n){
  int flag=1,i;
  while(flag){
    flag=0;
    for(i=n-1;i>0;i--){
      if(m[i].n < m[i-1].n){
        swap(&m[i],&m[i-1]);
        flag=1;
      }
    }
  }
}

void selectionSort(member *m,int n){
  int i,j,minj;
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(m[j].n < m[minj].n){
        minj = j;
      }
    }
    if(minj!=i){
      swap(&m[minj],&m[i]);
    }
  }
}

void swap(member *x,member *y){
  member r;
  r=*x;
  *x=*y;
  *y=r;
}



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

main(){
	while(true){
		char r[1000];

		cin>>r;

		// 入力の終わりはゼロひとつの行で示されます
		if( strcmp(r,"0") == 0 ){
			return 0;
		}

		cin>>(r+strlen(r));

		cin>>(r+strlen(r));

		int a=0, b=0;
		for(int i=1; r[i]!='\0'; ++i){

			if( r[i] == 'A'){
				a++;
			}else{
				b++;
			}

			if( (min(a,b)<10&&10<max(a,b)) || (10<=min(a,b) && 1<abs(a-b))){
				cout<<a<<" "<<b<<endl;
				a=0, b=0;
			}
		}
		
		(a>b?a:b)++;
		
		cout<<a<<" "<<b<<endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>

using namespace std;

using ll = long long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll x;
	cin >> x;
	
	ll res = 0;
	res += x / 1000 * 2000;
	if (x % 1000 >= 500) {
		res += 1000;
		res += x % 1000 - 500 - x % 10;
	} else {
		res += x % 1000 - x % 10;
	}
	if (x % 10 >= 5) res += 5;
	
	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    n, m = map(int, input().split())

    d = {}
    for i in range(1, n+1):
        d[i] = 0
    
    for _ in range(m):
        a, b = map(int, input().split())
        d[a] += 1
        d[b] += 1

    for i, v in sorted(d.items()):
        print(v)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string N = Console.ReadLine();
		int K = int.Parse(Console.ReadLine());
		long[,]D0 = new long[N.Length+1,5];
		long[,]D1 = new long[N.Length+1,5];
		D1[0,0] = 1;
		for(var i=0;i<N.Length;i++){
			int n1 = int.Parse(N.Substring(i,1));
			for(var j=0;j<5;j++){
				D0[i+1,j] += D0[i,j];
				if(n1>=1){
					D0[i+1,j] += D1[i,j];
				} else {
					D1[i+1,j] += D1[i,j];
				}
			}
			for(var j=1;j<5;j++){
				D0[i+1,j] += D0[i,j-1] * 9;
				if(n1>=1){
					D1[i+1,j] += D1[i,j-1];
					D0[i+1,j] += D1[i,j-1] * (n1-1);
                }
			}
		}
		for(var i=0;i<=N.Length;i++){
			for(var j=0;j<5;j++){
              Console.Error.Write(D0[i,j]+" ");
            }
			for(var j=0;j<5;j++){
              Console.Error.Write(D1[i,j]+" ");
            }
          	Console.Error.WriteLine();
		}
		Console.WriteLine(D0[N.Length,K]+D1[N.Length,K]);
	}
}

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

int main()
{
  string result;
  cin >> result;
  
  int num_siai = result.length();
  int win = 0;
  for(int i = 0; i < num_siai; i++){
    if(result[i] == 'o') win++;
  }
  
  if(win + (15 - num_siai) >= 8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  //cout << win;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, i, j;
	long max = -999999999999999999, min = 999999999999999999, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &j);
		sum += j;
		if (j > max)
			max = j;
		if (j < min)
			min = j;
	}
	printf("%ld %ld %ld\n", min, max, sum);

	return(0);
}

Measured memory_bytes: 600
#include <iostream>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(int argc, char const *argv[])
{
    int n, m, l;
    cin >> n >> m >> l;
    ll matA[100][100]{}, matB[100][100]{}, matans[100][100]{};

    rep(i, n)rep(j, m) cin >> matA[i][j];
    rep(i, m)rep(j, l) cin >> matB[i][j];
    
    rep(i, n)rep(j, l)rep(k, m) matans[i][j] += matA[i][k] * matB[k][j];

    rep(i, n){
        rep(j, l) {
            cout << matans[i][j];
            if(j!=l-1) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  char S[N];
  cin >> S;
  int ans = 1;
  for(int i=0; i<N-1; i++){
    if(S[i]!=S[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:i64 b:i64));
    //i+1本目の高さ
    let hei = (1..1000).map(|n| (n + 1) * n / 2).collect::<Vec<_>>();
    //iとi+1の差
    let i = hei
        .clone()
        .into_iter()
        .skip(1)
        .zip(hei.clone().into_iter())
        .map(|(x, y)| x - y)
        .enumerate()
        .find(|&(_, x)| x == b - a)
        .unwrap()
        .0;

    (hei[i] - a).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "8 13" => "2",
    test2: "54 65" => "1",
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int A,B; cin >> A >> B;
    if(A >= 10 || B >= 10){
        cout << -1 << endl;
    }
    else cout << A*B << endl;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		40010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//




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

	if(S[0]=='S')puts("Cloudy");
	else if(S[0]=='C')puts("Rainy");
	else puts("Sunny");

	return 0;
}




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

int main(){
  char s[101], p[101], r[201];

  scanf("%s %s",s,p);
  strcpy(r,s);
  strcat(r,s);
  
  if(strstr(r,p)==NULL) printf("No\n");
  else printf("Yes\n");
  
  return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    char num[1000] = "1";
    
    while(1){
        int S = 0;
        
        scanf("%s", num);
        
        if(num[0] == '0')break;
        
        for(int i = 0; i < 1001; i++){
            if(num[i] == '\0')break;
            
            S += (num[i] - '0');
        }
        
        cout << S << endl;
        
    }
}


Measured memory_bytes: 3132
//Substring 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s,t;cin>>s>>t;
    int ans = inf;
    rep(i,0,s.size()-t.size()+1){
        int c = 0;
        rep(j,0,t.size()){
            if(s[i+j]!=t[j])c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your code here Tanmay:)
	int n;
	string s;
	cin>>s;
	string st[8];
	st[1]="SAT";
	st[2]="FRI";
	st[3]="THU";
	st[4]="WED";
	st[5]="TUE";
	st[6]="MON";
	st[7]="SUN";
	for(int i=1;i<=7;i++)
	{
		if(st[i]==s)
			cout<<i;
	}

}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
num = list(input())
num = [int(i) for i in num]
 
if sum(num) == 7:
    print(f'{num[0]}+{num[1]}+{num[2]}+{num[3]}=7')
elif num[0]+num[1]+num[2]-num[3] == 7:
    print(f'{num[0]}+{num[1]}+{num[2]}-{num[3]}=7')
elif num[0]+num[1]-num[2]+num[3] == 7:
    print(f'{num[0]}+{num[1]}-{num[2]}+{num[3]}=7')
elif num[0]-num[1]+num[2]+num[3] == 7:
    print(f'{num[0]}-{num[1]}+{num[2]}+{num[3]}=7')
elif num[0]+num[1]-num[2]-num[3] == 7:
    print(f'{num[0]}+{num[1]}-{num[2]}-{num[3]}=7')
elif num[0]-num[1]+num[2]-num[3] == 7:
    print(f'{num[0]}-{num[1]}+{num[2]}-{num[3]}=7')
elif num[0]-num[1]-num[2]+num[3] == 7:
    print(f'{num[0]}-{num[1]}-{num[2]}+{num[3]}=7')
else:
    print(f'{num[0]}-{num[1]}-{num[2]}-{num[3]}=7')

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

ll dp[100001];

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(ll i=2;i<n;i++)
    {
        dp[i]=min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
 
    }
    cout<<dp[n-1]<<endl;

	return 0;
}

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

#define int long long
#define MOD 1000000007
 
using namespace std;

bool enough(int t,int n,int a,int b,int h[]){

    int c = a-b;
    int sum=0;

    for(int i=0;i<n;i++){
        int temp=h[i]-b*t;
        if(temp>0){
            int count = ceil((float)temp/c);
            sum = sum + count;
        }



        if(sum>t){
            return false;
        }

    }
    return true;

}



signed main(){

    int N,A,B;
    cin>> N >> A >> B;
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }

    int min = 1;
    int max = MOD;


    while(1){
        int pos = (min+max)/2;


        if((max-min)==1){

           if(enough(min,N,A,B,h)){
               cout <<min<<endl;
               return 0;
           }

            else{
                cout << max <<endl;
                return 0;
            }

        }

        if(enough(pos,N,A,B,h)){
            max = pos;
        }

        else{
            min = pos;
        }

    }

}

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

using namespace std;

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

    int n;
    cin >> n;

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

    vector <int> even, odd;

    for (int i = 0; i < n; i++) {
        if (i & 1) {
            odd.push_back(a[i]);
        } else {
            even.push_back(a[i]);
        }
    }
    int answer = 0;
    
    sort(a.begin(), a.end());
    for (int x : odd) {
        int num = lower_bound(a.begin(), a.end(), x) - a.begin();
        if (num % 2 == 0) answer++; 
    }

    cout << answer;
    
    return 0;
}


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

int main()
{
    int n;
    int bk = 0;
    int ret = 0;
  
    cin >> n;

    vector<int> a(n), b(n), c(n-1);
  
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
   
    for(int i = 0; i < n; i++)
    {
        cin >> b.at(i);
    }
  
    for(int i = 0; i < n-1; i++)
    {
        cin >> c.at(i);
    }  
  
    for(int i = 0; i < n; i++)
    {
        ret += b.at(a.at(i)-1);
        if(bk != 0)
        {
		    if(bk == a.at(i) - 1)
            {
              ret += c.at((a.at(i)-1)-1);
            }
        }
        bk = a.at(i);
    }
  
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n;
   cin>>n;
   int cmin=32;
   for(int i=0;i<n;i++)
   {
    int h;
    cin>>h;
    int j;
    for(j=0;j<32;j++)
    {
         if(h&(1<<j))
            break;
    }
      cmin=min(cmin,j);
   }
   cout<<cmin;

 return 0;
}








Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

const int MAX_V = 200005;
vec v[MAX_V];
int cnt[MAX_V];

int main(){
    int n, q;
    cin >> n >> q;
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    rep(i, q){
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    int ans[n];
    fill(ans, ans + n, 0);
    queue<P> que;
    bool visited[n];
    fill(visited, visited + n, false);
    que.push(P(0, cnt[0]));
    ans[0] = cnt[0];
    visited[0] = true;
    while(que.size()){
        P p = que.front();
        que.pop();
        int e = p.first, c = p.second;
        rep(i, v[e].size()){
            if(visited[v[e][i]]) continue;
            ans[v[e][i]] = c + cnt[v[e][i]];
            que.push(P(v[e][i], c + cnt[v[e][i]]));
            visited[v[e][i]] = true;
        }
        // cout << 1 << endl;
    }


    rep(i, n) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 18420