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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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

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

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N,M,X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vvec<ll> A(N,vec<ll>(M));
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }
    ll ans = INFLL;
    for(int s = 0; s < bit(N);s++){
        ll tmp = 0;
        vector<ll> sum(M,0);
        rep(i,N){
            if(s & bit(i)){
                tmp += C[i];
                rep(j,M){
                    sum[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        rep(j,M){
            if(sum[j] < X)ok = false;
        }
        if(ok){
            chmin(ans, tmp);
        }
    }
    if(ans == INFLL){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

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

int main() {
  int n; cin >> n;
  vector<char> arr(n);
  for (auto &a : arr) cin >> a;
  for (auto &a : arr) {
    if (a == 'Y') {
      cout << "Four\n";
      return 0;
    }
  }
  cout << "Three\n";
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

odd = 0
for n in range(N):
    n += 1
    if n%2==1:
        odd += 1

print(odd/N)

Measured memory_bytes: 8880
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
data = []
inf = 10**10
adjacent_list = [[] for i in range(n+1)]
for i in range(m):
    l,r,d = map(int, input().split())
    adjacent_list[l].append([r,d])
    adjacent_list[r].append([l,-d])
finished = set()
x = [0 for i in range(n+1)]
def dfs(node):
    finished.add(node)
    for nex, dis in adjacent_list[node]:
        if nex not in finished:
            x[nex] = x[node] + dis
            dfs(nex)
        else:
            if x[nex] != x[node] + dis:
                print("No")
                exit()
for i in range(1,n+1):
    if i not in finished:
        dfs(i)
print("Yes")



Measured memory_bytes: 139364
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod=1e9+7;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main()
{ 
  // input_from_file
  fastIO
  ll n;cin>>n;vector<ll> vec(n,0);for(auto &x:vec) cin>>x;
  ll ans=0;
  for(int i=0;i<n;i+=2){
    if(vec[i]%2==1) ans++;
  }
  cout<<ans;
  return 0;
}  



Measured memory_bytes: 3608
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		long ans=0;
		int tmp=0;
		int a[]=new int[N+1];
		int b[]=new int[N];
		
		for(int i=0;i<=N;i++) {
			a[i]=sc.nextInt();
			
		}
		for(int i=0;i<N;i++) {
			b[i]=sc.nextInt();
		}
		
		for(int i=0;i<N;i++) {
			if(a[i]>=tmp) {
				a[i]-=tmp;
				ans+=tmp;
			}else {
				ans+=a[i];
				tmp=b[i];
				continue;
			}
			
			if(a[i]>b[i]) {
				tmp=0;
				ans+=b[i];
			}else {
				tmp=b[i]-a[i];
				ans+=a[i];
			}
		}
		
		if(a[N]>=tmp)ans+=tmp;
		else ans+=a[N];
		
		
		p(ans);
		
		
		
		//System.out.println(cc);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 66904
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
X,N = map(int,input().split())
if N == 0:
    print(X)
else:

    d = defaultdict(int)
    p = list(map(int,input().split()))
    for i in range(N):
        d[p[i]] += 1
    mmin = 0
    Mmin = 101
    for i in range(X):
        if d[i] == 0:
            mmin = i
    for i in range(X,102):
        if d[i] == 0:
            Mmin = i
            break
    a = X-mmin
    b = Mmin-X
    if a == b or a < b:
        print(mmin)
    else:
        print(Mmin)



Measured memory_bytes: 10556
#include<iostream>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;

int main () {
  int N,M;
  cin >> N >> M ;
  int A=0;
  for (int i=0;i<M;i++){
    cin >> A;
    N-=A;
  }

  cout << max(-1,N);
  return 0;
}


Measured memory_bytes: 3632
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut vs = vec![vec![]; n];
    for i in 0..n {
        let a = get!(usize);
        for _ in 0..a {
            let x = get!(u32) - 1;
            let y = get!(u32);
            vs[i].push((x, y));
        }
    }
    let mut ans = 0;
    for p in 1u32..1 << n {
        let mut valid = true;
        for (i, es) in vs.iter().enumerate().filter(|&(i, _)| (p >> i) & 1 != 0 ) {
            for &(x, y) in es {
                if (p >> x) & 1 != y {
                	valid = false;
                    break;
                }
            }
        }
        if valid {
            ans = std::cmp::max(ans, p.count_ones());
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

void solve(int test) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& e : a) cin >> e;
    int lo = 1, hi = 1e9 + 8, mid;
    auto calc = [&](int x) {
        ll cur = 0;
        for (int& e : a) {
            cur += e / x;
            if (e % x == 0 && e >= x) cur--;
        }
        return (cur <= k);
    };
    while (lo < hi - 1) {
        mid = lo + (hi - lo) / 2;
        if (calc(mid))
            hi = mid;
        else
            lo = mid;
    }
    if (calc(lo)) hi = lo;
    cout << hi << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<double>v(n + 5);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    double dp[n + 5][n + 5];
    dp[1][0] = 1 - v[1];
    dp[1][1] = v[1];
    for(int i = 2; i <= n; i++){
        dp[i][0] = dp[i - 1][0]*(1 - v[i]);
        dp[i][i] = dp[i - 1][i - 1]*v[i];
        for(int j = 1; j < i; j++){
            dp[i][j] = dp[i - 1][j]*(1 - v[i]) + dp[i - 1][j - 1]*v[i];
        }
    }
    double ans = 0;
    for(int i = (n + 1)/2; i <= n; i++){
        ans = ans + dp[n][i];
    }
    printf("%0.10lf", ans);
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] x = new int[N+1];
		for(int i = 0;i < N;++i)
			x[i] = sc.nextInt();
		sc.close();
		x[N] = X;
		
		if(N == 1) {
			System.out.println(Math.abs(X - x[0]));
		}else {
			int[] sub = new int[N];
			for(int i = 0;i < N;++i)
				sub[i] = Math.abs(x[i] - X);
			Arrays.sort(sub);
			
			int gcd = 0;
			for(int i = sub[0];i >= 1;--i) {
				boolean flag = true;
				for(int j = 0;j < N-1;++j) {
					if(sub[j] % i != 0) {
						flag = false;
						break;
					}
				}
				if(flag) {
					gcd = i;
					break;
				}
			}
			
			System.out.println(gcd);
		}
	}
}


Measured memory_bytes: 48988
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 110

void main()
{
    int k;
    char s[N], s_[N];

    if (scanf("%d", &k) < 1)
        exit(1);
    if (scanf("%s", s) < 1)
        exit(1);

    if (strlen(s) > k)
    {
        strncpy(s_, s, k);
        s_[k] = '\0';
        strcat(s_, "...");
        printf("%s", s_);
    }
    else
    {
        printf("%s", s);
    }
}


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

//printVector(配列, 区切り文字)
template <typename T>
void printVector(vector<T> v, string delimiter) {
  for (int i=0; i<v.size(); i++) {
    if (i>0) cout << delimiter;
    cout << v[i];
  }
  cout << endl;
}

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

  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }


  bool flag = true;
  int cnt = 0;
  while (flag) {
    flag = false;
    for (int i=n-1; i>0; i--) {
      if (a[i] < a[i-1]) {
        swap(a[i], a[i-1]);
        flag = true;
        cnt++;
      }
    }
  }
  printVector(a, " ");
  cout << cnt << endl;
}



Measured memory_bytes: 3168
#include <iostream>
#include <climits>
#include <string>

#include <ios>
#include <iomanip>

using namespace std;

int main(){

  int N, b, flag = 1;
  string W[110];

  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> W[i];
  }

  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      if(W[i] == W[j]){
        flag = 0;
        break;
      }
    }
  }

  for(int i = 1; i < N; i++){
    b = W[i-1].size();
    if(W[i-1][b-1] != W[i][0]){
      flag = 0;
      break;
    }
  }



  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS
 

  string s,t;
  cin>>s>>t;
  int ans = 0;
  int n = s.size();
  for(int i =0;i<n;i++){
    if(s[i]!=t[i]) ans++;
  }
  cout<<ans<<endl;
    




  
}

