akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int keta(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int n;
  cin >> n;
  int sum=0;
  if(n%keta(n)==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
}
  

Measured memory_bytes: 256
#include<iostream>
using ll = long long;
#define int ll
signed main(){
  int l,r; 
  std:: cin >> l >> r;
  int dif = r - l;
  if(dif >= 2030) {
    std::cout << 0 << std:: endl;
  } else {
    int ans = 100000000000000000LL;
    for(int i = l; i <= r; ++i){
      for(int j = i + 1; j <= r; ++j){
       int cnt = (i * j) % 2019LL;
       ans = (ans > cnt ? cnt :  ans );
      }
  	}
    std::cout << ans << std::endl;
  }
  
}


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



struct UnionFind{
    vector<int> par;
    vector<int> sizes;

    UnionFind(int size) : par(size), sizes(size,1){
        for(int i=0;i<size;i++) par[i] = i;
    }

    bool unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x == y) return false;
        if(sizes[x] < sizes[y]) swap(x,y);

        par[y] = x;
        sizes[x] += sizes[y];
        sizes[y] = 0;

        return true;
    }

    int find(int x){
        if(par[x] == x) return x; 
        return par[x] = find(par[x]);
    }

    bool isSame(int x,int y){
        return find(x) == find(y);
    }

    int getSize(int x){
        return sizes[find(x)];
    }
};

signed main(){
    int N,M;
    cin >> N >> M;
    UnionFind forest(N);

    vector<int> A(M),B(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    vector<long> ans(M);
    ans[M-1] = N*(N-1l)/2l;

    for(int i=M-1;i>0;i--){
        long sizeA = forest.getSize(A[i]);
        long sizeB = forest.getSize(B[i]);
        ans[i-1] = ans[i];
        if(forest.unite(A[i],B[i])) ans[i-1] -= (sizeA*sizeB);
    }

    for(int i=0;i<M;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define ve vector

int n;
double dp[310][310][310];

double rec(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i==0&&j==0&&k==0) return 0.0;

    double res = 0.0;
    if(i>0) res += rec(i-1,j,k) * i;
    if(j>0) res += rec(i+1,j-1,k) * j;
    if(k>0) res += rec(i,j+1,k-1) * k;
    res += n;
    res *= 1.0/(i+j+k);
    return dp[i][j][k] = res;
}

int main(){
    cin >> n;
    int i=0, j=0, k=0;
    for(int x = 0; x < n; x++){
        int a;
        cin >> a;
        if(a==1)i++;
        if(a==2)j++;
        if(a==3)k++;
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0][0] = 0.0;
    double ans = rec(i,j,k);
    printf("%.10f\n", ans); 
    return 0;
}

Measured memory_bytes: 232960
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    int ans = 0, MAX = 0;
    rep(i, 0, n){
        cin >> a[i] >> b[i];
        if(MAX < a[i]){
            MAX = a[i];
            ans = a[i] + b[i];
        }
    }
    cout << ans << endl;
}

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

int calc_gcd(int x,int y){
    if(y == 0){
                return x;
    }
    else{
                return calc_gcd(y,x%y);
    }
}

int main(){
    int x,y;
    cin >> x >> y;
    if (x >= y){
        cout << calc_gcd(x,y) << endl;
    }
    else{
        cout << calc_gcd(y,x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			double d = sc.nextDouble();
			double e = sc.nextDouble();
			double f = sc.nextDouble();
			double det = a * e - b * d;
			if(det != 0) {
				double x = (double) ((e * c - b * f) / det);
				double y = (double) (( - d * c + a * f) / det);
				if (x == 0) x = 0;
				if (y == 0) y = 0;
				System.out.printf("%.3f %.3f\n",x,y);
			}
		}
	}
		
}

Measured memory_bytes: 20484
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    A--;
    ll a = A / C + A / D - A / (C / __gcd(C, D) * D);
    ll b = B / C + B / D - B / (C / __gcd(C, D) * D);
    cout << (B - A) - (b - a) << endl;
    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
rng = 400100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
def cmb(n,k):
  if n-k<0:
    return 0
  else:
    ls=[n]
    for i in range(k-1):
      ls.append(ls[-1]*(n-i-1)%mod)
    return ls[-1]*pow(fctr[k],mod-2,mod)%mod
n,a,b=map(int,input().split())
print((pow(2,n,mod)-cmb(n,a)-cmb(n,b))%mod-1)

Measured memory_bytes: 69872
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
    string s;
    cin >> s;
    
    if(s!="ARC" && s!="ABC"){
        return 0;
    }

    if(s=="ARC"){
        cout << "ABC";
    }
    else if(s=="ABC"){
        cout << "ARC";
    }
    
    return 0;

}

Measured memory_bytes: 3552
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      if(A * C <= B){
        System.out.println(C);
      }else{
        System.out.println(B / A);
      }
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("long_input.txt");
    #define cin input_from_file
#else

#endif


