akhauriyash/Code-Regression huggingface dataset:
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc172_f.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vl a(n);
  cin >> a;

  ll s = a[0] + a[1];
  ll x = 0;
  FOR(i, 2, n) { x ^= a[i]; }

  ll d = (s - x);
  if (d % 2 != 0) {
    cout << -1 << endl;
    return 0;
  }
  d /= 2;

  REP(i, 60) {
    if (((d >> i) & 1) && ((x >> i) & 1)) {
      cout << -1 << endl;
      return 0;
    }
  }

  if (d > a[0]) {
    cout << -1 << endl;
    return 0;
  }

  ll y = 0;
  for (int i = 60; i >= 0; i--) {
    if (((x >> i) & 1)) {
      if (((d ^ y) | (1LL << i)) < a[0]) {
        y |= (1LL << i);
      }
    }
  }

  if ((d ^ y) == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << a[0] - (d ^ y) << endl;

  return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b,c;
cin>>a>>b>>c;
int i;
for(i=min(a,b);i>=1;i--){
if(a%i==0&&b%i==0){
c--;
if(c==0){

cout<<i<<endl;
return 0;
}
}

}
//cout<<i;

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define lli long long int
#define INF 1e9+5
using namespace std;
int main()
{
	int n,W;
	cin>>n>>W;
	vector<lli> dp(W+1,0);
	//dp[i] max value so that total weight is i

	for(int i=0;i<n;i++){
		lli w,v;
		cin>>w>>v;
		//weight_already can go from 0 to W-w as the item may be the first item we are iterating over or the last
		for(lli weight_already=W-w; weight_already>=0;weight_already--)
		dp[weight_already+w]=max(dp[weight_already+w], dp[weight_already]+v);
		
	}
	lli answer=0;
	for(lli i=0;i<=W;i++)
	answer= max(answer, dp[i]);
	cout<<answer<<endl;

	
	
}

Measured memory_bytes: 1024
def resolve():
    A,B,C,K = map(int,input().split())

    score = 0

    if A >= K:
        print(K)
        return
    else:
        K-=A
        score+=A
    
    if B >= K:
        print(score)
        return
    else:
        K-=B
    
    print(score-K)







if __name__ == "__main__":
    resolve()

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

const int64_t MOD = 1e9 + 7;
struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

vector<pair<int64_t, int64_t>> p_fac(int64_t n)
{
    vector<pair<int64_t, int64_t>> res;
    for (int64_t p = 2; p * p <= n; p++)
    {
        if (n % p == 0)
        {
            int64_t e = 0;
            while (n % p == 0)
            {
                n /= p;
                e += 1;
            }
            res.push_back(make_pair(p, e));
        }
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

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

    vector<int> cnt(1e3);
    for (int i = 1; i <= N; i++)
    {
        for (auto &&p : p_fac(i))
        {
            cnt.at(p.first) += p.second;
        }
    }
    mint res = 1;
    for (int i = 0; i < 1e3; i++)
    {
        res *= cnt.at(i) + 1;
    }
    cout << res.x << endl;
}

Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()

i = 0
ans = 1
MOD = int(1e9) + 7
before = True  # 縦 or 横
while i < N:
    # 縦
    if S1[i] == S2[i]:
        if i == 0:
            ans = 3
        else:
            if before:
                ans *= 2
                ans %= MOD
            else:
                ans *= 1
        before = True
        i += 1
    # 横
    else:
        if i == 0:
            ans = 6
        else:
            if before:
                ans *= 2
            else:
                ans *= 3
                ans %= MOD
        before = False
        i += 2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    int p[M];
    string s[M];
    for (int i = 0; i < M; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int input;
            cin >> input;
            s[i] += to_string(input-1);
        }
    }
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        int num_on = 0;
        for (int j = 0; j < M; j++)
        {
            int count = 0;
            for (int k = 0; k < s[j].size(); k++)
            {
                if ((bit & (1 << (s[j][k] - '0'))))
                {
                    count++;
                }
            }
            if (count % 2 == p[j])
            {
                num_on++;
            }
        }
        if (num_on == M)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

struct Edge {
	int a, b, cost;
};

int n, m;
int root[100], high[100];
Edge e[100000];

void init(int n) {
	for (int i = 0; i < n; i++)root[i] = i, high[i] = 1;
}

int getroot(int n){
	if (n == root[n])return n;
	return root[n] = getroot(root[n]);
}

bool issame(int a, int b) {
	return getroot(a) == getroot(b);
}

void unite(int a, int b) {
	a = getroot(a), b = getroot(b);
	if (a == b)return;
	if (high[a] > high[b])root[b] = a;
	else if (high[a] < high[b])root[a] = b;
	else if (high[a] == high[b])root[a] = b, high[a]++;
}

int main() {
	while (cin >> n >> m, n + m) {
		for (int i = 0; i < m; i++) {
			cin >> e[i].a >> e[i].b >> e[i].cost;
		}
		sort(e, e + m, [](Edge& l, Edge& r) {
			return l.cost < r.cost;
		});
		int ans = 0;
		init(n);
		for (int i = 0; i < m; i++) {
			if (!issame(e[i].a, e[i].b)) {
				unite(e[i].a, e[i].b);
				ans += e[i].cost;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
	int n,rieki,answer;
	cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
for(int k=vec.at(1);0<k;k--){
  int count=0;
  for(int l=0;l<n;l++){
  if(vec.at(l)%k==0){
    continue;
  }
  else{
    count+=1;
  }
}
if(count==0 || count==1){
  answer =k;
  break;
}
}
cout<<answer<<endl;
}


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

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = input[0];
        var n = input[1];
        var m = input[2];
        var count = 0;
        for (int i = Math.Max(a, 1); i < m; i++)
        {
            var x = Math.Pow(i, n);
            if (x > m)
            {
                break;
            }
            var y = x.ToString().ToArray().Select(s => int.Parse(s.ToString())).Sum();
            if (i == y + a)
            {
                count++;
            }

        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 18464
#include <stdio.h>
#define M 100

int Selectsort(int,int *);

int main()
{
  int A[M], i = 0,v,limit,count=0;
  scanf("%d", &limit);
  for(i=0;i<limit;i++){
    scanf("%d", &A[i]);
    if (i == M-1)break;
  }
  //for(i=0;i<limit;i++)printf("%d",A[i]);
  v = Selectsort(limit,A);
  for (i = 0; i < limit - 1; i++) printf("%d ", A[i]);
  printf("%d\n%d\n", A[limit - 1],v);
	
  return 0;
}

int Selectsort(int N,int *A)
{
  int minj, i,j,kari,v=0;
  for (i = 0; i < N; i++) {
    minj = i;
    //printf("%d",minj);
    for (j = i; j < N; j++) {
      if (A[j] < A[minj]) {
	minj = j;
	
	//printf("a");
      }
    }
    if(A[i]!=A[minj])v++;
    kari = A[i];
    A[i] = A[minj];
    A[minj] = kari;
  }
  return  v;

}



Measured memory_bytes: 2100
#include <stdio.h>
int main(void)
{
	int month;
	int date;
	int mod;
	
	scanf("%d%d", &month, &date);
	
	while (month != 0){
		
		if(month == 1){
			mod = date % 7;
		}
		else if(month == 2){
			mod = (date + 31) % 7;
		}
		else if(month == 3){
			mod = (date + 60) % 7;
		}
		else if(month == 4){
			mod = (date + 91) % 7;
		}
		else if(month == 5){
			mod = (date + 121) % 7;
		}
		else if(month == 6){
			mod = (date + 152) % 7;
		}
		else if(month == 7){
			mod = (date + 182) % 7;
		}
		else if(month == 8){
			mod = (date + 213) % 7;
		}
		else if(month == 9){
			mod = (date + 244) % 7;
		}
		else if(month == 10){
			mod = (date + 274) % 7;
		}
		else if(month == 11){
			mod = (date + 305) % 7;
		}
		else if(month == 12){
			mod = (date + 335) % 7;
		}
		
		switch (mod){
			case 1:
			printf("Thursday\n");
			break;
			
			case 2:
			printf("Friday\n");
			break;
			
			case 3:
			printf("Saturday\n");
			break;
			
			case 4:
			printf("Sunday\n");
			break;
			
			case 5:
			printf("Monday\n");
			break;
			
			case 6:
			printf("Tuesday\n");
			break;
			
			default:
			printf("Wednesday\n");
			break;
		}
		scanf("%d%d", &month, &date);
	}
	return (0);
}

Measured memory_bytes: 0
N, A, B, C = map(int, input().split())

l = []
for i in range(N):
    l.append(int(input()))


INF = 10 ** 5


def dfs(depth, a, b, c):
    if depth == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF

    ret0 = dfs(depth+1, a, b, c)
    ret1 = dfs(depth+1, a+l[depth], b, c) + 10
    ret2 = dfs(depth+1, a, b+l[depth], c) + 10
    ret3 = dfs(depth+1, a, b, c+l[depth]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
# AOJ 1510 Independent Research
# Python3 2018.7.13 bal4u

mv = [[-1,-1,-1],[-1,-1,0],[-1,-1,1],[-1,0,-1],[-1,0,0],[-1,0,1],[-1,1,-1],[-1,1,0],[-1,1,1],
      [0,-1,-1],[0,-1,0],[0,-1,1],[0,0,-1],[0,0,1],[0,1,-1],[0,1,0],[0,1,1],
      [1,-1,-1],[1,-1,0],[1,-1,1],[1,0,-1],[1,0,0],[1,0,1],[1,1,-1],[1,1,0],[1,1,1]]
				
cno = 0
arr = [[[[0 for x in range(5)] for y in range(5)] for z in range(5)] for k in range(2)]
while True:
	n = int(input())
	if n == 0: break
	for z in range(5):
		if z > 0: input()
		for y in range(5): arr[0][z][y] = list(map(int, input()))
	a, b = [0]*27, [0]*27
	ts = input()
	if len(ts) == 0: ts = input()
	ts = list(map(int, ts.split()))
	for t in ts[1:]: a[t] = 1
	ts = list(map(int, input().split()))
	for t in ts[1:]: b[t] = 1
	for j in range(n):
		for z in range(5):
			for y in range(5):
				for x in range(5):
					s = 0;
					for i in range(26):
						xx, yy, zz = x+mv[i][0], y+mv[i][1], z+mv[i][2]
						if xx >= 0 and xx < 5 and yy >= 0 and yy < 5 and zz >= 0 and zz < 5:
							s += arr[j&1][zz][yy][xx] & 1
					if arr[j&1][z][y][x] & 1: arr[1-(j&1)][z][y][x] = b[s]
					else: arr[1-(j&1)][z][y][x] = a[s]
	if cno: print()
	cno += 1
	print("Case ", cno, ":", sep='')
	for z in range(5):
		if z > 0: print()
		for y in range(5): print(*arr[n&1][z][y], sep='')
		


Measured memory_bytes: 5644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    vector<int> v;
    for(int i=1;i<=n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            v.pb(i);
        }
    }
    for(int i=0;i<h;i++){
        if((i&1)==0){
            for(int j=0;j<w;j++){
                cout<<v[i*w+j]<<' ';
            }
        }
        else{
            for(int j=w-1;j>=0;j--){
                cout<<v[i*w+j]<<' ';
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int A[20], B[50], C[50];

int main() {
  int n;
  scanf("%d", &n);
  rep(i, n) scanf("%d", &A[i]);
  rep(i, n) scanf("%d", &B[i]);
  rep(i, n - 1) scanf("%d", &C[i]);
  int sum = 0;
  rep(i, n) {
    sum += B[A[i] - 1];
    if (i > 0 && A[i] == A[i - 1] + 1) sum += C[A[i - 1] - 1];
  }
  printf("%d", sum);
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = input()
if 1 <= int(N) <= 999:
	print("ABC")
else:
	print("ABD")

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 310, M = 1010;

int n;
int f[N][N];
bool st[N][N];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
			cin >> f[i][j];
			
	for (int k = 1; k <= n; k ++ )
		for (int i = 1; i <= n; i ++ )
			for (int j = 1; j <= n; j ++ )
				if (f[i][k] + f[k][j] < f[i][j])
				{
					puts("-1");
					return 0;
				}
	
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
			for (int k = 1; k <= n; k ++ )
				if (k != j && k != i && f[i][j] == f[i][k] + f[k][j])
					st[i][j] = true;
					
	LL res = 0;
	for (int i = 1; i <= n; i ++ )
		for (int j = i + 1; j <= n; j ++ )
			if (!st[i][j])
				res += f[i][j];
				
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    if (n % 2 == 1) {
        ll l = a[n / 2];
        ll r = b[n / 2];
        cout << (r - l + 1) << endl;
    }
    else {
        ll l = a[n / 2 - 1] + a[n / 2];
        ll r = b[n / 2 - 1] + b[n / 2];
        cout << (r - l + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int a1000,a100,a10,a1;
  a1000=N/1000;
  a100=N%1000/100;
  a10=N%1000%100/10;
  a1=N%1000%100%10;
  if(a10!=a100){
  	cout<<"No"<<endl;
  }else if(a1==a10||a1000==a10){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = a; i <= a * b; i += a)
		if (i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int M=1e5+10;
typedef long long ll;
ll a[M];
int main(int argc, char const *argv[])
{
	int h,n;
	cin>>h>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum<(ll)h)cout<<"No"<<endl;
	else	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1024
import math
n = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


np = factorization(n)


def cont(x):
    a = 0
    c = 0
    while True:
        c += 1
        a += c

        if x >= a and x < a + c + 1:
            break

    return c


ans = 0
for i in np:
    if i[0] == 1:
        continue
    else:
        # print(cont(i[1]))
        ans += cont(i[1])
# print(np)
print(ans)


Measured memory_bytes: 9488
from itertools import groupby

N = int(input())
sortedStrs = []
for i in range(N):
    sortedStrs.append("".join(sorted(list(input()))))
resultCount = 0
for (k, g) in groupby(sorted(sortedStrs), key=lambda m: m):
    count = len(list(g))
    if count > 1:
        resultCount += count * (count - 1) / 2
print(int(resultCount))


Measured memory_bytes: 11860
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	int n, a, b, c, x;
	while (scanf("%d %d %d %d %d", &n, &a, &b, &c, &x)) {
		if (!n)
			return 0;
		queue<int> ransus;

		for (int i = 0; n > i; i++) {
			int a;
			scanf("%d", &a);
			ransus.push(a);
		}
		int i;
		bool f = false;
		for (i = 0; 10000 >= i; i++) {
			if (ransus.front() == x) {
				ransus.pop();
				if (ransus.empty()) {
					f = true;
					break;
				}
			}
			x = (a*x + b) % c;
		}
		if (f)
			printf("%d\n", i);
		else
			printf("-1\n");
	}



	return 0;
}

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

int main(){
    int n,ans=0;
    cin>>n;
    vector<string> g(n),g2(n);
    rep(i,n)cin>>g[i];
  
    rep(i,n){
        rep(j,n)g2[(j+i)%n]=g[j];
        
        bool f=true;
        rep(p,n){
            rep(q,p){
                if( g2[p][q] != g2[q][p]){
                    f=false;
                    break;
                }
            }
        }
        if(f)ans += n;
    }




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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    string s;
    cin>>s;
    ll cnt= 0;
    rep(i,s.size()/2){
        if(s[i]!= s[s.size()-i-1]) cnt++;
    }
    cout<<cnt<<endl;
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=1000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int a,b;
    a=read(), b=read();
    int x=b;
    int cnt=0;
    while(x) x/=10, cnt++;
    int now=10;
    for(ri int i=1;i<cnt;i++) now*=10;
    int pp=a*now+b;
    int tt=sqrt(pp);
    if(tt*tt==pp) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> H(N);
    for (size_t i = 0; i < N; i++) {
        cin >> H[i];
    }

    int score = 0;
    int maxScore = 0;
    int currentH = H[0];

    for (int i = 1; i < N; i++) {
        if (currentH >= H[i]) {
            score++;
            maxScore = max(score, maxScore);
        } else {
            score = 0;
        }
        currentH = H[i];
    }

    cout << maxScore << endl;

    return 0;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key);

void init (void);

void printList(void);

void deleteNode(NodePointer);

void deleteFirst(void);

void deleteLast(void);

void delete(int);

void insert(int);

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d", &key);
      insert(key); np++; size++;
    }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf("%d",&key);delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


NodePointer listSearch(int key){
  /* your code */
  NodePointer n;

  for(n = nil->next; n != nil; n = n->next){
    if(n->key == key) return n;
  }
  return NULL;
  
}


void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}


void deleteNode(NodePointer t){
  /* your code */

  t->prev->next = t->next;
  t->next->prev = t->prev;

  free(t);
  
}

void deleteFirst(){

  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
  
}


void delete(int key){
  /* your code */
  NodePointer n;

  n = listSearch(key);

  if(n!=NULL) deleteNode(n);

  else return;

}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  /* 
   your code 
  */
  x->next = nil->next;
  x->next->prev = x;//
  nil->next = x;
  x->prev = nil;
  
}



Measured memory_bytes: 32984
from functools import reduce
mod = 998244353

N, M, K = map(int, input().split())
C = 1
ans = (M*pow(M-1, (N-1), mod))%mod
k = 1
while k <= K and k < N:
  C *= (N-k)*pow(k, mod-2, mod)
  C %= mod
  a = (C*M*pow(M-1, (N-k-1), mod))%mod
  ans = (ans+a)%mod
  k += 1
print(ans)


Measured memory_bytes: 74288
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int a,p;

signed main(){
  cin >> a >> p;
  p += a*3;
  cout << p/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
const int maxn=2e5+10;
int n,a[maxn],b[maxn],sum=0;
signed main()
{
    //int n;
    cin >> n;
   // int a[200005], b[200005];
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        b[a[i]]++;
    }
    //int sum=0;
    for(int i=1;i<=n;i++)
    {
        int ss = (b[i]*(b[i]-1))/2;
        sum+=ss;
    }
   /* for(int i=0;i<n;i++)
    cout<<b[i]<<" ";
  cout<<endl;*/
    for (int c = 1; c <= n; c++)
    {
        int s,t;
        s=b[a[c]];
        int k=s-1;
        if(s>=2)
        {
            int a1 = (s*(s-1))/2;
            int a2= ((k-1)*k)/2;
            t = sum- a1 + a2;
        }
        else
        {
            t=sum;
        }
        cout<<t<<endl;
    }
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef double Real;
typedef complex<Real> P;

bool ishit_circle_segment(P o, Real r, P t, P s){
    // s to origin
    o -= s;
    t -= s;
    // t on x axis
    if(s==t)return false;
    o = (o / t) * abs(t);
    
    Real d = r*r - o.imag()*o.imag();
    if(d < 0.0)return false;
    Real x0 = o.real() + sqrt(d);
    Real x1 = o.real() - sqrt(d);
    Real tb = abs(t);
    if(0.0 <= x0 && x0 <= tb)return true;
    if(0.0 <= x1 && x1 <= tb)return true;
    return false;
}
pair<P,P> hitpoint_circle_circle(P o1,Real r1,P o2,Real r2){
    if(o1==o2 && r1==r2){
        return make_pair(o1,o2);
    }
    // o1 to origin
    o2 -= o1;
    Real x1 = o2.real();
    Real y1 = o2.imag();
    Real a = (x1*x1 + y1*y1 + r1*r1 - r2*r2)/2.0;
    Real d = (x1*x1 + y1*y1)*r1*r1 - a*a;
    if(d < 0.0){
        return make_pair(o1,o2+o1);
    }
    if(x1*x1 + y1*y1 == 0.0){
        return make_pair(o1,o2+o1);
    }
    P hit1 = P((a*x1+y1*sqrt(d))/(x1*x1+y1*y1), (a*y1-x1*sqrt(d))/(x1*x1+y1*y1));
    P hit2 = P((a*x1-y1*sqrt(d))/(x1*x1+y1*y1), (a*y1+x1*sqrt(d))/(x1*x1+y1*y1));
    return make_pair(hit1+o1,hit2+o1);
}
bool inner_circle_point(P o,Real r,P p){
    return abs(p-o)<=r+1e-8;
}

int n;
P ps[125];

int main(void){
    // Here your code !
    while(true){
        scanf("%d",&n);
        if(n==0)break;
        REP(i,n){
            Real x,y;
            scanf("%lf,%lf",&x,&y);
            ps[i] = P(x,y);
        }
        vector<P> check;
        REP(i,n)REP(j,i){
            pair<P,P> t = hitpoint_circle_circle(ps[i],1.0,ps[j],1.0);
            check.push_back(t.first);
            check.push_back(t.second);
        }
        int ans = 1;
        REP(i,check.size()){
            P p = check[i];
            int tmp = 0;
            REP(j,n){
                if(inner_circle_point(ps[j],1.0,p)){
                    tmp++;
                }
            }
            if(tmp > ans){
               // printf("%f %f -> %d\n",p.real(),p.imag(),tmp);
               ans = tmp;
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3468
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get { () => (get().parse().unwrap()) }
    
    let s = get().as_bytes();
    let x: i32 = get!();
    let y: i32 = get!();
    
    let mut tmpx = std::collections::BTreeSet::new();
    let mut tmpy = std::collections::BTreeSet::new();
    tmpx.insert(0);
    tmpy.insert(0);
    
    let mut st = 0;
    let mut f = 0;
    let mut first = true;
    for &c in s.iter() {
    	if c == b'F' {
        	f += 1;
		} else {
	    	let mut tmpx2 = std::collections::BTreeSet::new();
    		let mut tmpy2 = std::collections::BTreeSet::new();
        	if st == 0 {
              for &cx in tmpx.iter() {
                  tmpx2.insert(cx+f);
                  if !first {
                  	tmpx2.insert(cx-f);
                  }
              }
              tmpy2 = tmpy;
			} else {
              for &cy in tmpy.iter() {
                  tmpy2.insert(cy+f);
                  tmpy2.insert(cy-f);
              }
              tmpx2 = tmpx;
            }
        	st = 1 - st;
            f = 0;
            first = false;
            tmpx = tmpx2;
            tmpy = tmpy2;
        }
    }
	    	let mut tmpx2 = std::collections::BTreeSet::new();
    		let mut tmpy2 = std::collections::BTreeSet::new();
        	if st == 0 {
              for &cx in tmpx.iter() {
                  tmpx2.insert(cx+f);
                  if !first {
                  	tmpx2.insert(cx-f);
                  }
              }
              tmpy2 = tmpy;
			} else {
              for &cy in tmpy.iter() {
                  tmpy2.insert(cy+f);
                  tmpy2.insert(cy-f);
              }
              tmpx2 = tmpx;
            }
        	st = 1 - st;
            f = 0;
            first = false;
            tmpx = tmpx2;
            tmpy = tmpy2;
    
    let mut can = 0;
    
    for &cx in tmpx.iter() {
    	if cx == x {
        	can += 1;
            break;
        }
    }
    for &cy in tmpy.iter() {
    	if cy == y {
        	can += 1;
            break;
        }
    }
    if can < 2 {
    	println!("No");
	} else {
    	println!("Yes");
    }
}

Measured memory_bytes: 4352
n,k=map(int,input().split())
a=list(map(int,input().split()))
n=[0]*200000
x=[]
for i in a:
    n[i-1]+=1
for i in n:
    if i!=0:
        x+=[i]
y=len(x)
z=y-k
if z<=0:
    print(0)
else:
    x.sort()
    print(sum(x[:z]))

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

vector<i64> arr;
i64 n;
map<i64,i64> dp;

int solve(){
    dp[n-1]=0;
    dp[n-2]=abs(arr[n-1]-arr[n-2]);
    for(int i=n-3;i>=0;i--){
        dp[i]=min(abs(arr[i]-arr[i+1])+dp[i+1], abs(arr[i]-arr[i+2])+dp[i+2]);
    }
    return dp[0];
}

int main(){
    cin>>n;
    int temp;
    for(i64 i=0;i<n;i++){
        cin>>temp;
        arr.push_back(temp);
    }
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,i,x=10,t=1,w=0;
	cin>>a;
	for(i=1;i<=a;i++){
		if(i>=x)x*=10,t++;
		w+=t&1;
	}
	cout<<w;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int A,B;

  cin >> A >> B ;

  int a=A+B;
  int b=A-B;
  int c=A*B;

  int ans=max(a,b);

  ans=max(ans,c);

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

Measured memory_bytes: 256
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())
 
if B > A and A+V*T >= B+W*T:
  print('YES')
elif B < A and A-V*T <= B-W*T:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9184
def main():
    x = int(input())
    if 400 <= x <= 599:
        print(8)
    elif 600 <= x <= 799:
        print(7)
    elif 800 <= x <= 999:
        print(6)
    elif 1000 <= x <= 1199:
        print(5)
    elif 1200 <= x <= 1399:
        print(4)
    elif 1400 <= x <= 1599:
        print(3)
    elif 1600 <= x <= 1799:
        print(2)
    elif 1800 <= x <= 1999:
        print(1)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int h = 2, w;

int dp[10][110];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(i + 1 < h) {
                chmax(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
            }
            if(j + 1 < w) {
                chmax(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 256
N, X = list(map(lambda x: int(x), input().split(' ')))
A = list(map(lambda x: int(x), input().split(' ')))

A.append(X)
A.sort()
diffs = [A[i+1] - A[i] for i in range(N)]

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


ans = diffs[0]
for d in diffs:
    ans = gcd(ans, d)

print(ans)


Measured memory_bytes: 63060
import java.util.*;

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

    String b = sc.next();

    if (b.equals("A")) {
      System.out.println("T");
    } else if (b.equals("T")) {
      System.out.println("A");
    } else if (b.equals("C")) {
      System.out.println("G");
    } else if (b.equals("G")) {
      System.out.println("C");
    }
  }
}


Measured memory_bytes: 21204
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll

struct Edge {
    int from, to, cost;
};

template<typename T>
vector<vector<T>> WarshallFloyd(vector<vector<T>> vec) {
    //return minimum dist table dp[i][j]
    assert(vec.size() == vec[0].size());
    int N = vec.size();
    auto dp = vec;
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    return dp;
};

signed main() {
    int N, M, R; cin >> N >> M >> R;
    vector<int> toVisit(R); rep(i, R) {
        cin >> toVisit[i]; toVisit[i]--;
    }
    vector<vector<int>> vec(N, vi(N,pint_INF));
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        vec[a][b] = c;
        vec[b][a] = c;
    }
    sort(ALL(toVisit));
    int cost = 1000000000000; // 1e12
    auto dp = WarshallFloyd(vec);
    do {
        int tmp = 0;
        for (int t = 1; t < R; t++) {
            tmp += dp[toVisit[t - 1]][toVisit[t]];
        }
        cost = min(cost, tmp);
    } while (next_permutation(ALL(toVisit)));
    cout << cost << endl;
}

Measured memory_bytes: 4284
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val S = sc.next()
  val aToZ = ('A' to 'Z') ++ ('A' to 'Z')
  println(S.map(s => aToZ(aToZ.indexWhere(_ == s) + N)))
}


Measured memory_bytes: 56460
#include<bits/stdc++.h>
#define N 200005
#define P 998244353
#define int long long
using namespace std;
int n,c[N],tree[N],zx[N],yx[N],zs[N],ys[N],E2[N],ans;
struct data{
	int x,y;
}a[N];
bool cmp(data a,data b){return a.y<b.y;}
void add(int x){
	while(x<=n)tree[x]++,x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)res+=tree[x],x-=x&-x;
	return res;
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].y),c[i]=a[i].x;
	sort(c+1,c+n+1);sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		a[i].x=lower_bound(c+1,c+n+1,a[i].x)-c;
		zx[i]=query(a[i].x);
		yx[i]=i-1-zx[i];
		add(a[i].x);
	}
	memset(tree,0,sizeof(tree));
	for(int i=n;i>=1;i--){
		zs[i]=query(a[i].x);
		ys[i]=n-i-zs[i];
		add(a[i].x);
	}
	E2[0]=1;for(int i=1;i<=n;i++)E2[i]=E2[i-1]*2%P;
	for(int i=1;i<=n;i++){
		ans+=(E2[zx[i]]-1)*(E2[ys[i]]-1)%P*(E2[zs[i]]+E2[yx[i]]-1)%P;
		ans+=(E2[zs[i]]-1)*(E2[yx[i]]-1)%P*(E2[zx[i]]+E2[ys[i]]-1)%P;
		ans+=(E2[zs[i]]-1)*(E2[yx[i]]-1)%P*(E2[zx[i]]-1)%P*(E2[ys[i]]-1)%P;
		ans+=E2[n-1];
		ans%=P;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

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;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    string s; cin >> s;
    int res=0;
    rep(i,3){
        if(s[i]=='1') res++;
    }
    cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

struct hoge {
  int id;
  int score;
  hoge(int id, int score) : id(id), score(score) {}
};
bool operator<(const hoge &a, const hoge &b) {
  return (a.score != b.score)? a.score > b.score : a.id < b.id;
}

int main() {
  int n;
  while(cin >> n, n) {
    cin.ignore();
    vector<hoge> w;
    while(n--) {
      stringstream ss;
      string s;
      getline(cin, s);
      ss << s;
      int id;
      ss >> id;
      int a;
      vector<int> v;
      while(ss >> a)
        v.push_back(a);
      int vn = v.size();

      int frame = 0;
      int cnt = 0;
      int score = 0;
      int i=0;
      while(frame < 9) {
        if (cnt == 0) {
          if (v[i] == 10) {
            score += 10 + v[i+1] + v[i+2];
          } else {
            cnt++;
          }
        } else {
          int tmp = v[i-1] + v[i];
          score += tmp;
          if (tmp == 10) {
            score += v[i+1];
          }
          cnt = 0;
        }
        if (cnt == 0)
          frame++;
        
        i++;
      }
      int tmp = v[i] + v[i+1];
      score += tmp;
      if (tmp >= 10) {
        score += v[i+2];
      }
      w.push_back(hoge(id, score));
    }
    sort(ALL(w));
    FOR(it,w) {
      printf("%d %d\n",(*it).id,(*it).score);
    }
  }
}

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

int n, i, c[10] = {3, 9, 2, 4, 8, 10, 6, 12};
int main()
{
	cin >> n;
	if (n == 3) {
		printf("2 5 63");
		return 0;
	}
	if (n % 2) {printf("30000 "); n--;}
	for (i = 0; i < n; i++) {
		printf("%d ", c[i % 8] + i / 8 * 12);
	}
    return 0;
}


Measured memory_bytes: 384
s1 = input()
s2 = input()
dp=[[0 for j  in range(len(s1) + 1)]for k in range(len(s2) + 1)]

for i in range(len(s1) + 1):
    dp[0][i] = i
for i in range(len(s2) + 1):
    dp[i][0] = i

for i in range(1, len(s1) + 1):
    for j in range(1, len(s2) + 1):
        if s1[i-1] == s2[j-1]:
            dp[j][i] = dp[j-1][i-1]
        else:
            dp[j][i] = min(dp[j-1][i], dp[j][i-1], dp[j-1][i-1]) + 1

print(dp[len(s2)][len(s1)])


Measured memory_bytes: 42892
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)    cin>>a[i];
    int cnt=0;
    bool flag = true;
    while(flag){
        for(int i=0;i<n;i++){
            if(a[i]%2==0){
                a[i] /= 2;
            }
            else{
                flag = false;
                break;
            }
            if(i==n-1){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
int sx,sy,tx,ty;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>sx>>sy>>tx>>ty;
    string ans="";
        for(int i=0;i<tx-sx;i++){
            ans+='R';
        }
        for(int i=0;i<ty-sy;i++){
            ans+='U';
        }
        for(int i=0;i<tx-sx;i++){
            ans+='L';
        }
        for(int i=0;i<ty-sy;i++){
            ans+='D';
        }
        ans+='D';
        for(int i=0;i<=tx-sx;i++){
            ans+='R';
        }
        for(int i=0;i<=ty-sy;i++){
            ans+='U';
        }
        ans+='L';
        ans+='U';
         for(int i=0;i<=tx-sx;i++){
            ans+='L';
        }
        for(int i=0;i<=ty-sy;i++){
            ans+='D';
        }
        ans+='R';
    cout << ans << "\n";
}




Measured memory_bytes: 256
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with

#A = int(input())
H1,M1,H2,M2,K= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())

H=(H2-H1)*60 + (M2-M1)
m=H-K
print(m)

Measured memory_bytes: 9156
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;

const int H = 4, W = 4;
char board[H][W];

int dp[110][10010];
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};

int main() {
  int N; cin >> N;
  map<string, int> point_map, cnt_map;
  for(int i=0; i<N; i++) {
    string pat; int point;
    cin >> pat >> point;
    point_map[pat] = point;
    cnt_map[pat] = 0;
  }

  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      cin >> board[i][j];
    }
  }

  fill(dp[0], dp[N+1], -1);
  dp[0][0] = 0;

  // pos, bit, string
  queue< tuple<int, int, string> > que;
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      int idx = i * W + j;
      int bit = (1 << idx);
      que.push(make_tuple(idx, bit, string(1, board[i][j])));
    }
  }

  while(que.size()) {
    auto tup = que.front(); que.pop();
    int pos, bit; string str; tie(pos, bit, str) = tup;

    if(cnt_map.count(str)) {
      cnt_map[str]++;
    }

    if(str.size() == 8) continue;
    int x = pos / W, y = pos % W;
    for(int k=0; k<8; k++) {
      int nx = x + dx[k], ny = y + dy[k];
      if(nx < 0 or nx >= H or ny < 0 or ny >= W) continue;
      int idx = nx * W + ny;
      if(bit >> idx & 1) continue;
      int nbit = bit | (1 << idx);
      string nstr = str + board[nx][ny];
      que.push(make_tuple(idx, nbit, nstr));
    }
  }

  int time_limit; cin >> time_limit;

  /*
  for(auto e : cnt_map) {
    cerr << e.first << ", " << e.second << endl;
  }
  */

  int i = 0;
  for(auto e : cnt_map) {
    int cost = e.first.size(), score = point_map[e.first];
    int num = e.second;

    for(int j=0; j<=time_limit; j++) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }
    
    for(int k=0; num; k++) {
      int take = min(num, 1 << k);
      int take_time = cost * take;
      int take_point = score * take;
      // fprintf(stderr, "i = %d, k = %d, take = %d\n", i, k, take);
      for(int j=time_limit - take_time; j>=0; j--) {
        if(dp[i][j] >= 0) {
          dp[i+1][j + take_time] = max(dp[i+1][j + take_time], dp[i][j] + take_point);
        }
        if(dp[i+1][j] >= 0) {
          dp[i+1][j + take_time] = max(dp[i+1][j + take_time], dp[i+1][j] + take_point);
        }
      }
      num -= take;
    }
    for(int j=0; j<=time_limit; j++) {
      if(dp[i+1][j] < 0) continue;
      // fprintf(stderr, "dp[%d][%d] = %d\n", i+1, j, dp[i+1][j]);
    }
    i++;
  }
    
  int ans = 0;
  for(int i=0; i<=time_limit; i++) {
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 18524