akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        es: [(usize1, usize1); m]
    }
    let mut a = vec![vec![0; n]; n];
    for &(i, j) in &es {
        a[i][j] += 1;
        a[j][i] += 1;
    }
    for i in 0..n {
        println!("{}", a[i].iter().cloned().sum::<usize>());
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop()
#define ppb         pop_back()
#define ppf         pop_front()
#define OK          cout<<"Ok"<<"\n";
#define TESTS       ll test;cin>>test;for(ll   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(2e6+9)



int main()
{
    FAST
    int n;
    int f=1,x;
    cin>>n;
    for(int i=0;i<n;i++)
    {
      cin>>x;
      if(x%2==0)
      {
        if(x%3==0) continue;
        else if(x%5==0) continue;
        f=0;

      }
    }
    if(f) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;






    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,max=1,b;
  cin>>n>>m;
  int a[n],c[1000]={0};
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    cin>>b;
    for(int j=1;j<=n;j++){
      if(b>=a[j]){
	c[j]++;
	break;
      }
    }
  }
  for(int i=1;i<=n;i++){
    if(c[max]<c[i])max=i;
  }
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 3108
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int h,w,k;
char c[10][10];
int main() {
	std::cin>>h>>w>>k;
	rep(i,h){
		rep(j,w)std::cin>>c[i][j];
	}
	int ans=0;
	rep(i,1<<h){
		rep(j,1<<w){
			int cnt=0;
			rep(k,h){
				rep(l,w){
					if(i&(1<<k)&&j&(1<<l)&&c[k][l]=='#')cnt++;
				}
			}
			if(cnt==k)ans++;
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
  long long int d, x, y;
  int n, cnt = 0;
  
  scanf("%d %lld", &n, &d);
  d *= d;
  
  for (int i = 0; i < n; i++)
  {
    scanf("%lld %lld", &x, &y);
    if (x * x + y * y <= d)
      cnt++;
  }
  
  printf("%d", cnt);
  
  return 0;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//根なら(-1)*(size)、子なら親を示す(main内でUnionFind uf(n)と宣言する。)
    int root(int x){
        if(d[x]<0) return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x, int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return -d[root(x)];}
};

ll lan[101010];

int main(){
    ll n,m;cin>>n>>m;
    UnionFind uf(n+1);
    vector<ll> uni;
    rep(i,0,n){
        ll k;cin>>k;
        vector<ll> l(k);
        uni.clear();
        rep(j,0,k){
            cin>>l[j];
            if(lan[l[j]]==0)lan[l[j]]=i+1;
            else{
                uni.push_back(lan[l[j]]);
            }
        }
        rep(j,0,uni.size()){
            if(!uf.same(i+1,uni[j]))uf.unite(i+1,uni[j]);
        }
    }
    ll ok=1;
    rep(i,2,n+1){
        if(!uf.same(1,i))ok=0;
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

    









Measured memory_bytes: 1280
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
pt_dict = {"r":P, "s":R, "p":S}
pt = 0
result = []
for i in range(N):
    if i <K:
        pt += pt_dict[T[i]]
        result.append("win")
    elif T[i] == T[i-K] and result[i-K]=="win":
            result.append("lose")
    else:
        pt += pt_dict[T[i]]
        result.append("win")
print(pt)

Measured memory_bytes: 4212
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

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

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

int x,y;

	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0) break;
	if(x>y){
		printf("%d %d\n",y,x);
	}
	else{
		printf("%d %d\n",x,y);
	}
	}
return 0;
}



Measured memory_bytes: 2028
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    else:
        if m==-1 or f==-1:
            print('F')
        elif m+f>=80:
            print('A')
        elif 80>m+f>=65:
            print('B')
        elif 65>m+f>=50:
            print('C')
        elif 50>m+f>=30:
            if r>=50:
                print('C')
            else:
                print('D')
        else:
            print('F')


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if (N % 10 == 3) {
    cout << "bon" << endl;
  } else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll t,a,b;
    cin>>t>>a>>b;
    ll ans=(t/(a+b))*a;
    t=t%(a+b);
    if(t>a){
        ans=ans+a;
    }
    else{
        ans=ans+t;
    }
    cout<<ans<<endl;
}

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

using namespace std;

vector<int> divisor(int a)
{
  vector<int> head, tail;

  for(int i=1; i*i<=a; i++){
    if(a%i == 0){
      head.push_back(i);
      if(i*i != a){
        tail.push_back(a/i);
      }
    }
  }
  while(tail.size() != 0){
    head.push_back(tail[tail.size()-1]);
    tail.pop_back();
  }

  return head;
}


int main()
{
  vector<int> div0, div1;
  int N;
  cin >> N;

  vector<int> data;
  for(int i=0; i<N; i++)
  {
    int x;
    cin >> x;

    data.push_back(x);
  }

  sort(data.begin(),data.end());

  int div0max, div1max;
  int enableCnt;

  div0 = divisor(data[0]);
  div0max = 1;
  for(int i=div0.size()-1; i>0; i--){
    enableCnt = N;
    for(int j=1; j<N; j++){
      if(data[j]%div0[i] != 0) enableCnt--;
      if(enableCnt<N-1) break;
    }
    if(enableCnt>=N-1){
      div0max = div0[i];
      break;
    }
  }

  div1 = divisor(data[1]);
  div1max = 1;
  for(int i=div1.size()-1; i>0; i--){
    enableCnt = N;
    for(int j=2; j<N; j++){
      if(data[j]%div1[i] != 0) enableCnt--;
      if(enableCnt<N) break;
    }
    if(enableCnt>=N){
      div1max = div1[i];
      break;
    }
  }

  cout << max(div0max,div1max);


  return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>

#define MAX(a, b) ((a > b) ? a : b)

int main(void) {
	int32_t A, B;

	scanf("%"PRId32" %"PRId32, &A, &B);

	printf("%"PRId32, MAX(A + B, MAX(A - B, A*B)));

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int arr[105];

int main()
{
	cio;

	int n;
	cin >> n;

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

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 2 == 1 && arr[i] % 2 == 1)
			ans++;
	}

	cout << ans;
}

Measured memory_bytes: 3084
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var ans = m1(0, n);
        Console.WriteLine(ans);
    }

    static int[] d = new[] { 7, 5, 3 };
    static int m1(int x, int max)
    {
        var sum = m2(x) ? 1 : 0;
        for (int i = 0; i < 3; i++)
        {
            var n = 10 * x + d[i];
            if (0 < n && n <= max)
            {
                sum += m1(n, max);
            }
        }
        return sum;
    }

    static bool m2(int x)
    {
        var s = x.ToString();
        return s.Contains('7') && s.Contains('5') && s.Contains('3');
    }
}

Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
const int N = 505;
int x[N*N], y[N*N];
int n;
 
