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

typedef pair<int, int> P;

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

	int N, M;
	cin >> N >> M;
	set<P> s;
	for(int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		s.insert({ a, b });
		s.insert({ b, a });
	}

	for(int i = 1; i < N - 1; i++) {
		if(s.count({ 0, i }) && s.count({ i, N - 1 })) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 19072
/*---> 10 February 2020 <--- > 19:34:09 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	string s;
	cin>>s;
	int n=sz(s);
	string ans(n,'x');
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

A,B = ints_raw()
ans =0
exk = 0
start_eve = A if A %2 ==0 else A+1
end_odd = B if B%2 ==1 else B-1

dd = int((end_odd-start_eve+1)/2) % 2

print (0 if start_eve == A else A)^dd^(0 if end_odd == B else B)


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

typedef unsigned  long long ll;

ll f(ll a) {
     ll res[] = {a, 1, a + 1, 0};
     return res[a % 4];
}

ll getXor(ll a, ll b) {
     return f(b) ^ f(a - 1);
}

int main(){
    ll a, b;
    scanf("%llu%llu", &a, &b);
    printf("%llu\n", getXor(a, b));

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, d;

    cin >> n >> d;

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;

        if (x * x + y * y <= d * d)
        {
            ans++;
        }
    }

    cout << ans << endl;
}


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

int main()
{
  string b;
  cin>>b;
  int N=b.length();
  for(int i=0;i<N;i++){
    if(b[i]=='A') cout<<'T';
    if(b[i]=='T') cout<<'A';
    if(b[i]=='C') cout<<'G';
    if(b[i]=='G') cout<<'C';
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<vector>
#define ll long long
const int ha=998244353,N=1000000,ni=ha/2+1;
#define pb push_back
using namespace std;

inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}

int inv[N+5],pfh[N+5],hpf[N+5],n,ans;

inline void init(){
	inv[1]=1;
	for(int i=2;i<=N;i++) inv[i]=ha-inv[ha%i]*(ll)(ha/i)%ha;
}

inline void solve(){
	for(int i=1;i<=N;i++){
		for(int j=i*2;j<=N;j+=i) ADD(hpf[i],hpf[j]),ADD(pfh[i],pfh[j]);
		hpf[i]=add(hpf[i]*(ll)hpf[i]%ha,ha-pfh[i])*(ll)ni%ha;
	}
	
	for(int i=N;i;i--){
		for(int j=2,u=i<<1;u<=N;j++,u+=i) ADD(hpf[i],ha-hpf[u]);		
		ADD(ans,hpf[i]*(ll)inv[i]%ha);
	}
}

int main(){
	scanf("%d",&n),init();
	for(int i=1,now;i<=n;i++)
	    scanf("%d",&now),ADD(hpf[now],now),ADD(pfh[now],now*(ll)now%ha);
	solve(),printf("%d\n",ans);
	return 0;
}

/*

*/

Measured memory_bytes: 12032
#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 <cstdlib>  // abs() for integer
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    ll n, k;
    cin >> n >> k;
    /*rep(i, 1000) {
        cout << abs(n - k) << "  ";
        n = abs(n - k);
    }*/
    cout << min(n % k,abs(k - n % k)) << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LLINF 1234567890//987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 100006
#define MAXK 200006
#define MAXX 15000006
#define rep(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define ph push
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
string x, y;
set <ll> ss[26];
inline ll c(char ch) { return ch-'a'; }
int main()
{
	cin >> x >> y;
	swap(x, y);
	rep(i, 0, x.length()) { ss[c(x[i])].ins(c(y[i]));  }
	
	rep(i, 0, 26)
	{
		if(ss[i].size() >= 2)
		{
			cout << "No";
			return 0;
		}
	}
rep(i, 0, 26)ss[i].clear();

swap(x, y);
rep(i, 0, x.length()) { ss[c(x[i])].ins(c(y[i]));  }
       rep(i, 0, 26)
       {
		if(ss[i].size() >= 2)
		{
			cout << "No";
			return 0;
		}
	}
	
	cout << "Yes";
}


Measured memory_bytes: 776
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

n = int(input())
a = list(map(int, input().split()))

element = gcd(a[0], a[1])
if n==2:print(element)
else:
    for i in range(2,n):
        element=gcd(element,a[i])
    print(element)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    vector<P> b(m);
    rep(i,m){
        cin>>b[i].second>>b[i].first;
        a[i]=b[i].second;
    }
    sort(begin(b),end(b));
    int check=b[0].first;//ここと左側を結ぶ橋を切る
    int ans=1;
    FOR(i,0,m){
        //cout<<check<<'\n';
        if(check<=b[i].second){
            check=b[i].first;
            //cout<<' '<<check<<'\n';
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

class UF{
public:
  int V;
  vector<int> par,rnk,sz;
  UF(){}
  UF(int V):V(V),par(V),rnk(V,0),sz(V,1){for(int i=0;i<V;i++)par[i]=i;}
  
  int find(int x){
    assert(x < V);
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rnk[x]<rnk[y])par[x]=y, sz[y] += sz[x];
    else{
      par[y]=x;
      sz[x] += sz[y];
      if(rnk[x]==rnk[y])rnk[x]++;
    }
  }
  
  bool same(int x,int y){return find(x)==find(y);}
  
  int size(int x){return sz[find(x)];}
};

typedef tuple<int,int,int> T;

int MST(int V, int E, vector<T> G){
  
  sort( G.begin(), G.end() );
  
  UF uf( V );
  
  int res = 0;
  
  for(int i=0;i<E;i++){
    
    int s, t, w;
    tie( w, s, t ) = G[i];
    
    if( uf.same( s, t ) ) continue;
    
    uf.unite( s, t );
    
    res += w;
    
  }
  
  return res;
}

signed main(){
  
  int V, E;
  cin >> V >> E;
  
  vector<T> G;
  
  for(int i=0;i<E;i++){
    
    int s, t, w;
    cin >> s >> t >> w;
    
    G.push_back( T( w, s, t ) );
    
  }
  
  cout << MST( V, E, G ) << endl;
  
  return 0;
}



Measured memory_bytes: 7808
<?php
/**
 * ABC130
 * A - Rounding
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $x, $a);

if ($x < $a) {
    echo 0, PHP_EOL;
} else {
    echo 10, PHP_EOL;
}



Measured memory_bytes: 4604
#include <bits/stdc++.h>
 
using namespace std;
 
int a, b;

int main() {
	scanf("%d%d", &a, &b);
  	if(a > 0 && a < 10 && b > 0 && b < 10)
      printf("%d", a*b);
   	else
      printf("%d", -1);
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define MOD 1000000007
#define MAX 100000
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
	int A,B,C,D,E,F;
	cin >> A >> B >> C >> D;
	while(1){
		C=C-B;
		if(C<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		A=A-D;
		if(A<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3636
//AtCoder ABC108 A - Pair
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll K; cin>>K;
    ll od,ev;
    if(K%2==0){
		od = K / 2;
		ev = K / 2;
	}else{
		od = K / 2;
		ev = K / 2+1;
    }
	cout<<od*ev<<endl;
	return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end


n,l=get_i
a=get_i
deque=array(n,1)
ans=array(n-l+1,1)
head=0
tail=0
n.times do|i|
  tail-=1 while head<tail and a[deque[tail-1]]>=a[i]
  deque[tail]=i
  tail+=1
  if i-l+1>=0
    ans[i-l+1]=a[deque[head]]
    head+=1 if deque[head]==i-l+1
  end 
end

puts ans.join(" ")


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

string s[3];

int main() {
   ios::sync_with_stdio(false);
   
    cin >> s[0] >> s[1] >> s[2];
    cout << s[0][0] << s[1][1] << s[2][2] << endl;
   
   
    return 0;
}



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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  if(N % 2 == 1) cout << "No" << endl;
  else{
    int half = N / 2;
    string split = S.substr(half);
    if(S == split + split) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a){
        cout << k << endl;
    }else if(k<=a+b){
        cout << a << endl;
    }else{
        cout << a-(k-a-b) << endl;
    }
}




Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int64 n;
  cin >> n;
  int64 ret = 0;
  ret += n / 11 * 2;
  n %= 11;
  if (n > 0) ++ret;
  if (n > 6) ++ret;
  cout << ret << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

constexpr int once = 100;

void solve(ll N, ll M, ll Q, vector<ll> a, vector<ll> b, vector<ll> c,
           vector<ll> d) {
  vector<int> n(10, once);
  for (auto i = 0; i != N; ++i) {
    n[i] = M;
  }

  int ma {0};
  int A[10];
  for (A[0] = 1; A[0] <= n[0]; ++A[0]) {
    for (A[1] = A[0]; A[1] <= n[1]; ++A[1]) {
      for (A[2] = A[1]; A[2] <= n[2]; ++A[2]) {
        for (A[3] = A[2]; A[3] <= n[3]; ++A[3]) {
          for (A[4] = A[3]; A[4] <= n[4]; ++A[4]) {
            for (A[5] = A[4]; A[5] <= n[5]; ++A[5]) {
              for (A[6] = A[5]; A[6] <= n[6]; ++A[6]) {
                for (A[7] = A[6]; A[7] <= n[7]; ++A[7]) {
                  for (A[8] = A[7]; A[8] <= n[8]; ++A[8]) {
                    for (A[9] = A[8]; A[9] <= n[9]; ++A[9]) {
                      int score = 0;
                      for (auto q = 0; q!= Q; ++q) {
                        if(A[b[q]-1] - A[a[q]-1] == c[q]) score += d[q];
                      }
                      ma = max(ma,score);
                      if (n[9] == once) break; 
                    }
                    if (n[8] == once) break; 
                  }
                  if (n[7] == once) break; 
                }
                if (n[6] == once) break; 
              }
              if (n[5] == once) break; 
            }
            if (n[4] == once) break; 
          }
          if (n[3] == once) break; 
        }
        if (n[2] == once) break; 
      }
      if (n[1] == once) break; 
    }
    if (n[0] == once) break; 
  }
  cout << ma << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  ll Q;
  cin >> Q;
  vector<ll> a(Q);
  vector<ll> b(Q);
  vector<ll> c(Q);
  vector<ll> d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    cin >> d[i];
  }
  solve(N, M, Q, move(a), move(b), move(c), move(d));
  return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  int N;
  cin >> N;

  int ans = 0;
  for (int x = 1; x <= N; x += 2) {
    int cnt = 0;
    for (int d = 1; d <= x; d++) {
      if (x % d == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      ans++;
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(lcm(a, b));
	}

	static int gcd(int a, int b){
		int tmp;

		while (a % b != 0)
		{
			tmp = b;
			b = a % b;
			a = tmp;
		}
		return b;
	}
	
    static long lcm(int a, int b, int gcd){
    	return (long)a*(b/gcd);
    }

    static long lcm(int a, int b){
    	int g = gcd(a, b);

    	return lcm(a,b,g);
    }

}


Measured memory_bytes: 21844
// topic8a
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string str;
   
  //空白も含めて1行まるごとを文字列として受け取るためにはgetline関数を使う
  getline(cin,str);
 
  for(int i=0;i<(int)str.size();i++){
    if('a'<=str[i]&&str[i]<='z'){
      str[i]=str[i]-'a'+'A';
    }else if('A'<=str[i]&&str[i]<='Z'){
      str[i]=str[i]-'A'+'a';
    }
  }
  cout<<str<<endl;
  return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=1e5+10,P=1e9+7;
int n,m;
int F[N],NO[N];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,m);
  for(int i=1;i<=m;++i) {
    int a; read(a);
    NO[a]=true;
  }
  F[0]=1; if(!NO[1]) F[1]=1;
  for(int i=2;i<=n;++i) if(!NO[i]) {
    F[i]=(F[i-1]+F[i-2])%P;
  }
  printf("%d\n",F[n]);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
string s[200100];
map<string,int> cnt;
set<string> ret;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		cnt[s[i]]++;
	}
	int mx=0;
	for(int i=1;i<=n;i++)
		mx=max(mx,cnt[s[i]]);
	for(int i=1;i<=n;i++){
		if(cnt[s[i]]==mx){
			ret.insert(s[i]);
		}
	}
	while(ret.size()){
		cout<<*ret.begin()<<endl;
		ret.erase(ret.begin());
	}
	return 0;
}


Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    int N; cin >> N;
    cout << N * N * N << "\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map.Entry;
import java.util.TreeMap;

/**
 * Production
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			TreeMap<Integer, Integer> product = new TreeMap<Integer, Integer>();
			int n = Integer.parseInt(line);

			int name, quant, delim;
			for (int i = 0; i < n; i++) {
				line = br.readLine();
				delim = line.indexOf(' ');
				name = stoi(line.substring(0, delim));
				quant = Integer.parseInt(line.substring(delim + 1));
				if (product.containsKey(name)) {
					product.put(name, product.get(name) + quant);
				} else {
					product.put(name, quant);
				}
			}
			StringBuilder sb = new StringBuilder();
			for (Entry<Integer, Integer> e : product.entrySet()) {
				sb.append(itos(e.getKey().intValue()) + " "
						+ e.getValue().toString() + "\n");
			}
			System.out.print(sb.toString());
		}
	}

	static int stoi(String str) {
		int result = 0;
		for (int i = 0; i < str.length(); i++) {
			result <<= 5;
			result += (str.charAt(i) - '@');
		}
		return result;
	}

	static String itos(int num) {
		char[] str = new char[5];
		int c, len = 0;
		//
		for (int i = 4; i >= 0; i--) {
			c = num >> 5 * i & 31;
			if (c != 0) {
				str[len] = (char) (c + '@');
				len++;
			}
		}
		return (new String(Arrays.copyOf(str, len)));
	}
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    string S;
    cin >> S;
    ll N = SZ(S);
    S = "0" + S;

    mat dp(N+1, vec(2, 0));
    dp[0][1] = 1;
    REP(i,1,N+1) {
        ll n = S[i] - '0';
        dp[i][0] = MIN(dp[i-1][0]+n,dp[i-1][1]+10-n);
        dp[i][1] = MIN(dp[i-1][0]+n+1,dp[i-1][1]+9-n);
    }
    PR(dp[N][0]);

    return 0;
}

/*



*/

Measured memory_bytes: 58784
#!/usr/bin/env python


def solve():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))

    a, b, c = 0, 0, 0
    for p in P:
        if p <= A:
            a += 1
        elif p <= B:
            b += 1
        else:
            c += 1
    print(min([a, b, c]))