const int MAXP = 20;

int qq[MAXP][MAXP];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N;
    cin >> N;
    vector<LL> A(N, 0);
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        LL e = 1;
        int d = 0;
        for (int k = 0; k < (int)s.size(); k++) {
            if (s[k] == '.') d = k;
            else {
                //~ cout << s[k] - '0' << " " << e << " " << (s[k] - '0')*e << endl;
                A[i] += (LL)(s[k] - '0')*e;
                e *= 10;
            }
        }
        while (d < 9) A[i] *= 10, d++;
        //~ A[i] *= 1<<(9-d);
        //~ cout << A[i] << endl;
    }
    for (int i = 0; i < N; i++) {
        int p2 = 0, p5 = 0;
        while (A[i] % 2 == 0 and p2 < MAXP-1) A[i] /= 2, p2++;
        while (A[i] % 5 == 0 and p5 < MAXP-1) A[i] /= 5, p5++;
        qq[p2][p5]++;
        //~ cout << A[i] << " " << p2 << " " << p5 << endl;
    }
    LL res = 0;
    for (int a = 0; a < MAXP; a++) for (int b = 0; b < MAXP; b++) {
        for (int c = 0; c < MAXP; c++) for (int d = 0; d < MAXP; d++) {
            if (a + c < 18 or b + d < 18) continue;
            if (qq[a][b] == 0 or qq[c][d] == 0) continue;
            //~ cout << a << " " << b << " " << qq[a][b] << ", " << c << " " << d << " " << qq[c][d] << endl;
            if (a == c and b == d) {
                res += (LL)qq[a][b]*(qq[c][d] - 1);
            }
            else res += (LL)qq[a][b] * qq[c][d];
        }
    }
    cout << res/2 << "\n";
    
}


Measured memory_bytes: 4676
a,b,c = map(int,input().split())

if(a<=c):
    p = 0
    if(b<=c-a):
        q = 0
    else:
        q = b -(c-a)
else:
    p = a-c
    q = int(b)

print(str(p) + " " + str(q))

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

using namespace std;

const double pi=acos(-1.0);
const int inf=0x3f3f3f3f;

int n,m;
int a,b;

inline void prework()
{
	scanf("%d%d%d",&n,&a,&b);
}

inline void mainwork()
{
	
}

inline void print()
{
	int ans;
	if(a+b<=n)
		ans=0;
	else
		ans=a+b-n;
	printf("%d %d",min(a,b),ans);
}

int main()
{
	prework();
	mainwork();
	print();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 final static int maxn=(int)2e5+10;
 static int l[]=new int [maxn];static int r[]=new int [maxn];
 static int lowerbound(int len,int num)
 {
	 int left=1;int right=len;
	 while(left<right)
	 {
		 int mid=(left+right)/2;
		 if(r[mid]>=num)right=mid;
		 else
			 left=mid+1;
	 }
	 return left;
 }
 static int upperbound(int len,int num)
 {
	 int left=1;int right=len;
	 while(left<right)
	 {
		 int mid=(left+right)/2;
		 if(r[mid]<=num)left=mid+1;
		 else
			 right=mid;
	 }
	 return left;
 }
 public static void main(String args[])
 {
	 Scanner input=new Scanner(System.in);
	int n=input.nextInt();
	for(int i=1;i<=n;i++)
	{
		int x=input.nextInt();
		l[i]=i-x;r[i]=i+x;
	}
	long ans=0;
   Arrays.sort(l,1,1+n);Arrays.sort(r,1,n+1);
   for(int i=1;i<=n;i++)
   {
	    int index1=lowerbound(n,l[i]);int index2=upperbound(n,l[i]);
	    if(r[index1]==r[index2-1])
	    {
	    	ans+=index2-1-index1+1;
	    }
   }
   System.out.println(ans);;
 }
} 


Measured memory_bytes: 51772
#include <iostream>
using namespace std;
int num, mini;
int count = 0;