Measured memory_bytes: 3784
unittest
{
	assert( [ "3", "2 1 2" ].parse.expand.solve == 1 );
	assert( [ "3", "2 2 2" ].parse.expand.solve == -1 );
	assert( [ "10", "3 1 4 1 5 9 2 6 5 3" ].parse.expand.solve == 7 );
	assert( [ "1", "1" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	if( as.find( 1 ).empty ) return -1;
	
	auto ans = 0L;
	auto j = 1L;
	foreach( i, a; as )
	{
		if( a == j ) j++;
		else         ans++;
	}
	return ans;
}


Measured memory_bytes: 11556
N,A = map(int,input().split())
X = list(map(int,input().split()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
  for k,v in list(dp.items()):
    dp[k+y]=dp.get(k+y,0)+v

print(dp[0]-1)

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

int main()
{
	string s;
	LL k, n;
	cin >> s;
	cin >> k;

	n = s.size();

	vector<LL> eq;

	LL cnt = 1;
	for (int i = 0; i < n-1; ++i) {
		if (s[i] == s[i+1]) {
			cnt++;
		}
		else {
			eq.push_back(cnt);
			
			cnt = 1;
		}
	}
	eq.push_back(cnt);

	LL sz = eq.size();
	LL sum = 0;

	if (sz == 1) {
		sum = (k*n)/2;
	}

	else if (k > 1 && s[0] == s[n-1]) {
		sum += eq[0]/2;
		sum += eq[sz-1]/2;

		eq[0] += eq[sz-1];
		eq.pop_back();
		sz--;

		for (auto &e : eq) {
			sum += k*(e/2);
		}
		sum -= eq[0]/2;
	}
	else {
		for (auto &e : eq) {
			sum += e/2;
		}

		sum *= k;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define N 100005
using namespace std;
int n, m, i, p, q, x, y, a[N];
struct IC{
	int i, c;
	bool operator < (const IC &A) const{
		if(c == A.c) return i < A.i;
		return c > A.c;
	}
} f[N], g[N];
int main(){
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%d", &a[i]);
	}
	for(i=1; i<=N-5; i++){
		f[i].i = g[i].i = i;
	}
	for(i=1; i<=n; i++){
		if(i&1) g[a[i]].c++;
		else f[a[i]].c++;
	}
	sort(f+1, f+N-4);
	sort(g+1, g+N-4);
	if(f[1].i != g[1].i){
		m = n - f[1].c - g[1].c;
	}
	else{
		m = min(n-f[1].c-g[2].c, n-f[2].c-g[1].c);
	}
	printf("%d\n", m);
	return 0;
}

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

using namespace std;


int main(int argc, char *argv[])
{

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M, k[10], s[10][10], p[10], cases = 0;
    
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            int temp;
            cin >> temp;
            temp--;
            s[i][j] = temp;
        }
    }
    
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }
    
    for (int i = 0; i < (1 << N); i++) {
        bitset<10> switches(i);
        bool valid = true;
        for (int j = 0; j < M; j++) {
            int count = 0;
            for (int l = 0 ; l < k[j]; l++) {
                if (switches.test(s[j][l])) {
                    count++;
                }
            }
            if (count % 2 != p[j]) {
                valid = false;
                break;
            }
        }
        if (valid) {
            cases++;
        }
    }
    
    cout << cases << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  set<char>st;
  for(int i=0;i<s.size();i++)st.insert(s[i]);
  if(st.size()==s.size())cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N, M, X, Y;
     cin >> N >> M >> X >> Y;
     vector<int> x(N);
     vector<int> y(M);
     for(int i = 0; i < N; i++) cin >> x[i];
     for(int i = 0; i < M; i++) cin >> y[i];
     sort(x.begin(),x.end());
     sort(y.begin(),y.end());

     if(y[0] <= X || Y <= x[N-1]) cout << "War" << endl;
     else if(x[N-1] < y[0]) cout << "No War" << endl;
     else cout << "War" << endl;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        String s = sc.next();
        String ans = s.substring(0, 3);

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32776
S = input()
OK = False
# if S[0] == 'A' and S[2] == 'C':
#     if S[1].islower() and S[3:].islower():
#         OK = True
# # print(S[3:], S[3:].islower())
# if S[0] == 'A' and S[-2] == 'C':
#     if S[1:-2].islower() and S[-1].islower():
#         OK = True
for i in range(2, len(S)-1):
    if S[0] == 'A' and S[i] == 'C':
        if S[1:i].islower() and S[i+1:].islower():
            OK = True
if OK:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    SORT(A);
    vector<int> v;
    vector<int> vv;
    REP(i, N) {
        int cnt = upper_bound(ALL(A), A[i]) - lower_bound(ALL(A), A[i]);
        if (cnt > 1 && !binary_search(ALL(v), A[i])) {
            v.push_back(A[i]);
            if (cnt > 3)
                vv.push_back(A[i]);
        }
    }

    ll ans = 0;
    if (v.size() > 1)
        ans = (ll)v[v.size() - 1] * v[v.size() - 2];
    if (vv.size() > 0) {
        ans = max(ans, (ll)vv[vv.size() - 1] * vv[vv.size() - 1]);
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int count = 0;
  for(int i = a; i <= b; ++i){
    int temp = i;
    int re = 0;
    while(temp > 0){
      re *= 10;
      re += temp % 10;
      temp /= 10;
    }
    if(i == re) ++count;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {

    vector<int> a(4), b(4);
    rep(i, 4) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    b[0] = 1;
    b[1] = 4;
    b[2] = 7;
    b[3] = 9;

    rep(i, 4) {
        if(a[i] != b[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int z = sc.nextInt();

            x -= z;

            System.out.println(x / (y + z));
        }
    }
}


Measured memory_bytes: 24020
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int cnt = 0;
        while(N!=0){
            if(N%10==2) cnt++;
            N /= 10;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;

int main(int argc,char *argv[])
{
	int n;
	std::cin >> n;
	
	ll tmp = n*(100.0/108.0);

	while(static_cast<int>(tmp*(108.0/100.0)) < n) ++tmp;
	
	if(static_cast<int>(tmp*(108.0/100.0)) == n) std::cout << tmp << std::endl;
	else std::cout << ":(" << std::endl;

	return 0;
}

Measured memory_bytes: 3632
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = []
for i in range(m-1):
    b.append(a[i+1]-a[i])
b.sort(reverse=True)
ans = 0
for i in range(n-1,len(b)):
    ans += b[i]
print(ans)


Measured memory_bytes: 13968
# -*- coding: utf-8 -*-

def main():
    down_positions = []
    ponds = []
    for index, value in enumerate(raw_input()):
        if value == '\\':
            down_positions.append(index)
        elif value == '/' and down_positions:
            right = index
            left = down_positions.pop()
            area = right - left
            # candidate_pond = []
            area2 = 0
            while ponds and left < ponds[-1][0]:
               # candidate_pond.append(ponds.pop(-1))
               area2 += ponds.pop(-1)[1]

            # new_pond = (left, area + sum([x[1] for x in candidate_pond]))
            new_pond = (left, area + area2)
            ponds.append(new_pond)
    
    print sum(x[1] for x in ponds)
    print len(ponds), 
    for pond in ponds:
        print pond[1], 

if __name__ == '__main__':
    main()

Measured memory_bytes: 6856
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
l, r = Y[N//2-1], Y[N//2]
A = []
for i in range(N):
    if X[i] <= l:
        print(r)
        # A.append(r)
    else:
        print(l)
        # A.append(l)
# print('\n'.join(map(str, A)))

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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int>A(N);
    map<int, ll>m;
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
        if (!m.count(A.at(i))) {
            m[A.at(i)] = 1;
        }
        else {
            m[A.at(i)]++;
        }
    }
    int Q;
    cin >> Q;
    vector<int>B(Q), C(Q);
    for (int i = 0; i < Q; i++) {
        cin >> B.at(i) >> C.at(i);
    }
    ll num = 0;
    for (pair<int, ll>p: m) {
        num += p.first * p.second;
    }
    for (int i = 0; i < Q; i++) {
        if (m.count(B.at(i))) {
            num += (C.at(i) - B.at(i)) * m[B.at(i)];
            if (!m.count(C.at(i))) {
                m[C.at(i)] = 0;
            }
            m[C.at(i)] += m[B.at(i)];
            m.erase(B.at(i));
        }
        cout << num << endl;
    }
}

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

int main(){
    string w,t;
    int ans = 0;
    cin >> w;
    for(int i=0; i<w.size(); i++){
        w[i] = toupper(w[i]);
    };
    while(true){
        cin >> t;
        if(t == "END_OF_TEXT"){
            break;
        };
        for(int i=0; i<t.size(); i++){
            t[i] = toupper(t[i]);
        };
        if(t == w){
            ans += 1;
        };
    };
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3184
fun main(args: Array<String>) {

    var (n, x) = readLine()!!.split(" ").map(String::toLong)
    val an = readLine()!!.split(" ").map(String::toLong)

    val sum = an.sum()
    val result = if (x > sum) {
        an.size - 1
    } else if (x == sum) {
        an.size
    } else {
        var c = 0
        for (num in an.sorted()) {
            if (x >= num) {
                c++
                x -= num
            } else {
                break
            }
        }
        c
    }
    println(result)
}





Measured memory_bytes: 37856
n = int(input())
s = list(str(input()))

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

ans = ""
for i in s:
  num = alpha2num(i)+n
  if num > 26:
    num -= 26
  ans += num2alpha(num)
print(ans)

Measured memory_bytes: 3188
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val k = readLong()

    if (s.all { it == '1' }) {
        out.println(1)
        return
    }

    val notOneIndex = s.indexOfFirst { it != '1' }
    val ans = if (k <= notOneIndex) {
        1
    } else {
        s[notOneIndex]
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int main(){

  int w,h,x,y,r;

  cin >> w >> h >> x >> y >> r;

  if(x - r < 0 || x + r > w || y - r < 0 || y + r > h) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0; 
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define ll long long
#define INF 20000000
#define INF2 2000000000000000000
 
using namespace std;

int main()
{
    IOS;
    int n;
    cin >> n;
    ll arr[n+1];
    ll pre[n+1];
    ll maxim[n+1];
    for(int i = 0; i <= n; i++)
        cin >> arr[i];
    maxim[0] = 1;
    for(int i = 0; i <= n; i++)
    {
        if(maxim[i] < arr[i])
        {
            cout << -1;
            return 0;
        }
        if(i == n)
            break;
        maxim[i+1] = min(INF2/2, (maxim[i] - arr[i])*2);
    }
    ll tot = 0;
    ll curr = arr[n];
    for(int i = n; i >= 0; i--)
    {
        if(curr > maxim[i])
            break;
        tot += curr;
        if(i == 0)
            break;
        ll nxgen = min(curr + arr[i-1], maxim[i-1]);
        if((curr/2) + (curr%2) + arr[i-1] > nxgen)
        {
            cout << -1;
            break;
        }
        curr = nxgen;
    }
    cout << tot << "\n";
}



Measured memory_bytes: 5172
<?php

$one = trim(fgets(STDIN));
$two = explode(' ', trim(fgets(STDIN)));

$max = 0;
$renzoku = 0;

$kijun = 0;
for ($i = 0; count($two) > $i; $i++) {

    if ($kijun >= $two[$i]) {
        $renzoku++;
    } else {
        $renzoku = 0;
    }
    $kijun = $two[$i];
//    for ($j = $i + 1; count($two) > $j; $j++){
////        echo $two[$j] . PHP_EOL;
//        if ($kijun >= $two[$j]) {
//            $kijun = $two[$j];
//            $renzoku++;
////            echo ':' . $renzoku . PHP_EOL;
//        } else {
//            break;
//        }
//    }

    if ($max < $renzoku) {
        $max = $renzoku;
    }

}

echo $max;

Measured memory_bytes: 14840
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public Hello(){}
    public static void Main(){
        new Hello().Calc();
    }
    void Calc(){
        var inputs = InputValue;
        foreach(var i in inputs){
            Console.WriteLine(i);
        }
    }
    string MakeRectangle(int h,int w){
        var temp = "";
        for(var y = 0;y < h;y++){
            for(var x = 0;x < w;x++){
                if((y == 0 || y == h - 1) || (x == 0 || x == w - 1)){
                    temp += "#";
                }else{
                    temp += ".";
                }
            }
            temp += "\n";
        }
        return temp;
    }
    List<string> InputValue{
        get{
            var inputs = new List<string>();
            
            while(true){
                var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if(line[0] == 0 && line[1] == 0){
                    break;
                }else{
                    inputs.Add(MakeRectangle(line[0],line[1]));
                }
                
            }
            return inputs;
        }
    }
}



Measured memory_bytes: 32060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K; int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    int DP[N]; fill(DP, DP+N, INT_MAX);
    DP[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K && i + j < N; j++){
            DP[i + j] = min(DP[i + j], DP[i] + abs(a[i] - a[i + j]));
        }
    }
    cout << DP[N-1];
}


Measured memory_bytes: 4404
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;

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

  cin >> A>> B;

  cout << 6-A-B << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		String s = scan.next();
		String[] Arrays = new String[s.length()];
		String ans = "";
		int count;
		
		
		for(int i = 0;i<s.length();i++){
			Arrays[i]= String.valueOf(s.charAt(i));
		}
		count = s.length()-2;
		ans = Arrays[0];
		ans = ans + String.valueOf(count);
		ans = ans + Arrays[s.length()-1];
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};

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

int N,M;

map<string,int> s2im;
int s2i(string a){
  if(s2im.count(a))
    return s2im[a];
  int sz=SZ(s2im);
  return s2im[a]=sz;
}

int in[200][200];
int g[200][200];

void solve(){
  rep(i,200)rep(j,200) g[i][j]=in[i][j]=9999+1;
  s2im.clear();
  rep(i,N) {
    string a,b;
    cin >> a;
    FOR(it,a) if(*it=='-') *it=' ';
    stringstream ss(a);
    ss >> a >> b;
    in[s2i(a)][s2i(b)]=1;
  }

  int n=SZ(s2im);
  rep(i,n)rep(j,n){
    bool ok=false;
    rep(k,n){
      if(in[i][k]==1 && in[j][k]==1) ok=true;
      if(in[i][k]==1 && in[k][j]==1) ok=true;
      if(in[k][i]==1 && in[j][k]==1) ok=true;
      if(in[k][i]==1 && in[k][j]==1) ok=true;
    }
    if(!ok) continue;
    ok=false;
    rep(k,n) if(in[k][i]==1 && in[j][k]==1) ok=true;
    if(ok) continue;
    rep(k,n) if(in[i][k]==1 && in[k][j]==1) ok=true;
    if(ok) continue;
    g[i][j]=g[j][i]=1;
  }
  
  rep(i,n)rep(j,n) g[i][j]=min(g[i][j],in[i][j]);
  rep(i,n)rep(j,n) if(in[i][j]==1) in[j][i]=1;


  
  rep(k,n)rep(i,n)rep(j,n){
    g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    in[i][j]=min(in[i][j],in[i][k]+in[k][j]);
  }
  

  cout << n << endl;
  cin >> M;
  rep(i, M){
    string a,b;
    cin >> a;
    FOR(it,a) if(*it=='-') *it=' ';
    stringstream ss(a);
    ss >> a >> b;
    int av=s2i(a);
    int bv=s2i(b);
    //cout << av << ' ' << bv << ' ' << g[av][bv] << ' ' << in[av][bv] << ' ' << in[bv][av] << endl;
    if(av<n && bv<n && g[av][bv]<9999 &&
       (in[av][bv]&1))cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

int main(int argc, char *argv[])
{
  while(cin >> N && N) solve();
  return 0;
}

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

int main()
{
    int N; cin >> N;

    auto values = vector<int>(3*N);
    for (auto& x : values) cin >> x;

    sort(begin(values), end(values));

    auto result = 0LL;
    for (auto i = N; i < 3*N; i += 2)
        result += values[i];
    cout << result << endl;
}


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

int main() {
    int N;
    cin >> N;
    map<long long, pair<long long, long long>> data;
    queue<long long> keep;
    for (long long i = 0; i < N; i++) {
        long long A;
        cin >> A;
        if (!data.count(i + 1 + A)) {
            data[i + 1 + A] = make_pair(1, 0);
            keep.push(i + 1 + A);
        }
        else {
            data.at(i + 1 + A).first++;
        }
        if (!data.count(i + 1 - A)) {
            data[i + 1 - A] = make_pair(0, 1);
            keep.push(i + 1 - A);
        }
        else {
            data.at(i + 1 - A).second++;
        }
    }
    long long ans = 0;
    while (!keep.empty()) {
        long long K = keep.front();
        keep.pop();
        ans += data.at(K).first * data.at(K).second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 29220
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;


class Solution{

public:
    bool isHaiku(vector<int>& lines){

        sort(lines.begin(), lines.end());
        return lines[0] == 5 && lines[1] == 5 && lines[2] == 7;
    }
};

int main() {

    vector<int> lines(3);
    for(int i = 0; i < 3; i ++)
        scanf("%d", &lines[i]);

    printf("%s\n", Solution().isHaiku(lines) ? "YES" : "NO");

    return 0;
}


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

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

  vector<string> a(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> a[i];

  int ac=0,wa=0,tle=0,re=0;
  rep(i,n) {
    if (a[i] == "AC") ac++;
    if (a[i] == "WA") wa++;
    if (a[i] == "TLE") tle++;
    if (a[i] == "RE") re++;
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 6336
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n,k;cin>>n>>k;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    while(n--)
    {
        ll a;cin>>a;
        pq.push(a);
    }
    ll ans=0;
    while(k--)
        ans+=pq.top(),pq.pop();
    cout<<ans<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    cin.tie(NULL);cout.tie(NULL);
//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3672
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	d := make([]int, 3)
	d[0] = next.Int()
	d[1] = next.Int()
	d[2] = next.Int()
	sort.Ints(d)

	fmt.Println(sum(d[:2]...))
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define debug(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);


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

inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
    x*=f;
    return x;
}

const int N = 100123;
int a[N];

int main(){
#ifdef LOCAL_DEFINE
    f_in
#else
    _
#endif
    int n = nxt();
    ll s = 0;
    ll ans = 0;
    map<ll, int> m;
    m[0] = 1;
    rep(i,0,n) s += nxt(), ans += m[s], m[s] ++;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n";
 #endif
}

Measured memory_bytes: 12928
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll dp[5005][5005];
// 数字iまで見たときに、iを絶対位置j番目に置くような場合の数

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll p[n];
    map <ll, int> pos;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        pos[p[i]] = i;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j] = dp[i-1][j];
            if (j < pos[i]) dp[i][j] += b;
            if (j > pos[i]) dp[i][j] += a;
            if (j) dp[i][j] = min(dp[i][j], dp[i][j-1]);
        }
    }

    cout << dp[n][n-1] << "\n";
    return 0;
}

Measured memory_bytes: 196096
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#ifdef ONLINE_JUDGE
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define dbg(v)
#else
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
#endif

// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int x;
    cin >> x;
    print(1 - x);

    return 0;
}

/*
  __ _   ___ _ __  _ __
 / _` | / __| '_ \| '_ \
| (_| || (__| |_) | |_) |
 \__,_(_)___| .__/| .__/
            |_|   |_|
*/


Measured memory_bytes: 3648