if __name__ == '__main__':
    solve() 


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template <typename T>
string printVector(const vector<T> &data)
{
    stringstream ss;
    ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x, y;
    cin >> n >> m;
    vector<int> ball(n, 1);
    vector<bool> is_contain(n, false);
    is_contain[0] = 1;

    for (int i = 0; i < m; ++i) {
        cin >> x >> y;
        is_contain[y - 1] = is_contain[x - 1] || is_contain[y - 1];
        ball[y - 1]++;
        ball[x - 1]--;
        if (ball[x - 1] == 0) is_contain[x - 1] = false;
    }

    int ans = 0;
    for (auto t: is_contain) {
        if (t) ans++;
    }
    cout << ans << endl;
}



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;

  std::vector<int64_t> v(n);
  std::iota(v.begin(), v.end(), 1);

  std::vector<int64_t> p(n), q(n);
  std::cin >> p >> q;

  int64_t p_n, q_n, num = 0;

  do {
    if (v == p) {
      p_n = num;
    }
    if (v == q) {
      q_n = num;
    }
    num++;
  } while (std::next_permutation(v.begin(), v.end()));

  std::cout << std::abs(p_n - q_n) << std::endl;

  return 0;
}

Measured memory_bytes: 256
n,s=map(int,input().split())
a=list(map(int,input().split()))
p=998244353