int d[N][N];
bool del[N][N];
const int xx[4]={1,0,-1,0};
const int yy[4]={0,1,0,-1};
 
void extend(int x,int y){
	// cout << x << " " << y << ":" << d[x][y] << endl;
	for(int i=0;i<4;i++){
		int nx=x+xx[i], ny=y+yy[i];
		int nd=d[x][y]+1-del[nx][ny];
		if(d[nx][ny]>nd){
			d[nx][ny]=nd;
			extend(nx,ny);
		}
	}
}
 
int main()
{
	cin >> n;
	for(int i=1;i<=n*n;i++){
		int p;scanf("%d",&p);
		x[i] = (p+n-1)/n,y[i] = p-(x[i]-1)*n;
		// cout << x[i] << ":" << y[i] << endl;
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)d[i][j]=min(min(i,j),min(n-i+1,n-j+1));
	int ans=0;
	for(int i=1;i<=n*n;i++){
		ans+=d[x[i]][y[i]]-1;
		del[x[i]][y[i]]=1;
		for(int j=0;j<4;j++){
			int nx=x[i]+xx[j],ny=y[i]+yy[j];
			d[x[i]][y[i]] = min(d[x[i]][y[i]], d[nx][ny]);
		}
		extend(x[i],y[i]);
		
	}
	cout << ans << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int oldmain(){
	
	int h,w,k;
	cin >>h >>w >>k;
	vector<ll> dp(w+3);
	dp[0] = 1;
	

	
	rep(i, h){
		vector<ll> np(w+3);
		rep(s, 1<<(w-1)){
			bool consw = false;
			rep2(p, 1, w-1){
				if((s>>p &1 )&&(s>>(p-1)&1))  consw=true;
			}
			if(consw) continue;
			rep(j, w){
				if(s>>j &1) (np[j+1] += dp[j])%=mod;
				else if(j>0 && s>>(j-1) &1) (np[j-1] += dp[j])%=mod;
				else (np[j] += dp[j])%=mod;
			}
		}
		swap(dp, np);
	}
	cout << dp[k-1] <<"\n";
}

int main(){
	
	vector<ll> fb={1,1};
	rep(i, 10) fb.push_back(fb[sz(fb)-2] + fb.back());
	int h,w,k;
	cin >>h >>w >>k;
	vector<ll> dp(w+3);
	dp[0] = 1;
	

	
	rep(i, h){
		vector<ll> np(w+3);
		rep(j, w){
			(np[j+1] += dp[j]*fb[j]%mod *fb[w-2-j])%=mod;
			if(j>0)(np[j-1] += dp[j]*fb[j-1]%mod *fb[w-1-j])%=mod;
			(np[j] += dp[j]*fb[j]%mod *fb[w-1-j])%=mod;
		}
		swap(dp, np);
		//for(auto x : dp) printf("%5lld, ",x);
		//printf("[%lld::%d]\n", accumulate(all(dp),0LL), i);
	}
	cout << dp[k-1] <<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int a[N][220];
int ans[N];
int main() {
    map<char, int> mp;
    string s;
    cin >> s;
    int n = s.length();
    int m[200] = {0};
    for(int i = 0; i < n; i++) {
        m[s[i]] = max(m[s[i]], i);
        if(s[i] == 'L') {
            int t = i - m['R'];
            if(t & 1) {
                ans[m['R'] + 1]++;
            } else {
                ans[m['R']]++;
            }
        }
    }
    memset(m, 0x3f, sizeof m);
    for(int i = n - 1; i >= 0; i--) {
        m[s[i]] = min(m[s[i]], i);
        if(s[i] == 'R') {
            int t = m['L'] - i;
            if(t & 1) {
                ans[m['L'] - 1]++; 
            } else {
                ans[m['L']]++;
            }
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] << " \n"[i==n-1];
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    string a, b;
    cin >> a >> b;
    int la = a.size(), lb = b.size();
    string ans;
    if(la > lb) ans = "GREATER";
    else if(la < lb) ans = "LESS";
    else if(a == b) ans = "EQUAL";
    else {
        rep(i, la) {
            if(a[i] > b[i]) {
                ans = "GREATER";
                break;
            } else if(a[i] < b[i]) {
                ans = "LESS";
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    int a[n+1],i,j=1;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]!=j)
            c++;
        else
            j++;
    }
    if(c==n)
        cout<<"-1";
    else
        cout<<c;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[30];
int main(){
	string s;
	cin>>s;
	memset(a,0,sizeof(a));
	for(int i=0;i<s.size();i++){
		a[s[i]-'a']=1;
	}
	for(int i=0;i<=26;i++){
		if(i==26){
			cout<<"None"<<endl;
			break;
		}
		if(a[i]==0){
			cout<<(char)('a'+i)<<endl;
			break;
		}
	}
	return 0;
}

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

long long lcm(long long a, long long b)
{
    long long x = a * b;

    /* 自然数 a > b を確認・入替 */
    if (a < b)
    {
        long long tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    long long r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }

    /* 最小公倍数を出力 */
    return x / b;
}

int main()
{
    long long A, B, C, D;

    cin >> A >> B >> C >> D;

    A--;

    long long sum = 0;
    sum += (B - (B / C) - (B / D) + (B / lcm(C, D)));

    sum -= (A - (A / C) - (A / D) + (A / lcm(C, D)));

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
       if(a==5 && b==5 || a==5 && c==5 || b==5 && c==5 )
       cout<<"YES\n";
       else
       cout<<"NO\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  
  int A = 0;
  
  int M = 100000000000;
  
  cin >> N;

  for (int i = 0; i < N; i++) {
    int C = 0;
    cin >> A;
    
    while (A % 2 == 0) {
      
      
      A = A / 2;
      C++;
    }
    if (M > C) {
      M = C;
    }
    
  }
  cout << M << endl;
}


Measured memory_bytes: 3572
#include<stdio.h>

int Calc(int, int);

int main()
{
	int i, N, count;
	
	while(1)
	{
		scanf("%d", &N);
		
		if(N == 0) break;
		
		count = 0;
		
		for(i = 1; i < N / 2 + 1; i++)
		{
			if(Calc(i, N) == N)
			{
				count++;
			}
		}
		
		printf("%d\n", count);
	}
	
	return 0;
}

int Calc(int start, int limit)
{
	int i;
	int result = start;
	
	i = start;
	
	do
	{
		result += ++i;
	} while(result < limit);
	
	return result;
}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int v[100010] = {};
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		++v[x];
	}
	int cnt = 0;
	int ans = 0;
	for(int i = 0; i < 100005; ++i) {
		if(v[i] > 1) {
			if(v[i]%2) ans += v[i]/2;
			else {
				ans += (v[i]-1)/2;
				++cnt;
			}
		}
	}
	cout << n - 2*(ans + (cnt+1)/2) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>
#include<bitset>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(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;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x,y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

long nCr(int n,int r) {
	long ans = 1;
	for (int i = n; i > n - r;i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1;i++) {
		ans = ans / i;
	}
	return ans;
}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI a,res = 0;
	cin >> N;
	vector<LLI>vec(N + 1);
	for (int i = 1; i < N + 1;i++) {
		cin >> a;
		vec[i] = vec[i - 1];
		vec[i] += a;
	}
	map < LLI, LLI>m;
	for (LLI i :vec) {
			m[i]++;
	}
	for (auto i : m) {
		a = nCr(m[i.first],2);
		res += a;
	}
	cout << res << endl;
}

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

int main() {
	string inp;
	cin >> inp;
	
	int a = 0, b = 0;
	
	for(auto i : inp) {
		if(i == 'A')
			++a;
		else ++b;
	}
	if(a > 0 && b > 0)
		puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(){
    char s1[11], s2[11], s3[11], s4[3];
    scanf("%s %s %s", s1, s2, s3);
    s4[0] = toupper(s1[0]);
    s4[1] = toupper(s2[0]);
    s4[2] = toupper(s3[0]);
    s4[3] = '\0';
    printf("%s\n", s4);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int main(){
    int N, H, W;
    cin >> N >> H >> W;
    int ans;
    ans = (N - H + 1) * (N - W + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    string n; cin>>n;
    int k,N=n.size(); cin>>k;
    vector<vector<int>> o(N,vector<int>(4,0)),x(N,vector<int>(4,0));
    o[0][0]=0; o[0][1]=1; x[0][0]=1; x[0][1]=n[0]-'0'-1;
    for(int i=1;i<N;i++){
        if(n[i]-'0'==0){
            rep(j,4) o[i][j]=o[i-1][j];
            x[i][0]=x[i-1][0];
            for(int j=1;j<=3;j++) x[i][j]=x[i-1][j]+9*x[i-1][j-1];
        }
        else{
            for(int j=1;j<=3;j++) o[i][j]=o[i-1][j-1];
            x[i][0]=x[i-1][0];
            for(int j=1;j<=3;j++) 
            x[i][j]=x[i-1][j]+9*x[i-1][j-1]+o[i-1][j]+(n[i]-'0'-1)*o[i-1][j-1];
        }
        
    }
    cout<<o[N-1][k]+x[N-1][k]<<endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec A(N);
  map<ll, ll> num;
  rep(i, N){
    cin >> A[i];
    num[A[i]]++;
  }
  llvec e;
  for(auto im:num){
    while(im.second>=2){
      e.push_back(im.first);
      im.second-=2;
    }
  }
  sort(ALL(e));
  reverse(ALL(e));
  if(e.size()<1){
    cout << 0 << endl;
  }else{
    cout << e[0] * e[1] << endl;
  }

  return 0;
}


Measured memory_bytes: 7296
def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    cnt = 0
    for i in range(k, n+2):
        l = (i-1)*i//2
        h = (n+n-i+1)*i//2
        cnt += h - l + 1
    print(cnt % mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(){
	string A,B;
	cin>>A;
	cin>>B;
	if(A.length()>B.length()){
		cout<<"GREATER";
	}
	else if(A.length()<B.length())
		cout<<"LESS";
	else if(A.length()==B.length()){
		for(int i=0;i<A.length();i++){
			if(A[i]>B[i]){
				cout<<"GREATER";
				return 0;
			}
			else if(A[i]<B[i]){
				cout<<"LESS";
				return 0;
			}
		}
		cout<<"EQUAL";
	}
		
}

Measured memory_bytes: 256
#include<stdio.h>

int judge_rock(int *p){
    int i;
    for(i=0;i<5;i++){
        if(p[i]==1)return 1;
    }
    return 0;
}

int judge_scissors(int *p){
    int i;
    for(i=0;i<5;i++){
        if(p[i]==2)return 1;
    }
    return 0;
}

int judge_paper(int *p){
    int i;
    for(i=0;i<5;i++){
        if(p[i]==3)return 1;
    }
    return 0;
}

int main(){
    int a[5],i;

    while(scanf("%d",&a[0]),a[0]){
        scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);

        if(judge_rock(a)+judge_scissors(a)+judge_paper(a) == 3||judge_rock(a)+judge_scissors(a)+judge_paper(a) == 1){
            puts("3\n3\n3\n3\n3");
        }else{
            if(judge_rock(a)&&judge_scissors(a)){
                for(i = 0;i < 5;i++){
                    printf("%d\n",a[i]);
                }
            }else if(judge_paper(a)&&judge_scissors(a)){
                for(i = 0;i < 5;i++){
                    printf("%d\n",a[i]-1);
                }
            }else if(judge_rock(a)&&judge_paper(a)){
                for(i = 0;i < 5;i++){
                    printf("%d\n",(a[i]+1)%3);
                }
            }
        }
    }
    return 0;
}

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

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        int pro = 1;
        for (int i = k; i < n; ++i)
        {
            if (a[i] > a[i - k])
                cout << "Yes"
                     << "\n";
            else
            {
                cout << "No"
                     << "\n";
            }
        }
    }
}

Measured memory_bytes: 5208
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			String[] S = sc.next().split("");
			String[] T = sc.next().split("");
			sc.close();
			if (S.length + 1 == T.length) {
				for (int i = 0; i < S.length; i++) {
					if (! S[i].equals(T[i])){
						System.out.println("No");
						return;
					}
				}
				System.out.println("Yes");
				return;
			}
			System.out.println("No");
    }
}


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

signed
main(){
		while(1)
		{
				string a,b;
				cin >> a;
				if(a == ".") break;
				cin >> b;
				
				int err_cnt = 0;
				vector<string> st_a, st_b;
				vector<string> oth_a, oth_b;

				int oa_cnt = 0,ob_cnt = 0;
				oth_a.push_back("");
				oth_b.push_back("");

				int st = 0, num = 0;
				bool flag = false;
				for(int i=0;i<a.size();i++)
				{
						if(flag){
								if(a[i]=='\"'){
										num++;
										st_a.push_back(a.substr(st,num));
										oth_a.push_back("");
										oa_cnt++;
										flag = false;
								}else{
										num++;
								}
						}else{
								if(a[i]=='\"'){
										st = i;
										flag = true;
										num = 1;

								}else{
										oth_a[oa_cnt] += a[i];
								}
						}
						
				}
				
				st = 0, num = 0;
				flag = false;
				for(int i=0;i<b.size();i++)
				{
						if(flag){
								if(b[i]=='\"'){
										num++;
										st_b.push_back(b.substr(st,num));
										oth_b.push_back("");
										ob_cnt++;
										flag = false;
								}else{
										num++;
								}
						}else{
								if(b[i]=='\"'){
										st = i;
										flag = true;
										num = 1;

								}else{
										oth_b[ob_cnt] += b[i];
								}
						}
	
				}
				
				int cnm_fcnt = 0;
				if(st_a.size()==st_b.size()){
						for(int i=0;i<st_a.size();i++)
						{
								if(st_a[i]!=st_b[i]) cnm_fcnt++;
						}
				}
				bool oth_flag = true;
				if(oth_a.size()!=oth_b.size()){
						oth_flag =false;
				}else{
						for(int i=0;i<oth_a.size();i++)
						{
								if(oth_a[i]!=oth_b[i]){
									oth_flag =false;
								}
						}
				}


				if(a==b){
						cout << "IDENTICAL" << endl;
				}else if(oth_flag && cnm_fcnt == 1){
						cout << "CLOSE" << endl;
				}else{
						cout << "DIFFERENT" << endl;
				}
		}
}



Measured memory_bytes: 3164
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;

int main(){
    fastio
    int n ; 
    cin >> n ; 
    string s ; 
    cin >> s ; 
    vector<int> sumW(n+1),sumE(n+1) ; 
    for(int i=0;i<n;i++){
    	if ( s[i] == 'W' ) sumW[i+1] = 1; 
    	else sumE[i+1] = 1 ; 
    }
    for(int i=1;i<=n;i++){
    	sumW[i] += sumW[i-1];
    	sumE[i] += sumE[i-1];
    }
    debug() << imie(sumW) ; 
    debug() << imie(sumE) ; 
    int ans = 1e9 + 10 ; 
    for(int i=0;i<n;i++){
    	int cntW = sumW[i] ; 
    	int cntE = sumE[n] - sumE[i+1] ; 
    	ans = min(ans,cntW+cntE) ; 
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 2964
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    Integer[] d;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        d = new Integer[N];
        for (int i = 0; i < N; i++) {
        	this.d[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int solve() {
        int count = 1;
        Arrays.sort(d, Collections.reverseOrder());

        for (int i = 1; i < N; i++) {
        	if (d[i] < d[i-1]) {
        		count++;
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 36092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_132
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            long[] nk = ReadLongs();
            long n = nk[0];
            long k = nk[1];

            long mask = 1000000000 + 7;

            for(long i = 1; i <= k; i++)
            {
                long blueRemain = k - i;
                long blues;
                if (i >= 2) blues = Combination(blueRemain + i - 1, i - 1, mask);
                else blues = 1;
                long redRemain = n - k - (i - 1);
                long reds = Combination(redRemain+i, i, mask);
                WriteLine(MultiMod(blues, reds, mask));
            }
        }
        static long Combination(long n, long m, long mask)
        {
            if (n < m) return 0;

            if (n - m < m) m = n - m;

            long val = Permutation(n, m, mask);
            long div = Permutation(m, m, mask);
            return MultiMod(val, ReverseMod(div, mask - 2, mask), mask);
        }

        static long Permutation(long n, long m, long mask)
        {
            long val = 1;
            for (long i = 0; i < m; i++)
            {
                val *= ((n - i) % mask);
                val %= mask;
            }
            return val;
        }

        static long[] AllPermutations(long n, long mask)
        {
            var perms = new long[n + 1];
            perms[0] = 1;
            for (int i = 1; i <= n; i++)
            {
                perms[i] = MultiMod(perms[i - 1], i, mask);
            }
            return perms;
        }

        static long MultiMod(long a, long b, long mask)
        {
            return ((a % mask) * (b % mask)) % mask;
        }

        static long ReverseMod(long a, long pow, long mask)
        {
            if (pow == 0) return 1;
            else if (pow == 1) return a % mask;
            else
            {
                long halfMod = ReverseMod(a, pow / 2, mask);
                long nextMod = MultiMod(halfMod, halfMod, mask);
                if (pow % 2 == 0)
                {
                    return nextMod;
                }
                else
                {
                    return MultiMod(nextMod, a, mask);
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
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; }
bool is_prime(int n) {
  if(n==1) return false;
  else if (n == 2) return true;
  else if (n%2 == 0) return false;
  for(int d = 3; d*d <= n; d += 2) {
    if( n % d == 0 ) return false;
  }
  return true;
}
int main()
{
    int Q;
    cin >> Q;
    int l = INT_MAX, r = 0;
    vector<P> A;
    rep(i, Q)
    {
        int a, b;
        cin >> a >> b;
        A.emplace_back(a, b);
        chmin(l, a);
        chmax(r, b);
    }
    //cout << l << "<" << r << endl;
    int l2 = (l+1)/2;
    int r2 = (r+1)/2;
    int n = r-l+1;
    vector<int> B1(n), B2(n);
    // is_prime(3);
    // return 0;
    B1[0] = 0;//(is_prime(l) && is_prime((l+1)/2) ? 1 : 0);
    //return 0;
    //B2[0] = (is_prime((l+1)/2) ? 1 : 0);
    rep(i, 1+n)
    {
        B1[i] = B1[i-1] + (is_prime(l+i-1)&&is_prime((l+i)/2) ? 1 : 0);
        //B2[i] = B2[i-1] + (is_prime((l+i+1)/2) ? 1 : 0);
    }
    rep(i, Q)
    {
        int a = A[i].first-l;
        int b = A[i].second-l+1;
        int ans = B1[b]-B1[a];
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 4840
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int n;
int a;
vi A;
vi S;
map<int,int> maap;
int ans=0;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){ cin>>a;A.pb(a);}
    S.resize(n+1);
    S[0]=0;
    REP(i,1,n+1){
        S[i]=S[i-1]+A[i-1];
    }
    rep(i,n+1){
        if(maap[S[i]]) ans+=maap[S[i]];
        maap[S[i]]++;
    }

    cout<<ans<<endl;

    return 0;
}

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder 
//begineer 140
//c

int n;
int a[110], b[110];

int main()
{
	cin>>n;

	FOR0(i, n-1) cin>>b[i];

	if(n==2)
	{
		cout<<2*b[0]<<endl;
		return 0;
	}

	int ans = 0;

	a[0] = b[0];
	a[1] = b[0];

	ans+=a[0];

	for (int i = 1; i < n-1; ++i)
	{
		if(b[i]>=a[i])
			a[i+1] = b[i];
		else
		{
			a[i] = b[i];
			a[i+1] = b[i];
		}

		ans+=a[i];
	}

	ans += a[n-1];

	cout<<ans<<endl;
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,j;
	int count;
	int map[21][21];
	int n,m;
	int x,y;
	int jx,jy;
	int l;
	char d;
		
	while(1){
		count=0;
		x=10;
		y=10;
		for(i=0;i<21;i++){
			for(j=0;j<21;j++){
				map[i][j]=0;
			}
		}
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		else{
			for(i=0;i<n;i++){
				scanf("%d %d",&jx,&jy);
				map[jx][jy]=1;
			}
		}
		
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("%c", &d);
			scanf("%c %d",&d,&l);
			//printf("%c %d\n",d, l);
			for(j=0;j<l;j++){
				switch(d){
					case 'N': y++;
							  break;
					case 'S':
							  y--;
							  break;
					case 'E':
							  x++;
							  break;
					case 'W':
							  x--;
							  break;
				}
				if(map[x][y]==1){
					map[x][y]=0;
					count++;
				}
			}
		}
		
		if(count==n) printf("Yes\n");
		else		 printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
int main(){
    double a[10],ans;
    while(scanf("%lf",&a[0])!=EOF){
        ans=a[0];
        for(int i=1;i<10;i++){
            if(i%2==1){
                a[i]=a[i-1]*2;
            }
            else{
                a[i]=a[i-1]/3;
            }
            ans+=a[i];
        }
        printf("%lf\n",ans);
    }
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int fn(int n){
	int sum = 0;
	while(n > 0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;

	if(n%fn(n) == 0) cout << "Yes" <<endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from decimal import Decimal

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

product = 1
max_product = 10**18

if 0 in A_list:
    print(0)
    sys.exit()


for a in A_list:
    check = Decimal(str(max_product)) / Decimal(str(product))

    if a <= check:
        product *= a
    else:
        print(-1)
        sys.exit()

print(product)


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

int main(void) {
  int n;
  int array[101];
  double sum;
  double ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> array[i];
  }
  for (int i = 0; i < n; i++) {
    sum += (1.0 / array[i]);
  }
  ans = 1.0 / sum;

  cout << ans << endl;
}


Measured memory_bytes: 256
// C - Grid Repainting 2
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using VS = vector<string>;

int main(){
	int H,W; cin>>H>>W;
	VS S(H); rpz(i, H) cin>>S[i];

	vi dy{-1,1,0,0}, dx{0,0,-1,1};//{U,D,L,R}
	rpz(h, H) rpz(w, W){
		if(S[h][w] == '.') continue;
		int d;
		for(d=0; d<4; ++d){
			int y = h + dy[d], x = w + dx[d];
			if(y<0 || x<0 || y>H-1 || x>W-1) continue;
			if(S[y][x] != '.') break;
		}
		if(d >= 4){ puts("No"); return 0; }
	}
	puts("Yes");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		String str = sc.next();
		for (int i = 0; i < n; i++) {
			if (str.charAt(i) == 'R') {
				count++;
			} else {
				count--;
			}
		}
		if (count > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll N,K; cin>>N>>K;
  vector<double> d(N), s(N+1,0.0);
  rep(i,N) {
    double x; cin>>x;
    d.at(i)=(x+1)/2;
    s.at(i+1)=s.at(i)+d.at(i);
  }
  double ans=0.0;
  rep(i,N-K+1) ans=max(ans,s.at(i+K)-s.at(i));
  //rep(i,N+1) cout<<s.at(i)<<endl;

  cout<<setprecision(7)<<ans<<endl;


}

Measured memory_bytes: 3328
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(n);
    cinai(d, n);

    ll ans=0;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            ans+=d[i]*d[j];

    cout<<ans<<endl;
}



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

#define CLR(X) memset((X), 0, sizeof(X))

int main(void){
  int num[200][3], pt[200], cnt[100];
  int n;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> num[i][0] >> num[i][1] >> num[i][2];
  }
  CLR(pt);
  for (int i=0; i<3; i++){
    CLR(cnt);
    for (int j=0; j<n; j++){
      cnt[num[j][i]-1]++;
    }
    for (int j=0; j<n; j++){
      if (cnt[num[j][i]-1]==1) pt[j] += num[j][i];
    }
  }
  for (int j=0; j<n; j++){
    cout << pt[j] << endl;
  }
  return 0;
}


Measured memory_bytes: 3132