akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;

#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(v) v.begin(), v.end()
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(j) FOR(i, 0, j, 1)
#define rrep(j) RFOR(i, j, 0, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define T ll t; cin>>t; while(t--)

int main(){
  FAST

  string s;
  cin>>s;
  int c=0,i;
  for(i=0; i<s.length()/2; i+=2){
  	if(s[i]=='h' && s[i+1]=='i')
  	c++;
  }
  
  if(s.length()%2 == 0 && c>0)
  cout<<"Yes";
  
  else cout<<"No";
  
  return 0;
}








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

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

    int val = 7%K;

    for(int i=1;i<10000000;i++){
        if(val == 0){
            cout << i << endl;
            return 0;
        }
        val = (val*10 + 7)%K;
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
#define random(a,b) (rand()%(b-a+1)+a)
#define ll long long
#define ull unsigned long long
#define e 2.71828182
#define Pi acos(-1.0)
#define ls(rt) (rt<<1)
#define rs(rt) (rt<<1|1)
#define lowbit(x) (x&(-x))
using namespace std;
int read()
{
	int s=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
	while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
	return x*s;
}
#define P pair<int,int>
P city[10];
int order[10];
double dis(P a,P b){
	return 
	sqrt((double)(a.first-b.first)*(a.first-b.first)+(double)(a.second-b.second)*(a.second-b.second));
}
int main()
{
	int N=read();
	for(int i=1;i<=N;++i){
		cin>>city[i].first>>city[i].second;
		order[i]=i;
	}
	double ans=0.0;
	int num=0;
	do{
		for(int i=1;i<=N-1;++i){
			ans+=dis(city[order[i]],city[order[i+1]]);
		}
		num++;
	}while(next_permutation(order+1,order+N+1));
	printf("%.7f",ans/num);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(x: "List[int]"):
    a = 1
    for i in x:
        if i == 0:
            print(a)
        a += 1
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int(next(tokens)) for _ in range(5)]  # type: "List[int]"
    solve(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
N = int(input())

A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]


sum = 0
previous = -10
for a in A:
    sum += B[a - 1]

    if a == previous + 1:
        sum += C[a - 2]
    previous = a
print(sum)

Measured memory_bytes: 3064
S = list(input())
N = len(S)
K = int(input())

for i in range(N - 1):
    d = (ord("a") - ord(S[i])) % 26
    if d <= K:
        S[i] = "a"
        K -= d

S[-1] = chr((ord(S[-1]) - ord("a") + K) % 26 + ord("a"))
print("".join(S))

Measured memory_bytes: 4156
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

// #define INF 0x3f3f3f3f

using namespace std;

const int N = 2e5 + 10;

int nums[N];
int maxes[N];
const long long INF = 1e18;

map<pair<int, int>, long long> memo;


long long solve(int i, int j) {
    if (i <= 0) return -INF;
    if (2 * j > i + 2) return -INF;
    if (j == 0) return 0;
    if (j == 1) return maxes[i - 1];
    auto it = memo.find(make_pair(i, j));
    if(it != memo.end()) return it->second;
    long long ans = max(solve(i - 2, j - 1) + nums[i - 1], solve(i - 1, j));
    memo[make_pair(i, j)] = ans;
    return ans;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        nums[i] = x;
        if(i == 0) maxes[i] = x;
        else maxes[i] = max(x, maxes[i - 1]);
    }
    int m = n / 2;
    cout << solve(n, m) << "\n";
    return 0;

}