data=[[0]*(s+1) for i in range(n)]

gen=data[0]
gen[0]=2
if(a[0]<=s):
    gen[a[0]]+=1

for i in range(1,n):
    gen=data[i]
    mae=data[i-1]
    for j in range(s+1):
        gen[j]=mae[j]*2
        if(j-a[i]>=0 and j-a[i]<=s):
            gen[j]+=mae[j-a[i]]
        gen[j]%=p

print(data[-1][-1])

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

int bubbleSort(vector<int> &a, int n){
    int ans = 0;
    bool flag = 1;
    int i = 0;
    while(flag){
        flag = 0;
        for(int j = n-1; j > i; j--){
            if (a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                flag = 1;
                ans++;
            }
        }
        i++;
    }
    return ans;
}

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int ans = bubbleSort(a, n);
    rep(i, n-1) cout << a[i] <<" ";
    cout << a[n-1] <<endl;
    cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {
    int x;
    cin >> x;
    x ^= 1;
    cout << x;       
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int a[3];
int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  REP(i, 3) cin >> a[i];

  sort(a, a + 3);

  int ans = 0;
  // 他の 2 要素の差は偶数倍か？
  if ((a[1] - a[0]) % 2 == 0) {
    ans += (a[1] - a[0]) / 2;
    ans += (a[2] - a[1]);
  }
  // 他の 2 要素の差は奇数倍か？
  else {
    ans += (a[1] - a[0]) / 2;
    ans += (a[2] - a[1]) - 1;  // a[0] = a[2] - 2, a[1] = a[2] - 1  にする
    ans++;                     // 操作1 a[1] = a[2], a[2] = a[2] + 1
    ans++;                     // 操作2 a[0] = a[2]
    ans++;                     // 操作2 a[0] = a[2] + 1, a[1] = a[2] + 1
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // メインプログラムここから
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = (A % 2) * B * C;
    ans = min(ans, (B % 2) * C * A);
    ans = min(ans, (C % 2) * A * B);
    cout << ans << endl;
    // ここまで
}


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> point;

ll a, b, c, d, e, r, g;

ll f(ll x) {
  return x - x%2;
}

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

  cin >> a >> b >> c >> d >> e >> r >> g;

  ll sol = max(f(a) + f(d) + f(e), (min(a, min(d, e)) > 0 ? 3 + f(a - 1) + f(d - 1) + f(e - 1) : 0));

  cout << sol + b;
}



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

