akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<double, int> P;

string S;

bool replace_all(string from)
{
    bool update = false;
    int pos=0;
    while (pos = S.find(from, pos), pos != string::npos) {
        S.replace(pos, from.size(), "C");
        pos += from.size();
        update |= true;
    }
    return update;
}

int main()
{
    cin>>S;

    string list[] = {"mew", "mCew", "meCw", "mCeCw"};

    while (true) {
        bool update = false;
        // cerr << S << endl;
        
        for (int i=0; i<4; i++) {
            update |= replace_all(list[i]);
        }

        if (!update) break;
    }

    cout << (S == "C" ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 1212
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

for i in range(2**n):
    i = format(i, "b").zfill(n)
    for j in range(len(s)):
        tmp = 0
        for k in s[j][1:]:
            tmp += int(i[k - 1])
		
        if p[j] != tmp % 2:
            break
        if j == len(s) - 1:
            ans += 1

print(ans)


Measured memory_bytes: 3064
function Main(input) {
	input = input.trim().split(" ");
  input.sort(function(a,b){
  	return parseInt(b) - parseInt(a);
  });
  console.log(parseInt(input[0] + input[1]) + parseInt(input[2]));
}

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


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

typedef long double ld;
#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vpi vector< pair<int,int> >
#define F first
#define S second 
#define mem1(a) memset(a,-1,sizeof(a))
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())

ld pi= 3.14159265358979;
//const int mod=998244353; 
const int mod = 1e9+7;
const int maxn=2e5+5;

void solve()
{   
	int l; cin>>l;
    string n; cin>>n;
    rep(i, 0, l){
    	if(i >= sz(n)) break;
    	cout<<n[i];
	}
	if(l < sz(n) ) cout<<"...";
} 

signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cout<<setprecision(14);
    int tc=1;// cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s; cin >> s;
  ll k; cin >> k;
  int cnt = 0;
  char next = '1';
  for(int i=0;i<s.size();i++){
    if(s[i] == '1'){
      cnt++;
    }else{
      next = s[i];
      break;
    }
  }
  if(k <= cnt){
    cout << '1' << endl;
  }else{
    cout << next << endl;
  }
}

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