Measured memory_bytes: 36424
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0;
	cin >>n;
	vector<pair<ll,ll>>ab(n);
	rep(i,n){
		cin>>ab[i].F>>ab[i].S;
	}
	for(int i=n-1;i>=0;i--){
	//	clog << "+ " << (ab[i].S - (ab[i].F + ans) % ab[i].S) ;
		if((ab[i].F+ans)%ab[i].S){
		ans += ab[i].S - (ab[i].F + ans) % ab[i].S;
		}
	//	clog << " " << ans << endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
SCORE=[]
n=int(input())
for i in range(n):
    BASE=[False]*3
    OUTcount=0
    preSCORE=0
    while OUTcount<3:
        spam=input()
        if 'HIT' in spam:
            if BASE[2]==True:
                preSCORE+=1
            BASE[2]=BASE[1]
            BASE[1]=BASE[0]
            BASE[0]=True
        elif 'OUT' in spam:
            OUTcount+=1
        elif 'HOMERUN' in spam:
            preSCORE+=sum(x for x in BASE)+1
            BASE=[False]*3
    SCORE.append(preSCORE)
for i in SCORE:
    print(i)

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll INF = 1e+18;

int main(){
    int N,M;
    map<ll,int> mod;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll m=0;
    ll sum=0;
    ll ans=0;
    rep(i,N){
        sum+=A[i]%M;
        sum%=M;
        if(sum==0) ans++;
        if(mod.count(sum)) ans+=mod[sum];
        mod[sum]++;
    }

    cout << ans << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 080_arc_a / Link: https://arc080.contest.atcoder.jp/tasks/arc080_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	int four = 0, two = 0;
	cin >> N;
	FOR(i, 0, N) {
		int a; cin >> a;
		if (a % 4 == 0)four++;
		else if (a % 2 == 0)two++;
	}
	int ok = 1;

	if (N > 2 * four + 1 && N > 2 * four + two)ok = 0;
	cout << (ok ? "Yes" : "No") << "\n";

	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    ll ans=700;
    for (int i = 0; i < 3; ++i) {
        if(s[i]=='o')ans+=100;
    }
    cout <<ans <<endl;
    return 0;
}

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

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

constexpr int mod = 1000000007;
constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int main()
{
	int dp[200005] = {};
	int N;
	int n = 0;
	int C[200005], T[200005];
	
	dp[0] = 1;
	
	cin >> N;
	for ( int i = 0; i < N; i++ ) cin >> C[i];
	
	int loop = 0;
	while ( loop < N ) {
		int c = C[loop];
		while ( loop < N && c == C[loop] ) loop++;
		T[n] = c;
		n++;
	}
	
	int prev_pos[200005];

	vector < int > G[200005];	

	fill_n(prev_pos, 200005, -1);

	for ( int i = 0; i < n; i++ ) {
		if ( prev_pos[T[i]] != -1 ) {
			G[prev_pos[T[i]]].push_back(i);
		}
		prev_pos[T[i]] = i;
	}
	
	for ( int i = 0; i < n; i++ ) {
		if ( i > 0 ) (dp[i] += dp[i - 1]) %= mod;
		for ( int &x : G[i] ) {
			(dp[x] += dp[i]) %= mod;
		}
	}
	
	cout << dp[n - 1] << endl;

	return ( 0 );
}


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

int main() {
    
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i=0; i<n; i++) cin >> arr[i];
    sort(arr, arr+n); reverse(arr, arr+n);
    int sm = 0;
    for (int i=0; i<k; i++) sm += arr[i];
    cout << sm << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;

int main(){
  int n,count=0;
  cin>>n;
  int S[10001];
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  int q,data;
  cin>>q;
  for(int i=0;i<q;i++){
    scanf("%d",&data);
    S[n]=data;
    int k=0;
    while(data!=S[k]) k++;
    if(k!=n) count++;
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3240
import math

A, B, H, M = map(int, input().split())

a = (H * 60 + M) * 5.5 % 360
a = min(a, 360-a)
ans = A**2 + B**2 - 2 * A * B * math.cos(math.radians(a))
ans = ans**0.5

print(ans)

Measured memory_bytes: 9564
//
//  main.cpp
//  dp
//
//  Created by 贾皓翔 on 2019/11/26.
//  Copyright © 2019 贾皓翔. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <string>
using namespace std;


int main(){
    int k;
    int x;
    cin>>k>>x;
    if(k*500>=x){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    

}




Measured memory_bytes: 256
#include <algorithm>
#include <atcoder/all>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

using mint = atcoder::modint998244353;
mint ten_pow[660000];
mint inv_9;
struct Entry {
    mint sum;
    int digit;
    Entry(mint sum, int digit) : sum(sum), digit(digit) {}
};

struct SetDigit {
    int num;
    int time;
    SetDigit(int num, int time) : num(num), time(time) {}
};

Entry op(Entry x, Entry y)
{
    return Entry(x.sum * ten_pow[y.digit] + y.sum, x.digit + y.digit);
}

Entry e()
{
    return Entry(0, 0);
}

Entry mapping(SetDigit x, Entry y)
{
    if (x.num == 0)
        return y;
    return Entry((ten_pow[y.digit] - 1) * inv_9 * x.num, y.digit);
}

SetDigit composition(SetDigit x, SetDigit y)
{
    if (x.time > y.time)
        return x;
    else
        return y;
}

SetDigit id()
{
    return SetDigit(0, -1);
}

using lazy_seg =
    atcoder::lazy_segtree<Entry, op, e, SetDigit, mapping, composition, id>;

int main()
{
    inv_9 = mint(1) / 9;
    ten_pow[0] = 1;
    for (int i = 1; i < 660000; i++)
        ten_pow[i] = ten_pow[i - 1] * 10;
    int n, q;
    cin >> n >> q;
    vector<Entry> repunit(n, Entry(1, 1));
    lazy_seg seg(repunit);
    for (int t = 0; t < q; t++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;

        seg.apply(l, r + 1, SetDigit(d, t));
        cout << seg.prod(0, n).sum.val() << endl;
    }
    return 0;
}

Measured memory_bytes: 13224
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

const int maxn = 1e5 + 7;

vector<int> s[maxn];
int color[maxn], h[maxn];
int parent[maxn];

void dfs(int v){
	color[v] = 1;
	for (int u : s[v]){
		if (color[u] == 0){
			h[u] = h[v] + 1;
			parent[u] = v;
			dfs(u);
		}
	}
}

int in[maxn];

int main(){
    srand(17);
    ios_base::sync_with_stdio(0);
  	int n, m;
  	cin >> n >> m;
  	if (m & 1){
  		cout << -1 << endl;
  		return 0;
  	}
  	for (int i = 0; i < m; i++){
  		int a, b;
  		cin >> a >> b;
  		s[a - 1].push_back(b - 1);
  		s[b - 1].push_back(a - 1);
  	}
  	dfs(0);
  	vector<int> lst(n);
  	for (int i = 0; i < n; i++)
  		lst[i] = i;
  	sort(lst.begin(), lst.end(), [](int a, int b) {return h[a] > h[b];});
  	for (int u : lst){
  		if (u == 0)
  			break;
  		for (int v : s[u]){
  			if (h[v] + 1 < h[u]){
  				cout << u + 1 << " " << v + 1 << "\n";
  				in[u]++;
  			}
  		}
  		if (in[u] & 1)
  			cout << u + 1 << " " << parent[u] + 1 << "\n";
  		else{
  			cout << parent[u] + 1 << " " << u + 1 << "\n";
  			in[parent[u]]++;
  		}
  	}
    return 0;
}

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

#define REP(i, N) for(int i = 0; i < N ; i ++)

int mouitta[50][50];
int main(int argc, const char * argv[]) {
    int H ,W;
    cin >> H >> W;
    char masume[50][50];
    int kabe = 0;
    REP(i, H){
        REP(j,W){
            cin >> masume[i][j];
            if(masume[i][j] == '#') {kabe++;}
        }
    }
    queue <pair<int, int>> masumequeue;
    queue <int> tuuka;
    tuuka.push(1);
    int susumu[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    int genzaichi[2] = {0, 0};
    mouitta[0][0] = 1;
    int goal = 0;
    while(goal == 0){
        REP(i , 4){
            if ((genzaichi[0] == 0 && susumu[i][0] == -1) || (genzaichi[1] == 0 && susumu[i][1] == -1) || (genzaichi[0] == H - 1 && susumu[i][0] == 1) || (genzaichi[1] == W - 1 && susumu[i][1] == 1)){
                continue;
            }
            else if(genzaichi[0] + susumu[i][0] == H - 1 && genzaichi[1] + susumu[i][1] == W - 1){
                cout << H * W - kabe - tuuka.front() - 1;
                goal = 1;
                break;
            }
            else if((masume[genzaichi[0] + susumu[i][0]][genzaichi[1] + susumu[i][1]] == '.') && (mouitta[genzaichi[0] + susumu[i][0]][genzaichi[1] + susumu[i][1]] == 0)){
                mouitta[genzaichi[0] + susumu[i][0]][genzaichi[1] + susumu[i][1]] = 1;
                masumequeue.push(pair<int,int>(genzaichi[0] + susumu[i][0],genzaichi[1] + susumu[i][1]));
                tuuka.push(tuuka.front() + 1);
            }
        }
        if(goal == 1) break;
        if(masumequeue.empty() == true){cout << -1;break;}
        genzaichi[0] = masumequeue.front().first;
        genzaichi[1] = masumequeue.front().second;
        masumequeue.pop();
        tuuka.pop();
    }
}


Measured memory_bytes: 384
class DisjointSet:
    def __init__(self,n):
        self.parent = [i for i in range(n)]
        self.siz = [1]*n

    def root(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def same(self,x,y): 
        return self.root(x) == self.root(y)

    def unite(self,x,y): 
        x = self.root(x)
        y = self.root(y)
        if x == y: 
            return
        if self.siz[x] < self.siz[y]: 
            x,y = y,x
        self.parent[y] = x
        self.siz[x] += self.siz[y]

    def size(self,x):
        return self.siz[self.root(x)]

n,m = map(int,input().split())
brg = [[int(i)-1 for i in input().split()] for _ in range(m)]
cnt = n*(n-1)//2
ans = [0]*m
ds = DisjointSet(n)
for i in range(m)[::-1]:
    ans[i] = cnt
    a,b = brg[i]
    if not ds.same(a,b):
        cnt -= ds.size(a)*ds.size(b)
        ds.unite(a,b)
print("\n".join(map(str,ans)))

Measured memory_bytes: 35900
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if(s> w)
            System.out.println("safe");
        else
            System.out.println("unsafe");
    }
}


Measured memory_bytes: 27084
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
const lnt INF = 0xffffffffffff;
lnt n,m,x,y,z,s;
lnt dl[200][200];
lnt ds[200][200];
lnt vis[1000];
lnt ans[200][1000];
char str[10];
int main()
{while(1){
	cin>>n>>m;
	if(!n&&!m) return 0;
	for(int i=0;i<200;i++) {
		for(int j=0;j<1000;j++) {
			if(j<200){
				dl[i][j]=INF;
				ds[i][j]=INF;
			}
			ans[i][j]=INF;
		}
	}//fill(dl[0],dl[200]+200,INF);
	//fill(ds[0],ds[200]+200,INF);
	//fill(ans[0],ans[200]+1000,INF);
	for(int i=0;i<n;i++) dl[i][i]=ds[i][i]=0;
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld%s",&x,&y,&z,str);
		x--; y--;
		if(*str=='L') dl[x][y]=dl[y][x]=z;
		else ds[x][y]=ds[y][x]=z;
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dl[i][j]=min(dl[i][j],dl[i][k]+dl[k][j]);
				ds[i][j]=min(ds[i][j],ds[i][k]+ds[k][j]);
			}
		}
	}
	cin>>s;
	for(lnt i=0;i<s;i++){
		cin>>vis[i];
		vis[i]--;
	}
	ans[vis[0]][0]=0;
	for(int i=1;i<s;i++){
		if(i==1){
			for(int j=0;j<n;j++){
				ans[j][1]=ds[vis[0]][j]+dl[j][vis[1]];
			}
		}
		else{
			for(int j=0;j<n;j++){//vis[i-1]????????????j????????????k ?????? vis[i]
				for(int k=0;k<n;k++){
					if(j==k) ans[k][i]=min(ans[k][i],ans[j][i-1]+dl[vis[i-1]][vis[i]]);
					else ans[k][i]=min(ans[k][i],ans[j][i-1]+dl[vis[i-1]][j]+ds[j][k]+dl[k][vis[i]]);
				}
			}
		}
	}
	lnt res=INF;
	for(int i=0;i<n;i++) res=min(res,ans[i][s-1]);
	cout<<res<<endl;
}}

Measured memory_bytes: 3440
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int a = sc.nextInt(), b = sc.nextInt();
                        System.out.printf("%d %d %f\n", a / b, a % b, (double)a / (double)b);
                }
        }
}

