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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    ll total = 0;

    REP(i, N){
        cin >> A[i];
        total += A[i];
    }

    ll count = 0;
    REP(i, N){
        // cout << total/(4*M) << endl;
        if(A[i] > (total-1)/(4*M)) count++;
    }
    if(count >= M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REREASE
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
int main(){
    int N,M;
    cin>>N>>M;
    
    std::map<int, vector<int>> s;
    
    REP(i,M){
        int a,b;
        cin>>a>>b;
        s[a].push_back(b);
        s[b].push_back(a);
    }
    
    VECi(ll,w,N,INF);
    VECi(ll,h,N,INF);
    
    w[1]=0;
    vector<int> q={0,1};
    vector<bool> flag(N,false);
    REP(i,q.size()){
        s("size",q.size());
        REP(j,s[q[i]].size()){
            //s("j",s[q[i]][j-1]);
            if(w[q[i]]+1<w[s[q[i]][j-1]]){
                h[s[q[i]][j-1]]=q[i];
                w[s[q[i]][j-1]]=w[q[i]]+1;
            }
            if(!flag[s[q[i]][j-1]])q.push_back(s[q[i]][j-1]);//w[s[i][j-1]]=min(w[i]+1,w[s[i][j-1]]);
            flag[s[q[i]][j-1]]=true;
        }
        s(q.size());
        sl();
    }
    cout<<"Yes"<<endl;
    FOR(i,2,N)cout<<h[i]<<endl;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 17284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000000

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

	vector<int> spare(4,0);
	for(int i=0;i<n;i++){
		spare[a[i]%4]++;
	}

	bool ok=true;

	if(spare[1]+spare[3]>spare[0] && !(spare[1]+spare[3]==spare[0]+1 && spare[1]+spare[3]+spare[0]==n)){ok=false;}//oddが存在する時点でその数以上の4の倍数が必要(mod4が　1 0 1 0 1のようになる場合は例外)
	if(spare[0]==0 && spare[1]+spare[3]>=1){ok=false;}

	if(ok){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
	return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K =  inputIL()
S = list(input())


S[K-1] = S[K-1].lower()


print("".join(S))

Measured memory_bytes: 63980
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	double n,k,ans=0;
	cin >> n >> k;
	for(double i = 1; i <= n;i++){
		double tmp_ans = 1/n;
		double tmp_i = i;
		while(tmp_i<k){
			tmp_i *= 2;
			tmp_ans /=2;
		}
		ans += tmp_ans;
	}
	printf("%.15lf\n" ,ans);
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	bool ok = 0;
	while(n > 0)
	{
		if (n%10 == 7) ok = 1;
		n/=10;
	}
	if (ok) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3660
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	counter := make(map[string]int, 0)
	for i := 0; i < n; i++ {
		str := readString()
		counter[str]++
	}

	fmt.Println(len(counter))
}


Measured memory_bytes: 18304
#include <iostream>
#include <vector>
using namespace std;
vector<int> v[200005];
pair<int,int> dfs(int node,int p)
{
	pair<int,int> ans={-1,node};
	for (int u:v[node])
	{
		if (u!=p)
		ans=max(ans,dfs(u,node));
	}
	ans.first++;
	return ans;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	auto a=dfs(1,0),b=dfs(a.second,0);
	if (b.first%3==1)
	printf("Second");
	else
	printf("First");
}

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

int partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p-1;
	for (int j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}

int main(int argc, char *argv[]) {
	int n;
	int A[100002];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	int res = partition(A, 0, n-1);
	for (int i = 0; i < n; i++) {
		if (i) {
			printf(" ");
		}
		if (i == res) {
			printf("[");
		}
		printf("%d", A[i]);
		if (i == res) {
			printf("]");
		}
	}
	printf("\n");
	return 0;
}


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

#define IL inline 
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

bool ban[20];
IL bool check(int x) {
	while (x) {
		if (ban[x % 10]) return false;
		x /= 10;
	} return true;
}
int main() {

	int n = read(); int k = read();
	for (int i = 1; i <= k; ++i) {
		int t = read();
		ban[t] = 1;
	}

	for (int i = n; i <= 99999; ++i) if (check(i)) { cout << i << endl; break; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define llint long long
#define mod 1000000007

using namespace std;

int n;
llint dp[105][4][4][4];

int main(void)
{
	cin >> n;
	dp[0][3][3][3] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 4; k++){
				for(int l = 0; l < 4; l++){
					for(int m = 0; m < 4; m++){
						if(k == 0 && l == 1 && m == 2) continue;
						if(k == 1 && l == 0 && m == 2) continue;
						if(k == 0 && l == 2 && m == 1) continue;
						if(j == 0 && k == 1 && m == 2) continue;
						if(j == 0 && l == 1 && m == 2) continue;
						dp[i+1][k][l][m] += dp[i][j][k][l];
						dp[i+1][k][l][m] %= mod;
					}
				}
			}
		}
	}
	llint ans = 0;
	for(int j = 0; j < 4; j++){
		for(int k = 0; k < 4; k++){
			for(int l = 0; l < 4; l++){
				ans += dp[n][j][k][l];
				ans %= mod;
			}
		}
	}
	cout << ans <<endl;
	
	return 0;
}

Measured memory_bytes: 256
def power(n,p,m):
    if p == 0:
        return 1
    elif p%2:
        return (power(n,p-1,m)*n)%m
    else:
        return ((power(n,p//2,m))**2)%m

def choose(n,t,m):
    x, y = 1, 1
    for i in range(t):
        x = x * (n - i) % m
        y = y * (i + 1) % m
    return x * power(y,m-2,m) % m


m = 10**9+7
n,a,b = map(int,input().split())


flower = (power(2,n,m)-1) - choose(n,a,m) - choose(n,b,m)
while flower < 0:
    flower += m

print(flower)

Measured memory_bytes: 3064
import java.util.*;
import java.awt.geom.*;
public class Main {

	//0041 start
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		final int MAX = 1299709;
		boolean [] isprime = new boolean[MAX + 1];
		for(int i = 2; i <= MAX; i++){
			isprime[i] = true;
		}
		for(int i = 2; i * i <= MAX; i++){
			if(isprime[i]){
				for(int j = i * 2; j <= MAX; j+= i){
					isprime[j] = false;
				}
			}
		}
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int pre = n;
			int forward = n;
			while(true){
				if(isprime[pre--]) break;
			}
			pre++;
			while(true){
				if(isprime[forward++])break;
			}
			forward--;
			System.out.println(forward-pre);
		}
		
		
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 14000
import sys
from collections import defaultdict

input = sys.stdin.readline

S = list(input().strip())
count = defaultdict(int)
for c in S:
    count[c] += 1

kind = len(count.keys()) == 2
nums = all(freq == 2 for freq in count.values())
if kind and nums:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N;
vector<string> res;

void dfs(int cnt, int tot, string tmp)
{
	if(tmp.length() == N){
		if(cnt == tot){
			res.pb(tmp);
		}
		return;
	}
	for(int i=0;i<cnt;++i){
		tmp += i+'a';
		dfs(cnt, tot, tmp);
		tmp.pop_back();
	}
	if(cnt < tot){
		tmp += cnt+'a';
		dfs(cnt+1,tot,tmp);
	}
}

void helper(int x)
{
	if(x == 1) res.pb(string(N, 'a'));
	else if(x == N){
		string t;
		for(int i=0;i<N;++i) t += i+'a';
		res.pb(t);
	}else{
		dfs(0, x, "");
	}
}

void solve()
{
	for(int i=1;i<=N;++i) helper(i);
	const int n = res.size();
	set<string> ans;
	for(int i=0;i<n;++i) ans.emplace(res[i]);
	for(auto& s : ans){
		cout << s << '\n';
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
	return 0;
}


Measured memory_bytes: 14452
#include<cstdio>
#include <vector>
#include <utility>
#include <functional>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	unsigned A[N];
	for (int i = 0; i < N; ++i){
		scanf("%u", A + i);
	}
	sort(A, A + N);
	vector<pair<unsigned, unsigned> > B;
	for (int i = 0; i < M; ++i){
		unsigned tmp1, tmp2;
		scanf("%u %u", &tmp1, &tmp2);
		B.push_back(make_pair(tmp2, tmp1));
	}
	sort(B.begin() , B.end(), greater<pair<unsigned, unsigned> >());
	unsigned a_now = 0, b_now = 0;
	while(a_now < N && B[b_now].first > A[a_now]){
		unsigned i = 0;
		while(i < B[b_now].second && a_now < N && B[b_now].first > A[a_now]){
			A[a_now++] = B[b_now].first;
			i++;
		}
		if(i < B[b_now].second) break;
		b_now++;
	}
	ull ans = 0;
	for (int i = 0; i < N; ++i){
		ans += A[i];
	}
	printf("%llu\n", ans);
	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b * 2)
    cout << 0;
  else
    cout << a - b * 2;
  cout << endl;
}


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

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

using namespace std;

int main(){
  int x; cin >> x;
  if (x<1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i,c=0;
  char s[17],w[17]="CODEFESTIVAL2016";
  scanf("%s",s);
  for(i=0;i<16;i++){
    if(s[i]!=w[i])c++;
  }
  printf("%d\n",c);
  return 0;
}


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

int main(){
  int r,g,b,A,B;
  cin >> r >> g >> b;
  A=10*g+b;
  B=A%4;
  if(B==0){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}
    

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理
    int temp_s = s.size();
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());

    // 出力
    if (s.length() == temp_s) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    };

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  string s,t;cin>>s;int i,ans=100;char x;
  t=s;sort(ALL(t));
  REP(i,26){
    int S,j=0,c=0;x='a'+i;
    if(binary_search(ALL(t),x)){
      while(j<s.size()){
        S=j;
        while(j<s.size()&&s[j]!=x)j++;
        c=max(j-S,c);j++;
      }
      ans=min(c,ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
const int MAXN=200010;
using namespace std;
int n;
int a[MAXN];
vector<int> pos[MAXN];
#define all(c) (c).begin(), (c).end()
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 20; j++) {
			if (a[i] & (1 << j)) {
				pos[j].push_back(i);
			}
		}
	} 
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		int t = n - 1;
		for (int j = 0; j < 20; j++) {
			int g = lower_bound(all(pos[j]), i) - pos[j].begin();
			int gr;
			if (g + 1 >=pos[j].size()) {
				gr = n - 1;
			} else {
				gr = pos[j][g + 1] - 1;
			}
			t=min(t, gr);
		}
		sum += t - i + 1;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 13652
#150_D
from fractions import gcd
from functools import reduce
def lcm(x, y):
    return x * y // gcd(x, y)
n, m = map(int, input().split())
a = list(map(int, input().split()))
flg = True
cnt0 = 0
while a[0] % 2 == 0:
    a[0] //= 2
    cnt0 += 1

for i in range(1, n):
    cnti = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        cnti += 1
    
    if cnti != cnt0:
        flg = False
        break
        
lcm_a = reduce(lcm, a) * (2 ** (cnt0 - 1))
x = m // lcm_a
print(-(-x // 2) if flg else 0)

Measured memory_bytes: 16236
#include<iostream>
#include<string>
#include<cstdio>
#include<cassert>
using namespace std;
string S;
int cur=0;
int factor();
bool isdigit();
int number();
int term();
int expression();
int main(){
  int n;
  cin>>n;
  while(n--){
    cin>>S;
    cur=0;
    cout<<expression()<<endl;
  }
}

bool isdigit(){
  return '0'<=S[cur]&&S[cur]<='9';
}
int digit(){
  assert(isdigit());
  int ret=(int)(S[cur]-'0');
  cur++;
  return ret;
}
int number(){
  int ret=1;
  while(!isdigit()){
    ret=(S[cur]=='-')?-1:1;
    cur++;
  }
  ret*=digit();
  while(isdigit()){
    ret=ret*10+digit();
  }
  return ret;
}

int factor(){
  int ret=0;
  if(S[cur]=='('){
    cur++;
    ret=expression();
    cur++;//')'
  }else{
    ret=number();
  }
  return ret;
}
int term(){
  int ans=factor();
  while(cur<(int)S.size()-1&&S[cur]!='+'&&S[cur]!='-'&&S[cur]!=')'){
    char op=S[cur];
    cur++;
    int right=factor();
    //cout<<"TERMop=="<<op<<" "<<right<<endl;
    switch(op){
    case '*':
      ans*=right;
      break;
    case '/':
      ans/=right;
      break;
    default ://///
      break;
    } 
  }
  return ans;
}
int expression(){
  int ans=term();
  while(cur<(int)S.size()-1&&S[cur]!=')'){
    char op=S[cur];
    cur++;
    int right=term();
    //cout<<"EXop=="<<op<<" "<<right<<endl;
    switch(op){
    case '+':
      ans+=right;
      break;
    case '-':
      ans-=right;
      break;
    default ://///
      break;
    } 
  }
  return ans;
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
using namespace std;

int main(){
  int N, i=1;
  cin >> N ;
  int v;
  vector<int> ans;
  while(N){
    vector<int> vec(N);
    for(int i = 1; i <= N;i++){
      cin >> v;
      vec[i-1] = v;
      if(i == N){
        sort(vec.begin(),vec.end());
        ans.push_back((int)(accumulate(vec.begin()+1,vec.end()-1,0)/(N-2)));
      }
    }
    cin >> N;
  }
  for(int i  =0 ; i < (int)ans.size();i++){
    cout << ans[i] << endl;
  }
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int N,M; cin >> N >> M;
        if(N == 0 && M == 0) break;

        VI imos[M];
        VI exis[M];
        VI acc[M];
        REP(i,M) imos[i] = VI(1000,0);
        REP(i,M) exis[i] = VI(1000,0);
        REP(i,M) acc[i] = VI(1000,0);

        int r; cin >> r;
        REP(i,r){
            int t,n,m,s; cin >> t >> n >> m >> s;
            t -= 540;
            m--;
            if(s == 1){
                imos[m][t]++;
            }
            else{
                imos[m][t]--;
            }
        }

        REP(i,M){
            REP(j,1000){
                exis[i][j+1] = exis[i][j] + imos[i][j];
            }
            REP(j,1000){
                acc[i][j+1] = acc[i][j] + (exis[i][j] > 0 ? 1 : 0);
            }
        }
        int q; cin >> q;
        REP(i,q){
            int s,e,m; cin >> s >> e >> m;
            s -= 540; e-= 540;
            m--;
            cout << acc[m][e+1] - acc[m][s+1] << endl;
        }

        //REP(j,400){
            //cout << j+540 << " " << acc[0][j] << endl;
        //}
    }

}



Measured memory_bytes: 117656
n = int(input())
a = list(map(int, input().split()))
forward = [0] * n
backward = [0] * n
for i in range(n):
  if i + a[i] < n:
    forward[i + a[i]] += 1
  if i - a[i] >= 0:
    backward[i - a[i]] += 1
count = 0
for i in range(n):
  count += forward[i] * backward[i]
print(count)

Measured memory_bytes: 32208
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    long long a,b,c,x;
    cin >> a >> b >> c ;
    x = max({a,b,c}) ;
    if(x == a && x == b && x != c)
        cout << x*10 + c + b ;
    else if(x==a && x==c && x != b)
        cout << x*10 + b + a ;
    else if(x == c && x == b && x != a)
        cout << x*10 + c + a ;
    else if(x == a && x == b && x == c)
        cout << x*10 + a + b ;
    else if(x == a)
        cout << x*10 + c + b ;
    else if(x == b)
        cout << x*10 + a + c ;
    else if(x == c)
        cout << x*10 + a + b ;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

    int A, B, T;

    cin >> A >> B >> T;

    cout << T / A * B << endl;

    return 0;
}


Measured memory_bytes: 256
N,K,Q = list(map(int, input().split()))
c_nums = [int(input()) for i in range(Q)]
A_points = [K - Q for i in range(N)]
#print(A_points)
for i in c_nums:
  A_points[i-1] += 1

#print(A_points)
print('\n'.join(['Yes' if i > 0 else 'No' for i in A_points]))

Measured memory_bytes: 12188
import java.util.Scanner;

//Debt Hell
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = 100000;
		while(n--!=0){
			a+=a/20;
			int r=a%1000;
			if(r!=0)a+=1000-r;
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 12000
fun main(args : Array<String>) {
  val n = readLine()!!.toInt()
  readLine()!!.split(" ").map { it.toInt() }.apply {
    sorted().let { sort -> forEach { if (sort[n / 2 - 1] < it) println(sort[n / 2 - 1]) else println(sort[n / 2]) } }
  }
}

Measured memory_bytes: 98832
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vll vector<long long>
#define ll long long
#define pii pair<int,int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inputf.txt","r",stdin);
    freopen("outputf.txt","w",stdout);
#endif
    
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++){
    	sum=(sum+s[i]-'0')%9;
    }
    if(sum==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3728
import sys

n,m = map(int,input().split())
l = [-1] * n

for i in range(m):
    s,c = map(int,input().split())
    if l[s - 1] != -1:
        if l[s - 1] != c:
            print(-1)
            exit()
    l[s - 1] = c

if n==1:
    if l[0]==-1 or l[0]==0:
        print(0)
        exit()

if l[0] == 0:
    print(-1)
    exit()
elif l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0

for i in l:
    sys.stdout.write(str(i))
print("")

Measured memory_bytes: 38460
#include<cstdio>
#include<algorithm>
#include<bitset>
#define MN 2005
using namespace std;
int n,tt,ans[MN*MN];
bitset<MN*MN> f;
int main(){
	scanf("%d",&n);int x;f[0]=1;
	for(int i=1;i<=n;i++)scanf("%d",&x),f|=f<<x;
	for(int i=1;i<MN*MN;i++)if(f[i])ans[++tt]=i;
	printf("%d\n",ans[(tt+1)/2]);
}

Measured memory_bytes: 11392
#include <iostream>
using namespace std;
int main()
{
    int y,m,d;
    char s1,s2;
    cin >> y >> s1 >> m >> s2 >> d;
    
    if(m <= 4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    
    }
    
    return 0;
}

Measured memory_bytes: 256
import Data.List ( sortBy )

main :: IO ()
main = do
  n <- readLn :: IO Int
  ass <- map read . words <$> getLine :: IO [Int]
  print $ g n ass

sort' :: [Int] -> [Int]
sort' = sortBy (flip compare)

f :: Int -> [Int] -> [Int]
f n ass = take n $ h ass'
  where
    h :: [Int] -> [Int]
    h (a:b:bs) = b: h bs

    ass' = sort' ass

g n = sum . f n

Measured memory_bytes: 119164
#!/bin/bash

read tenki
len=${#tenki}
i=0
cnt=0
res=0

while [ $i -lt $len ]
do
	if [ "${tenki:$i:1}" == "R" ]
	then
		(( cnt += 1 ))
		(( res =  res > cnt ? res : cnt ))
	elif [ "${tenki:$i:1}" == "S" ]
	then 
		cnt=0
	fi

	(( ++i ))
done	
echo "$res"


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;

int main() {
	string s;
  	cin >> s;
  	set<char> ss;
  	int a = s.size();
  	rep(i,a) ss.insert(s[i]);
  	if(a == ss.size()) cout << "yes" << endl;
  	else cout << "no" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_taple
const int INF = 1 << 30;
using namespace std;

signed main() {
	int N, K;
	int h[100010];
	cin >> N >> K;
	rep(i, 0, N) cin >> h[i];
	sort(h, h+N);
	int ans = INF;
	for (int i = 0; i+K <= N; i++) {
		ans = min(ans, h[i+K-1] - h[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = 0;
		int minCount = 0;
		for (int i = 0; i < n; i++) {
			int count = 0;
			a = sc.nextInt();
			while(true) {
				if (count != 0) {
					a /= 2;
				}
				if (a % 2 != 0) {
					break;
				}
				count++;
			}
			if (i == 0) {
				minCount = count;
			} else if (count < minCount) {
				minCount = count;
			}
		}
		System.out.println(minCount);
	}

}


Measured memory_bytes: 23892
/*input
3
1000000000 1000000000 1000000000
*/
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define mpr make_pair
#define MX 1000000007
#define ui unsigned int
#define ll long long
#define ld long double
#define fi first
#define se second
#define testcases int testcases;cin>>testcases;while(testcases--)
#define printvector(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl
#define printarray(v,n)  for(int i=0;i<n;i++) cout<<v[i]<<" ";  cout<<endl
#define inputarray(v,n)  for(int i=0;i<n;i++)cin>>v[i]
#define debug(i) cout<<"debug: "<<i<<endl
#define pr(i) cout<<i<<endl
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


// class graph{
//     unordered_map<int,vector<int>> adjList;
//     int n;
// public:
//     graph(int n){
//         this->n = n;
//     }
//     void addEdge(int a, int b){
//         adjList[a].pb(b);
//     }
    
//     int dfs(int from, vector<int>&dp){
//         if(dp[from] != -1)return dp[from];
//         int mx = 0;
//         for(auto to : adjList[from]){
//             mx = max(mx, dfs(to,dp));
//         }
//         return dp[from] = 1 + mx;
//     }
// };

ll cal(vector<ll> &a, int n){
    vector<vector<ll>>dp(n,vector<ll>(n,0));
    vector<ll>prefix(n+1,0);
    for(int i=1;i<=n;++i)
        prefix[i] = prefix[i-1] + a[i-1];

    for(int l=2;l<=n;++l){
        for(int i=0;i<=n-l;++i){
            int j = i+l-1;
            if(l == 2){
                dp[i][j] = a[i] + a[j];
            }else{
                dp[i][j] = 2e18;
                for(int k=i;k<j;++k){
                    dp[i][j] = min(dp[i][j], (dp[i][k] + dp[k+1][j]) + prefix[j+1]-prefix[i]);
                }
            }

        }
    }
    return dp[0][n-1];
}



int main() {
    fast_io
    int n;
    cin>>n;
    vector<ll>a(n); inputarray(a,n);
    pr(cal(a,n));

}

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

int main(){
  double dp[1<<15][15];
  int prv[1<<15][15];
  int n;
  int num[15],pos[15],w[15],ans[15];

  cin >> n;
  for(int i=0;i<n;i++)cin >> num[i] >> pos[i] >> w[i];

  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++){
      dp[i][j] = 1e+10;
      prv[i][j] = -1;
    }
  }
  for(int i=0;i<n;i++){
    dp[(1<<i)][i] = (double)pos[i]*70/20000;
    prv[(1<<i)][i] = i;
  }

  for(int i=0;i<(1<<n);i++){
    int weight = 0;
    for(int j=0;j<n;j++){
      if( i &(1<<j) )weight += w[j];
    }
    for(int j=0;j<n;j++){
      if( i &(1<<j) ){
	int tmp = i-(1<<j);
     
	for(int k=0;k<n;k++){
	  if(tmp &(1<<k)){
	    double dis = abs(pos[k] - pos[j]);

	    double d = dp[tmp][k]+dis*(70+20*(weight-w[j]))/20000;
	    //cout << dp[tmp][k] << " " << d << endl;
	    if(dp[i][j]>d){
	      dp[i][j] = d;
	      prv[i][j] = k;
	    }
	  }
	}
      }
    }
  }
  /*
  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++)cout << dp[i][j] << " ";
    cout << endl;
  }
  */

  int a;
  double m = 1e+10;
  for(int i=0;i<n;i++){
    if(dp[(1<<n)-1][i]<m){
      m = dp[(1<<n)-1][i];
      a = i;
    }
  }
  int c = n-1;
  int p = (1<<n) - 1;
  
  while(p){
    //cout << a << endl;
    ans[c] = a;
    a = prv[p][a];
    p -= (1<<ans[c]);
    c--;
  }

  for(int i=0;i<n-1;i++)cout << num[ans[i]] << " ";
  cout << num[ans[n-1]] << endl;
 
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    string ans="UNRESTORABLE";
    rep(i,n-m+1){
        string u=s;
        bool flag=true;
        rep(j,m){
            if(u[i+j]=='?') u[i+j]=t[j];
            if(u[i+j]!=t[j]) flag=false;
        }
        if(!flag) continue;
        rep(j,n) if(u[j]=='?') u[j]='a';
        ans=u;
    }
    cout<<ans;
}

Measured memory_bytes: 3636
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        lst = 0
        for k in range(d):
            lst += (x[i][k]-x[j][k])**2
        if (lst)**(1/2)%1 == 0.0:
            cnt += 1
        else:
            cnt += 0
print(cnt)

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

struct segtree {
	vector<int> T;
	void init(vector<int> &A, int idx, int s, int e) {
		if(s == e) {
			T[idx] = A[s];
			return;
		}
		int m = s+e >> 1;
		init(A, idx*2, s, m);
		init(A, idx*2+1, m+1, e);
		T[idx] = max(T[idx*2], T[idx*2+1]);
	}
	int get(int idx, int s, int e, int l, int r) {
		if(e < l || r < s) return -1e9;
		if(l <= s && e <= r) return T[idx];
		int m = s+e >> 1;
		return max(get(idx*2, s, m, l, r), get(idx*2+1, m+1, e, l, r));
	}
};

int N, M, A[5009], B[5009][209];
ll PA[5009], ans;
segtree seg[509];

void dnc(int s, int e, int l, int r) {
	if(e < s) return;
	int m = s+e >> 1;
	vector<int> mx(M+1, 0);
	ll ret = -1, id = -1;
	for(int i=1; i<=M; i++) mx[i] = seg[i].get(1, 1, N, min(m, r), m);
	for(int i=min(m, r); i>=l; i--) {
		ll s = 0;
		for(int j=1; j<=M; j++) {
			mx[j] = max(mx[j], B[i][j]);
			s += mx[j];
		}
		if(ret < s - (PA[m-1] - PA[i-1])) ret = s - (PA[m-1] - PA[i-1]), id = i;
	}
	ans = max(ans, ret);
	if(ret == -1) return;
	dnc(s, m-1, l, id);
	dnc(m+1, e, id, r);
}

int main() {
	scanf("%d%d",&N,&M);
	for(int i=1; i<N; i++) {
		scanf("%d",&A[i]);
		PA[i] = PA[i-1] + A[i];
	}
	vector<int> S[509];
	for(int i=1; i<=M; i++) S[i].push_back(-1);
	for(int i=1; i<=N; i++) {
		for(int j=1; j<=M; j++) {
			scanf("%d",&B[i][j]);
			S[j].push_back(B[i][j]);
		}
	}
	for(int i=1; i<=M; i++) {
		seg[i].T.resize(N*4);
		seg[i].init(S[i], 1, 1, N);
	}

	dnc(1, N, 1, N);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 25600
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
if len(xi) == 1:
  d = xi[0]
print(abs(d))   

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-10;

int dp[110][100];

int main(){
	int n, k;
	cin>>n>>k;
	vi a(k), b(k);
	vi v(110, -1);
	rep(i, k) {
		cin>>a[i]>>b[i];
		b[i]--;
		v[a[i]] = b[i];
	}
	if(v[1]==-1){
		for(int i = 0; i < 3; i++){
			dp[1][i*3] = 1;
		}
	}
	else dp[1][v[1]*3] = 1;

	int past1, past2;
	for(int i = 2; i <= n; i++){
		if(i==2){
			for(int j = 0; j < 3; j++){
				past1 = j;
				if(v[i]!=-1){
					dp[i][v[i]*3+past1] += dp[i-1][j*3];
					dp[i][v[i]*3+past1] %= 10000;
				}
				else{
					for(int k = 0; k < 3; k++){	
						dp[i][k*3+past1] += dp[i-1][j*3];
						dp[i][k*3+past1] %= 10000;
					}
				}
			}
			continue;
		}

		for(int j = 0; j < 9; j++){
			past1 = j/3; past2 = j%3;
			if(v[i]!=-1){
				if((past1!=v[i]||past2!=v[i])){
					dp[i][v[i]*3+past1] += dp[i-1][j];
					dp[i][v[i]*3+past1] %= 10000;
				}
			}
			else{
				for(int k = 0; k < 3; k++){
					if((past1!=k||past2!=k)){
						dp[i][k*3+past1] += dp[i-1][j];
						dp[i][k*3+past1] %= 10000;
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 9; i++){
		ans += dp[n][i];
		ans %= 10000;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1240
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
ll A[MAX_N];

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

void solve()
{
  int ans = A[0];
  for (int i = 1; i < N; i++) {
    ans = gcd(ans, A[i]);
  }
  cout << ans << endl;
}

int main(void)
{
  cin >> N;
  REP(i, N) cin >> A[i];
  solve();
  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int P[200000];
int ma[20000];

int main() {
  CIN(int, N);
  REP(i, N) cin >> P[i];
  int m = numeric_limits<int>::max();
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    m = min(m, P[i]);
    if (m >= P[i]) ++ans;
  }
  COUT(ans);
}


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

def check_palindrome(n):
    n = str(n)
    for i, c in enumerate(n):
        if n[-1-i] == c:
            continue
        return False
    return True

ans = 0
for n in range(a, b+1):
    if check_palindrome(n):
        ans += 1
print(ans)


Measured memory_bytes: 2940
n, k = map(int, input().split())

lis = [0] * n

for i in range(k):
    num = int(input())
    dos = list(map(int, input().split()))
    for k in range(num):
        lis[dos[k]-1] += 1

count =0
for p in range(n):
    if lis[p] == 0:
        count += 1
        
print(count)

Measured memory_bytes: 9200
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  cout << ((a + b) % 2 == 0 ? "Alice" : "Borys") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 20;

string s[N];
int d[N][N];
int h,w;

void bfs(pii p){
	int _di[4]={1,-1,0,0}, _dj[4]={0,0,1,-1};
	rep(i,h) rep(j,w) d[i][j]=INF;
	d[p.first][p.second]=0;
    queue<pii> Q;
    Q.push(p);
    while(!Q.empty()){
        pii p1=Q.front();Q.pop();
        int i=p1.first,j=p1.second;
        rep(k,4) {
            int di=_di[k],dj=_dj[k];
            if(i+di<0||i+di>h-1||j+dj<0||j+dj>w-1) continue;
            if(s[i+di][j+dj]=='#') continue;
            if(d[i+di][j+dj]>d[i][j]+1){
                d[i+di][j+dj]=d[i][j]+1;
                Q.push(pii(i+di,j+dj));
            }
        }
    }
}

int main() {
	cin>>h>>w;
	rep(i,h) cin>>s[i];
	int ans=0;
	rep(i,h) rep(j,w) {
		if(s[i][j]=='#') continue;
		bfs(pii(i,j));
		rep(k,h) rep(l,w) if(s[k][l]=='.') ans=max(ans,d[k][l]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int a[105];
int b[105];
int c[105];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int i,ans=0;
        a[0]=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        //sort(a+1,a+n+1);
        for(i=n;i>=1;i--)
        {
            ans+=a[i];
            b[i]=ans;
        }
        for(i=1;i<=n;i++)
        {
            a[i]=a[i-1]+a[i];
        }
        for(i=1;i<n;i++)
        {
            c[i]=abs(a[i]-b[i+1]);
        }
        sort(c+1,c+n);
        printf("%d\n",c[1]);
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s[s.size()-1] == 's') s += "es";
  else s += 's';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include<iostream>
#include<cmath>
typedef long long ll;
const ll INF=1e10;

using namespace std;
int a[10];
int main() {
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x<=399)	a[1]++;
		else if(x<=799)	a[2]++;
		else if(x<=1199)	a[3]++;
		else if(x<=1599)	a[4]++;
		else if(x<=1999)	a[5]++;
		else if(x<=2399)	a[6]++;
		else if(x<=2799)	a[7]++;
		else if(x<=3199)	a[8]++;
		else a[9]++;
	}
	int ans=0;
	for(int i=1;i<=8;i++){
		if(a[i]!=0)	ans++;
	}
	//输出最小
	if(ans!=0){
		cout<<ans<<" ";
	}
	else cout<<"1"<<" ";
	//输出最大
	cout<<ans+a[9]<<endl;
	return 0;
}





Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
public class Main {
	int INF = 1 << 24;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int m = sc.nextInt();
			int [][] pass = new int[n][n];
			for(int i = 0; i < n; i++){
				Arrays.fill(pass[i], INF);
				pass[i][i] = 0;
			}
			for(int i = 0; i < m; i++){
				String [] s = sc.next().split(",");
				int from = Integer.parseInt(s[0]);
				int to = Integer.parseInt(s[1]);
				int cost = Integer.parseInt(s[2]) / 100 - 1;
				pass[from][to] = cost;
				pass[to][from] = cost;
			}

			int [] mincost = new int[n];
			boolean [] isused = new boolean[n];
			Arrays.fill(mincost, INF);
			mincost[0] = 0;
			int res = 0;
			while(true){
				int v = -1;
				for(int i = 0; i < n; i++){
					if(! isused[i] && (v == -1 || mincost[i] < mincost[v])){
						v = i;
					}
				}

				if(v == -1){
					break;
				}
				res += mincost[v];
				isused[v] = true;
				for(int i = 0; i < n; i++){
					mincost[i] = Math.min(mincost[i], pass[v][i]);
				}
			}
			System.out.println(res);
		}
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstring>
using namespace std;
int a[100005];
int n;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
    }
    long long maxx=2,minn=2;
    for(int i=n;i>=1&&maxx>=minn;i--){
        if(minn%a[i]!=0){
	       minn=(long long)(minn/a[i])*a[i]+a[i];
	    } 
        maxx=(long long)(maxx/a[i]+1)*a[i]-1;
    }
    if(maxx>=minn){
        printf("%lld %lld\n",minn,maxx);
    }
    else {
	   printf("-1\n");
   }

    return 0;
}


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

using namespace std;
typedef long long ll; 


int main(){
    //int num_mod[1000000000] = {0};
    map<int, int> num_mod;
    int n, m;
    cin >> n >> m;
    vector<int> sum;
    ll sum_mod = 0;
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        sum_mod += tmp;
        sum_mod %= m;
        sum.push_back(sum_mod);
        num_mod[(int)sum_mod]++;
    }

    ll ans = 0;
    ans += num_mod[0];
    for(int i = 0; i < n; i++)
    {
        num_mod[sum[i]]--;
        ans += num_mod[sum[i]];
    }
       

    cout << ans << endl;

}

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

int main()
{
  string a, b;
  cin >> a >> b;
  int n = a.length();
  int m = b.length();
  vector<vector<int>> dp(n + 1, vector<int> (m + 1));
  
  for(int i = 1; i <= n; i++)
  {
    for(int j = 1; j <= m; j++)
    {
      if(a[i - 1] == b[j - 1])
        dp[i][j] = 1 + dp[i - 1][j - 1];
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  string path = "";
  int i = n, j = m;
  while(i > 0 and j > 0)
  {
    if(a[i- 1] == b[j - 1])
    {
      path = a[i - 1] + path;
      i--;
      j--;
    }
    else if(dp[i][j] == dp[i][j - 1])
      j--;
    else 
      i--;     
  }
  cout << path;
        
 
  return 0;
}


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

typedef long long LL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e2 + 10;
double a[MAXN];

LL gcd(LL a, LL b)
{
	return b == 0 ? a : gcd(b, a % b);
}

LL qp(LL a, LL b)
{
	LL ans;
	for (ans = 1; b; b >>= 1, a = a * a % MOD)
		if (b & 1)
			ans = ans * a % MOD;
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	double ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		ans += 1.0 / a[i];
	}
	cout << 1 / ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A == 1 && B == 2){
        printf("3 \n");
    }
    else if(A == 2 && B == 1){
        printf("3 \n");
    }

    else if(A == 1 && B == 3){
        printf("2 \n");
    }
    else if(A == 3 && B == 1){
        printf("2 \n");
    }
 
    else if(A == 2 && B == 3){
        printf("1 \n");
    }
    else if(A == 3 && B == 2){
        printf("1 \n");
    }

    return 0;
}


Measured memory_bytes: 128
from collections import deque

N,K=map(int,input().split())
A=list(map(int,input().split()))
if A[0]==1:
    print(1)
    exit()
if K==1:
    print(A[0])
    exit()
for i in range(N):
    A[i]-=1


#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [0]*N
L = deque()
S[0]=1
L.append(1)
count=1
pos=A[0]

for i in range(N+1):
    
    if S[pos]==0:
        count+=1
        S[pos]=count
        L.append(pos+1)
        pos=A[pos]
        
    else:
        roopcount=count-S[pos]+1
        L.append(pos+1)
        break


if count>K:
    ans=L[K]

else:
    K=K-(count-roopcount)
    K=K%roopcount
    for i in range(count-roopcount):
        ret=L.popleft()
    ans=L[K]
    
print(ans)

Measured memory_bytes: 33868