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

#define DEBUG if(0)
#define lli long long int
const int maxN = 11;

int main()
{
  char s[maxN], t[maxN + 1];
  scanf("%s %s", s, t);
  string ss = string(s), tt = string(t);
  printf("%s\n", tt.substr(0, ss.size()) == ss ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int main() 
{  
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
    long long int N;
    cin>>N;
    long long int arr[N];
    for(int i=0;i<N;i++)
    {
        cin>>arr[i];
    }
    long long int sum=0;
    for(int i=0;i<N;i++)
    {
        if(i%2==0)
        {
            sum+=arr[i];
        }
        else
        {
            sum-=arr[i];
        }
    }
    vector<int> ans;
    ans.push_back(sum);
    sum=sum/2;
    for(int i=0;i<N-1;i++)
    {
        ans.push_back(2*(arr[i]-sum));
        sum=arr[i]-sum;
    }
    for(auto it:ans)
    {
        cout<<it<<" ";
    }
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
#pragma GCC target ("avx")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

template<class T>
struct RollingHash{
	int Base=283;
	const int MASK30=(1ll<<30)-1;
	const int MASK31=(1ll<<31)-1;
	const int MOD=(1ll<<61)-1;
	vector<int>hash,power;
	int calcmod(int v){
		v=(v&MOD)+(v>>61);
		if(v>MOD)v-=MOD;
		return v;
	}
	int mul(int x,int y){
		int xu=x>>31,xd=x&MASK31;
		int yu=y>>31,yd=y&MASK31;
		int mid=xd*yu+xu*yd,midu=mid>>30,midd=mid&MASK30;
		return calcmod(xu*yu*2+midu+(midd<<31)+xd*yd);
	}
	RollingHash(T s){
		int sz=s.size();
		hash.resize(sz+1,0);power.resize(sz+1,1);
		rep(i,sz){
			hash[i+1]=calcmod(mul(hash[i],Base)+s[i]);
			power[i+1]=calcmod(mul(power[i],Base));
		}
	}
	int get(int l,int r){
		return calcmod(hash[r]-mul(hash[l],power[r-l])+MOD);
	}
	int lcp(int x,int y){
		int len=min(hash.size()-1-y,hash.size()-1-x);
		int ok=0,ng=len+1;
		while(ng-ok>1){
			int mid=(ok+ng)/2;
			if(get(x,x+mid)==get(y,y+mid))ok=mid;
			else ng=mid;
		}
		return ok;
	}
};

int N;
string S[200005];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N){
		cin>>S[i];reverse(all(S[i]));
	}
	unordered_map<int,int>has;
	int ans=0;
	int cnt[26];
	rep(i,N){
		RollingHash<string>RH(S[i]);
		has[RH.hash[len(S[i])]]++;
	}
	rep(i,N){
		RollingHash<string>RH(S[i]);
		memset(cnt,0,sizeof(cnt));
		for(char c:S[i])cnt[c-'a']++;
		rep(j,26)if(cnt[j]){
			if(has.find((int)('a'+j))==has.end())continue;
			ans+=has[(int)('a')+j];
		}
		rep(j,len(S[i])){
			cnt[S[i][j]-'a']--;
			rep(k,26){
				if(cnt[k]){
					int p=(RH.mul(RH.hash[j+1],RH.Base)+(int)('a'+k))%RH.MOD;
					if(has.find(p)==has.end())continue;
					ans+=has[p];
				}
			}
		}
	}
	cout<<ans-N<<endl;
}


Measured memory_bytes: 26632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(void){
  int n,k,i,bi,hs=0,max;
  string s;
  vector<int> w;
  cin >> n >> k >> s;
  if (s[0]=='0') w.push_back(0);
  i=0;
  while (i<n){
    bi=i;
    while (i<n && s[i+1]==s[i]) i++;
    w.push_back(i-bi+1);
    i++;
  }
  if (s[n-1]=='0') w.push_back(0);
  if (w.size()<=k*2+1){
    cout << n << endl;
    return 0;
  }
  for (i=0;i<k*2+1;i++) hs+=w[i];
  max=hs;
  for (i=0;i+k*2+2<w.size();i+=2){
    hs+=w[i+k*2+1]+w[i+k*2+2]-w[i]-w[i+1];
    if (max<hs) max=hs;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
int N,A;
int x[51];
long long int dp[51][5050];
int main(){
  int i,j;
  int X;
  scanf("%d %d",&N,&A);X=A;
  for(i=1;i<=N;i++){
    scanf("%d",&x[i]);
    if(X<x[i])X=x[i];
    x[i]-=A;
  }
 
  dp[0][N*X]=1;
  for(i=1;i<=N;i++){
    for(j=0;j<=2*N*X;j++){
      dp[i][j]=dp[i-1][j]+dp[i-1][j-x[i]];
    }
    
  }

 
  
  printf("%lld\n",dp[N][N*X]-1);
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2);
    vector<ll> t(b+2);
    vector<ll> x(q);
    s[0] = -1e15L;
    t[0] = -1e15L;
    s[1] = 1e15L;
    t[1] = 1e15L;
    for(int i = 2; i < a+2; i++)
    {
        cin >> s[i];
    }
    for(int i = 2; i < b+2; i++)
    {
        cin >> t[i];
    }
    for(int i = 0; i < q; i++)
    {
        cin >> x[i];
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for(int i = 0; i < q; i++)
    {
        ll cand = x[i];
        ll sc = lower_bound(s.begin(), s.end(), cand) - s.begin();
        ll tc = lower_bound(t.begin(), t.end(), cand) - t.begin();
        ll ans = 1e15;
        for(int j = 0; j < 2; j++)
        {
            for(int k = 0; k < 2; k++)
            {
                ll c1 = abs(cand - s[sc-j]) + abs(s[sc-j] - t[tc-k]);
                ll c2 = abs(cand - t[tc-k]) + abs(s[sc-j] - t[tc-k]);
                ll tmp = min(c1, c2);
                ans = min(ans, tmp);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void){
    int N;
    int K;
    string S;

    cin>>N;
    cin>>K;
    cin>>S;

    if(K>=N){
        int mini;
        for(int i=0;i<S.size();i++){
            if(S.at(i)<S.at(mini))
            {
                mini = i;
            }
        }

        string result = string(N,S.at(mini));
        cout << result << endl;
        return 0;
    }
    string T = S;
    reverse(T.begin(),T.end());
    string base = S+T;

    string min_S = base.substr(0,N);
    for(int i=0;i<N;i++){
        string cut_S = base.substr(i,N);
        reverse(cut_S.begin(),cut_S.end());
        if(cut_S<min_S){
            min_S = cut_S;
        }
    }

    char head = min_S.at(0);
    int times  = 1;
    while(true){
        if(head != min_S.at(times)){
            break;
        }
        times++;
    }

    string result;
    int powt = times;
    for(int i=0;i<K-1;i++){
        powt *= 2;
        if(powt>N){
        string result = string(N,min_S.at(0));
        cout << result << endl;
        return 0;
    }
    }

    K--;
    string add = min_S.substr(0,N-powt+times);
    result = string(powt-times,min_S.at(0)) + add;
    cout << result << endl;
    return 0;

}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int gcd(int a,int b)
{
    int t;
    if(b>a)
    {
        t=b;
        b=a;
        a=t;
    }
    while(t=a%b)
    {
        a=b;
        b=t;
    }
    return b;
}
int main(int argc, const char * argv[])
{
    int a,b,k,cnt=0;
    cin>>a>>b>>k;
    int t=gcd(a, b);
    for(int i=t;i>=1;i--)
    {
        if(t%i==0) cnt++;
        if(cnt==k)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  int N;
  cin>>N;
  vector<tuple<string,int,int>>a;
  for(int i=1;i<=N;++i){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
  rep(i,N){
    cout<<get<2>(a[i])<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

a = input().split()
N = int(a[0])
M = int(a[1])

l = []
f = []
for i in range(N):
	temp = []
	l.append(temp)
	f.append(0)

for i in range(M):
	b = input().split()
	X = int(b[0]) - 1
	Y = int(b[1]) - 1
	l[X].append(Y)
	l[Y].append(X)

def search(cnt, li, flag, num):
	if(flag[num] == 0):
		flag[num] = cnt
		if(len(li[num]) != 0):
			for i in range(len(li[num])):
				search(cnt, li, flag, li[num][i])
		
cnt = 0
for i in range(N):
	if(f[i] == 0):
		cnt += 1
		search(cnt, l, f, i)			
print(cnt)

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


struct Edge{
    ll to;
    ll cost;
};

struct Node{
    ll pos;
    bool isOdd;
};

int main(){
  ll n;
  cin >> n;
  vector<ll> u(n);
  vector<ll> v(n);
  vector<ll> w(n);
  rep(i, n-1) cin >> u[i] >> v[i] >> w[i];


  rep(i, n-1) w[i] %= 2;

  vector<vector<Edge>> g(n, vector<Edge>());

  rep(i, n-1){
    g[u[i]-1].push_back({v[i]-1, w[i]});
    g[v[i]-1].push_back({u[i]-1, w[i]});
  }

  queue<Node> que;
  que.push({0, true});

  vector<char> memo(n, '?');
  while(!que.empty()){
    Node node = que.front(); que.pop();

    if(memo[node.pos] != '?') continue;
    memo[node.pos] = node.isOdd? '1':'0';

    for(auto e : g[node.pos]){
      if(e.cost%2 == 0) que.push({e.to, node.isOdd});
      else              que.push({e.to, !node.isOdd});
    }
  }

  rep(i, n) cout << memo[i] << endl;
  
  
  return 0;
}



Measured memory_bytes: 12288
#include <iostream>

using namespace std;

int main(void) {
	int A,B;
	cin >> A >> B;
	if (A%2 == 0 || B%2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];
ll ifact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++) fact[i] = (fact[i-1] * i) % MOD;
  ifact[maxf]=modpow(fact[maxf],MOD-2);
  for(ll i=maxf; i>=1; i--) ifact[i-1] = (ifact[i] * i) % MOD;
}

ll comb(ll n, ll r){
  if(n<r || n<0 || r<0) return 0;
  if(fact[0] == 0) fact_init();
  return ((fact[n] * ifact[n-r]) % MOD * ifact[r]) % MOD;
}

ll naive_comb(ll n, ll r){
  ll res = 1;
  for (ll i = n; i > n - r; i--) res = res * i % MOD;
  for (ll i = 1; i <= r; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}


ll g(ll r, ll c){
  return comb(r+1+c+1,r+1)-1;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll r1,c1,r2,c2; cin>>r1>>c1>>r2>>c2;
  r1--,c1--;
  
  ll ans=g(r2,c2)-g(r2,c1)-g(r1,c2)+g(r1,c1);
  while(ans<0) ans+=MOD;
  ans%=MOD;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 156544
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var list = readLine()!!.split(" ").map{it.toInt()}.toMutableList()
    val count = selectionSort(list, n)
    for(i in 0 until list.size) {
        print(list[i].toString())
        if(i != list.size-1) {
            print(" ")
        } else {
            println()
        }
    }
    println(count)
}

fun selectionSort(A: MutableList<Int>, n: Int): Int {
    var count = 0
    for(i in 0 until n) {
        var min = i
        for(j in i until n) {
            if (A[j] < A[min]) {
                min = j
            }
        }
        if(min != i) {
            A.swap(i, min)
            count++
        }
    }
    return count
}

fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1]
    this[index1] = this[index2]
    this[index2] = tmp
}


Measured memory_bytes: 32000
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, m;
        cin >> n >> m;
        int sum = 0;
        for(int i = 0; i < m; i++){
            int x;
            cin >> x;
            sum += x;
        }
        cout << max(-1LL, n - sum) << '\n';
    }
}

Measured memory_bytes: 34584
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c;
	int tsum,hsum;
	tsum=hsum=0;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(a==b)	hsum++;
		else{
			if(a<b&&b<c||a>b&&a<c)	tsum++;
		}
	}
	cout<<tsum<<endl;
	cout<<hsum<<endl;
	return 0;
}


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

int main() {
  int N,cnt=0;
  string s;
  cin >> N;
  map<string,bool>S;
  for(int i=0;i<N;i++){
    cin >> s;
    if(S[s]==false){
      S[s]=true;
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<ll> dp(n+1,1e18);

    vector<int> arr(n+1);
    for(int i=1;i<=n;++i)cin>>arr[i];

    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);

    for(auto i=3;i<=n;++i)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }

    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1408
n = int(input())
data = [[0, 0, 0]] + [list(map(int, input().split())) for i in range(n)]

for i in range(1, n+1):
    distance = abs(data[i][1] - data[i-1][1]) + abs(data[i][2] - data[i-1][2])
    time = abs(data[i][0] - data[i-1][0])
    if not (distance <= time and distance % 2 == time % 2):
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 28068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll mod=998244353;

ll com(ll N, ll K, ll L) {
  ll d=1,e=(L*K)%mod,m_=mod-2;
  while(m_!=0) {
    if(m_&1) d=(d*e)%mod;
    e=e*e%mod;
    m_=m_>>1;
  }
  return (N*d)%mod;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k,ans=0;cin>>n>>m>>k;
  if(m==1) {
    if(k==n-1) print(1);
    else print(0);
    return 0;
  }
  lvector fact(n+10,1);rep(i,n+5) fact[i+1]=(fact[i]*(i+1))%mod;
  lvector m_m1(n+10,m);rep(i,n+5) m_m1[i+1]=(m_m1[i]*(m-1))%mod;
  ans+=m_m1[n-1]%mod;
  for(ll v=1;v<=k;++v) {
    ans+=(com(fact[n-1],fact[v],fact[n-1-v])*m_m1[n-1-v])%mod;
    ans%=mod;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 6264
#include<stdio.h>

int main()
{	
	char a[3];
	int b=0,c=0,d=0;
	scanf("%s",&a);
	int i;
	for(i=0;a[i]!='\0';i++)
	{
		if(a[i]=='a')
			b++;	
		if(a[i]=='b')
			c++;
		if(a[i]=='c')
			d++;
	}
	if(c>1 || b>1 || d>1)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

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

int main() {
  ll n;cin>>n;
  bool f=n<0;
  ll k=0;
  ll b=2;
  stringstream ss;
  if(n==0) {
    cout<<0<<endl;
    return 0;
  }
  for(int i=0; i<62; i++) {
    if(f) {
      if(i%2==0) {
	if(n%b!=0) {
	  n+=(n%b);
	  ss<<"1";
	} else {
	  ss<<"0";
	}
      } else {
	if(n%(-b)!=0) {
	  n-=(n%(-b));
	  ss<<"1";
	} else {
	  ss<<"0";
	}
      }
    } else {
      if(i%2==0) {
	if(n%b!=0) {
	  n-=(n%b);
	  ss<<"1";
	} else {
	  ss<<"0";
	}
      } else {
	if(n%(-b)!=0) {
	  n+=(n%(-b));
	  ss<<"1";
	} else {
	  ss<<"0";
	}
      }
    }
    if(n==0)
      break;
    b*=(-2);
  }
  string s = ss.str();
  reverse(s.begin(),s.end());
  cout << s << endl;
  return 0;
}


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

int main() {

 int N,K;
  cin >> N >> K;
  int x = 1;
  for (int i= 0;i<N;i++){
   if (x+K>2*x){
     x=x*2;
  }
  else{
    x=x+K;
  }
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int n;
 cin >> n;
 vector<long long> a(n);
  rep(i,n) cin >> a.at(i);
  
  rep(i,n) a.at(i) = a.at(i) * 2; 
 
  vector<long long> mount(n);
 
 long long de = 0;
 rep(i,n-1){
 if (i%2 == 0) de += a.at(i);
   if(i%2 == 1) de -= a.at(i);
 }
 
 mount.at(0) = (de + a.at(n-1))/2;
 
 rep(i,n-1){
  mount.at(i+1) = a.at(i) - mount.at(i); 
 }
 
 
 
  rep(i,n) cout << mount.at(i) << endl;
  
  
  return 0;
  
  
}

Measured memory_bytes: 2944
using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      while (true)
      {
        int sum = 0;
        string a = Console.ReadLine();
        if (a == "0") break;

        for (int x = 0; x < a.Length; x++)
        {
          sum += int.Parse(a[x].ToString());
        }
        Console.WriteLine(sum);
      }
    }
  }
}


Measured memory_bytes: 9180
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MOD=1000000007;
const int MAXN=2000;


int n,pos;
int p2[MAXN+1];
int dp[MAXN+1][MAXN+1][2];

int bf() {
	set<vector<int> > res;
	REP(i,1<<(n-1)) REP(j,1<<(n-1)) {
		deque<int> q;
		q.push_back(0); REP(k,n-1) if(i&(1<<k)) q.push_back(k+1); else q.push_front(k+1);
		vector<int> cur;
		REP(k,n-1) if(j&(1<<k)) cur.PB(q.back()),q.pop_back(); else cur.PB(q.front()),q.pop_front(); cur.PB(q.back()),q.pop_back();
		if(cur[pos]!=0) continue;
		res.insert(cur);
	}
	//for(set<vector<int> >::iterator it=res.begin();it!=res.end();++it) { printf("sol:"); REPSZ(i,*it) printf(" %d",(*it)[i]); puts(""); }
	return SZ(res);
}

int solve() {
	p2[0]=1; FORE(i,1,n) p2[i]=(ll)p2[i-1]*2%MOD;
	int nafter=n-pos-1;
	memset(dp,0,sizeof(dp));
	REPE(j,n-1) {
		if(j>=nafter) dp[1][j][1]=nafter==0?1:p2[nafter-1];
		if(j==nafter) dp[1][j][0]=nafter==0?1:p2[nafter-1];
	}
	FORE(i,2,n) REPE(j,n-i) {
		dp[i][j][0]=((ll)dp[i-1][j+1][0]+dp[i-1][j][1])%MOD;
		dp[i][j][1]=((ll)dp[i-1][j+1][0]+dp[i-1][j][1]+(j==0?0:dp[i][j-1][1]))%MOD;
	}
	//REPE(i,n) REPE(j,n-i) REP(k,2) if(dp[i][j][k]!=0) printf("dp[%d][%d][%d]=%d\n",i,j,k,dp[i][j][k]);
	int ret=dp[n][0][0];
	/*if(n<=10) {
		int chk=bf();
		if(chk!=ret) printf("have %d want %d\n",ret,chk);
	}*/
	return ret;
}

void run() {
	scanf("%d%d",&n,&pos); --pos;
	printf("%d\n",solve());

}

int main() {
	run();
	return 0;
}


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

const int MAX_N = 100 * 1000, MAX_M = 100 * 1000;
vector<int> adjLis[MAX_N + 1], adjInd[MAX_N + 1], EdgeDir[MAX_N + 1];
bitset<MAX_N + 1> markVer, isOddDeg;
stack<int> path;

void dfs(int preVer, int v) {
    markVer[v] = true;
    int u;
    if (isOddDeg[v]) {
        path.push(v);
        if (path.size() > 1) {
            isOddDeg[v] = false;
            int w;
            while (path.size() > 1) {
                u = path.top();
                path.pop();
                w = path.top();
                for (int i = 0; i < adjLis[u].size(); i++) {
                    if (adjLis[u][i] == w) {
                        EdgeDir[u][i] = !EdgeDir[u][i];
                        EdgeDir[w][adjInd[u][i]] = !EdgeDir[w][adjInd[u][i]];
                        break;
                    }
                }
            }
            isOddDeg[w] = false;
            path.pop();
        }
    } else if (!path.empty())
        path.push(v);
    for (int i = 0; i < adjLis[v].size(); i++) {
        u = adjLis[v][i];
        if (!markVer[u])
            dfs(v, u);
    }
    if (!path.empty())
        if (!isOddDeg[v]) {
            path.pop();
            if (path.top() != preVer) {
                path.push(v);
                path.push(preVer);
            }
        } else
            path.push(preVer);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    int A[M + 1], B[M + 1];
    for (int i = 1; i <= M; i++) {
        cin >> A[i] >> B[i];
        adjLis[A[i]].push_back(B[i]);
        adjLis[B[i]].push_back(A[i]);
        adjInd[A[i]].push_back(adjLis[B[i]].size() - 1);
        adjInd[B[i]].push_back(adjLis[A[i]].size() - 1);
        EdgeDir[A[i]].push_back(true);
        EdgeDir[B[i]].push_back(false);
        isOddDeg[A[i]] = !isOddDeg[A[i]];
    }
    if (M % 2 == 1)
        cout << "-1\n";
    else {
        dfs(-1, 1);
        int u;
        for (int v = 1; v <= N; v++)
            for (int i = 0; i < adjLis[v].size(); i++) {
                u = adjLis[v][i];
                if (EdgeDir[v][i])
                    cout << v << ' ' << u << '\n';
            }
    }
    return 0;
}


Measured memory_bytes: 23296
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    cin >> n;

    vector<double> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    
    vector<vector<double>> dp(n+1, vector<double>(n+2));  // dp[i][j] : i枚目のコインまででj枚表の確率
    dp[0][0] = 1.0;
    rep(i, n) {
        exrep(j, 0, n) {
            dp[i+1][j+1] += p[i]*dp[i][j];
            dp[i+1][j] += (1 - p[i])*dp[i][j];
        }
    }

    double ans = 0.0;
    exrep(j, n/2 + 1, n) {
        ans += dp[n][j];
    }

    exout(ans);
    re0;
}

Measured memory_bytes: 73788
N = int(input())
A = [int(a) - 1 for a in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]]
  if i != N-1 and A[i] + 1 == A[i+1]:
    ans += C[A[i]]
print(ans)

Measured memory_bytes: 38256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2400

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct Team {
	int accept;
	int pena;
	int tID;
	
	bool operator<( const Team& right ) const {
			if(accept == right.accept)
			{
				if(pena == right.pena){
					return tID < right.tID;
				}else{
					return pena < right.pena;
				}
			}else{
				return accept > right.accept;
			}
	}
};

int main()
{
	int T,P,R;
	while(cin >> T >> P >> R)
	{
		if(T == 0 && P == 0 && R == 0){ break; }
		vector<Team> team(T);
		rep(i,T){ team[i] = {0,0,i+1}; }

		int miss[T][P];
		fill_n((int *)miss, sizeof(miss) / sizeof(int), 0);

		rep(i,R)
		{
			int tID, pID, time;
			string message;

			cin >> tID >> pID >> time >> message;

			tID--; pID--;

			if(miss[tID][pID] != -1)
			{
				if(message == "WRONG")
				{
					miss[tID][pID] += 1;
				}
				else
				{
					team[tID].accept += 1;
					team[tID].pena += miss[tID][pID]*1200 + time; 		
					miss[tID][pID] = -1;
				}
			}
		}


		sort(ALL(team));

		rep(i,T){
			cout << team[i].tID << " " << team[i].accept << " " << team[i].pena << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
N=int(input())
*A, = map(int,input().split())
B = {}
for a in A: B[a] = B.get(a,0)+1
m = min(B)
M = max(B)
if m+1<M:
    print("No")
    exit()
def check(n):
    b0 = B.setdefault(n-1,0)
    b1 = B.setdefault(n,0)
    if b1==0:
        return b0==n
    else:
        return 1<= n-b0 <= b1//2
if m+1==M:
    ans = check(M)
else:
    ans = check(m) or check(m+1)
print("Yes" if ans else "No")

Measured memory_bytes: 17400
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N, L; cin >> N >> L;
  int t = 0;
  rep(i,1,N+1) t += L+i-1;

  int m = numeric_limits<int>::max();
  int ans;
  rep(i,1,N+1){
    if(abs(L+i-1)<m){
      m = abs(L+i-1);
      ans = t-(L+i-1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(map(int, input().split())))

ans = []
flg = 0
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if a[i][j] % 2 == 1:
                flg += 1
            val = [i+1,j+1,i+1,j+2]
            if val[2] <= h and val[3] <= w and flg % 2 == 1:
                ans.append(val)
            elif val[2] < h and val[3] > w and flg % 2 == 1:
                ans.append([i+1,j+1,i+2,j+1])
    else:
        j = w-1
        while j >= 0:
            if a[i][j] % 2 == 1:
                flg += 1
            val = [i+1,j+1,i+1,j]
            if val[2] <= h and val[3] > 0 and flg % 2 == 1:
                ans.append(val)
            elif val[2] < h and val[3] <= 0 and flg % 2 == 1:
                ans.append([i+1,j+1,i+2,j+1])

            j -= 1
print(len(ans))
for i in range(len(ans)):
    print(' '.join(map(str,ans[i])))


Measured memory_bytes: 29824
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll ans=0;
int n,x,y,z;
struct node
{ll a,b,c;
}p[100005],q[100005],nt[100005];
inline bool cmp1(node a,node b)
{return a.b-a.a>b.b-b.a;}
multiset <pair<ll,int> > q1,q2,q3;
int main (){
	int i,j;
	scanf ("%d%d%d",&x,&y,&z);
	n=x+y+z;
	for (i=1;i<=n;i++)
	{scanf ("%lld%lld%lld",&p[i].a,&p[i].b,&p[i].c);
	ans+=p[i].a;
	}
	sort(p+1,p+n+1,cmp1);
	for (i=1;i<=y;i++) 
	{ans+=p[i].b-p[i].a;
	q1.insert(make_pair(p[i].c-p[i].b,i));
	}
	for (i=y+1;i<=n;i++)
	{q2.insert(make_pair(p[i].b-p[i].a,i));
	q3.insert(make_pair(p[i].c-p[i].a,i));
	}
	for (i=1;i<=z;i++)
	{ll tp1,tp2;
	tp1=((*q1.rbegin()).first)+((*q2.rbegin()).first);
	tp2=((*q3.rbegin()).first);
	if (tp1>tp2)
	{ans+=tp1;
	int pos=(*q2.rbegin()).second;
	q1.insert(make_pair(p[pos].c-p[pos].b,pos));
	q3.erase(q3.lower_bound(make_pair(p[pos].c-p[pos].a,pos)));
	q1.erase(q1.lower_bound(*q1.rbegin()));
	q2.erase(q2.lower_bound(*q2.rbegin()));
	}
	else 
	{ans+=tp2;
	int pos=(*q3.rbegin()).second;
	q3.erase(q3.lower_bound(*q3.rbegin()));
	q2.erase(q2.lower_bound(make_pair(p[pos].b-p[pos].a,pos)));
	}
	}
	printf ("%lld\n",ans);
	return 0;
}
	
	

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

int main() {
    int n,m;
    cin >> n >> m;
    int A[n][m], b[m];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }
    int t;

    for (int i = 0; i < n; i++){
        t = 0;
        for (int j = 0; j < m; j++){
            t += A[i][j] * b[j];
        }
        cout << t << "\n";
    }

    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll dp[200010], sum[200010];

vector<pair<int, int>> runLengthEncoding(vector<int> s) {
    int n = s.size();
    vector<pair<int, int>> res;
    int pre = s[0];
    int cnt = 1;
    for (int i = 1; i < n; i++) {
        if (pre != s[i]) {
            res.pb({pre, cnt});
            pre = s[i];
            cnt = 1;
        }
        else cnt++;
    }
    res.pb({pre, cnt});
    return res;
}

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

    int NN; cin >> NN;
    vector<int> CC(NN);
    rep(i, NN) cin >> CC[i];

    vector<P> C = runLengthEncoding(CC);
    int N = C.size();

    dp[0] = 1;
    rep(i, N) {
        int c = C[i].fi;
        dp[i+1] += sum[c] + dp[i];
        dp[i+1] %= mod;
        sum[c] = dp[i+1];
        sum[c] % mod;
    }

    cout << dp[N] % mod << endl;
}

Measured memory_bytes: 5856
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    char c;  cin >> c;
    int num = int(c) + 1;
    cout << char(num) << endl;

    return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  vector<string> s(n);
  
  for ( int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());
  
  cout << s.size() << endl;
  
}



Measured memory_bytes: 9548
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
long long int MOD = 1000000007;
using namespace std;

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

long long int LCM(long long int a, long long int b){
	long long int dummy1, dummy2, dummy;
	dummy1 = max(a, b);
	dummy2 = min(a, b);
	while(true){
		dummy = dummy1 % dummy2;
		dummy1 = dummy2;
		dummy2 = dummy;
		if(dummy == 0){
			break;
		}
	}
	return (a / dummy1) * (b / dummy1) * dummy1;
}

long long int GCD(long long int a, long long int b){
	long long int dummy1, dummy2, dummy;
	dummy1 = max(a, b);
	dummy2 = min(a, b);
	while(true){
		dummy = dummy1 % dummy2;
		dummy1 = dummy2;
		dummy2 = dummy;
		if(dummy == 0){
			break;
		}
	}
	return dummy1;
}

int main(){
	
	int n;
	cin >> n;
	
	long long int ans = 1;
	for(int i = 0; i < n; i++){
		int num;
		cin >> num;
		ans = LCM(ans, num);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main(){
  
 	int a[6];
  	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
  	string ans;
  	if(a[4] - a[0] <= a[5]){
    	 ans = "Yay!";
    }else{
     	ans = ":(";
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int a, b, d, r;
            double f;
            string[] num = Console.ReadLine().Split(' ');
            a = int.Parse(num[0]);
            b = int.Parse(num[1]);

            d = a / b;
            r = a % b;
            f = (double)a / b;

            Console.Write(d + " " + r + " ");
            Console.WriteLine("{0:0.000000}", f); 
        }
    }



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

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

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

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a%2==0 or b%2==0 or c%2==0){
		cout<<0<<endl;
	}else{
		cout<<min((ll)a*b,min((ll)b*c,(ll)c*a))<<endl;
	}

	
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

const int mod = 1000000007;

struct Mod {
  int n;
  Mod () : n(0) {;}
  Mod (int m) : n(m) {
    if (n >= mod) n %= mod;
    else if (n < 0) n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};

bool operator==(Mod a, Mod b) { return a.n == b.n; }
Mod operator+=(Mod &a, Mod b) { a.n += b.n; if (a.n >= mod) a.n -= mod; return a; }
Mod operator-=(Mod &a, Mod b) { a.n -= b.n; if (a.n < 0) a.n += mod; return a; }
Mod operator*=(Mod &a, Mod b) { a.n = ((long long)a.n * b.n) % mod; return a; }
Mod operator+(Mod a, Mod b) { return a += b; }
Mod operator-(Mod a, Mod b) { return a -= b; }
Mod operator*(Mod a, Mod b) { return a *= b; }
Mod operator^(Mod a, int n) {
  if (n == 0) return Mod(1);
  Mod res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}

ll inv(ll a, ll p) {
  return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
Mod operator/(Mod a, Mod b) { return a * Mod(inv(b, mod)); }

#define MAX_N 1024000

Mod fact[MAX_N], factinv[MAX_N];
void init() {
  fact[0] = Mod(1); factinv[0] = 1;
  REP(i,MAX_N-1) {
    fact[i+1] = fact[i] * Mod(i+1);
    factinv[i+1] = factinv[i] / Mod(i+1);
  }
}
Mod comb(int a, int b) {
  return fact[a] * factinv[b] * factinv[a-b];
}

int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  init();
  Mod res = Mod(0);
  for(int i = B; i < W; ++i) {
    res += comb(H - 1 - A + i, i) * comb(A - 2 + W - i, A - 1);
  }
  cout << res.n << endl;
  return 0;
}



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

const int maxn = 2000007;
bitset<maxn> dp;

int main()
{
	int n;
	cin>>n;
	//vector<int> A(n);
	int x;
	int sum = 0;
	dp[0] = 1;
	for(int i = 1 ; i <= n ; i++)
	{
		cin>>x;
		sum += x;	
		dp = (dp|(dp<<x));
	} 
	int target = ((sum+1)/2);
	for(int i = target ; i <=sum ; i++)
	{
		if(dp[i])
		{
			cout<<i;
			break;
		}
	}
	return 0;	 
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> vec(n, k-q);
    for(int i=0; i<q; i++){
        int a;
        cin >> a;
        vec[a-1]++;
    }

    for(int i=0; i<n; i++){
        if(vec[i] > 0) out("Yes");
        else out("No");
    }
}

Measured memory_bytes: 1024
#!/usr/bin/env ruby

N = 60_000 # ??¢?´¢???????´???°?????????
elt = Array.new(N, 1) # ??¨????????????????????????????????????
primes = [] # ?´???°???????´???????


# ??¨????????????????????????
elt[0] = 0
elt[1] = 0

N.times do |i|
  next if elt[i].zero?
  primes << i
  k = i * 2
  while k < N
    elt[k] = 0
    k += i
  end
end

while line = gets
  n = line.chomp!.to_i
  (primes.length).times do |j|
    if n == primes[j]
      puts "#{primes[j-1]} #{primes[j+1]}"
      break
    elsif n > primes[j] && n < primes[j+1]
      puts "#{primes[j]} #{primes[j+1]}"
      break
    end
  end
end

Measured memory_bytes: 9176
#include <stdio.h>

int main() {
  int N; scanf("%d", &N);
  int a[1001];
  for(int n = 2; n <= N; ++n) a[n] = n;
  int prod = 1;
  for(int p = 2; p <= N; ++p) {
    if(a[p]==1) continue;
    int cnt = 0;
    for(int n = p; n <= N; n += p) {
      while(a[n] % p == 0) {
        a[n] /= p;
        ++cnt;
      }
    }
    prod = (long long)prod * (cnt + 1) % 1000000007;
  }
  printf("%d\n", prod);
  return 0;
}


Measured memory_bytes: 128
INFINITY = 10 ** 10
WHITE = 0
GRAY = 1
BLACK = 2


n = int(input())
M = [[INFINITY] * n for _ in range(n)]

for _ in range(n):
    u, k, *list_num = map(int, input().split())

    for i in range(0, k * 2, 2):
        M[u][list_num[i]] = list_num[i + 1]

d = [INFINITY] * n

def dijkstra():
    color = [WHITE] * n
    p = [None] * n

    d[0] = 0
    p[0] = -1

    while True:
        cost_min = INFINITY
        for i in range(n):
            if color[i] != BLACK and d[i] < cost_min:
                cost_min = d[i]
                top_now = i

        if cost_min == INFINITY:
            break
    
        color[top_now] = BLACK

        for v in range(n):
            if color[v] == BLACK or M[top_now][v] == INFINITY:
                continue

            cost_now = d[top_now] + M[top_now][v]
            if cost_now < d[v]:
                d[v] = cost_now
                p[v] = top_now
                color[v] = GRAY


dijkstra()

for i, cost in enumerate(d):
    print(i, cost)



Measured memory_bytes: 5748
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

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

    Vii G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(n, -1);
    vector<int> sign(n);
    queue<int> que;

    dist[0] = 0;
    que.push(0); 

    while (!que.empty()) {
        int v = que.front(); 
        que.pop();

        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            sign[nv] = v + 1;
            que.push(nv);
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << sign[i] << endl;
    }
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> v;
  int mx = 0;
  string ms = "";
  for (auto m : mp) {
    if (m.second > mx) {
      ms = m.first;
      mx = m.second;
    }
  }
  for (auto m : mp) {
    if (m.second == mx) {
      v.push_back(m.first);
    }
  }
  sort(v.begin(), v.end());
  rep(i, v.size()) cout << v[i] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

map<lli,vector<lli>> d;
bool vis[100100];
lli dp[100100];
lli k;

void func(lli now,lli depth,lli num){
	if(vis[now])return;
	if(DEBUG)cout<<"now="<<now<<endl;
	dp[now] = num;
	vis[now] = true;
	if(DEBUG)cout<<"dp[now]="<<dp[now]<<endl;
	lli nextNum = k;
	if(depth==0)nextNum--;
	else nextNum-=2;
	for(auto e:d[now]){
		if(vis[e])continue;
		func(e,depth+1,nextNum);
		nextNum = max(0LL,nextNum-1);
	}
}

signed main(){

	lli n;
	cin>>n>>k;
	REP(i,0,n-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		d[a].push_back(b);
		d[b].push_back(a);
	}
	func(0,0,k);

	lli sum = 1;
	REP(i,0,n){
		sum *= dp[i];
		sum %= MOD;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 19072
N = int(input())
p_list =  list(map(int, input().split()))

i = 0
count = 0

if p_list[-1] == N:
    temp = p_list[-1]
    p_list[-1] = p_list[-2]
    p_list[-2] = temp
    count = count + 1

while i < N:
    if p_list[i] == i + 1:
        temp = p_list[i+1]
        p_list[i+1] = p_list[i]
        p_list[i] = temp
        count = count + 1
        i = i + 1
    i = i + 1

print(count)


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


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d)
        cout <<"Yes\n";
    else cout << "No\n";
}



Measured memory_bytes: 256