Measured memory_bytes: 26416
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            char[] person = Console.ReadLine().ToCharArray();
            int R = 0, B = 0;
            foreach (var p in person)
                if (p == 'R') R++; else B++;

            Console.WriteLine(R > B ? "Yes" : "No");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();

		int ans = 0;
		while(x <= y) {
			x *= 2;
			ans++;
		}
		System.out.println(ans);
	}
}


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

const int MAXN = 3e3 + 3;
vector<int> adj[MAXN];
bool dp[MAXN];
int a[MAXN];
int n;

void input();
void dfs(int, int);
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

void input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

void dfs(int u, int par) {
	for (auto v: adj[u]) {
		if (v == par) continue;
		dfs(v, u);
		if (a[u] > a[v]) dp[u] |= (!dp[v]);
	}
}

void solve() {
	vector<int> ans;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			dp[j] = false;
		dfs(i, -1);
		if (dp[i]) ans.push_back(i + 1);
	}
	sort(ans.begin(), ans.end());
	for (auto i: ans)
		cout << i << " ";
}


Measured memory_bytes: 4032
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll A, B, C, K;

int main() {
  cin >> A >> B >> C >> K;
  
  if (K%2 == 0) cout << A - B << endl;
  else cout << B - A << endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <cstring>

#include <vector>

#include <string>

#include <algorithm>

using namespace std;

int main()

{
	
	string s;
	
	cin>>s;
	
	int ans[27]={};
	
	for(int i=0;i<s.length();i++)
	
	{
		
		for(int j=0;j<26;j++)
		
		{
			
			
			
			if(s[i]==char('a'+j))
			
			{
				
				ans[j]=true;
				
			}
			
			else
			
			continue;
			
		}
		
	}
	
	for(int i=0;i<26;i++)
	
	{
		
		if(ans[i]==0)
		
		{
			
			cout<<char('a'+i);
			
			return 0;
			
		}
		
		else
		
		continue;
		
	}
	
	cout<<"None";
	
	return 0;
	
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define N 205
using namespace std;
const int mo=998244353;
int n,m,pw[N],ans,cnt;
struct dot{
	int x,y;
	dot(int _x=0,int _y=0){ x=_x,y=_y;}
}a[N];
dot operator +(const dot &p,const dot &q){ return dot(p.x+q.x,p.y+q.y);}
dot operator -(const dot &p,const dot &q){ return dot(p.x-q.x,p.y-q.y);}
int C(int n,int m){ if(m==0) return 1; if(m==1) return n; return n*(n-1)/2;}
int cj(dot p,dot q){ return p.x*q.y-p.y*q.x;}
void inc(int &x,int y){ x=x+y>=mo ? x+y-mo : x+y;}
void dec(int &x,int y){ x=x-y<0 ? x-y+mo : x-y;}
int main()
{
	int i,j,k;
	scanf("%d",&n);
	pw[0]=1;
	for(i=1;i<=n;i++) pw[i]=pw[i-1]*2%mo;
	ans=pw[n];
	dec(ans,C(n,2));
	dec(ans,C(n,1));
	dec(ans,C(n,0));
	for(i=1;i<=n;i++)
		scanf("%d %d",&a[i].x,&a[i].y);
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++){
			for(k=1;k<=j;k++)
				if(k!=i&&k!=j&&cj(a[k]-a[i],a[j]-a[i])==0) break;
			if(k<j) continue;
			cnt=2;
			for(k=j+1;k<=n;k++)
				if(cj(a[k]-a[i],a[j]-a[i])==0) cnt++;
			dec(ans,pw[cnt]);
			inc(ans,C(cnt,0));
			inc(ans,C(cnt,1));
			inc(ans,C(cnt,2));
		  }
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SAT")
	{
		cout<<"1"<<endl;
	}
	if(s=="FRI")
	{
		cout<<"2"<<endl;
	}
	if(s=="THU")
	{
		cout<<"3"<<endl;
	}
	if(s=="WED")
	{
		cout<<"4"<<endl;
	}
	if(s=="TUE")
	{
		cout<<"5"<<endl;
	}
	if(s=="MON")
	{
		cout<<"6"<<endl;
	}
	if(s=="SUN")
	{
		cout<<"7"<<endl;
	}
}

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

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	int min_b = *min_element(b.begin(), b.end());
	int max_a = *max_element(a.begin(), a.end());
	int ans = 0;
	vector<pair<int, int>> p(n);
	for (int i = 0; i < n; i++) {
		p[i] = make_pair(min_b - a[i] + 1, b[i] - max_a + 1);
	}
	sort(p.begin(), p.end());
	int m2 = (int)1.01e9;
	for (int i = 0; i < n - 1; i++) {
		m2 = min(m2, p[i].second);
		ans = max(ans, p[i + 1].first + m2);
	}
	for (int i = 0; i < n; i++) {
		int cur = b[i] - a[i] + 1;
		cur += max(0, min_b - max_a + 1);
		ans = max(ans, cur);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1920
n = int(input())

dp = [[0 for _ in range(3)] for _ in range(n+1)]
for i in range(n):
    a, b, c = map(int, input().split())
    dp[i+1][0] = max(dp[i][1] + a, dp[i][2] + a)
    dp[i+1][1] = max(dp[i][0] + b, dp[i][2] + b)
    dp[i+1][2] = max(dp[i][0] + c, dp[i][1] + c)

print(max(dp[n][0], dp[n][1], dp[n][2]))


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

typedef unsigned long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    
    ll ans = 1;
    if(a[0]==0)ans=0;
    else{
        rep(i,n){
          ans*=a[i];
          if(ans > 1000000000000000000 || (i < n-1 && a[i]> 1000000000)|| ans<0){
            cout<<-1<<endl;
            return 0;
        }
        }
    }

    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4408
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        mut k: usize,
        candles: [isize; n],
    }

    let mut ans = 0;

    if candles[0] > 0 {
        ans = candles[k-1];
    } else if candles[n-1] < 0 {
        ans = candles[n-k].abs();
    }
    let index = match candles.binary_search(&0) {
        Ok(o) => { k -= 1; o},
        Err(e) => e,
    };

    if ans != 0 {
        println!("{}", ans);
    } else if k == 0 {
        println!("{}", k);
    } else {
        let left: &Vec<isize> = &candles[..index].iter().rev().map(|k| k.abs()).collect();
        let right = &candles[index..];

        //println!("index: {} left {:?} right {:?}", index, left, right);
        let mut min = if right.len() >= k {
            right[k-1]
        } else {
            isize::max_value()
        };
        for i in 0..cmp::min(k, index) {
            let tmp1 = left.get(i);
            let tmp2 = right.get(k-i-2);
            //println!("tmp1: {} tmp2: {}", tmp1, tmp2);
            if let Some(t1) = tmp1 {
                if let Some(t2) = tmp2 {
                    //println!("t1: {} t2 {}", t1, t2);
                    min = cmp::min(cmp::min(t1*2+t2, t1+t2*2), min);
                }
            }
        }
        ans = min;
        println!("{}", ans);
    }


}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
 
