akhauriyash/Code-Regression huggingface dataset:
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fineam> //http://www.cplusplus.com/reference/fineam/fineam/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
std::ifineam inFile("input.txt");
std::ofineam outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    int n;
    int k;
    cin >> n >> k;

    int res = 0;
    for (int i = 0; i < n; i++)
    {
        int aux;
        cin >> aux;
        if (aux >= k)
        {
            res++;
        }
    }
    cout << res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 1005;
vector<int> primes;
void pre() {
	vector<bool> pri(N,1);

	for(int i = 4; i < N; i += 2) pri[i] = 0;

	for(int i = 3; i * i < N; i += 2) {
		if(!pri[i])
			continue;
		for(int j = i * i; j < N; j += i)
			pri[j] = 0;
	}
	repA(i,2,N-1)
		if(pri[i])
			primes.pb(i);
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int n;
	string st;
	cin >> n >> st;

	int mx = 0, te = 0;
	rep(i,n) {
		if(st[i] == 'D')
			te--;
		else if(st[i] == 'I')
			te++;
		mx = max(te,mx);
	}
	cout << mx << '\n';
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if (N == 1) {cout << 1 << endl; return 0;}
    int ans = INF2;
    int x[51], y[51];
    rep(i, N) cin >> x[i] >> y[i];
    set<pair<int, int>> st;
    rep(i, N) st.insert({x[i], y[i]});
    rep(i, N) {
        rep(j, N) {
            if (i == j || (x[i] == x[j] && y[i] == y[j])) continue;
            int p = x[i] - x[j];
            int q = y[i] - y[j];
            int sum = 0;
            map<pair<int, int>, bool> check;
            //cout << p << " " << q << endl;
            rep(k, N) {
                if(check[{x[k], y[k]}]) continue;
                sum++;
                REP(l, 1, N){
                    if (st.find({x[k] + p*l, y[k] + q * l}) != st.end())
                        check[{x[k] + p*l, y[k] + q * l}] = true;
                    else 
                        break;
                }
                RREP(l, -1, -N) {
                    if (st.find({x[k] + p*l, y[k] + q * l}) != st.end())
                        check[{x[k] + p*l, y[k] + q * l}] = true;
                    else
                        break;
                }
            }
            //cout << sum << endl;
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n<-readInt
  print $ (1+n-1)*(n-1) `div` 2

Measured memory_bytes: 380
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------
import sys
sys.setrecursionlimit(10**6)
from types import GeneratorType
#use:- put @bootstrap overrecursive function
def bootstrap(func, stack=[]):
    def wrapped_function(*args, **kwargs):
        if stack:
            return func(*args, **kwargs)
        else:
            call = func(*args, **kwargs)
            while True:
                if type(call) is GeneratorType:
                    stack.append(call)
                    call = next(call)
                else:
                    stack.pop()
                    if not stack:
                        break
                    call = stack[-1].send(call)
            return call
    return wrapped_function


n,k = mapi()
a = [0]+list(mapi())
gr = defaultdict(int)
for i in range(1,n+1):
    gr[i]=a[i]

vis ={}
path = []
p = 1

@bootstrap
def dfs(s):
    global p
    if s in vis:
        p = s
        yield 0
    path.append(s)
    vis[s] = 1
    res =0
    res+= yield dfs(gr[s])
    yield res
dfs(1)
i = 0
ln = 0
path2 = path[:]
while i<len(path):
    if p==path[i]:
        path2 = path2[i:]
        break
    i+=1
#print(path)
if k<len(path)-len(path2):
    print(path[k])
else:
    k -= len(path)-len(path2)
    print(path2[k%len(path2)])
#print(dfs(1,k))


Measured memory_bytes: 168636
n=int(input())
if n==1:
  if int(input())==0:
    print(n)
  else:
    print(0)
  exit()
a=list(map(int,input().split()))
m=10**9+7
x=[]
if n%2==1:
  x.append(0)
for i in range(n%2+1,n,2):
  x.append(i)
  x.append(i)
if sorted(a)==x:
  print((2**(n//2))%m)
else:
  print(0)

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> a(N+1);
    for (int i=1;i<=N;i++) cin >> a[i];
    vector<int> res(N+1);
    for (int i=N;i>=1;i--){
        int sum = 0;
        for (int x=2*i;x<=N;x+=i){
            sum += res[x];
            sum %= 2;
        }
        res[i] = a[i]^sum;
    }
    vector<int> ans;
    for (int i=1;i<=N;i++){
        if (res[i] == 1) ans.push_back(i);
    }
    cout << ans.size() << "\n";
    for (int i=0;i<ans.size();i++){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  int ym=0;
  int my=0;
   if(s%100<=12&&!(s%100==0)){
    ym=1; 
   }
   if(s/100<=12&&!(s/100==0)){
    my=1 ;
   }
   if(ym==1&&my==1){
   cout<<"AMBIGUOUS"<<endl;     
   }else if(ym==1){
   cout<<"YYMM"<<endl;     
   }else if(my==1){
   cout<<"MMYY"<<endl;     
   }else{
   cout<<"NA"<<endl;
   }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

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

void Main()
{
	int a, b, c;
  	cin >> a >> b >> c;
  	if(c%gcd(a,b)==0) cout << "YES" << endl;
    else cout << "NO" << endl;
	return;
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int r, c;
    scanf("%d %d", &r, &c);
    int spr[r+1][c+1];
    for (int x=0; x<r+1; x++) {
        for (int y=0; y<c+1; y++) {
            spr[x][y] = 0;
        }
    }
    for (int i=0; i<r; i++) {
        for (int j=0; j<c; j++) {
            scanf("%d", &spr[i][j]);
        }
    }
    for (int k=0; k<r; k++) {
        for (int l=0; l<c; l++) {
            spr[k][c] += spr[k][l];
        }
    }
    for (int t=0; t<c; t++) {
        for (int s=0; s<r; s++) {
            spr[r][t] += spr[s][t];
        }
    }
    for (int sum=0; sum<c; sum++) {
        spr[r][c] += spr[r][sum];
    }
    for (int p=0; p<r+1; p++) {
        for (int q=0; q<c+1; q++) {
            printf("%d", spr[p][q]);
            if (q < c) {
                putchar(' ');
            } else {
                putchar('\n');
            }
        }
    }
    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)

int main()
{

    double N, D;
    cin >> N >> D;

    rep(i, 20)
    {
        if (N / (2 * D + 1) <= i)
        {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define ll long long 
 
int main()
{
	ll n;
	cin >> n;
 
	int len = 5;
	vector<ll> arr(len);
	for (int i = 0; i < len; i++)
	{
		cin >> arr[i];
	}
 
	ll minEl = *min_element(arr.begin(), arr.end());
 
	if (minEl >= n)
	{
		cout << len << endl;
		return 0;
	}
	ll d = n / minEl;
 
	if (n % minEl == 0)
	{
		d--;
	}
 
	cout << (ll)len + d << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;


int main()
{
	vector<int> S;
	int n;
	string str;
	cin>>str;
	n = str.size();
	for(int i = 0; i < n; i++){
		int num = str[i] - '0';
		S.push_back(num);
	}
	unsigned long long int sum=0,num;
	for(int bit = 0; bit <(1<<n-1);bit++){
		num = 0;
		for(int i = 0; i < (n-1);i++){
			if( bit & (1<<i)){
				num = 10*num + S[i];
				sum += num;
				//cout<<num<<" ";
				num = 0;
			}else{
				num = 10*num + S[i];
			}
		}
		num = num*10 + S[n-1];
		sum += num;
		//cout<<num<<endl;
	}
	cout<<sum<<endl;
	return 0;
}



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


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
 int64_t N,K;
 cin>>N>>K;
 if(K%2!=0){
  cout<<(N/K)*(N/K)*(N/K)<<endl;
 }
 else{
  cout<<(N/K)*(N/K)*(N/K)+((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K)<<endl;
 }
 return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
long long N,s;
int main()
{
	cin>>N;
	for(long long n=1;n<=3500;n++)
	 for(long long w=1;w<=3500;w++)
	 {
	 	s=4*n*w-N*w-N*n;
	 	if (s>=1&&(N*n*w)%s==0)
	 	{
	 		s=(N*n*w)/s;
	 		long long a=max(s,max(n,w)),c=min(s,min(n,w)),b;
	 		if (a==n) b=(c==w)?s:w;
	 		if (a==w) b=(c==n)?s:n;
	 		if (c==n) b=(a==w)?s:w;
	 		if (c==w) b=(a==n)?s:n;
	 		
	 		cout<<c<<" "<<b<<" "<<a<<endl;
	 		return 0;
		}
	 }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MEM(a,x) memset(a,x,sizeof(a))
#define MEMINF(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN=2e5 + 10;
const int INF=0x3f3f3f3f;
const int MOD=1000000007;
int main() {
  LL len;
  string s;
  cin >> s;
  len = s.length();
  if ((len%2 == 0) ^ (s[0] == s[len-1]))
    cout << "Second" << endl;

  else   cout  << "First" << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int a[100005];
int main()
{
	int n,maxh=0;
	cin >> n;
	for(int i=1;i<=n;i++)
	    cin >> a[i];
	maxh=a[1];
	for(int i=2;i<=n;i++)
	{
		if(a[i]-maxh<=-2) 
		{
			cout << "No";
			return 0;
		 } 
		maxh=max(a[i],maxh);
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define LEN 10

void QuickSort(int array[], int begin, int end)
{
 int i = begin;
 int j = end;
 int pivot;
 int temp;
   
 pivot = array[ ( begin + end ) / 2 ];  // 中央の値をpivotにする
  
 while( 1 )
 {
  while( array[i] < pivot ){ ++i; }  /* 枢軸以上の値が見つかるまで右方向へ進めていく */
  while( array[j] > pivot ){ --j; }  /* 枢軸以下の値が見つかるまで左方向へ進めていく */
  if( i >= j )break;  // 軸がぶつかったらソート終了
   
  // 入れ替え
  temp = array[i];
  array[i] = array[j];
  array[j] = temp;
  i++;
  j--;
 }
  
 // 軸の左側をソートする
 if( begin < i - 1 ){ QuickSort( array, begin, i - 1 ); }
 // 軸の右側をソートする
 if( j + 1 < end ){ QuickSort( array, j + 1, end ); }
}

int main(void){
	int n;
	int tmp;
	int sum;
	int array[100];
	int i;
	
	while ( 1 ) {
		scanf("%d", &n);
		if ( !n ) {
			break;
		}
		sum = 0;
		for ( i = 0; i < n; i++ ) {
			scanf("%d", &array[i]);
		}
		QuickSort(array, 0, n-1);
		for ( i = 1; i < n-1; i++ ) {
			sum += array[i];
		}
		printf("%d\n", sum / (n - 2 ));
	}
	return 0;
}


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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t, x;
  cin >> x >> t;
  cout << max(x - t, 0) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    int a,b,c,n,x,y,m=-1,k,w,sum=1,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << max(0,a+b-n);
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <string.h>
	#include <math.h>
using namespace std;
//2乗＝pow(x,2)
//root=sqrt(x)
typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

int n,k,q;
  string t;
  //char s[101];
  k=0;
  //cin>>s;
 
  cin>>t;
  
  if(t=="SUN")cout<<7<<endl;
  else if(t=="MON")cout<<6<<endl;
  else if(t=="TUE")cout<<5<<endl;
  else if(t=="WED")cout<<4<<endl;
  else if(t=="THU")cout<<3<<endl;
  else if(t=="FRI")cout<<2<<endl;
	else if(t=="SAT")cout<<1<<endl;
  //rep(i,sizeof(s))if(s[i]==s[i+1]&&s[i]!='\0')k++;
// cout<<"Hellow worldy yes"<<endl;
 
  //k=k*n;
  
 

  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());

  
 return 0; 
}

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

typedef long long ll;
const int maxn=1e5+10;
ll k,a[maxn],x=2,y=2;

int main(){
	cin>>k;
	for(int i=1;i<=k;++i)
		cin>>a[i];
	for(int i=k;i;--i){
		if(x%a[i])
			x=(x/a[i]+1)*a[i];
		if(y%a[i])
			y=y/a[i]*a[i];
		if(x>y){
			puts("-1");
			return 0;
		}
		y=y+a[i]-1;
	}
	cout<<x<<' '<<y<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
cost = [0] + a + [0]

q = [0] * (n + 2)
SUM = 0
for i in range(n + 1):
    temp = abs(cost[i + 1] - cost[i])
    SUM += temp
    q[i] += temp
    q[i + 1] += temp
#print(SUM)

for i in range(n):
    temp = abs(cost[i + 2] - cost[i])
    print(SUM + temp - q[i + 1])

Measured memory_bytes: 13920
public class Main {


  private static void solve() {
    int n = ni();
    int[] a = na(n);
    long x = a[0];
    for (int v : a) {
      x = gcd(v, x);
    }
    System.out.println(x);
  }

  public static long gcd(long a, long b) {
    while (b > 0){
        long c = a;
        a = b;
        b = c % b;
    }
    return a;
  }
  
  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36396
uses crt;
var
        n,i,j,k,h:integer;
begin
        read(n);
        h:=0;
        for i:=1 to n do
            if i mod 2=1 then
               begin
                 k:=0;
                 for j:=1 to n do
                     if i mod j =0 then inc(k);
                 if k=8 then inc(h);
               end;
        write(h);
       // readln;
       // readln;
end.

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

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

        long[] ar = new long[n];
        for (int i = 0; i < n; i++) {
            ar[i] = scan.nextLong();
        }

        Arrays.sort(ar);
        
        if(ar[0] == ar[n/3-1] && ar[n/3] == ar[2*n/3-1] && ar[2*n/3] == ar[n-1] && (ar[0]^ar[n/3]^ar[n-1])==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 59056
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; 
        x=(x*x)%p;
    }
    return res;
}
inline void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */

/* -------------------------------------- */

int main() {
	boost();
	int n;cin>>n;double sum=0;
	for(int i=0;i<n;i++){
		double x;cin>>x;
		sum += (1/x);
	}
	cout<< setprecision(15)<<(1/sum);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

using namespace std;
using ll = long long;
using ull = unsigned long long;


int main() {
    double const PI = 4.0 * atan(1.0);

    int R; cin >> R;

    cout << 2.0 * PI * R << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
#define Maxn 1000000 + 10
using namespace std;
int n;
int main()
{
    double result=1;
    cin>>n;
    if(n%2)
    {
        result=(n/2+1)*1.0/n;
    }
    else
    {
        result=n/2*1.0/n;
    }
    printf("%.10lf",result);
    cout<<endl;
}


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

using namespace std;

int main() {
	int a, b;
	string buf;
	cin >> a >> b;
	auto sa=to_string(a);
	auto sb=to_string(b);
	buf = sa +sb;
	auto num = atoi(buf.c_str());
	int n = sqrt(num);
	if (n*n == num) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final char[] s = scanner.next().toCharArray();
        int k = scanner.nextInt();
        for (int i = 0; i < s.length - 1; i++) {
            if (s[i] == 'a') {
                continue;
            }
            final int index = s[i] - 'a';
            if (k >= 26 - index) {
                k -= 26 - index;
                s[i] = 'a';
            }
        }

        s[s.length - 1] = (char) ((s[s.length - 1] - 'a' + k) % 26 + 'a');
        System.out.println(new String(s));
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 35696
#include<iostream>
#include<cmath>
using namespace std;
long q,h,s,d,n,m1,m2;
int main()
{
	cin>>q>>h>>s>>d>>n;
	m1=min(q*4,min(h*2,s));
	m2=min(d,m1*2);
	cout<<n/2*m2+n%2*m1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N, Y;
  scanf("%d %d", &N, &Y);
  for (int x = N; x >= 0; x--) {
    for (int y = N - x; y >= 0; y--) {
      int z = N - x - y;
      if (10000*x + 5000*y + 1000*z == Y) {
        printf("%d %d %d\n", x, y, z);
        return 0;
      }
    }
  }

  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 128
class Dice(list):
    def __init__(self, l):
        super().__init__(l)

    def roll(self, command):
        # /  0
        # / 3124
        # /  5
        if command == 'N':
            self[0], self[1], self[5], self[4] = self[1], self[5], self[4], self[0]
        elif command == 'S':
            self[0], self[1], self[5], self[4] = self[4], self[0], self[1], self[5]
        elif command == 'W':
            self[0], self[3], self[5], self[2] = self[2], self[0], self[3], self[5]
        elif command == 'E':
            self[0], self[3], self[5], self[2] = self[3], self[5], self[2], self[0]

    def right_spin(self, repeat=1):
        for _ in range(repeat):
            self[3], self[1], self[2], self[4] = self[1], self[2], self[4], self[3]

    def _fix_position(self):
        self._min_num_to_top()
        self._min_side_num_to_front()

    def _min_num_to_top(self):
        min_idx = self.index(min(self))
        if min_idx == 0:
            pass
        elif min_idx == 1:
            self.roll('N')
        elif min_idx == 2:
            self.roll('W')
        elif min_idx == 3:
            self.roll('E')
        elif min_idx == 4:
            self.roll('S')
        elif min_idx == 5:
            self.roll('N')
            self.roll('N')

    def _min_side_num_to_front(self):
        idx = self.index(min(self[3], self[1], self[2], self[4]))
        if idx == 1:
            pass
        elif idx == 2:
            self.right_spin(1)
        elif idx == 3:
            self.right_spin(3)
        elif idx == 4:
            self.right_spin(2)

    def __hash__(self):
        self._fix_position()
        return tuple(self).__hash__()


if __name__ == '__main__':
    n = int(input())
    dices = set(Dice(map(int, input().split())) for _ in range(n))
    print('Yes' if n == len(dices) else 'No')

Measured memory_bytes: 6816
#include "bits/stdc++.h"
using namespace std;

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


int main() {
	long long n;
	cin >> n;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Main abc116A = new Main();
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    System.out.println(abc116A.solve(x, y, z));

  }

  public int solve(int x, int y, int z) {
    int[] a = {x, y, z};
    Arrays.sort(a);
    return a[0] * a[1] / 2;
  }

}



Measured memory_bytes: 21588
class RectangleCaliculator
  def calcArea(width, height)
    return width * height
  end
 
  def calcCircumference(width, height)
    return (width + height) * 2
  end
end
 
# ??\???????¨??????????????????????
inputArray = gets.split(nil)
height = inputArray[0].to_i
width = inputArray[1].to_i
 
# ?¨??????????????????????????????¢????????¨?????????????¨????
rect = RectangleCaliculator.new
area = rect.calcArea(width, height)
circumference = rect.calcCircumference(width, height)
 
# ??????
puts area.to_s + " " + circumference.to_s

Measured memory_bytes: 8584
import java.util.Scanner;

public class Main{
   public static void main(String[] a){
      Scanner scn = new Scanner(System.in);
      int c = scn.nextInt();
      int b = scn.nextInt();
      if(c<b){
          System.out.println("a < b");
      }else if(c == b){
         System.out.println("a == b");
      }else{
         System.out.println("a > b");
      }
   }
}

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

int main() {
  int N, L;
  string s[100];
  cin >> N >> L;
  for (int i = 0; i < N; i++){
    cin >> s[i];
  }
  sort(s, s+N);
  for (int j = 0; j < N; j++){
    cout << s[j];
  }
  cout << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main()
{
    int n, q, i;
    int S[10001], T, ans = 0;

    scanf("%d", &n);

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

    scanf("%d", &q);

    for (i = 0; i < q; i++) {
        scanf("%d", &T);
        if (search(S, n, T))
            ans++;
    }

    printf("%d\n", ans);

    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int x[105], y[105], h[105];
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0){
            swap(x[i], x[1]);
            swap(y[i], y[1]);
            swap(h[i], h[1]);
        }
    }
    for(int cx = 0; cx <= 100; cx++){
        for(int cy = 0; cy <= 100; cy++){
            int ch = h[1] + abs(cx - x[1]) + abs(cy - y[1]);
            bool checker = true;
            for(int i = 2; i <= n; i++){
                if(max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]){
                    checker = false;
                }
            }
            if(checker){
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
a,b,x=map(int,input().split())
import numpy as np

half = a*a*b*0.5

if x>half:
    tant = (a*a*b-x)/(0.5*a*a*a)
    theta = np.rad2deg(np.arctan(tant))
else:
    tant = (2*x)/(a*b*b)
    theta = np.rad2deg(np.arctan(tant))
    theta = 90-theta
    
print(theta)

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, L;
	cin >> N >> L;
	int A[100000];
	rep(i, N) cin >> A[i];

	int saidai = 0;
	int basho = 0;
	rep(i, N - 1) {
		int kari = A[i] + A[i + 1];
		if (kari > saidai) {
			saidai = kari;
			basho = i;
		}
	}

	if (saidai >= L) {
		co("Possible");
		rep(i, basho) {
			co(i + 1);
		}
		for (int i = N - 1; i > basho + 1; i--) {
			co(i);
		}
		co(basho + 1);
	}
	else co("Impossible");

	Would you please return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>inline bool read(T &x)
{
    x=0;register char c=getchar();register bool f=0;
    while(!isdigit(c)){if(c==EOF)return false;f^=c=='-',c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    if(f)x=-x;
    return true;
}
template<class T>inline void print(T x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10^48);
}
template<class T>inline void print(T x,char c){print(x),putchar(c);}
template<class T,class ...S>inline bool read(T &x,S &...y){return read(x)&&read(y...);}

ll temp,ans,b[5055],c[5055],cnt,k;
int p[5055],now,n;
int main(){
	read(n,k);
	for (int i=1;i<=n;i++)read(p[i]);
	for (int i=1;i<=n;i++)read(c[i]);
	ans=c[1];
	for (int i=1;i<=n;i++){
		cnt=0;
		now=i;
		while(cnt==0||now!=i) cnt++,now=p[now],b[cnt]=b[cnt-1]+c[now];
		if (cnt>=k){
			temp=b[1];
			for (ll j=1;j<=k;j++)
			temp=max(temp,b[j]);
		}else{
			if (b[cnt]>0){
				temp=b[1];
				for (ll j=1;j<=k%cnt;j++)
				temp=max(temp,k/cnt*b[cnt]+b[j]);
				for (ll j=1;j<=cnt;j++)
				temp=max(temp,(k/cnt-1)*b[cnt]+b[j]);
			}else{
				temp=b[1];
				for (ll j=1;j<=cnt;j++)
				temp=max(temp,b[j]);
			}
		}
		ans=max(ans,temp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int p[100001];

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

	int N; cin >> N;
	for (int i = 1; i <= N; i++) cin >> p[i];

	int ans = 0;
	for (int i = 1; i <= N - 1; i++) {
		if (p[i] == i) {
			int tmp = p[i];
			p[i] = p[i + 1];
			p[i + 1] = tmp;
			ans++;
		}
	}
	if (p[N] == N) {
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define inf LLONG_MAX

void solve()
{
	ll n,k,i;
	cin>>n>>k;

	ll hash=0;
	for(i=0;i<k;i++)	
	{
		ll val;
		cin>>val;

		hash|=(1LL << val);
	}

	while(1)
	{
		ll val=0;

		for(i=n;i>0;i/=10)	
		{
			val|=(1LL<<(i%10));
		}
		
		if((val & hash )== 0)
		{
			cout<<n<<endl;
			return;
		}
		n++;
	}
	
}


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		solve();
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, m;
    cin >> n;
    vi t(n);
    fo(i, n) cin >> t[i];
    cin >> m;

    int p, x;
    fo(i, m) {
        cin >> p >> x;
        int soma = 0;
        fo(j, n) {
            if ( j == p - 1 ) soma += x;
            else soma += t[j];
        }
        cout << soma << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
from math import gcd
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

g = 0
for a in A:
  g = gcd(g, a)
if g > 1:
  print("not coprime")
  exit()

def factorize(n):
    d = set()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d.add(m)
        m += 1
    if n > 1:
        d.add(n)
    return d

st = set()
for a in A:
    fac = factorize(a)
    if fac.intersection(st) :
        print('setwise coprime')
        exit()
    st.update(fac)
print('pairwise coprime')

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 1000000007
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back
#define p 31

using namespace std;

void solve()
{
    ll n,m;
    cin>>n>>m;
    vi a(n);
    rep(i,0,n)
        cin>>a[i];
    priority_queue <ll> pq(begin(a),end(a));
    while(m>0)
    {
        ll x=pq.top();
        pq.pop();
        x/=2;
        m--;
        pq.push(x);
    }
    ll sum=0;
    while(!pq.empty())
    {
        sum+=pq.top();
        pq.pop();
    }
    cout<<sum;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

signed main(){
    string S;
    cin >> S;
    
    string s = S;
    
    if(S=="keyence"){
        cout << "YES" << endl;
        return 0;
    }
    
    for(int i=0;i<S.size();i++){
        for(int k=1;k<S.size();k++){
            s = S;
            s.erase(i,k);
            if(s=="keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 764
n = int(input())
ary = list(map(int, input().split()))
#print(n,ary)

ary_2 = [ary[0]]
for i in range(1, n):
    ary_2.append(ary[i] + ary_2[i-1])
ary_2 = [0] + ary_2
#print(ary_2)

from collections import Counter
c = Counter(ary_2)
v = (c.values())
#print(v)

ans = 0
for j in v:
    if j >1:
        ans += j * (j-1) // 2

print(ans)


Measured memory_bytes: 44492
# Sの入力
S = input()
# Tの入力
T = input()

boolean = True

for i in range(len(S)):
  if (S[i] != T[i]):
    boolean = False

if (len(S) + 1 != len(T)):
  boolean = False

if (boolean):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9064
import sys
n = int(sys.stdin.readline())

A = B = 1

for _ in xrange(n):
    a, b = map(int, sys.stdin.readline().split())
    k = max(B/b,A/a)
    while k * a < A or k * b < B:
        k += 1
    A= k*a
    B= k*b
print A+B

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

int gcd(int a, int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int gcd_num = gcd(a,b);
    return gcd_num * (a / gcd_num) * (b /gcd_num);
}
int main()
{
    int a,b;
    while(cin >> a >> b)
    {
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int p[210],q[210],cnt;
long long n;
void solve(long long n)
{
    if(n==0)
        return;
    if(~n & 1)
    {
        q[++q[0]]=cnt++;
        solve(n - 1);
    }
    else
    {
        p[++p[0]]=cnt++;
        solve(n >> 1);
    }
}
int main()
{
    cin>>n;
    solve(n);
    cout<<cnt+100<<endl;
    for(int i=1;i<=q[0];++i)
        cout<<cnt-q[i]<<" ";
    for(int i=p[0];i>0;--i)
        cout<<cnt-p[i]<<" ";
    for(int i=1;i<=100;++i)
        cout<<i<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int m1 = stdIn.nextInt();
		int d1 = stdIn.nextInt();
		
		int m2 = stdIn.nextInt();
		int d2 = stdIn.nextInt();
		
		if(m1 ==1 || m1 == 3 || m1 == 5 || m1 == 7 || m1 ==8 || m1 == 10 || m1 ==12) {
			if(d1 == 31) {
				System.out.println(1);
			}else {
				System.out.println(0);
			}
		}
		
		if( m1 == 4 || m1 == 6 || m1 == 9 || m1 ==11) {
			if(d1 == 30) {
				System.out.println(1);
			}else {
				System.out.println(0);
			}
		}
		
		if(m1 == 2) {
			if(d1 == 28) {
				System.out.println(1);
			}else {
				System.out.println(0);
			}
		}
		
	}

}


Measured memory_bytes: 23764
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] o = scanner.next().toCharArray(), e = scanner.next().toCharArray();
			StringBuilder sb = new StringBuilder();
			IntStream.range(0, e.length).forEach(i -> sb.append(o[i]).append(e[i]));
			IntStream.range(0, o.length - e.length).forEach(i -> sb.append(o[o.length - 1 - i]));
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 35956
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();
		double r=0;
		for(int i=1;i<=n;++i) {
			double t=Math.max(0,Math.log(k/(double)i)/Math.log(2));
			r+=Math.pow(0.5,Math.ceil(t));
		}
		System.out.println(r/n);
	}
}

Measured memory_bytes: 21844
import bisect
S=list(input())
T=list(input())

N=len(S)
p=[[] for _ in range(26)]
for i in range(N):
    p[ord(S[i])-97].append(i+1)

res=0
b=0
for t in T:
    k=ord(t)-97
    if len(p[k])==0:
        print(-1)
        exit()
    r=bisect.bisect_right(p[k],b)
    if len(p[k])>r:
        res+=p[k][r]-b
        b=p[k][r]
    else:
        res+=N-b+p[k][0]
        b=p[k][0]

print(res)

Measured memory_bytes: 60400
#include <iostream>

using namespace std;

void disp(int h[3][10]) {
	for(int i=0; i<3; i++) {
		for(int j=0; j<10; j++) {
			cout << " " << h[i][j];
		}
		cout << endl;
	}
}

int main(){
	int n, b, f, r, v;
	int h1[3][10], h2[3][10], h3[3][10], h4[3][10];

	for(int i=0; i<3; i++) {
		for(int j=0; j<10; j++) {
			h1[i][j] = h2[i][j] = h3[i][j] = h4[i][j] = 0;
		}
	}

	cin >> n;

	for(int i=0; i<n; i++) {
		cin >> b >> f >> r >> v;
		switch(b) {
			case 1:
				h1[f-1][r-1] += v;
				break;
			case 2:
				h2[f-1][r-1] += v;
				break;
			case 3:
				h3[f-1][r-1] += v;
				break;
			case 4:
				h4[f-1][r-1] += v;
				break;
		}
	}

	disp(h1);
	cout << "####################" << endl;
	disp(h2);
	cout << "####################" << endl;
	disp(h3);
	cout << "####################" << endl;
	disp(h4);

	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n;
int a[maxn], b[maxn], fa[maxn];
int tot;
std::map<int, int> map;
std::multiset<int> s0, s1;
inline int find(int x) {
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n) cin >> a[i], a[n + 1] ^= a[i];
	rep(i, 1, n) cin >> b[i], b[n + 1] ^= b[i];
	++ n;
	rep(i, 1, n) {
		if(!map.count(a[i])) map[a[i]] = ++tot;
		s0.emplace(a[i] = map[a[i]]);
	}
	rep(i, 1, n) {
		if(!map.count(b[i])) map[b[i]] = ++tot;
		s1.emplace(b[i] = map[b[i]]);
	}
	if(s0 != s1) {
		cout << -1 << '\n';
		return 0;
	}
	rep(i, 1, tot) {
		fa[i] = i;
	}
	std::set<int> set;
	int ans = - 1;
	rep(i, 1, n - 1) {
		if(a[i] != b[i]) {
			set.emplace(a[i]);
			set.emplace(b[i]);
			++ ans;
			if(find(a[i]) != find(b[i])) {
				fa[find(a[i])] = find(b[i]);
				-- ans;
			}
		}
	}
	if(!set.count(a[n])) ++ ans;
	if(a[n] != b[n] && !set.count(b[n])) ++ ans;
	cout << ans + set.size() << '\n';
}


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

using namespace std;

int main() {

	int n, m, ans = 0;
	vector<int> l, r;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		l.push_back(a);
		r.push_back(b);
	}

	int rm = *min_element(r.begin(), r.end());
	int lm = *max_element(l.begin(), l.end());


	// cout << min << max << endl;
	ans = rm - lm + 1;
	if (ans > 0) cout << ans << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 1276