akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A;
    int K;
    cin >> N >> K >> A;
    mint p = A;
    p /= 100;
    vec<mint> dp(K+1,0);
    mint n = N;
    mint invN = n.inv();
    for(int i=1;i<K;i++){
        if(i-N<=0) dp[i] += invN;
        int l = max(i-N,1);
        dp[i] += (dp[i-1]-dp[l-1])*p*invN;
//        cerr << dp[i] << "\n";
        if(i!=K-1) dp[i+1] += dp[i];
    }
    mint ans = 0;
    for(int i=max(K-N,0);i<K;i++){
        ll num = N-(K-i-1);
        if(i==0) ans += invN*num;
        else ans += (dp[i]-(i!=1? dp[i-1]:0))*num*invN*p;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3520
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	for(int x=0;x<9;x++){
		for(int i=0;i<9;i++){
			if(a[i] > a[i+1]){
				swap(a[i],a[i+1]);
			}
		}
		
	}
	cout<<a[9]<<endl;
	cout<<a[8]<<endl;
	cout<<a[7]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int S, W;
    cin >> S >> W;
    if(W >= S)cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
using namespace std;
int n,a[3],x,y;
string s,t;
vector<int> v;
int main(void){
    cin>>n>>a[0]>>a[1]>>a[2];
    cin>>s;
    for(int i=0;i<n;i++){
        if(i!=n-1)cin>>t;
        else t=s;
        x=s[0]-'A';
        y=s[1]-'A';
        if(a[x]==0&&a[y]==0){cout<<"No"<<endl;return 0;}
        else if(a[x]==0){a[x]++;a[y]--;v.push_back(x);}
        else if(a[y]==0){a[y]++;a[x]--;v.push_back(y);}
        else if(a[x]>a[y]){a[x]--;a[y]++;v.push_back(y);}
        else if(a[x]<a[y]){a[y]--;a[x]++;v.push_back(x);}
        else{
            if((t[0]-'A')==x||(t[1]-'A')==x){a[x]++;a[y]--;v.push_back(x);}
            else {a[x]--;a[y]++;v.push_back(y);}
        }
        s=t;
    }
    cout<<"Yes"<<endl;
    for(auto x:v){
        cout<<char(x+'A')<<endl;
    }
}


Measured memory_bytes: 3912
from math import pi,sqrt,sin,cos

def main():
    A,B,H,M = map(int,input().split())

    a,b = 2*pi*(H/12+M/(60*12)),2*pi*(M/60)


    ans = sqrt(A**2 + B**2 - 2*A*B*cos(a-b))
    print(ans)

if __name__ == "__main__":
    main()


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


int main() {
    int h,w; cin>>h>>w;
    char a[h][w];
    long long int dp[h][w];

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
           cin>>a[i][j];
        }
    }


   for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#')dp[i][j]=0;
            else if(i==0&&j==0)dp[i][j]=1;
            else if(i==0)dp[i][j]=dp[i][j-1]%1000000007;
            else if(j==0)dp[i][j]=dp[i-1][j]%1000000007;
            
            else dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;//左からと上から
          
        }
    }

    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
class Saikoro:

    def sai(self,one,two,three,four,five,six):
        self.s1=int(one)
        self.s2=int(two)
        self.s3=int(three)
        self.s4=int(four)
        self.s5=int(five)
        self.s6=int(six)

    def turnE(self):
        e=[self.s4,self.s2,self.s1,self.s6,self.s5,self.s3]
        self.s1=e[0]
        self.s2=e[1]
        self.s3=e[2]
        self.s4=e[3]
        self.s5=e[4]
        self.s6=e[5]

    def turnN(self):
        n=[self.s2,self.s6,self.s3,self.s4,self.s1,self.s5]
        self.s1=n[0]
        self.s2=n[1]
        self.s3=n[2]
        self.s4=n[3]
        self.s5=n[4]
        self.s6=n[5]


l=input().split()

sai1=Saikoro()
sai1.sai(l[0],l[1],l[2],l[3],l[4],l[5])

q=int(input())