int main(void){
    int W,H,x,y,r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
    if(r<=x&&x<=W-r&&r<=y&&y<=H-r){
      cout << "Yes" << endl;
    } 
    else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 3088
import math
a,b,x= map(int,input().split())
tri = a*a*b/2
if x>=tri:
  tan = 2*b/a - (2*x/a**3)
  print(math.degrees(math.atan(tan)))
else:
  tan = a*(b**2)/(2*x)
  print(math.degrees(math.atan(tan)))

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

#define endl '\n'

using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=m; j++) {
			int x = i * m + j * n - 2 * i * j;
			if(x == k) {
				cout << "Yes" << endl;
				return 0;
			}
			if(m*n - x == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(int a, int b)
{
	return a > b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(ll n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n), b(n), dis(n);

	rep(i, n)
	{
		cin >> a[i] >> b[i];
		dis[i] = b[i]-a[i] % b[i];
		if(dis[i]==b[i]){
			dis[i]=0;
		}
		
	}
	reverse(all(a));
	reverse(all(b));
	reverse(all(dis));
	ll now = 0;
	rep(i, n)
	{
		if (now > dis[i])
		{
			int rem=(now+a[i])%b[i];
			if(rem==0){

			}else{
				now+=b[i]-rem;
			}
		}
		else
		{
			now = dis[i];
		}
	}
	cout<<now<<endl;
}

Measured memory_bytes: 2560
import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
L = lr()
L.sort()
answer = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        index = bisect_left(L, (L[i]+L[j]))
        answer += index - j - 1

print(answer)


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
using namespace std;

char str[123456];

int main(void)
{
	scanf("%s", str);
	int n = strlen(str);
	for (int i = 1; i < n; ++i)
	{
		if (str[i - 1] == str[i])
		{
			return 0 * printf("%d %d", i, i + 1);
		}
	}
	for (int i = 2; i < n; ++i)
	{
		if (str[i - 2] == str[i])
		{
			return 0 * printf("%d %d", i - 1, i + 1);
		}
	}
	printf("-1 -1\n");
	return 0;
}


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

int func(int i, vector<int> &a, vector<int> &memo) {
  if (a[i] == 1) return 0;
  if (i == 0 || i == 1) return 1;
  if (memo[i] != -1) return memo[i];
  memo[i] = (func(i-1, a, memo) + func(i-2, a, memo))%MOD;
  return memo[i];
}

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n+1, 0);
  rep(i,m){
    int x; cin >> x;
    a[x] = 1;
  }
  vector<int> memo(n+1, -1);
  int ans = func(n, a, memo);
  cout << ans << endl;
}

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