int main(void) {
    cin >> num;
    int array[num] = {};
    for (int i = 0; i < num; i++) {
        cin >> array[i];
    }
    for( int i = 0; i < num; i++) {
        mini = i;
        for(int j = i; j < num; j++) {
            if( array[j] < array[mini]) {
                mini = j;
            }
        }
        if(mini != i) {
            int temp = array[i];
            array[i] = array[mini];
            array[mini] = temp;
            count++;
        }
    }

    for(int i = 0; i < num; i++) {
        if(i != num - 1) {
            cout << array[i] << " ";
        } else {
            cout << array[i] << endl;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3096
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    int win = 0;
    while(a>0 && c>0){
        if(win)
            a -= d;
        else
            c -= b;
        win ^= 1;
    }
    cout<< (win? "Yes": "No");
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
int a[maxn];
int main(){
	int n,ans=0;
	cin >> n;
	n*=2;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i+=2)
		ans+=a[i];
	cout << ans << endl;
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	string ans = "No";
	if (S == "abc" || S == "acb" || S == "bca" || S == "bac" || S == "cab" || S == "cba") ans ="Yes";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
import Data.ByteString.Char8 as BS

main :: IO ()
main = do
  _ <- BS.getLine
  s <- BS.getLine :: IO BS.ByteString
  print $ calc s 0 0

calc :: BS.ByteString -> Int -> Int -> Int
calc xs n m
  | xs == mempty = m 
  | BS.head xs == 'I' = if ninc > m then
                                      calc t ninc ninc
                                    else
                                      calc t ninc m 
  | otherwise         = calc t ndec m
    where t = BS.tail xs
          ninc = n+1
          ndec = n-1 


Measured memory_bytes: 380
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		Set<Integer> set = new HashSet<Integer>();
		for(int i=0;i<k;i++){
			set.add(sc.nextInt());
		}
		
		while(true){
			boolean has = contain(n, set);
			if(has)
				n++;
			else
				break;
		}
		
		System.out.println(n);
	}
	static boolean contain(int n, Set<Integer> set){
		while(n>0){
			if(set.contains(n%10))
				return true;
			n/=10;
		}
		return false;
	}
}


Measured memory_bytes: 23892
#define ll long long
    #define pub push_back
    #define pob pop_back
    #define puf push_front
    #define pof pop_front
    #define mp make_pair
    #define fo(i , n) for(ll i = 0 ; i < n ; i++)
    //#include<bits/stdc++.h>
    #include<iomanip>
    #include<cmath>
    #include<cstdio>
    #include<utility>
    #include<iostream>
    #include<vector>
    #include<string>
    #include<algorithm>
    #include<map>
    #include<queue>
    #include<set>
    #include<stack>
    ll pi = acos(-1) ;
    ll z =  998244353 ;
    ll inf = 100000000000000000 ;
    ll p1 = 37 ;
    ll p2 = 53 ;
    ll mod1 =  202976689 ;
    ll mod2 =  203034253 ;
    ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
    ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
    ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
    ll max(ll a , ll b){if(a > b) return a ; return b ;}
    ll min(ll a , ll b){if(a < b) return a ; return b ;}
    ll left(ll i){return ((2*i)) ;}
    ll right(ll i){return ((2*i) + 1) ;}
    void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
    //ios_base::sync_with_stdio(0);
    //cin.tie(0); cout.tie(0);
    using namespace std ;
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    // ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
    // s.find_by_order(i)  itertor to ith element (0 indexed)
    ll cnt = 1 ;

    void solve()
    {
        ll a , b  , c ;
        cin >> a >> b >> c ;
        cout << c << ' ' << a << ' ' << b << '\n' ;
        return ;
        
    }

    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
        /*#ifndef ONLINE_JUDGE
        freopen("inputf.txt" , "r" , stdin) ;
        freopen("outputf.txt" , "w" , stdout) ;
        freopen("error.txt" , "w" , stderr) ;
        #endif*/
        
        ll t ;
        //cin >> t ;
        t = 1 ;
        while(t--)
        {
            solve() ;
        }
        //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";*/

        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a;
  cin>>a;
  if(a<10){
    cout<<a<<"\n";
  }else if(a>=10 && a<100){
    cout<<"9\n";
  }else if(a>=100 && a<1000){
    cout<<a-90<<"\n";
  }else if(a>=1000 && a<10000){
    cout<<"909\n";
  }else if(a>=10000 && a<100000){
    cout<<a-9090<<"\n";
  }else if(a==100000){
    cout<<"90909\n";
  }
}


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

signed main(){
  lint H, W; cin >> H >> W;
  vector<vector<char> > field(H, vector<char> (W));
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++) cin >> field[i][j];
  }
  lint left[H][W], right[H][W], up[H][W], down[H][W];
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++){
      if(field[i][j] == '#') left[i][j] = -1;
      else if(j == 0) left[i][j] = 0;
      if(j != 0 && field[i][j] == '.') left[i][j] = left[i][j - 1] + 1;
    }
  }
  for(lint i = 0; i < H; i++){
    for(lint j = W - 1; j >= 0; j--){
      if(field[i][j] == '#') right[i][j] = -1;
      else if(j == W - 1) right[i][j] = 0;
      if(j != W - 1 && field[i][j] == '.') right[i][j] = right[i][j + 1] + 1;
    }
  }
  for(lint j = 0; j < W; j++){
    for(lint i = 0; i < H; i++){
      if(field[i][j] == '#') up[i][j] = -1;
      else if(i == 0) up[i][j] = 0;
      if(i != 0 && field[i][j] == '.') up[i][j] = up[i - 1][j] + 1;
    }
  }
  for(lint j = 0; j < W; j++){
    for(lint i = H - 1; i >= 0; i--){
      if(field[i][j] == '#') down[i][j] = -1;
      else if(i == H - 1) down[i][j] = 0;
      if(i != H - 1 && field[i][j] == '.') down[i][j] = down[i + 1][j] + 1;
    }
  }
  lint ans = 0;
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++){
      if(field[i][j] != '#'){
        ans = max(ans, up[i][j] + left[i][j] + right[i][j] + down[i][j]);
      }
    }
  }
  cout << ans + 1 << endl;
}

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