i=0
Ans=[]
while i<q:
    m=input().split()
    ichi=int(m[0])
    ni=int(m[1])
    sai1.sai(l[0],l[1],l[2],l[3],l[4],l[5])
    p=0
    while p<4:
        if ichi==int(l[0]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[5]) or ichi==int(l[5]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[0]) :
            Ans.append(int(l[4]))
            break
        elif ichi==int(l[5]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[0]) or ichi==int(l[0]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[5]) :
            Ans.append(int(l[1]))
            break
        w=0
        sai1.turnE()
        while w<4:
            sai1.turnN()
            if sai1.s1==ichi and sai1.s2==ni:
                Ans.append(sai1.s3)
                break
            else:
                pass
            w+=1
        p+=1
    i+=1

for A in Ans:
    print(A)



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  //mint(ll x = 0):x((x%mod+mod)%mod) {} // for minus
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(1);
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  
  //for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
bool operator==(const mint& a, const mint& b){
  return a.x == b.x;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 2000005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  mint S(0);
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
    S += a;
  }

  mint ret(0);
  rep(i,N){
    S -= v[i];
    ret += S * v[i];
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 35480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif
 
const int mod = 1e9 + 7;
 
ll pw(ll a, ll x) {
    if (x == 0) return 1;
    if (x % 2 == 0) {
        ll t = pw(a, x / 2);
        return (t * t) % mod;
    }
    return (a * pw(a, x - 1)) % mod;
}

ll inv(ll a) {
    return pw(a, mod-2);
}

int main() {
    int n;
    cin >> n;
    vector<ll> C(n);
    for (int i=0; i<n; ++i) cin >> C[i];
    sort(C.begin(), C.end());
 
    ll cost = 0;
    for (int i=0; i<n; ++i) {
        ll m = n-i-1;
 
        ll t1 = pw(2, n-1);
        ll t2 = pw(2, n-1);
        (t2 *= m) %= mod;
        (t2 *= inv(2)) %= mod;
        ll k = (t1 + t2) % mod;
        (k *= pw(2, n)) %= mod;
 
        ll add = (C[i] * k) % mod;
        (cost += add) %= mod;
    }
    cout << cost << endl;
 
    return 0;
}

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

int main () {
    string S;
    cin >> S;

    int i = 0;
    bool b = true;

    while (i < S.size()) {
        if (i%2 == 0 && S.at(i) == 'L') {
            b = false;
            break;
        }
        else if (i%2 == 1 && S.at(i) == 'R'){
            b = false;
            break;
        }
        i++;
    }

    if (b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int main(void)
{
    int i;
    int num, x, y;
    int p1 = 0;
    int p2 = 0;

    for (;;) {
        scanf("%d", &num);
        if (num == 0) {
            break;
        }

        for (i = 0; i < num; i++) {
            scanf("%d %d", &x, &y);
            if (x > y) {
                p1 += (x+y);
            }
            else if (x < y) {
                p2 += (x+y);
            }
            else {
                p1 += x;
                p2 += y;
            }
        }
        printf("%d %d\n", p1, p2);
        p1 = p2 = 0;
    }

    return 0;
}

Measured memory_bytes: 1188
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("in.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
#endif 
}

int N,W;
int w[100],v[100];
int memo[100][100000];


int solve(int i, int x){
	if(x>W) return -INF;
	if(i==N) return 0;
	if(memo[i][x]!=-1) return memo[i][x]; 
	return memo[i][x]=max(solve(i+1,x+w[i])+v[i],solve(i+1,x));
}

int32_t main(){
   boost;
   IO();
   memset(memo,-1,sizeof(memo));
   cin>>N>>W;
   for(int i=0; i<N; i++) cin>>w[i]>>v[i];
   cout << solve(0,0) << endl;   

   return 0;
}



Measured memory_bytes: 81748
#include<iostream>

using namespace std;

int max(int ,int );

int main(void){
  int min,x=0;
  int e;
  cin >> e;
 
  while(e!=0){
    min=e;
    for(int z=0;z*z*z<=e;z++){
      for(int y=0;y*y <= e-z*z*z ;y++){
	x = e - z*z*z - y*y;
	if(x+y+z<min) min = x+y+z;
      }
    }
      
    cout << min << endl;
    cin >> e;
  }
  return 0;
}

Measured memory_bytes: 3076
import itertools
import math
N = input()
l = list(map(int,input().split(" ")))
av = sum(l)/len(l)
can1 = int(math.ceil(av))
can2 = int(math.floor(av))
ans1 = sum(list(map(lambda x:(x-can1)**2,l)))
ans2 = sum(list(map(lambda x:(x-can2)**2,l)))
print(min(ans2,ans1))

Measured memory_bytes: 38512
N = int(input())
S = input()

AL = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 
      'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
L = [0 for i in range(len(S))]
for i in range(len(S)):
  for j in range(26):
    if S[i] == AL[j]:
      L[i] = j
for i in range(len(L)):
  L[i] = (L[i] + N) % 26
NS = ''
for i in range(len(L)):
  NS = NS[:] + AL[L[i]]
print(NS)

Measured memory_bytes: 3188
//
// ABC163A
// URL : https://atcoder.jp/contests/abc162/tasks/abc163_a
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC163A
    {
        static void Main(string[] args)
        {
            preprocess();


            // 整数の入力
            long r = long.Parse(Console.ReadLine());

            var ans = r * 2 * Math.PI;

            Console.WriteLine(ans.ToString());
            Console.Out.Flush();
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }

        static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static long Lcm(long m, long n)
        {
            var gcd = Gcd(m, n);
            //return (m * n) / gcd;
            return m / gcd * n;//桁あふれ対策
        }
    }
}



Measured memory_bytes: 27596
#include<stdio.h>
int main(void){
int i,j,n,m,tem,sum;
int p[1001];

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

//for(i=0;i<n;i++) printf("%d ",p[i]);
//puts("");

if(n>=m){
for(i=0;i<n;i++){
for(j=0;j<n-i-1;j++){
if(p[j]<p[j+1]){
tem=p[j];
p[j]=p[j+1];
p[j+1]=tem;
}
}
}

//for(i=0;i<n;i++) printf("%d ",p[i]);

for(i=0;i<n;i++){
if((i%m)!=(m-1)) sum+=p[i];
}
} else {
for(i=0;i<n;i++) sum+=p[i];
}
printf("%d\n",sum);
}
return 0;
}

Measured memory_bytes: 604
n = int(input())
s = input()

ans = 0

for i in range(1000):
    ss = str(i).zfill(3)
    if (ss[0] in s):
        ind1 = s.index(ss[0])
        if (ss[1] in s[ind1+1:]):
            ind2 = ind1+1 + s[ind1+1:].index(ss[1])
            if (ss[2] in s[ind2+1:]):
                ans += 1

print(ans)

Measured memory_bytes: 3064
//abc165_c.cpp
//Sun May 24 22:06:33 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int n,m,q;
int x[10];
int a[50],b[50],c[50],d[50];
int ans;

void dfs(int ind, int used){
	if (ind==n){
		int tmpans = 0;
		for (int i=0;i<q;i++){
			if (x[b[i]]-x[a[i]]==c[i]){
				tmpans += d[i];
			}
		}
		// for (int i=0;i<n;i++){
			// cout << x[i] << " ";
		// }
		ans = max(ans,tmpans);
		// cout << tmpans << endl;
	}else {
		for (int i=0;i<=m-1-used;i++){
			x[ind] = x[ind-1]+i;
			dfs(ind+1,used+i);
		}
	}
}

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

	fill(x,x+n,0);

	for (int i=0;i<q;i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}

	ans = 0;
	for (int i=1;i<=m;i++){
		x[0] = i;
		dfs(1,i-1);
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3604
# B - 美しい文字列
def main():
    import collections

    w = input()

    w_c = collections.Counter(w)

    for v in w_c.values():
        if v % 2 != 0:
            print('No')
            exit()
    else:
        print('Yes')
        

    
if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9276
#include<cstdio>
#include<iostream>

using namespace std;

#define HMAX 20
#define WMAX 20

char room[HMAX+5][WMAX+5];
int W,H;

typedef struct{
	int x;
	int y;
}map;

int solve(int x,int y){
	int dx[4]={ 0, 0, 1,-1};
	int dy[4]={ 1,-1, 0, 0};
	int cnt=0;

	room[y][x]='#';
	
	for(int i=0;i<4;i++){
		if(x+dx[i]>=0&&x+dx[i]<W&&y+dy[i]>=0&&y+dy[i]<H){
			if(room[y+dy[i]][x+dx[i]]=='.'){
				cnt+=solve(x+dx[i],y+dy[i]);
			}
		}
	}

	return cnt+1;
}

int main(void){

	map start;

	while(1){
		cin>>W>>H;
		if(W==0&&H==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>room[i][j];
				if(room[i][j]=='@') start.x=j,start.y=i;
			}
		}
		cout<<solve(start.x,start.y)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
N = int(input())
nowt = 0
nowx = 0
nowy = 0
for i in range(N):
  t, x, y = map(int, input().split())
  ti = t - nowt
  xi = x - nowx
  yi = y - nowy
  if ti < abs(xi) + abs(yi):
    print('No')
    exit()
  if ti%2 != (xi+yi)%2:
    print('No')
    exit()
  nowt = t
  nowx = x
  nowy = y
    
print('Yes')


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 100;
int N,D;

int A[maxn][maxn];

int cal(int x1,int x2){
    int ret = 0;
    _for(i,0,D){
        ret += (A[x1][i] - A[x2][i])*(A[x1][i] - A[x2][i]);
    }
    return ret;
}

int is_per(int k){
    int nn = (sqrt(k)+ 0.1);
    if(nn*nn == k) return true;
    return false;
}

int main()
{
    cin >> N >> D;
    _for(i,0,N){
        _for(j,0,D){
            cin >> A[i][j];
        }
    }

    int ans = 0;
    _for(i,0,N){
        _for(j,i+1,N){
            int k = cal(i,j);
            if(is_per(k)) ans++;
        }
    }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Integer[] L = new Integer[N];
        for (int i = 0; i < N; ++i) {
            L[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(L, Collections.reverseOrder());
        int ans = 0;
        for (int i = 0; i < K; ++i) {
            ans += L[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <deque>
#include <cassert>
using namespace std;

int N,M;
vector<int> A(110);
deque<int> resA,resB;

int main(){
    cin >> N >> M;
    int cnt = 0;
    vector<int> odd;    
    for(int i=1;i<=M;i++){
        cin >> A[i];
        if(A[i]%2==1){
            cnt++;
            odd.push_back(A[i]);
        }
    }
    if(cnt>=3){
        cout << "Impossible" << endl;
        return 0;
    }
    if(M==1){
        resA.push_back(A[1]);
        if(A[1]%2==1){
            resB.push_back(1);
            for(int i=3;i<=N;i+=2) resB.push_back(2);
        }else{
            if(N%4==0){
                resB.push_back(1);
                for(int i=3;i<=N/2-1;i+=2) resB.push_back(2);
                resB.push_back(1);
                for(int i=N/2;i<N;i+=2) resB.push_back(2);
            }else{
                resB.push_back(1);
                for(int i=3;i<=N/2;i+=2) resB.push_back(2);
                resB.push_back(1);
                for(int i=N/2+1;i<N;i+=2) resB.push_back(2);
            }
        }
    }else{
        if(odd.size()!=0){
            resA.push_back(odd.back());
            odd.pop_back();
        }
        for(int i=1;i<=M;i++) if(A[i]%2==0) resA.push_back(A[i]);
        if(odd.size()!=0){
            resA.push_back(odd.back());
        }
        int n = resA.size();
        for(int i=0;i<n;i++){
            if(i==0 && resA[i]!=1) resB.push_back(resA[i]-1);
            else if(i==n-1) resB.push_back(resA[i]+1);
            else if(i!=0 && i!=n-1) resB.push_back(resA[i]); 
        }
    }
    for(auto& x:resA) cout << x << " ";
    cout << endl;
    cout << resB.size() << endl;
    int sum = 0;
    for(auto& x:resB){
        cout << x << " ";
        sum += x;
    }
    cout << endl;
    assert(N==sum);
}

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

int main(){
	int a, b, c;
	int n = 0;
	cin >> a >> b >> c;
	for (int i = a; i < b + 1; i++){
		if (c % i == 0){
			n++;
		}
	}
	cout << n << endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] li = new int[3];
		li[0] = sc.nextInt();
		li[1] = sc.nextInt();
		li[2] = sc.nextInt();
		Arrays.sort(li);
		int i = (li[2] - li[1]) + (li[1] - li[0]);
		System.out.println(i);
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                //ios_base::sync_with_stdio(false);
                //cin.tie(NULL);
                lli t,n,i,j,b,a,q,m;
                string s1,s2;
                cin>>s1>>s2;
                for(i=0;i<s1.length();i++){
                    if(s1[i]!=s2[i]){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
                cout<<"Yes"<<endl;

            }



Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B; cin >> A >> B;
    vector<int> v={A, A-1, B, B-1};
    sort(v.begin(), v.end(),greater<int>());
    
    cout << v[0]+v[1] << endl;
    
    return 0;
}

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

int a[3], b[3];
long d[33333333];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	for (int i = 0; i < 3; i++)
		cin >> b[i];
	iota(d, d + n + 1, 0);
	for (int i = 0; i < 3; i++)
		for (int k = a[i]; k <= n; k++)
			d[k] = max(d[k], d[k - a[i]] + b[i]);
	n = d[n];
	iota(d, d + n + 1, 0);
	for (int i = 0; i < 3; i++)
		for (int k = b[i]; k <= n; k++)
			d[k] = max(d[k], d[k - b[i]] + a[i]);
	cout << d[n] << endl;
	return 0;
}


Measured memory_bytes: 196864
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  
  ll ans=INF;
  for(ll i=0;i<=2*max(x,y);i+=2){
    ll cost=0;
    cost+=c*i;
    cost=cost+max(0ll,x-i/2)*a+max(0ll,y-i/2)*b;
    ans=min(ans,cost);  
   
  }
  cout << ans << endl; 
}


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

int main(){
    string s;
    cin >> s;
    if( s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    if( (s[1] >= 'A') && (s[1] <= 'Z')) {
        cout << "WA" << endl;
        return 0;
    }

    bool found=false;
    bool upper=false;
    for(int i=2; i<s.length()-1; i++){
        if(s[i] == 'C'){
            if( found==false ) found=true;
            else{
                cout << "WA" << endl;
                return 0;
            }
        }else{
            if( (s[1] >= 'A') && (s[1] <= 'Z')) {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    if( found== false ){
        cout << "WA" << endl;
        return 0;
    }
    if( (s[s.length()-1] >= 'A') && (s[s.length()-1] <= 'Z')) {
        cout << "WA" << endl;
        return 0;
    }

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


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

int digit_sum (int num) {
    int ans = 0;
    while (num > 0) {
        ans += num % 10;
        num = num / 10;
    }
    return ans;
}

int main() {
    int A, B, C;
    long long K;
    cin >> A >> B >> C >> K;
    
    if (K % 2 == 0) {
        cout << A - B << endl;
    } else {
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct N {
  int i;
  ll pen, cor;
  ll v[10];
};
bool operator<(const N &l, const N &r) {
  if (l.cor == r.cor) {
    if (l.pen == r.pen)
      return l.i < r.i;
    return l.pen < r.pen;
  }
  return l.cor > r.cor;
}

int main() {
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if (t == 0)
      break;
    vector<N> teams(t);
    for (int i = 0; i < t; i++)
      teams[i].i = i;
    for (int i = 0; i < r; i++) {
      int tid, pid, time;
      string s;
      cin >> tid >> pid >> time >> s;
      tid--;
      pid--;
      if (s == "CORRECT" && teams[tid].v[pid] >= 0) {
        teams[tid].cor++;
        teams[tid].pen += time + teams[tid].v[pid] * 1200;
        teams[tid].v[pid] = -1;
      }
      if (s == "WRONG" && teams[tid].v[pid] >= 0) {
        teams[tid].v[pid]++;
      }
    }
    sort(teams.begin(), teams.end());
    for (int i = 0; i < t; i++)
      cout << teams[i].i + 1 << " " << teams[i].cor << " " << teams[i].pen
           << endl;
  }
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h.at(i);
  
  vector<int> cost(n, INT_MAX);
  cost.at(0) = 0;
  cost.at(1) = abs(h.at(1)-h.at(0));
  for(int i = 2; i < n; i++){
    for(int j = 1; j <= k && i-j>=0; j++){
      cost.at(i) = min(cost.at(i), cost.at(i-j)+abs(h.at(i)-h.at(i-j)));
    }
  }
  cout << cost.at(n-1) << endl;
}

Measured memory_bytes: 4028
import itertools

s = input().split()[0]

start_index = 0

sum_list = []

# 0のとき
sum_list.append(int(s))

# 0以外のとき
for spliter_n in range(1, len(s)):
	# print('spliter_n: {}'.format(spliter_n))

	comb_list = list(itertools.combinations(list(range(0, len(s)-1)), spliter_n))
	# print('comb_list: {}'.format(comb_list))
	
	for comb_set in comb_list:
		s_copy = s
		number_list = []
		comb_set_list = list(comb_set)
		comb_set_list = [-1] + comb_set_list
		# print('comb_set_list: {}'.format(comb_set_list))

		for i, a in enumerate(comb_set_list):

			if a == comb_set_list[-1]:
				# 最後の要素だったら
				s_i = comb_set_list[i]+1
				number_list.append(s[s_i:])
				
			else:
				# 最後の要素じゃなかったら
				s_i, e_i = comb_set_list[i]+1, comb_set_list[i+1]+1
				number_list.append(s[s_i:e_i])

		debug_text = (' + ').join(number_list)
		# print('debug_text = {}'.format(debug_text))

		number_list = [int(x) for x in number_list]
		# print(number_list)
		sum_list.append(sum(number_list))
	# print('------------')

# print(sum_list)
answer = sum(sum_list)
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

int N;
vector<int> p;
vector<set<int>> ip;

bool check(const vector<int> &res) {
    for (int i = 0; i + 1 < res.size(); ++i) {
        if (res[i+1] == p[res[i]]) return false;
    }
    return true;
}

void last(vector<int> &res, vector<int> &rem) {
    do {
        if (res.size() > 0 && rem[0] == p[res.back()]) continue;
        if (check(rem)) {
            for (int i = 0; i < res.size(); ++i) cout << res[i] + 1 << " ";
            for (int i = 0; i < rem.size(); ++i) cout << rem[i] + 1 << " ";
            cout << endl;
            return;
        }
    } while (next_permutation(rem.begin(), rem.end()));

    cout << -1 << endl;
    return;
}

const int NOKORI = 5;
void solve() {
    if (N <= NOKORI) {
        vector<int> res, rem(N);
        for (int i = 0; i < N; ++i) rem[i] = i;
        last(res, rem);
        return;
    }

    vector<int> res;
    set<int> rem;
    for (int i = 0; i < N; ++i) rem.insert(i);
    while (N - (int)res.size() > NOKORI) {
        int dame = -1;
        if (res.size() > 0) dame = p[res.back()];

        // とりあえず Greedy に
        int ne = -1;
        for (auto it : rem) {
            if (it == dame) continue;
            ne = it;
            break;
        }

        // ne を選んでしまうと詰むときは取り替える
        if (ip[p[ne]].size() + res.size() == N-1) {
            ne = p[ne];
        }

        // ne を選ぶ
        res.push_back(ne);
        rem.erase(ne);
        ip[p[ne]].erase(ne);
    }
    vector<int> vrem;
    for (int i = 0; i < N; ++i) if (rem.count(i)) vrem.push_back(i);
    last(res, vrem);
}

int main() {
    while (cin >> N) {
        p.resize(N);
        ip.assign(N, set<int>());
        for (int i = 0; i < N; ++i) {
            cin >> p[i];
            --p[i];
            ip[p[i]].insert(i);
        }
        solve();
    }
}


















Measured memory_bytes: 15232
#include<bits/stdc++.h>
#define rep(i,n) for(int i=1; i<=n; i++)
using namespace std;
int main(){
  int n,l,r;
  while(cin >> n >> l >> r,n){
    int count=0;
    int a[51];
    a[0] = 0;
    rep(i,n) cin >> a[i];
    for(int x=l; x<=r; x++){
      bool flag=false;
      rep(i,n){
        if(x%a[i] == 0){
          flag = true;
          if(i%2 != 0) {
            count++;
          }
          break;
        }
      }
      if(flag == false && n%2 == 0) count++;
    }
    cout << count << endl;
  }
  return 0;
}




Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <deque>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

int main(void){
  char a,b;
  cin>>a>>b;
  if(a==b) cout<<"H"<<endl;
  else cout<<"D"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
g = [[] for i in range(n+1)] #隣接リスト
for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

visited = [False] * (n+1)
visited[0] = True
visited[1] = True
cnt = 0

def dfs(list):
    global cnt
    if not False in visited:
        cnt += 1
        return
    for i in list:
        if visited[i] == False:
            visited[i] = True
            dfs(g[i])
            visited[i] = False

dfs(g[1])
print(cnt)


Measured memory_bytes: 73092
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int n, m;
	ll k;

	cin >> n >> m >> k;

	vector<ll> a(n + 3);
	vector<ll> b(m + 3);

	int co = 0;
	int ans = 0;

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

	a[n] = 1000000005;
	b[m] = 1000000005;

	ll a_c = 0;
	ll b_c = 0;

	while(1){
		if (a[a_c] > k) {
			break;
		}
		else {
			k -= a[a_c];
			a_c++;
			co++;
		}
	}

	ans = co;

	while (1) {
		if (b[b_c] > k) {
			break;
		}
		else {
			k -= b[b_c];
			b_c++;
			ans++;
		}
	}

	int h = ans;

	for (int i = 0; i < co;i++) {
		a_c--;
		ans--;
		k += a[a_c];
		
		while (1) {
			if (b[b_c] > k) {
				break;
			}
			else {
				k -= b[b_c];
				b_c++;
				ans++;
			}
		}

		if (h < ans) {
			h = ans;
		}

	}
	
	cout << h << endl;

	return 0;
}

Measured memory_bytes: 6404
//kruskal tree
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define M 99999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	double s=0;
	int i,n,m;
	scanf("%d%d",&n,&m);
	vector<pair<double,double> >v(n);
	for(i=0;i<n;i++)scanf("%lf%lf",&v[i].first,&v[i].second);
	for(i=0;i<m;i++){
		int x,y;
		scanf("%d%d",&x,&y),x--,y--;
		a[i]=x,b[i]=y;
		node[i].first=-hypot(v[x].first-v[y].first,v[x].second-v[y].second);
		s-=node[i].first;
		node[i].second=i;
	}
	sort(node,node+m);
	for(i=0;i<n;i++)parent[i]=i;
	for(i=0;i<m;i++)if(unite(a[node[i].second],b[node[i].second]))s+=node[i].first;
	printf("%f\n",s);
}

Measured memory_bytes: 2940
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

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

const int mod=1000000007;

int fac[8010],inv[8010];
int a[4010][4010],b[4010][4010];

int power(int x,int y)
{
	int t=1;
	while (y)
	{
		if (y&1) t=ll(t)*x%mod;
		x=ll(x)*x%mod;y>>=1;
	}
	return t;
}

int c(int x,int y)
{
	return ll(fac[x+y])*inv[x]%mod*inv[y]%mod;
}

int main()
{
	int n;scanf("%d",&n);
	int ans=0;
	fac[0]=1;for (int i=1;i<=8000;i++) fac[i]=ll(fac[i-1])*i%mod;
	inv[8000]=power(fac[8000],mod-2);
	for (int i=8000;i;i--) inv[i-1]=ll(inv[i])*i%mod;
	for (int i=1;i<=n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ans=(ans-c(x+x,y+y)+mod)%mod;
		a[2000-x][2000-y]++;
		b[x+2000][y+2000]++;
	}
	for (int i=0;i<=4000;i++)
		for (int j=0;j<=4000;j++)
		{
			if (i>0) a[i][j]=(a[i-1][j]+a[i][j])%mod;
			if (j>0) a[i][j]=(a[i][j-1]+a[i][j])%mod;
			if (b[i][j]) ans=(ll(b[i][j])*a[i][j]+ans)%mod;
		}
	ans=ll(ans)*power(2,mod-2)%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 86272
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      int result = b >= a ? a : a - 1;

      System.out.println(result);
    }
  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}



int main(void) {

	int n;
	cin >> n;

	int count = 0,bh = 0;

	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		if (bh <= h)
			count++;
		CHMAX(bh, h);
	}

	COUT(count);

	return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
st={}
ts={}
for i in range(len(s)):
    if s[i] in st:
        if st[s[i]]!=t[i]:
            print("No")
            break
    else:
        st[s[i]]=t[i]
    if t[i] in ts:
        if ts[t[i]]!=s[i]:
            print("No")
            break
    else:
        ts[t[i]]=s[i]
    if i==len(s)-1:
        print("Yes")

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

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

  if (N / 500 == 0) {
    cout << "Yes";
  } 
  
  else {
    if ((N % 500) > A) {
      cout << "No";
    } else {
      cout << "Yes";
    }
  }
  
    
}

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

def main():
	N, M = map(int, input().split(" "))
	
	if N - M >= 2 or M - N >= 2:
		print(0)
		sys.exit()
		
	A_ans = 1
	for i in range(1, M+1):
		A_ans = (A_ans * i) % 1000000007
		
	B_ans = 1
	for i in range(1, N+1):
		B_ans = (B_ans * i) % 1000000007
	
	ans = (A_ans * B_ans) % 1000000007
	if N == M:
		ans = (ans * 2) % 1000000007
		
	print(ans)
		
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3064
#include<iostream>
#include<bitset>
using namespace std;
int main(){
  int n;
  
  cin >> n;
  int A[20], x[20][20], y[20][20];
  for (int i = 0; i < n; i++)
  {
    cin >> A[i];
    for (int j = 0; j < A[i];j++){
      cin >> x[i][j] >> y[i][j];
      x[i][j] -= 1;
    }
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++){
    bool honest[20] = {false};
    for(int i=0; i < n; i++){
      if(bit & (1<<i)){  //iが含まれているか
        honest[i] = true;
      }
    }
    
    bool flag = true;

    for (int i = 0; i < n; i++){
      for(int j=0; j<A[i]; j++){
        if(honest[x[i][j]] != y[i][j] && honest[i]){
          flag = false;
          break;
        }
      }
    }

    int count = 0;
    if(flag){
      for(int i=0; i<n; i++){
        if(honest[i]){
          count++;
        }
      }
    }
    if(count > ans){
      ans = count;
    }
  }

  cout << ans << "\n";
  return 0;

  /*
  int A = 0x2d;
  int B = 0x19;
  cout << A << " AND " << B << " = " << (A & B) << endl;
  cout << bitset<8>(A)  << " AND " << "\n" << bitset<8>(B) << " = " << "\n" <<  bitset<8>(A & B) << endl;
*/
}

Measured memory_bytes: 256
n,q=map(int,input().split())
S=input()
L=[0]
c=0
for i in range(n-1):
    if S[i:i+2]=='AC':
        c+=1    
    L.append(c)
for j in range(q):
    s,e=map(int,input().split())
    print(L[e-1]-L[s-1])

Measured memory_bytes: 6100
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k=0;string s;
    cin>>k;
    cin>>s;
    if((int)s.length()>k)
    {
    	for(int i=0;i<k;++i)
    		cout<<s[i];
    	cout<<"...";
    }
    else
    	cout<<s;
    cout<<endl;
}

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

int main(){
	int H[300], W[300];
	int s = 0;
	for (;;){
		cin >> H[s] >> W[s];
		if (H[s] == 0 && W[s] == 0)break;
		s++;
	}
	for (int t = 0; t < s; t++){
		for (int i1 = 0; i1 < H[t]; i1++){
			for (int i2 = 0; i2 < W[t]; i2++){
				if ((i1 + i2) % 2 == 0)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  int D;

  cin >> D;

  if (D==25) cout << "Christmas" << "\n";
  else if(D==24) cout << "Christmas Eve" << "\n";
  else if(D==23) cout << "Christmas Eve Eve" << "\n";
  else if(D==22) cout << "Christmas Eve Eve Eve" << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
        int K, A, B;
        cin >> K;
        cin >> A >> B;
        for(int i=A; i<=B; i++){
                if(i % K == 0){
                        cout << "OK" << endl;
                        return 0;
                }
        }
        cout << "NG" << endl;
        return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int n,m;
int A[100100][3];

int main() {
	cin >> n >> m;
	if (n == m)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int c;
	int r = 0;
	int ll = 0;
	//cout << "enter a sentence:" << endl;
	while ((c = cin.get()) > 10) {
		if (c == 'S')
			if (r < 0)
				r = -r + 1;
			else
				r++;
		else
			if (r <= ll)
			{
				r++;
				ll++;
			}
			else
				r--;
	}
	cout << r<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
 int i, a, b, c, x;
 x = 0;
 scanf("%d %d %d", &a, &b, &c);
 for (i = a;i <= b;i++)
	{
	 if (c%i == 0)
	 {
	  x = x + 1;
          }
	}
	printf("%d\n",x);
	
	return 0;
}




Measured memory_bytes: 2112