using namespace std;
vector<int> g[200001];
int mx  = 0 , vert = 1;
void dfs(int cur , int len = 0, int p = -1) {
    if(len > mx) {
        mx = len;
        vert = cur;
    }
    for(auto to : g[cur]) {
        if(to != p)
            dfs(to , len + 1 , cur);
    }
}

int main() {
    int n;
    cin >> n;
    for(int i = 1; i < n; i ++) {
        int a , b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1);
    mx = 0;
    dfs(vert);
    if(mx % 3 == 1)
        cout << "Second";
    else
        cout << "First";
    return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

  char a, b, c;
  cin >> a >> b;
  double ans, ra, rb;
  string dolphinManJotaro;
  if(a < b){
    cout << '<';
  }else if(a > b){
    cout << '>';
  }else{
    cout << '=';
  }
  return 0;
}


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

const ll mod = 1e9 + 7 ;
int main(){
    string s ;
    cin >> s ;
    ll i = s.size() ;
    if(s[i-1] == 's'){
        rep(j,i) cout << s[j] ;
        cout << "es" << endl;
    }
    else{
        rep(j,i) cout << s[j] ;
        cout << "s" << endl;
    }
}

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

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


int main() {
  int n,ans;
  cin>>n>>ans;
  for(int i=0;i<n-1;i++){
    int a;
    cin>>a;
    ans=gcd(max(a,ans),min(a,ans));
  }
  cout<<ans;
}