int main(){
  
  int N;
  cin >> N;
  
  ll L1 = 2;
  ll L2 = 1;
  ll Li = 0;
  
  if(N==1){
    cout << L2 << endl;
  }else{
    for(int i=0;i<N-1;i++){
      Li = L1 + L2;
      L1 = L2;
      L2 = Li;
    }
    cout << Li << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n, k; cin >> n >> k;
    cout << (k == 1 ? 0 : n - k) << "\n";
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val x = scanner.nextLong()
    var value = 100L
    var count = 0
    while(true){
        value = (value*1.01).toLong()
        count++
        if(value >= x) break
    }
    println(count)

}

Measured memory_bytes: 36360
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<int> vs;
    for (int i = 0; i < 3; i++)
    {
        vs.push_back(n % 10);
        n /= 10;
    }
    cout << (vs[0] == vs[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 10000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
bool prime[N],primesquare[N];
ll a[1000006],n;
ll ans[N];
void SieveOfEratosthenes(int n) 
{ 
    for (ll i = 2; i <= n; i++) 
        prime[i] = true; 
    for (ll i = 0; i <= n; i++) 
        primesquare[i] = false; 
    prime[1] = false; 
    for (ll p = 2; p * p <= n; p++) { 
        if (prime[p] == true) { 
            for (ll i = p * 2; i <= n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    ll j = 0; 
    for (ll p = 2; p <= n; p++) { 
        if (prime[p]) { 
            a[j] = p; 
            if(p*p<=n)primesquare[p * p] = true; 
            j++; 
        } 
    } 
} 
ll countDivisors(ll n) {
    if (n == 1) 
        return 1; 
  
  
    ll ans = 1; 
  
    for (int i = 0;; i++) { 
        if (a[i] * a[i] * a[i] > n) 
            break; 
  
        ll cnt = 1; 
        while (n % a[i] == 0)
        { 
            n = n / a[i]; 
            cnt ++;
        } 
  
        ans = ans * cnt; 
    } 
    if (prime[n]) 
        ans = ans * 2; 
  
    // Second case 
    else if (primesquare[n]) 
        ans = ans * 3; 
  
    // Third casse 
    else if (n != 1) 
        ans = ans * 4; 
  
    return ans; // Total divisors 
} 
void solve(){
	cin>>n;
	cout<<ans[n];
}
int main()
{
	SieveOfEratosthenes(1e7);
	for(ll i=1;i<N;i++)ans[i]=ans[i-1]+i*countDivisors(i);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 106492
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

template <typename T>
using GPQ=priority_queue<T,vector<T>,greater<T>>;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  string s,t; cin  >> s >> t;
  int ans=0;
  rep(i,0,3) if(s[i]==t[i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
//#define vector<int> vi


signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    vector<int> pre(k+1,0);
    dp[0]=1;
    
    forn(i,1,n)
    {
        pre[0]=dp[0];
        forn(j,1,k)
            (pre[j]=pre[j-1]+dp[j])%MOD;
      // forn(j,0,k)cout<<pre[i]<<" ";nl;
            
        int a;cin>>a;
        rfor(j,k,1)
        {
            int r=j-1,l=max(0LL,j-a);
            int ans=pre[r];
            if(l>0)ans-=pre[l-1];
            (ans +=MOD)%MOD;;
            dp[j]+=ans;
            dp[j]%=MOD;
        }
    }
    
    //forn(i,0,k)cout<<dp[i]<<" ";nl;
    
    cout<<dp[k];


     return 0;

}

//       g++ -g c.cpp ; ./a.exe

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

int main() {
  
  int N;
  cin >> N;
  
  int64_t a = 2;
  int64_t b = 1;
  int64_t c = 3;

  if (N == 1) {
    cout << b << endl;
  }
  else {
    for (int i = 1; i < N; i++) {
      c = b + a ;
      a = b;
      b = c;
    }
    cout << c << endl;    
  }
  
  
return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1'000'000'007LL;

#define INT(NAME) int NAME; cin>>NAME;
#define VECTOR(NAME, TYPE, SIZE) std::vector<TYPE> NAME((SIZE));\
    for(int xxxx_i=0; xxxx_i<SIZE; xxxx_i++) cin>>NAME[xxxx_i];
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

void solve() {
    INT(K)
    INT(N)
    VECTOR(A, int, N)
    A.push_back(A[0]+K);
    int max_dist = -1;
    REP(i, N)
        max_dist = max(max_dist, A[i+1]-A[i]);
    int ans = K - max_dist;
    cout<<ans<<endl;

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

int main() {
    solve();

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
long long N;
cin>>N;
long long sum=0;
for(int i=1;i<=N;i++){
    if(i%3==0 || i%5==0){
        
    }
    else{
        sum=sum+i;
    }
}
cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3636
n, m = map(int, input().split(" "))

a=[]
b=[]
c=[]
d=[]

for i in range(0, n):
    x,y = map(int, input().split(" "))
    a.append(x)
    b.append(y)

for i in range(0, m):
    x,y = map(int, input().split(" "))
    c.append(x)
    d.append(y)

for i in range(0, n):
    v = -1
    index = 0
    for j in range(0, m):

        l=abs(a[i] - c[j]) + abs(b[i] - d[j])
        if v == -1 or v > l:
            index = j
            v = l
    print(index + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N;
    cin >> N;
    u64 ans = 0;
    u64 temp = 0;
    int keta = 1;
    int k = 0;

    while (N / keta)
    {
        keta *= 10;
        ++k;
    }
    keta /= 10;

    if (k & 1)
    {
        ans = (N / keta - 1) * keta + 1;
        ans += N % keta;
        k -= 2;
        while (k > 0)
        {
            temp = temp * 100 + 9;
            k -= 2;
        }
        ans += temp;
    }
    else
    {
        while (k > 0)
        {
            ans = ans * 100 + 9;
            k -= 2;
        }
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<iostream>

#define	mp(a,b)	make_pair((a),(b))
#define	dis		first
#define	node	second

using namespace std;

typedef	pair<int,int>	pii;
typedef	pair<int,pii>	pipii;

vector<int> mst;

int UF_root(int i)
{
	if(mst[i]==-1)	return i;
	return mst[i]=UF_root(mst[i]);
}

bool UF_find(int i,int j)
{
	return UF_root(i)==UF_root(j);
}

void UF_union(int i,int j)
{
	mst[UF_root(j)]=UF_root(i);
}

int main()
{
	for(int n;cin>>n,n;){
		mst=vector<int>(n,-1);

		priority_queue< pipii,vector<pipii>,greater<pipii> > pq;
		int m;	cin>>m;
		while(m--){
			int a,b,dis;
			scanf("%d,%d,%d",&a,&b,&dis);
			pq.push(mp(dis,mp(a,b)));
		}

		int total=0;
		while(!pq.empty()){
			pipii path=pq.top();	pq.pop();
			if(!UF_find(path.node.first,path.node.second)){
				UF_union(path.node.first,path.node.second);
				total+=path.dis/100-1;
			}
		}

		cout<<total<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.LinkedHashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        LinkedHashSet<String> items = new LinkedHashSet<String>();
        for (int i = 0; i < N; i++) {
            items.add(scan.next());
        }
        System.out.println(items.size());
    }
}

Measured memory_bytes: 78440
#%%
N = int(input())
H = list(map(int, input().split()))

ans = 0
s = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        s += 1
    else:
        ans = max(ans, s)
        s = 0
    ans = max(ans, s) 

print(ans)



Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n;
	cin>>n;
	int i=0,j=0,flag=0;
	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			if(i*4+7*j==n){
				flag=1;
				break;
			}
		}
	}
	if(flag==0){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())

if a == 1 and b == 2:
  print(3)
elif a == 1 and b == 3:
  print(2)
elif b == 1 and a == 2:
  print(3)
elif b == 1 and a == 3:
  print(2)
elif b == 2 and a == 3:
  print(1)
elif b == 3 and a == 2:
  print(1)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int A[];
        A=new int[N];
        for(int i=0;i<N;i++) A[i]=sc.nextInt();
        double ans=0;
        for(int i=0;i<N;i++) ans+=(double)1/A[i];
        ans=1/ans;
        System.out.printf("%.10f\n",ans);
    }
}

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

int main()
{
    int n, i;

    cin >> n;

    for(i = 1; i < 10; i++){
        if(n % i == 0){
            if((n / i) < 10){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) < abs(b - x)) cout << "A" << endl;
	else cout << "B" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;
template <class T, class U>
ll euclid_gcd(T a, U b){
    if(a < b)return euclid_gcd(b,a);
    ll r;
    while((r = a%b)){
        a = b;
        b = r;
    }
    return b;
}
int main(){
    ll n; cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    ll ans = 1;
    rep(i,n){
        ll g = euclid_gcd(ans, t[i]); 
        ans = ans * (t[i] / g);
    }
    cout << ans << endl;
}

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

int main(){
	int n;
	cin>>n;
	long sum;
	long input;
	cin>>sum;
	long ans1,ans2,sum1,sum2;
	if(sum>0){
		sum1=sum;
		sum2=-1;
		ans1=0;
		ans2=abs(sum)+1;
	}
	else if(sum<0){
		sum1=1;
		sum2=sum;
		ans1=abs(sum)+1;
		ans2=0;
	}
	else{
		sum1=1;
		sum2=-1;
		ans1=1;
		ans2=1;
	}
	for(long i=1;i<n;++i){
		cin>>input;
		if(sum1*(sum1+input)>=0){
			ans1+=abs(sum1+input)+1;
			if(sum1<0) sum1=1;
			else sum1=-1;
		}
		else sum1+=input;
		if(sum2*(sum2+input)>=0){
			ans2+=abs(sum2+input)+1;
			if(sum2<0) sum2=1;
			else sum2=-1;
		}
		else sum2+=input;
	}
	cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 256
h1 , m1 , h2 , m2 , k = map(int,input().split())
if m2 >= m1:
    time = (h2 - h1)*60 + m2 - m1
elif m2 < m1:
    time = (h2 - h1 - 1) * 60 + m2 + 60 - m1

print(time-k)

Measured memory_bytes: 61756
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
    
        String s = sc.nextLine();
    
        if (s.equals("ABC")) {
          System.out.println("ARC");
        } else if (s.equals("ARC")) {
          System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 35636
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<vector<char>> a(n, vector<char> (n));
    vector<vector<char>> b(m, vector<char> (m));

    rep(i,n)rep(j,n) cin >> a[i][j];
    rep(i,m)rep(j,m) cin >> b[i][j];

    bool ans = false;

    rep(i,n-m+1){
        rep(j,n-m+1){
            bool jud = true;

            rep(k,m){
                rep(l,m){

                    if(a[i+k][j+l] != b[k][l]){
                        jud = false;
                    }

                }
            }

            ans = jud;

            if(ans){
                cout << "Yes" << endl;
                return 0;
            }

        }
    }

    cout << "No" << endl;
}

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

using namespace std;


int main () {
	string s;

	int  i_cnt = 0, n_cnt = 0, cnt=0, tcnt=0,ti_cnt=0,tn_cnt=0;

	cin >> s;


	for (int i = 0; i < s.size(); i+=2) {
		if (s[i] + s[i + 1] == 96) {
			cnt++;
		}
		else if (s[i] + s[i + 1] == 98) {
			cnt++;
		}
		else {
			if (s[i] == '0') {
				i_cnt++;
			}
			else {
				n_cnt++;
			}
		}
	}
	if (i_cnt > n_cnt) {
		cnt += 2*n_cnt;

	}
	else {
		cnt += 2*i_cnt;

	}
	

	for (int i = s.size()-1; i >=0; i -= 2) {
		if (s[i] + s[i - 1] == 96) {
			tcnt++;
		}
		else if (s[i] + s[i - 1] == 98) {
			tcnt++;
		}
		else {
			if (s[i] == '0') {
				ti_cnt++;
			}
			else {
				tn_cnt++;
			}
		}
	}
	if (ti_cnt > tn_cnt) {
		tcnt += 2 * tn_cnt;

	}
	else {
		tcnt += 2 * ti_cnt;

	}

	if(tcnt>cnt) cout << cnt;
	else cout << tcnt;


}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
    INIT;

    string O, E;
    cin >> O >> E;

    string ans = "";
    int m = min(O.size(), E.size());
    REP(i, m){
        ans += O[i];
        ans += E[i];
    }
    if(O.size() > E.size()){
        ans += O[O.size() - 1];
    }else if(O.size() < E.size()){
        ans += E[E.size() - 1];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
bc=int(b//c)
if a%c==0:
    ac=int(a//c)-1
else:
    ac=int(a//c)
bd=b//d
if a%d==0:
    ad=int(a//d)-1
else:
    ad=int(a//d)
e=c
f=d
while f:
    e, f = f, int(e % f)
gcd=int(e)
l=int(c*d/gcd)
bl=int(b//l)
if a%l==0:
    al=int(a//l)-1
else:
    al=int(a//l)
s=int(b-a+1)
s2=int(bc-ac+bd-ad-bl+al)
print(s-s2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int X;
    cin >> X;
    if (X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,X,M;
    cin >> N >> X >> M;
    if(X==0){
        cout << 0 << "\n";
        return 0;
    }
    int K = 40;
    vvec<ll> f(K+1,vec<ll>(M)),val = f;
    for(ll i=0;i<M;i++){
        ll ne = i*i%M;
        f[0][i] = ne;
        val[0][i] = ne;
    }

    for(int k=0;k<K;k++){
        for(int i=0;i<M;i++){
            f[k+1][i] = f[k][f[k][i]];
            val[k+1][i] = val[k][i]+val[k][f[k][i]];
        }
    }
    ll ans = X;
    ll now = N-1;
    int pos = X;
    for(int k=K;k>=0;k--){
        if(now>>k&1){
            ans += val[k][pos];
            pos = f[k][pos];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 67348
#include <cstdio>

using namespace std;

int gcd( int, int );

int main()
{
	int a, b;
	char buf[1024];
	
	while (	fgets( buf, sizeof( buf ), stdin ) && buf[0] != '\n' )
	{
		sscanf( buf, "%d %d", &a, &b );

		printf("%d ", gcd( a, b ) );

		for ( int i = 1; i * a < 2000000000; i++ )
		{
			if ( !( i * a % b ) )
			{
				printf("%d\n", i * a );
				break;
			}
		}
	}

	return 0;
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,k;
    cin >> a >>b >>k;
    int cnt=0,m0;
    m0 =min(a,b);
    vector<int> hai_l(m0,0);
    for(int i=m0;i>0;i--){
        if(a%i==0 && b%i ==0){
            hai_l.at(cnt) = i;
            cnt++;
        }
    }
    cout << hai_l.at(k-1) <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A,B,C,X,a,b,c,counter;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&X);
  
  for(a=0;a<=A;a++)
  {
    for(b=0;b<=B;b++)
    {
      for(c=0;c<=C;c++)
      {
        if(500*a+100*b+50*c==X)
        {
          counter++;
        }
      }
    }
  } 
  printf("%d",counter);
  return 0; 
}


Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    _ <- getLine
    -- スペース区切り整数の入力
    as <- sort . map strToInt . words <$> getLine
    -- 出力
    putStrLn . show $ solve as

solve :: [Int] -> Int
solve as = if even . length $ filter even newas then length newas else length newas - 1
    where newas = map ((\x -> if even x then 2 else 1) . length) $ group as


Measured memory_bytes: 31612
#include <iostream>
#include <string>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    vector<int> v(3,0);
    cin>>v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end());
    if(v[2]!=v[0]+v[1]) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

if N % 2 == 0:
    hasZero = False
    for a in A:
        if a % 2 == 0:
            print(0)
            exit(0)

if N % 2 == 1:
    hasZero = False
    for a in A:
        if a == 0:
            if hasZero:
                print(0)
                exit(0)
            hasZero = True
        elif a % 2 == 1:
            print(0)
            exit(0)
    if not hasZero:
        print(0)
        exit(0)

ans = 1
for _ in range(N // 2):
    ans *= 2
    ans %= MOD

print(ans)

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

int nn = 0 , pos;

int find( int a[] , int n , int s ){
	
	int i;
	for( i = 0; i < n; i++ ){
		if( a[i] == s ){
			return i;
		}
	}
	return -1;
}

void rec( int l , int r , int n , int pre[] , int in[] , int post[] ){
	
	if( l >= r ){
		return;
	}
	int root = pre[pos++];
	int m = find( in , n , root );
	rec( l , m , n , pre , in , post );
	rec( m+1 , r , n , pre , in , post );
	post[nn++] = root;
}

void solve( int n , int pre[] , int in[] , int post[] ){
	
	pos = 0;
	rec( 0 ,n , n , pre , in , post );
	printf( "%d" , post[0] );
	
	for( int i = 1; i < n; i++ ){
		printf( " %d" , post[i] );
	}
	printf( "\n" );
} 

int main( void ){
	
	int n;
	
	scanf( "%d" , &n );
	
	int *pre,*in,*post;
	pre = ( int* )malloc( sizeof(int)*n );
	in = ( int* )malloc( sizeof(int)*n );
	post = ( int* )malloc( sizeof(int)*n );
	
	for( int i = 0; i < n; i++ ){
 		scanf( "%d" , &pre[i] );
	}
	for( int i = 0; i < n; i++ ){
		scanf( "%d" , &in[i] );
	}
	
	solve( n , pre , in , post );
	
	return 0;
}
	


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int H, W; cin >> H >> W;
    int a[H][W]; rep(i, H){rep(j, W){cin >> a[i][j];}}

    // 一筆書きの経路を作り，あとは条件に沿うように移動していけばいずれ見つかる
    vector<P> route;
    rep(i, H){
        if (i % 2 == 0){
            rep(j, W){route.push_back(make_pair(i, j));}
        } else {
            rep(j, W){route.push_back(make_pair(i, (W-1)-j));}
        }
    }

    using quadruplet = tuple<int, int, int, int>;
    vector<quadruplet> ans;
    rep(i, route.size() - 1){
        ll prev_y = get<0>(route.at(i)), prev_x = get<1>(route.at(i));
        ll next_y = get<0>(route.at(i+1)), next_x = get<1>(route.at(i+1));
        if (a[prev_y][prev_x] % 2 == 1){
            ans.push_back(make_tuple(prev_y+1, prev_x+1, next_y+1, next_x+1));
            a[prev_y][prev_x]--;
            a[next_y][next_x]++;
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()){
        quadruplet q = ans.at(i);
        cout << get<0>(q) << " " << get<1>(q) << " " << get<2>(q) << " " << get<3>(q) << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11116
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}
int n, a[1000000];


signed main() {
	cin >> n;
	rep(i, n) {
		if (i % 2 == 0) {
			cin >> a[100000 - i / 2];
		}
		else
			cin >> a[100000 + (i + 1) / 2];
	}

	if (n % 2 == 0) {
		rep(i, n) {
			cout << a[100000 + n / 2 - i] << ' ';
		}
		cout << endl;
	}
	else {
		rep(i, n) {
			cout << a[100000 - (n + 1) / 2 + i + 1] << ' ';
		}
		cout << endl;
	}

	return 0;
}


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

#define debug 0

using namespace std;
typedef long long lint;

const int mod = 1e9+7;

typedef long long lint;

lint rz[105][10][10];
lint fibo[105];

lint mlt(lint x)
{
    if(x < 0) { x = 0; }
    return fibo[x];
}

lint ans(lint h, lint w, lint k)
{
    if(rz[h][w][k] != 0) {
        return rz[h][w][k];
    }

    if(k - 1 > h) { return 0; }

    if(h == 0) { return 1; }

    lint rez = 0, r1 = 1, r2 = 1, st = 0, dr = 0, r3 = 1;

    if(k >= 2)
    {
        st = k - 1 - 1 - 1;
        dr = w - k - 1;

        r1 *= mlt(st); r1 %= mod;
        r1 *= mlt(dr); r1 %= mod;

        r1 *= ans(h-1, w, k-1); r1 %= mod;
    }
    else
    {
         r1 = 0;
    }

    if(k <= w - 1)
    {
        st = k-1 - 1;
        dr = w - (k + 1) - 1;

        r2 *= mlt(st); r2 %= mod;
        r2 *= mlt(dr); r2 %= mod;

        r2 *= ans(h-1, w, k+1); r2 %= mod;
    }
    else
    {
        r2 = 0;
    }

    // free fall
    {
        st = k - 2; dr = w - k - 1;
        r3 *= mlt(st); r3 %= mod;
        r3 *= mlt(dr); r3 %= mod;
        r3 *= ans(h-1, w, k); r3 %= mod;
    }

    rez = r1 + r2; rez %= mod;
    rez += r3; rez %= mod;
    return rz[h][w][k] = rez;
}

lint h, w, k;
int main()
{
    #if debug
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
    #endif

    cin >> h >> w >> k;

    fibo[0] = 1;
    fibo[1] = 2;
    fibo[2] = 3;
    for(int i = 3; i <= 102; i ++) {
        fibo[i] = fibo[i-1] + fibo[i-2];
        fibo[i] %= mod;
    }

    cout << ans(h, w, k) << '\n';

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N,T,A;
    cin >> N >> T >> A;
    vector<int> H(N);
    rep(i,N) cin >> H.at(i);
    double mi = DBL_MAX;
    int pos = 0;
    rep(i,N) {
        double C = T - H.at(i) * 0.006;
        if (mi > abs(A-C)) {
            mi = abs(A-C);
            pos = i;
        }
    }
    cout << pos + 1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int N, M, A[100];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    copy_n(istream_iterator<int>(cin), M, A);
    int odd = partition(A, A + M, [](int v) -> bool { return v % 2; }) - A;
    vector<int> ans;
    if (odd == 0) {
        ans.push_back(1);
        if (M > 1) ans.push_back(A[0]);
        copy(A + 1, A + M - 1, back_inserter<decltype(ans)>(ans));
        ans.push_back(1);
        if (A[M - 1] > 2) ans.push_back(A[M - 1] - 2);
    } else if (odd == 1) {
        if (A[0] > 1) ans.push_back(A[0] - 1);
        copy(A + 1, A + M, back_inserter<decltype(ans)>(ans));
        ans.push_back(1);
    } else if (odd == 2) {
        if (A[0] > 1) ans.push_back(A[0] - 1);
        swap(A[1], A[M - 1]);
        copy(A + 1, A + M - 1, back_inserter<decltype(ans)>(ans));
        ans.push_back(A[M - 1] + 1);
    } else {
        return cout << "Impossible\n", 0;
    }
    for (int i = 0; i < M; i++) cout << A[i] << " \n"[i + 1 == M];
    cout << ans.size() << '\n';
    for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << " \n"[i + 1 == (int)ans.size()];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<string>
using namespace std;
int main()
{
    set <string> s;
    string inp;
    int n;
    cin >> n;
    while(n--)
    {
        cin >> inp;
        s.insert(inp);
    }
    cout << s.size();
}


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

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

int main(){
    int N;
    cin >> N;
    map<ll, int> mp;
    rep(i, N){
        ll a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto p : mp){
        if(p.second >= p.first){
            ans += (p.second - p.first);
        }else{
            ans += p.second;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int long long sum(int long long n) {
  if (n == 1) {
   return 1;
  }


  int long long  s = sum(n/2);  
  return s*2+1;  
}

int main() {
  int long long h;
  cin >> h;
  
  int64_t  x = sum(h);
  printf("%ld", x) ;
 // cout << sum(h);
  
}


Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char const* argv[])
{
	int n, x;
	scanf("%d %d", &n, &x);
	while(!(n == 0 && x == 0)){
			int count = 0;
			for(int i = 1; i <= n; i++){
					for(int j = i+1; j <= n; j++){
							if(i + 2*j < x && x <= i + j + n){
								count++;
							}
							else if(x <= i + j)break;
					}
			}
			printf("%d\n", count);
			scanf("%d %d", &n, &x);
	}
	return 0;
}



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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-9;
const double INFD = numeric_limits<double>::infinity();
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	ll n, k; cin >> n >> k;
	double ans = 0;
	Loop1(i, n) {
		ll m = ceil(log2(ceildiv(k, i)));
		ans += pow(0.5, m) / n;
	}
	cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

int ab[100010];

int main()
{
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	if (n % 10 == 0) {
		cout << 10 << endl;
		return 0;
	}
	string s;
	s = to_string(n);
	//cout << s;
	ll ret = 0;
	rep(i, s.size()) ret += (s[i] - '0');
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int N;
    int[] X, Y;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        X = new int[N];
        Y = new int[N];
        foreach (i; 0 .. N) {
            scanf("%d %d\n", &X[i], &Y[i]);
        }
        return true;
    }

    void solve() {
        int[] ys = Y.dup;
        ys = ys.sort.uniq.array;

        double[] nX, nY;
        foreach (i; 0 .. N - 1) {
            nX ~= X[i];
            nY ~= Y[i];
            int min = Y[i] < Y[i + 1] ? i : i + 1;
            int max = Y[i] > Y[i + 1] ? i : i + 1;
            auto range = Y[i] < Y[i + 1] ? ys.dup : ys.dup.reverse;
            foreach (y; range) {
                if (Y[min] < y && y < Y[max]) {
                    double d = y - Y[i];
                    if (d != 0) {
                        double dx = X[i + 1] - X[i];
                        double dy = Y[i + 1] - Y[i];
                        nX ~= X[i] + dx * (d / dy);
                        nY ~= y;
                    }
                }
            }
        }
        nX ~= X.back;
        nY ~= Y.back;

        N = cast(int)nX.length;

        double dist(int a, int b) {
            double dy = nY[a] - nY[b],
                   dx = nX[a] - nX[b];
            return sqrt(dy * dy + dx * dx);
        }

        struct S {
            int a, b;
            double cost;
        }
        BinaryHeap!(Array!S, "a.cost > b.cost") PQ;
        PQ.insert(S(0, N - 1, 0));
        struct P {
            int a, b;
        }
        double[P] D;
        D[P(0, N - 1)] = 0;
        while (!PQ.empty) {
            S c = PQ.front; PQ.removeFront;
            for (int da = -1; da <= 1; da++) {
                for (int db = -1; db <= 1; db++) {
                    int na = c.a + da,
                        nb = c.b + db;
                    if (c.a == na && c.b == nb) continue;
                    if (na < 0 || nb >= N || na > nb) continue;
                    if (nY[na] != nY[nb]) continue;
                    auto next = S(na, nb, c.cost + dist(c.a, na) + dist(c.b, nb));
                    if (D.get(P(na, nb), 1e9) > next.cost) {
                        //writeln("next: ", next);
                        D[P(na, nb)] = next.cost;
                        PQ.insert(next);
                    }
                }
            }
        }

        //foreach (L; D) L.writeln; writeln;

        double Ans = 1e9;
        foreach (i; 0 .. N) {
            Ans = min(Ans, D.get(P(i, i), 1e9));
        }
        writefln("%.10f", Ans);
    }
    while (input) solve;
}

Measured memory_bytes: 7024
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    
    int ans=0;
    for(int i=0;i<2;i++){
        if(a>b){
            ans+=a;
            a--;
        }else{
            ans+=b;
            b--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    card = [[0] * 3 for _ in range(3)]
    for i in range(3):
        line = list(map(int, input().split()))
        card[i] = line
    mark = [[0] * 3 for _ in range(3)]
    n = int(input())
    for _ in range(n):
        b = int(input())
        for i, j in product(range(3), repeat=2):
            if card[i][j] == b:
                mark[i][j] = 1
                break

    for i in range(3):
        s = 0
        for j in range(3):
            s += mark[i][j]
        if s == 3:
            print("Yes")
            sys.exit()

    for j in range(3):
        s = 0
        for i in range(3):
            s += mark[i][j]
        if s == 3:
            print("Yes")
            sys.exit()

    s = 0
    for i in range(3):
        s += mark[i][i]
    if s == 3:
        print("Yes")
        sys.exit()

    s = 0
    for i in range(3):
        s += mark[i][2 - i]
    if s == 3:
        print("Yes")
        sys.exit()

    print("No")


if __name__ == "__main__":
    main()


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

bool is_palindrome(std::string s){
    std::string t = s;
    std::reverse(t.begin(), t.end());
    return s == t;
}

int main(){
    std::string s;
    std::cin >> s;

    int n = s.size();
    if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1) / 2)) && is_palindrome(s.substr((n + 1) / 2)))
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

vector<int> adj[N];
pair<int, int> p[N];
int kam[N];
set<int> st[N];
map< pair<int, int>, int > mp;

void dfs(int node, int par, int col){
    int c = 0;
    for(auto i: adj[node]){
        if(i == par) continue;
        c++;
        if(c == col) c++;
        mp[{node, i}] = mp[{i, node}] = c;
        dfs(i, node, c);
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        cin >> p[i].first >> p[i].second;
        adj[p[i].first].push_back(p[i].second);
        adj[p[i].second].push_back(p[i].first);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, (int)adj[i].size());
    cout << ans << '\n';
    fill(kam, kam + N, 1);
    dfs(1, 0, 0);
    for(int i = 1; i < n; i++) cout << mp[p[i]] << '\n';

    return 0;
}


Measured memory_bytes: 36152
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;
const int N = 100010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

void init_f(){
    fact[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
    }
    invf[N-1] = divll(1, fact[N-1]);
    FORR(i,N-1,1){
        invf[i-1] = (invf[i] * i) % mod;
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) a[i] = in();
    sort(ALL(a));
    reverse(ALL(a));
    init_f();
    VL s(n + 1);
    REP(i,n) s[i + 1] = s[i] + a[i];

    ll ans = 0;
    FOR(x,k,n){
        ll p = (s[n - x + 1] - s[n] + s[x - 1]) % mod;
        p = (p * nCr(x - 2, k - 2)) % mod;
        ans = (ans + p) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328