int main (){
    int N, M;
    cin>>N>>M;
    priority_queue<long long> Q;
    for(int n=0; n<N; n++){
        int A;
        cin>>A;
        Q.push(A);
    }
    for(int i=0; i<M; i++){
        long long A=Q.top();
        Q.pop();
        A /= 2;
        Q.push(A);
    }

    long long Sum=0;
    while(!(Q.empty())){
        Sum+= Q.top();
        Q.pop();
    }
    cout<<Sum<<endl;
}

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

int main() {
  string S;
  cin >>S;
  if(S == "Sunny")
    cout << "Cloudy" << endl;
  else if(S == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
     
}

Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
       string[] input = Console.ReadLine().Split(' ');
       int x = int.Parse(input[0]);
       int A = int.Parse(input[1]);
       int B = int.Parse(input[2]);
       
       if(Math.Abs(x - A) < Math.Abs(x - B)){
           Console.WriteLine("A");
       }else{
           Console.WriteLine("B");
       }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

#include <ccomplex>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll N = 1e6 + 100;
const ll M = 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void da()
{
	cout << "Yes";
	exit(0);
}

void $main()
{
	ll x, n; cin >> x >> n;

	set<ll> sit;
	for (ll i = -1000; i < 1000; ++i)
		sit.emplace(i);

	for (ll i = 0; i < n; ++i)
	{
		ll x; cin >> x;
		if (sit.find(x) != sit.end())
			sit.erase(x);
	}

	ll ans = 0, del=INF;

	if (abs(*(--sit.upper_bound(x)) - x) < del)
		del = abs(*(--sit.upper_bound(x)) - x), ans = *(--sit.upper_bound(x));
	if (abs(*sit.upper_bound(x) - x) < del)
		del = abs(*sit.upper_bound(x) - x), ans = *sit.upper_bound(x);

	cout << ans;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}

Measured memory_bytes: 3756
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;


int main() {

    LL a, b;
    cin >> a >> b;

    if (a > 0) {
        cout << "Positive";
        return 0;
    }

    if (a <= 0 && b >= 0) {
        cout << "Zero";
        return 0;
    }

    LL d = b - a + 1;
    if(d % 2 == 0) cout << "Positive";
    else cout << "Negative" ;

    return 0;
}



























Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAXN 100005
using namespace std;

int n, m, ans, indeg[MAXN], dp[MAXN];
vector<int> adj[MAXN];

int dfs(int x) {
	if (dp[x]) return dp[x] + 1;
	int ret = 0;
	for (int i : adj[x]) {
		ret = max(ret, dfs(i));
	}
	dp[x] = ret;
	return ret + 1;
}

int main() {
	cin >> n >> m;
	int x, y;
	for (int i=0; i<m; i++) {
		cin >> x >> y;
		adj[x].push_back(y);
		indeg[y]++;
	}

	for (int i=1; i<=n; i++) {
		if (indeg[i] == 0) {
			ans = max(ans, dfs(i) - 1);
		} 
	}
	// for (int i=1; i<=n; i++) {
	// 	cout << dp[i] << ' ';
	// }
	// cout << "\n";
	cout << ans << "\n";
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(dt,i,a,b) for(dt i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define E9 1000000007
#define E5 100007
#define INF 1e9+7
#define PI 3.1415926
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define all(a) a.begin(),a.end()
typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef map<char,int> mci;
typedef pair<long long int,long long int> pll;
typedef long long int lli;  //  e-18 to e18
void solve(){
  
}
int main(){
    fastIO();
    // lli t(1);
    // cin>>t;
    // while(t--) solve();
    string s,tt;
    bool check=false;
    cin>>s>>tt;
    lli n1=s.size();
    lli n2=tt.size();
    f0(0,n1){
       if(s[i]==tt[i]){
           check=true;
       }
       else{
           check=false;
           break;
       }
    } 
    if(check==true && n2==n1+1) cout<<"Yes\n";
    else cout<<"No\n"; 
    ret 0; 
}                                                             

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	static int[] arr = new int[110];
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(gcd(a,b));
	}
	
	public static long gcd(long a,long b){
		return b==0?a:gcd(b,a%b);
	}
}


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

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

int main() {
    ll a,b;
    cin>>a>>b;
    if(a<=0&&0<=b)cout<<"Zero"<<endl;
    else if(a>0&&b>0)cout<<"Positive"<<endl;
    else if(a<0&&b<0){
        ll d=abs(a-b)+1;
        if(d%2)cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
N, K = map(int,input().split())
l = [0] * N
for i in range(N):
    l[i] = list(map(int, input().split()))

l.sort()
count = 0
tmp = 0

for i in range(N):
    count += l[i][1]
    if count >= K:
        ans = l[i][0]
        break
    else:
        pass

print(ans)
 


Measured memory_bytes: 27872
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while(1){
	string s;
	cin>>s;
	if( s=="0" ) break;
	ll res = 0;
	vector<ll> cnt(11,0);
	for(ll i=0;i<s.size();i++){
	    vector<ll> tmp(11,0);
	    ll k = s[i]-'0';
	    for(int j=0;j<11;j++){
		tmp[(j*10+k)%11] += cnt[j];
	    }
	    if( k != 0 )tmp[ k ]++;
	    //cout<<s[i]<<endl;
	    //for(auto l:tmp)cout<<l<<' ';
	    //cout<<endl;
	    res += tmp[0];
	    cnt = tmp;
	}
	cout<<res<<endl;
    }
    return 0;
}



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

int main(void) {

	int a[200000];
	int i=0,N=0,count=0;

	scanf("%d", &N);

	while(i<N){
	scanf("%d",&a[i]);
	i++;
	}

	for(i=0;i<N;i++){
	if(a[i]==count+1){
		count++;
	}
	}

	if(count == 0){
		printf("%d", -1);
	}
	else{
	printf("%d", N-count);
	}
	return 0;
}


Measured memory_bytes: 896
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        a: u64,
        b: u64,
    }

    println!("{}", a * b);
}