Measured memory_bytes: 384
from operator import itemgetter

n = int(input())
sp = []
for i in range(n):
    s, p = input().split()
    sp.append((s, int(p), i))
for i in sorted(sorted(sp, key=itemgetter(1), reverse=True), key=itemgetter(0)):
    print(i[2] + 1)


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char const *argv[])
{
	char c = '9' + 1;
	string s;
	cin>>s;
	for(int i : s)
	{
		cout<<c - i;
	}
	cout<<endl;
	return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main(){
    char s;
    cin>>s;
    if(s=='a'||s=='i'||s=='u'||s=='e'||s=='o'){
        cout<<"vowel";
    }else{
        cout<<"consonant";
    }


}

Measured memory_bytes: 256
n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates_list = [[],[]]
for i in range(3):
	if aa[i] > bb[i]:
		rates_list[1].append([bb[i], aa[i]])
	else:
		rates_list[0].append([aa[i], bb[i]])

max_d = n
for j in range(2):
	rates = rates_list[j]
	if len(rates) == 1:
		max_d = (max_d // rates[0][0]) * rates[0][1] + max_d % rates[0][0]
	elif len(rates) == 2:
		val = [rates[0][1] * i for i in range(max_d // rates[0][0] + 1)]
		rest = [max_d - rates[0][0] * i for i in range(max_d // rates[0][0] + 1)]
		val = [val[i] + rates[1][1] * (rest[i] // rates[1][0]) + (rest[i] % rates[1][0]) if rest[i] > 0 else val[i] for i in range(len(val))]
		max_d = max(val)
	elif len(rates) == 3:
		dp = [(d // rates[0][0]) * rates[0][1] + d % rates[0][0] for d in range(max_d + 1)]
		for d in range(1, max_d + 1):
			dp[d] = max([dp[d]] + [dp[d - rates[i][0]] + rates[i][1] if d - rates[i][0] >= 0 else d for i in range(1, len(rates))])
		max_d = dp[-1]
print (max_d)


Measured memory_bytes: 153536
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
void solve();
 
class Solver {
public:
  string s;

  int ans() {
    int cnt = 0;
    for (auto& c : s) {
      if (c == '1') cnt += 1;
    }
    return cnt;
  }
 
  void solve() {
    cin >> s;
    cout << ans() << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(){
   int n,ok=1;
   scanf("%d ", &n);
   char st[n+2];
   char ch[n];
   fgets(st,sizeof(st),stdin);
   if(n%2!=0){ ok=0;}
   else{
     strncpy(ch,st,n/2);
     for(int i=0;i<n;i++){
       if(i<n/2){ 
          if (ch[i]!=st[i]){ok=0;  }
         
       }else {
		 if(ch[i-n/2]!=st[i]){ok=0; }
         
       }
     } 
   }
  if(ok==1){ printf("Yes");}
  else {printf("No");}
   return 0;
 
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sat Aug  4 18:47:44 2018

@author: maezawa
"""

s = input()

a0 = ''
i0 = -1
a1 = ''
i1 = -1
flag = 0
for j, c in enumerate(s):
    if a1 == c:
        print('{} {}'.format(i1+1, j+1))
        flag = 1
        break
    elif a0 == c:
        print('{} {}'.format(i0+1, j+1))
        flag = 1
        break
    else:
        a0 = a1
        a1 = c
        i0 = i1
        i1 = j
if flag == 0:
    print('-1 -1')
    

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
	int D;//日数
	uint32_t c[26+1];// 満足度低下係数
	uint32_t s[365+1][26+1]; //d日目にコンテストタイプiを実施したときの満足度増加幅
	uint32_t t[365+1]; //D日目にどのコンテストタイプを実施するか
	
	// 入力
	cin >> D;
	for(int i = 1; i <= 26; ++i) {
		cin >> c[i];
	}
	for(int i = 1; i <= D; ++i) {
		for(int j = 1; j <= 26; ++j) {
			cin >> s[i][j];
		}
	}
	for(int i = 1; i <= D; ++i) {
		cin >> t[i];
	}
	
	//計算
	int last[26+1];
	int32_t v = 0; //満足度
	for(int d = 1; d <= D; ++d) {
		int type = t[d];
		last[type] = d;
		
		//増加
		v += s[d][ type ];
		
		//減少
		for(int i = 1; i <= 26; ++i) {
			v -= c[i] * (d - last[i]);
		}
		
		cout << v << endl;
	}

	return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
int check(double *p1, double *p2, double *target) {
	if (p1[0] == p2[0]) {
		return p1[0] > target[0];
	}
	double gradient = (p1[1] - p2[1]) / (p1[0] - p2[0]);
	double y_intercept = p1[1] - gradient * p1[0];
	return gradient * target[0] + y_intercept > target[1];
}
int main() {
	double a[2], b[2], c[2], d[2];
	int judge1, judge2;
	while (scanf(
			" %lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
			a, a+1, b, b+1, c, c+1, d, d+1) != EOF) {
		judge1 = check(a, c, b) == check(a, c, d);
		judge2 = check(b, d, a) == check(b, d, c);
		if (judge1 || judge2)
			puts("NO");
		else
			puts("YES");
	}
	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;


string s;

int main()
{

		cin >> s;

		int fl = s.length();
		int cl = 0;

		while (s != "mew") {
			int i = 0;
			string ns = "";

			while (i < fl) {
				if (i < fl - 2) {
					if (s[i] == 'm'&&s[i + 1] == 'e'&&s[i + 2] == 'w') {
						i += 3;
					}
					else {
						ns += s[i];
						i++;
					}
				}
				else {
					ns += s[i];
					i++;
				}
			}
			cl = ns.length();
			if (fl == cl) {
				break;
			}
			fl = ns.length();
			s = ns;
			//cout << s << endl;

		}
		if (s == "mew") {
			cout << "Cat" << endl;
		}
		else {
			cout << "Rabbit" << endl;
		}

	
	return 0;
}



Measured memory_bytes: 3224
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
 
        final Scanner sc = new Scanner(System.in);
        int headSum =sc.nextInt();
        int footSum =sc.nextInt();
        //全部亀
        int kameFoot = headSum * 4;
        if(kameFoot >= footSum){
            if((kameFoot-footSum)%2==0&&(kameFoot-footSum)/2 <=headSum){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }

       }
    }
        /*  int N =sc.nextInt();
        int K =sc.nextInt();
        Map<Integer,Integer> numMap = new HashMap<>();
        Map<Integer,Integer> newMap = new HashMap<>();
        Map<Integer,Integer> hogeMap = new HashMap<>();
        if(N>41){

        }
        for(int i =1;i<=N;i++){
            numMap.put(i, sc.nextInt());
            newMap.put(i,0);
            hogeMap.put(i,0);
        }
        for(int i= 0;i<K;i++){
            //newMap =  numMap;

            for(int i2= 1; i2<=N;i2++){

                    for(int i4 =0 ;i4 <=numMap.get(i2)&&i4+i2<=N;i4++){
                        newMap.replace(i2+i4, newMap.get(i2+i4)+1);
                        if(i4<i2&&i4 != 0){
                            newMap.replace(i2-i4, newMap.get(i2-i4)+1);
                        }
                    }
   /*                  for(int i4 =1 ;i4<i2&&i4<=numMap.get(i2);i4++){
                        newMap.replace(i2-i4, newMap.get(i2-i4)+1);
                    } */


Measured memory_bytes: 35752
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

// 再帰関数による深さ優先探索
void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt;    // 最初の訪問
    for (v = 0; v < n; v++) {
        if (M[u][v] == 0) continue;
        if (color[v] == WHITE) dfs_visit(v);
    }

    color[u] = BLACK;
    f[u] = ++tt;    // 訪問の完了
}


void dfs() {
    int u;
    // 初期化
    for (u = 0; u < n; u++) color[u] = WHITE;
    tt = 0;

    for (u = 0; u < n; u++) {
        // 未訪問の u を始点として深さ優先探索
        if (color[u] == WHITE) dfs_visit(u);
    }

    for (u = 0; u < n; u++) {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
}

int main() {
    int u, v, k, i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }

    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}



Measured memory_bytes: 2044
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

res = 0
li = []
dic = {}
for i in range(5):
    li.append(int(input()))
for i in range(5):
    if li[i] % 10 != 0 and li[i] % 10 not in dic.values():
        dic[i] = li[i] % 10
if len(dic) == 0:
    res = sum(li)
else:
    m = min(dic.values())
    for j in range(5):
        if li[j] % 10 == 0:
            res += li[j]
        else:
            if li[j] % 10 == m and j in dic.keys():
                res += li[j]
            else:
                res += (li[j] // 10 + 1) * 10
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> b;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    int cnt=1;
    bool flag=false;
    for(int i=0; i<n-1; i++){
        if(a[i]==a[i+1])cnt++;
        else cnt=1;
        if(cnt%2==0)b.push_back(a[i]);
        if(b.size()>=2){
            flag=true;
            break;
        }
    }
    if(flag){
        ll ans=b[1]*b[0];
        cout << ans << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 640
import sys

input = sys.stdin.readline


def main():
    S = input()

    for i in range(2 ** 3):
        ans = 0
        ans += int(S[0])
        for j in range(3):
            if i >> j & 1:
                ans += int(S[j + 1])
            else:
                ans -= int(S[j + 1])

        if ans == 7:
            print(S[0], end="")
            for j in range(3):
                if i >> j & 1:
                    print("+" + S[j + 1], end="")
                else:
                    print("-" + S[j + 1], end="")
            print("=7")
            break


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064