int main() {
    int n;cin>>n;
    int a;
    int ans=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        ans+=a-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int main()
{
	auto& in = cin;
	int N, M, X;
	in >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N);
	for (int i = 0; i < N; ++i) {
		in >> C[i];
		A[i].resize(M);
		for (int j = 0; j < M; ++j)
			in >> A[i][j];
	}

	int total = (int)pow(2, N);
	vector<vector<int>> r(total);
	vector<int> p(total);
	for (int i = 0; i < total; ++i) {
		int price = 0;
		r[i].resize(M);
		for (int j = 0; j < N; ++j) {
			if ((1 << j) & i) {
				for (int k = 0; k < M; ++k) {
					r[i][k] += A[j][k];
				}
				price += C[j];
			}
		}
		bool ok = true;
		for (int k = 0; k < M; ++k) {
			if (r[i][k] < X) {
				ok = false;
				break;
			}
		}
		if (ok) {
			p[i] = price;
		}
		else {
			p[i] = INT_MAX;
		}
	}
	auto itMin = min_element(p.begin(), p.end());
	if (*itMin == INT_MAX)
		cout << -1;
	else
		cout << *itMin;

	return 0;
}


Measured memory_bytes: 4344
s = list(map(int, input().split()))
a, b, c, x, y = s[0], s[1], s[2], s[3], s[4]
pa = 0
pb = 0
res = 10**10
for i in range(0, 2*(x+y+1), 2):
 t = i*c+(x-min(x, i//2))*a+(y-min(y, i//2))*b
 if t<res:
  res = t

print(res)

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string a, b;
    cin >> a >> b;

    if (a.size() == b.size())
    {
        if (a > b)
            cout << "GREATER" << endl;
        else if (a < b)
            cout << "LESS" << endl;
        else
            cout << "EQUAL" << endl;
    }
    else
    {
        if (a.size() < b.size())
            cout << "LESS" << endl;
        else
        {
            cout << "GREATER" << endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
    #include<math.h>
    int main()
    {
    	int a,b,c,d;
    	scanf("%d %d %d %d",&a,&b,&c,&d);
    	if(abs(c-a+1)<=d*2)
    		printf("Yes");
    	else
    		printf("No");
    	return 0;
    }

Measured memory_bytes: 128
unittest
{
	assert( [ "25" ].solve == "No" );
	assert( [ "30" ].solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	return ( 30 <= x ) ? "Yes" : "No";
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll n, m; cin >> n >> m;
  VVi a(n, Vi(m));
  Vi b(m);
  Vi c(n, 0);
  REP(i, n){
    REP(j, m){
      cin >> a[i][j];
    }
  }
  REP(j, m) cin >> b[j];
  REP(i, n){
    REP(j, m){
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
}




Measured memory_bytes: 3248
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

struct UnionFind {
  vector<int> data;
  void init(int n) { data.assign(n, -1); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  int ans = 0;
  UnionFind uf;
  set<int> st;
  for (int i = 0; i < m; ++i) {
    uf.init(n);
    for (int j = 0; j < m; ++j) {
      if (i == j) continue;
      uf.unite(a[j], b[j]);
    }
    st.clear();
    for (int j = 0; j < n; ++j) {
      st.insert(uf.root(j));
    }
    if (st.size() != 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i,N) for(int i = 0; i < (int)(N); ++i)
#define ALL(v) (v).begin(), (v).end()
typedef long long Int;
template<class T> void pv(T a, T b){for(T i=a;i!=b;++i)cout<<*i<<" ";cout<<endl;}

int main() {
        for(int N, W; cin >> N >> W, (N || W); ) {
                int count[1024] = {};
                int a[N];
                REP(i, N) cin >> a[i];
                REP(i, N) {
                        int x = a[i];
                        count[x / W]++;
                }
                int highest = 0;
                REP(i, 1024) highest = max(highest, count[i]);

                int end = 0;
                REP(i, 1024) {
                        if( count[i] ) end = i;
                }
                double gray = 1.0;
                double sum = 0.01;
                REP(i, end) {
                        sum += gray * ((double) count[i] / highest);
                        gray -= 1.0 / end;
                }
                
                printf("%f\n", sum);
        }
        return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	printf("%.8lf\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
	return 0;
}

Measured memory_bytes: 3272
N,M,C=[int(x) for x in str(input()).split()]
r=[int(x) for x in str(input()).split()]
ABC=[[0 for i in range(4)]]

dis=[[1000000000000 for i in range(N+1)]]

for i in range(N):
  dis.append([1000000000000 for i in range(N+1)])


for i in range(M):
  x=[0]+[int(x) for x in str(input()).split()]
  ABC.append(x)
  dis[x[1]][x[2]]=x[3]
  dis[x[2]][x[1]]=x[3]
  y=[0,x[2],x[1],x[3]]
  ABC.append(y)

for i in range(1,N+1):
  dis[i][i]=0


for k in range(1,N+1):
  for i in range(1,N+1):
    for j in range(1,N+1):
      dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j])


mi=1000000000000
def perm(a,i):
  global mi
  if i==len(a):      

    p=0
    for x in range(len(a)-1):
      p+=dis[a[x]][a[x+1]]

    mi=min(mi,p)


  else:
    for j in range(i,len(a)):
      a[i],a[j]=a[j],a[i]
      perm(a,i+1)
      a[i],a[j]=a[j],a[i]


perm(r,0)

print(mi)


Measured memory_bytes: 67160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

vector<string> v;

int main() {
    int n, l;
    cin >> n >> l;
    rep(i, n){
        string s;
        cin >> s;
        v.pb(s);
    }

    sort(all(v));

    foreach(e, v){
        print(e);
    }

    cout << endl;
}

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

int main(){
    int N,H,W;
    cin>>N>>H>>W;
    int A[10000],B[10000];
    int cnt=0;
    for(int i=1;i<=N;i++){
        cin>>A[i]>>B[i];
        cnt+=(A[i]>=H&&B[i]>=W);
    }

    cout<<cnt<<endl;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans1=0
ans2=0
inf=-10**18
if n%2:
    dp=[[inf]*3 for i in range(n)]
    dp[0][0]=a[0]
    dp[2][0]=dp[0][0]+a[2]
    for i in range(2,n):
        dp[i][0]=dp[i-2][0]+a[i]
        if i>=3:
            dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i]
        else:
            dp[i][1]=dp[i-2][1]+a[i]
        if i>=4:
            dp[i][2]=max(dp[i-4][0],dp[i-3][1],dp[i-2][2])+a[i]
        elif i>=3:
            dp[i][2]=max(dp[i-3][1],dp[i-2][2])+a[i]
        else:
            dp[i][2]=dp[i-2][2]+a[i]
    ans=max(dp[n-3][0],dp[n-2][1],dp[n-1][2])
    # print(dp)
    dp=[[inf]*2 for i in range(n)]
    dp[1][0]=a[1]
    for i in range(3,n):
        dp[i][0]=dp[i-2][0]+a[i]
        dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i]
    ans=max(ans,dp[-1][1],dp[-2][0])
    for i in range(2,n,2):
        ans1+=a[i]
    print(max(ans,ans1))
else:
    dp=[[inf]*2 for i in range(n)]
    dp[0][0]=a[0]
    for i in range(2,n):
        dp[i][0]=dp[i-2][0]+a[i]
        if i>2:
            dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i]
        else:
            dp[i][1]=dp[i-2][1]+a[i]
    ans=max(dp[-1][1],dp[-2][0])
    for i in range(1,n,2):
        ans1+=a[i]
    print(max(ans1,ans))

Measured memory_bytes: 134772
#include <iostream>
#include <string>
int main(){
  std::string S;
  std::cin >> S;
  if(S.length()&1){
    std::cout << "No" << std::endl;
    return 0;
  }
  for(int i = 0; i < S.length(); ++i){
    if(i&1){
      if(S[i] != 'i'){
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    else{
      if(S[i] != 'h'){
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){
  int a,b; cin >> a >> b;
  cout << a*b << endl;
}


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

using namespace std;

const int Nmax = 100001;

int N, A[Nmax];

int main() {
    cin>>N;
    for(int i=1; i<=N; i++) {
        cin>>A[i];
    }
    sort(A+1,A+N+1);
    int sa=0;
    int sb=0;
    int sv=0;
    for(int i=N; i>=1; i--) {
        if(!sv) sv=A[i];
        else {
            if(sv == A[i]) {
                if(sa){ 
                    if(!sb) sb=sv, sv=0;
                }
                else sa=sv, sv=0;
            }
            else {
                sv=A[i];
            }
        }
    }
    cout<<1LL*sa*sb<<'\n';
    return 0;
}

Measured memory_bytes: 768
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws IOException
	{
		try{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String arr[]=br.readLine().split(" ");
		long ans=0;
		long h=0;long p=0;
		h=Math.max(Long.parseLong(arr[0])*Long.parseLong(arr[2]),Long.parseLong(arr[0])*Long.parseLong(arr[3]));
		p=Math.max(Long.parseLong(arr[1])*Long.parseLong(arr[2]),Long.parseLong(arr[1])*Long.parseLong(arr[3]));
		ans=Math.max(h,p);
		System.out.println(ans);
		}
	catch(Exception e){}
}}

Measured memory_bytes: 32692
// C - Make a Rectangle
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

ll solve(int N, vi &A){
	sort(allr(A));
	ll a = 0, b = 0;
	int i = 0, c = 0;
	while(i<N && c<2){
		if(A[i-1] == A[i]){
			if(c == 0){
				a = A[i];
				i++;
			}
			else if(c == 1){
				b = A[i];
			}
			c++;
		}
		i++;
	}
	return a*b;
}

int main(){
	int N; cin>>N;
	vi A(N);
	rp(i, 0, N) cin>>A[i];
	cout<< solve(N, A) <<endl;
}

Measured memory_bytes: 640
#include "iostream"
using namespace std;
#define LL long long int
int main()
{
    LL n;
    cin>>n;
    if(n==0)
    {
        cout<<"0"<<endl;
        exit(0);
    }
    LL ans=0;
    ans+= (n/500)*1000;
    n=n%500;
    ans+= (n/5)*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int,int> sum;
int main(){
	int n;
	cin>>n;
	vector<int> l(n);
	for(int i=0;i<n;i++)
	{
		cin>>l[i];
	}
	sort(l.begin(),l.end());
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++){
			int k=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin()-1;
			ans+=(k-j);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define vv(dt) vector<vector<dt>>
#define vec vector<int>
#define un unsigned
#define mp(x,y) make_pair(x,y)
#define dbl double
#define wking(t) cout<<"Working "<<t<<endl;
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define min2(a,b) (a)<(b)?(a):(b)
#define mod %1000000007
#define eps 0.000000001
#define inf 100000000000000001
using namespace std;


dbl f(int h,int n,vector<dbl> &p,vv(dbl) &dp)
{
    if(h>n || h<0) return 0;
    if(dp[h][n]!=-1) return dp[h][n];
    dp[h][n] = f(h-1,n-1,p,dp)*p[n] + f(h,n-1,p,dp)*(1.0-p[n]);
    return dp[h][n];
}

dbl calc(vector<dbl> &p)
{
    int n=p.size()-1;
    dbl ans=0.0;
    vv(dbl) dp(n+1,vector<dbl> (n+1,-1));
    dp[0][0] = 1;
    loop(h,(n/2)+1,n+1) ans += f(h,n,p,dp);
    return ans;
}

int main()
{
    int n;
    cin>>n;
    vector<dbl> p(n+1);
    p[0] = 0;
    loop(i,1,n+1) cin>>p[i];
    cout<<setprecision(15)<<calc(p)<<endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n;
int dir[4][2]={0,1,0,-1,-1,0,1,0};
int a[250005],vis[505][505],d[505][505];
pii q[250005];

void bfs(int x,int y){
	queue<pii> tmp;
	int front=0,rear=0;
	q[rear++]=mp(x,y);
	while(front<rear||!tmp.empty()){
		pii t;
		if(!tmp.empty()) t=tmp.front(),tmp.pop();
		else t=q[front++];
		for(int i=0;i<4;i++){
			int dx=t.fi+dir[i][0],dy=t.se+dir[i][1];
			if(dx<1||dx>n||dy<1||dy>n) continue;
			if(chkmin(d[dx][dy],d[t.fi][t.se]+vis[dx][dy])){
				if(!vis[dx][dy]) tmp.push(mp(dx,dy));
				else q[rear++]=mp(dx,dy);
			}
		}
	}
}

int main(){
	n=readint();
	for(int i=1;i<=n*n;i++) a[i]=readint();
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) d[i][j]=min(min(i-1,j-1),min(n-i,n-j))+1,vis[i][j]=1;
	int ans=0;
	for(int i=1;i<=n*n;i++){
		int x=(a[i]-1)/n+1,y=(a[i]-1)%n+1,fl=0;
		ans+=d[x][y]-1;
		for(int j=0;j<4;j++){
			int dx=x+dir[j][0],dy=y+dir[j][1];
			if(dx<1||dx>n||dy<1||dy>n) d[x][y]=0,fl=1;
			else if(d[dx][dy]<d[x][y]) d[x][y]=d[dx][dy],fl=1;
		}
		vis[x][y]=0;
		if(fl) bfs(x,y);
//		cout<<"test "<<i<<' '<<x<<' '<<y<<' '<<ans<<endl;
//		for(int ii=1;ii<=n;ii++){
//			for(int jj=1;jj<=n;jj++) cout<<d[ii][jj]<<' ';
//			cout<<endl;
//		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6908
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        if(A*B > C*D){
            System.out.println(A*B);
        }
        if(A*B < C*D){
            System.out.println(C*D);
        }
        if(A*B == C*D){
            System.out.println(A*B);
        }
    }
}

Measured memory_bytes: 23252
#include <iostream>
 #include <utility>
 #include <vector>
 
 using namespace std;
 
 // 頂点を1, 0で塗り分ける
 void dfs(int v, int p, int c, vector<vector<pair<int,int>>> &G, vector<int> &result){
     
     result[v] = c; // 頂点vを色cで塗る
     
     // vに隣接する頂点を深さ優先探索する
     for (auto e : G[v]){
         
         //　子から親への逆流を防止する
         if (e.first == p) continue;
         
         // vとeの間の距離が奇数ならば違う色で塗る
         if (e.second % 2 == 1) dfs(e.first, v, 1-c, G, result);
         else dfs(e.first, v, c, G, result); // vとeの間の距離が偶数ならば同じ色で塗る
     }
 }
 
 
 
 int main(){
     int n;
     cin >> n;
     
     // 重みつきグラフの入力を受け取る
     vector<vector<pair<int,int>>> G(n, vector<pair<int,int>>());
     
     for (int i = 0; i < n-1; i++){
         int u, v, w;
         cin >> u >> v >> w;
         u--, v--;
         
         G[u].push_back(pair<int,int>(v,w));
         G[v].push_back(pair<int,int>(u,w));
     }
     
     // 頂点の塗り分け方を記録する
     vector<int> result(n);
     
     // DFSでツリーを探索する
     dfs(0,-1,1,G,result);
     
     for (auto p : result) cout << p << endl;
     
     return 0;
 }

Measured memory_bytes: 9728
N,T=list(map(int,input().split()))
minCos = 10000
ans = 0
for i in range(N):
  c,t=list(map(int,input().split()))
  if t <= T:
    if min(minCos,c) == c:
      ans = c
      minCos = c
if ans == 0:
  print("TLE")
else:
  print(ans)

Measured memory_bytes: 9088
import math
N = int(input())
r = math.floor(math.sqrt(N))
#print(r)
for i in range(r):
    if N%(r-i)==0:
        l=N/(r-i)
        r=r-i
        break
#print(l,r)
print("{:}".format(int(r+l-2)))

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);    
    ll ans = 0;
    for(ll i=0;i<k;i++)
    {
        ans+=arr[i];
    }
    cout<<ans<<"\n";
}
    // Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3572
MOD = 10**9 + 7

N = input()
S1 = list(input())
S2 = list(input())

res = 1
right_used_color = 0
while len(S1) > 0:
    if S1[len(S1)-1] == S2[len(S1)-1]:
        res = res * (3 - right_used_color) % MOD
        right_used_color = 1
    elif right_used_color == 2:
        res = res * 3 % MOD
        S1.pop()
        S2.pop()
    else:
        res = res * (3 - right_used_color) * (2 - right_used_color) % MOD
        right_used_color = 2
        S1.pop()
        S2.pop()
    S1.pop()
    S2.pop()

print(res)


Measured memory_bytes: 62004
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a,const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b) {if(b<a){a=b; return 1;} return 0;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  ll ans=0;
  int sum=0,r=0;
  REP(l,n) {
    while(r < n) {
      if ((sum^a[r]) != (sum+a[r])) break;
      sum += a[r];
      r++;
    }
    ans += r - l;

    if (r == l) r++;
    sum -= a[l];
  }

  COUT(ans);
  return 0;
}

Measured memory_bytes: 3992
//53
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    int c[10];
    for(int i=0;i<n;i++){
      cin>>c[i];
    }
    int mm[100001];
    fill(mm,mm+m+1,1<<29);
    mm[0]=0;
    for(int i=0;i<1<<n;i++){
      int cc=0;
      for(int j=0;j<n;j++){
	if(i>>j&1){
	  cc+=c[j];
	}
      }
      for(int j=0;j+cc<=m;j++){
	mm[j+cc]=min(mm[j+cc],mm[j]+1);
      }
    }
    cout<<mm[m]<<endl;
  }
  return 0;
}

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

#define df(b, e) ((b) > (e))
#define fore(i, b, e) for(auto i = (b) - df(b, e); i != e - df(b, e); i += 1 - 2 * df(b, e))
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define pb push_back

typedef long long lli;
typedef long double ld;
typedef pair<int, int> ii;

template <class T>
struct rge { T b, e; };

template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}

template <class T> auto dud(T *x) -> decltype(cerr << *x, 0);
template <class T> char dud(...);

struct debug {
#ifdef LOCAL
  ~debug() { cout << endl; }

  template <class T>
  typename enable_if<sizeof dud<T>(0) != 1, debug &>::type operator << (T i) {
    cout << boolalpha << i;
    return *this;
  }

  template <class T>
  typename enable_if<sizeof dud<T>(0) == 1, debug &>::type operator << (T i) {
    return *this << range(begin(i), end(i));
  }

  template <class A, class B>
  debug & operator << (pair<A, B> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }

  template <class T>
  debug & operator << (rge<T> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
      *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
#else
  template <class T> 
  debug & operator << (const T&) {
    return *this; 
  }
#endif
};

#define deb(...) " " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " "

const int N = 101;
const int K = 4;

lli mem[N][K][2];
short done[N][K][2], timer = 0;
string num;
int k;

lli dp(int i, int cnt, bool small) {
  if (cnt > k)  
    return 0LL;
  if (i == sz(num))
    return cnt == k;
  lli &ans = mem[i][cnt][small];
  if (done[i][cnt][small] != timer) {
    done[i][cnt][small] = timer;
    ans = 0;
    int lo = 0, hi = small ? 9: num[i] - '0';
    fore (x, lo, hi + 1) 
      ans += dp(i + 1, cnt + (x != 0), small | (x < hi));
  } 
  return ans;
} 

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> num >> k) {
    ++timer;
    cout << dp(0, 0, 0) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
N,M,K = map(int,input().split())
mod = 998244353
n = 200050
frac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(n):
    frac[i+1] = (i+1)*frac[i]%mod
finv[-1] = pow(frac[-1],mod-2,mod)
for i in range(1,n+1):
    finv[n-i] = finv[n-i+1]*(n-i+1)%mod
def nCr(n,r):
    if n<0 or r<0 or n<r: return 0
    r = min(r,n-r)
    return frac[n]*finv[n-r]*finv[r]%mod


# M* n-1Ck*1^k*(M-1)^(N-1-k)
ans = 0
for i in range(K+1):
    tmp=(M*nCr(N-1,i))%mod
    tmp*=pow(M-1,N-1-i,mod)
    ans += tmp%mod
print(ans%mod)

Measured memory_bytes: 79540
#include <iostream>

using namespace std;

int main(){
  int A,B,N;
  cin >> N >> A >> B;
  if(B-A>N){
    cout << "dangerous" <<endl;
  }else if(B-A>0){
    cout << "safe" << endl;
  }else{
    cout << "delicious" <<endl;
  }
}


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

int main() {
  int N, min_2;
  cin >> N;
  
  
  for (int i = 0; i < N; i++) {
    int x,counter = 0;
    cin >> x;
    while (x % 2 == 0) {
      counter++;
      x /= 2;
    }
    
  if (i == 0)
    min_2 = counter;
  if (counter < min_2)
    min_2 = counter;
  }
  
  cout << min_2 << endl;
}

Measured memory_bytes: 256
import sys

N,K = map(int,input().split())
array = [ a for a in range(1,N+1) ]

for I in range(K):
    _ = input()
    sweets = list(map(int,input().split()))
    for K in sweets:
        if K in array:
            array.remove(K)
print(len(array))

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n,m; cin >> n >> m;
    VL a(n);
    rep(i,n) cin >> a[i];

    ll sum=0;
    rep(i,n) sum += a[i];

    sum = (sum + 4*m - 1)/(4*m);
    ll cnt = 0;
    rep(i,n){
        if(a[i] >= sum) cnt++;
    }

    Ans(cnt >= m);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <functional>
using namespace std;
string s;
int N;
int a[27];
int ans;
int Min=100;
bool C(string t){
  for(int i=0;i<t.length()-1;i++){
    if(t[i]!=t[i+1])return false;
  }
  return true;
}


int main(){
  cin >> s;
  string t,u;
  for(char c='a';c<='z';c++){
    int ite=0;
    t=s;
    while(C(t)!=1 && ite<=s.length()){
      for(int i=0;i<t.length()-1;i++){
	if(t[i]==c || t[i+1]==c)t[i]=c;
	else t[i]=t[i+1];
      }
      t.erase(t.end()-1);
      ite++;
    }
    Min=min(Min,ite);
  }
  cout << Min << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int binarysearch(int A[], int n, int key) {
	int left = 0;
	int right = n;
	int mid;

	while (left < right) {
		mid = (left + right) / 2;
		if (A[mid] == key) {
			return A[mid] == key;
		}
		else if (A[mid] < key) {
			left = mid + 1;
		}
		else {
			right = mid;
		}
	}
	return 0;

}

int main() {
	//数値の読み込み
	int i, n;
	int A[100000];
	int q, key, sum = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (binarysearch(A, n, key)) {
			sum++;
		}
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 2104
num_cnt = int(input().rstrip())

nums = list(map(int, input().rstrip().split(" ")))

for i in range(num_cnt):
    tmpNum = nums[i]
    j = i -1 
    
    while j >=0:
        if nums[j] <= tmpNum:
            break
        nums[j+1] = nums[j]
        j = j-1
    nums[j+1] = tmpNum
    print (" ".join(map(str,nums)))

Measured memory_bytes: 7668
import sys
input = sys.stdin.readline

def main():
    N = int(input().rstrip())
    S = input()
    Q = int(input())
    Ks = list(map(int, input().split()))

    for K in Ks:
        # [D, M, DM, DMC]
        dp = [0]*4
        for i in range(N):
            if i-K >= 0:
                sk = S[i-K]
                if sk == 'D':
                    dp[0] -= 1
                    dp[2] -= dp[1]
                elif sk == "M":
                    dp[1] -= 1
            s = S[i]
            if s == "D":
                dp[0] += 1
            elif s == 'M':
                dp[1] += 1
                dp[2] += dp[0]
            elif s == 'C':
                dp[3] += dp[2]
        
        print(dp[3])
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 50156