Measured memory_bytes: 2120
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  int sn = 0;
  for(int cur = n; cur > 0; cur /= 10) {
    sn += cur % 10;
  }
  puts(n % sn == 0 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
program main
    implicit none
    integer(8):: h
    integer(4):: n
    integer(4), allocatable:: a(:)
    read*, h, n
    allocate(a(n))
    read*, a(:)
    if (sum(a(:)) >= h)then
        print*, 'Yes'
    else
        print*, 'No'
    end if
end program main

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

int main()
{
    int n, m, x, y, z;
    int arr1[101];
    int arr2[101];
    cin >> n >> m >> x >> y;
    for (int i = 0; i < n; i++) {
        cin >> arr1[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> arr2[i];
    }
    sort(arr1, arr1 + n);
    sort(arr2, arr2 + m);
    for (int i = x + 1; i <= y; i++) {
        if (i > arr1[n - 1] && i <= arr2[0]) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const w = arg[0].split("");
    
    const set = new Set(w);
    const unique = [...set];
    
    for(let i in unique) {
        if(w.filter(n=>n===unique[i]).length % 2 !== 0) {
            console.log("No");
            return;
        }   
    }
    
    console.log("Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}
int32_t main(){
	boost;osit;
	int n,x;
	cin>>n>>x;
	int arr[n],sum[n+1];
	rep(i,0,n){
		cin>>arr[i];
	} sum[0]=0;
	rep(i,0,n){
		sum[i+1]=sum[i]+arr[i];
	}
	rep(i,0,n+1){
		//cout<<sum[i]<<" ";
		if(sum[i]>x){
			cout<<i;
			return 0;
		}
	}
	cout<<n+1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll u[N],m[N],b[N];
int main(){
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
   cin>>n;
   vector<int>a,b,c;
   for(int i=0;i<n;i++){
        int x;
   cin>>x;
   a.push_back(x);
   }
   for(int i=0;i<n;i++){
        int x;
   cin>>x;
   b.push_back(x);
   }
   for(int i=0;i<n;i++){
        int x;
   cin>>x;
   c.push_back(x);
   }
   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   sort(c.begin(),c.end());
   ll ans=0;
   for(int i=0;i<n;i++){
    int ans1=lower_bound(a.begin(),a.end(),b[i])-a.begin();
    int ans2=upper_bound(c.begin(),c.end(),b[i])-c.begin();

    ans+=1LL*ans1*(n-ans2);
   }
   cout<<ans;



    return 0;
}


Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
int main (){
  int s;
  bool set[1000010];
  rep(i,1000010) set[i]=false;
  cin>>s;
  int i=1;
  while(1){
    if(set[s]){
      cout<<i;
      return 0;
    }
    set[s]=true;
    if(s%2==0){
      s=s/2;
    }
    else{
      s=3*s+1;
    }
    i++;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
    int n; cin >> n;
    double ans;
    if(n==1) ans=1;
    else if(n%2==0) ans=(double)1/2;
    else ans=(double)((n/2)+1)/n;
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
AC = 0
WA = 0
TLE = 0
RE = 0

a_list = [input() for j in range(int(input()))]

for a in a_list:
  if a == "AC":
    AC += 1
  elif a == "WA":
    WA += 1
  elif a == "TLE":
    TLE += 1
  else:
    RE += 1
  
print(f"AC x {AC}\nWA x {WA}\nTLE x {TLE}\nRE x {RE}")

Measured memory_bytes: 16320
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int ar[100005];
int cnt1[100005];
int cnt2[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>ar[i];
	}
	for(int i=0;i<n;i+=2){
		cnt1[ar[i]]++;
	}
	for(int i=1;i<n;i+=2){
		cnt2[ar[i]]++;
	}
	int mx10=0,mxi10=0,mx11=0,mxi11=0,mx20=0,mxi20=0,mx21=0,mxi21=0;
	for(int i=0;i<100005;i++){
		if(cnt1[i]>mx10){
			mx11=mx10;
			mxi11=mxi10;
			mx10=cnt1[i];
			mxi10=i;
		}
		else if(cnt1[i]>mx11){
			mx11=cnt1[i];
			mxi11=i;
		}
	}
	for(int i=0;i<100005;i++){
		if(cnt2[i]>mx20){
			mx21=mx20;
			mxi21=mxi20;
			mx20=cnt2[i];
			mxi20=i;
		}
		else if(cnt2[i]>mx21){
			mx21=cnt2[i];
			mxi21=i;
		}
	}
	//cout<<mx10<<" "<<mx11<<" "<<mx20<<" "<<mx21;
	if(mxi10!=mxi20){
		cout<<(((n/2)-mx10)+((n/2)-mx20));
		return 0;
	}
	if(mx21>mx11){
		mx20=mx21;
	}
	else{
		mx10=mx11;
	}
	cout<<(((n/2)-mx10)+((n/2)-mx20));
}


Measured memory_bytes: 1408
def main():
    from collections import Counter
    from operator import itemgetter

    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    a = map(int, input().split())

    ctr = Counter(a)
    for _ in range(M):
        b, c = map(int, input().split())
        ctr[c] += b

    ans = 0
    rest = N
    for integer, count in sorted(ctr.items(), key=itemgetter(0), reverse=True):
        take = min(rest, count)
        ans += take * integer
        rest -= take
        if not rest:
            break

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


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

  cin >> a >> b;

  if(0<a){
    cout<< "Positive" << endl;
  }

  else if(a==0){
    cout << "Zero" <<endl;
  }

  else{
    if(0<=b){
      cout << "Zero" <<endl;
    }

    else{
      int n=b-a;
      if(n%2==0) cout<< "Negative" << endl;
      else cout<< "Positive" << endl;
    }

  }
  
  return 0;
}

Measured memory_bytes: 256