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

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

  int count = 0;
  for (int i=0; i<S.length(); i++){
    if (S[i] == 'o'){
      count++;
    }
  }
  if (8 - count <= 15 - S.length()){
    cout << "YES" << endl;
  } else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<long>calc(vector<pair<int,long> >X)
{
	sort(X.begin(),X.end());
	long pre[16][16],zr[16][16];
	const long INF=3e18;
	for(int i=0;i<X.size();i++)for(int j=i+1;j<=X.size();j++)
	{
		pre[i][j]=INF;
		long R=0,mR=0;
		for(int k=i;k<j;k++)
		{
			R+=X[k].first*X[k].second;
			mR+=X[k].second;
		}
		long L=0,mL=0;
		for(int k=i;k<j;k++)
		{
			R-=X[k].first*X[k].second;
			mR-=X[k].second;
			L+=X[k].first*X[k].second;
			mL+=X[k].second;
			pre[i][j]=min(pre[i][j],R-mR*X[k].first+mL*X[k].first-L);
		}
		zr[i][j]=0;
		for(int k=i;k<j;k++)
		{
			zr[i][j]+=abs(X[k].first)*X[k].second;
		}
	}
	long dp[17][16];
	for(int i=0;i<=15;i++)for(int j=0;j<=15;j++)dp[i][j]=INF;
	dp[0][0]=0;
	for(int i=0;i<X.size();i++)for(int j=0;j<=i;j++)
	{
		for(int k=i+1;k<=X.size();k++)
		{
			dp[j+1][k]=min(dp[j+1][k],dp[j][i]+pre[i][k]);
			dp[j][k]=min(dp[j][k],dp[j][i]+zr[i][k]);
		}
	}
	vector<long>ret(16);
	for(int i=0;i<=15;i++)ret[i]=dp[i][X.size()];
	return ret;
}
long ans[16];
main()
{
	int N;
	cin>>N;
	int X[15],Y[15];
	long P[15];
	for(int i=0;i<N;i++)
	{
		cin>>X[i]>>Y[i]>>P[i];
	}
	for(int i=0;i<=N;i++)ans[i]=9e18;
	for(int i=0;i<1<<N;i++)
	{
		vector<pair<int,long> >x,y;
		for(int j=0;j<N;j++)
		{
			if(i>>j&1)x.push_back(make_pair(X[j],P[j]));
			else y.push_back(make_pair(Y[j],P[j]));
		}
		vector<long>Ax=calc(x);
		vector<long>Ay=calc(y);
		for(int j=0;j<=N;j++)for(int k=0;j+k<=N;k++)
		{
			ans[j+k]=min(ans[j+k],Ax[j]+Ay[k]);
		}
	}
	for(int i=0;i<=N;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3636
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int v[102], w[102];
int n,W;    
int dp[102][100002];
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    
    cin >> n >> W;
    
    rep(i, 1,n+1){
        cin >> w[i] >> v[i];
    }
    rep(i, 0, n+1){
        rep(j, 0, W+1){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }
            else if(w[i] > j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }

    // rep(i, 0, n+1){
    //     rep(j, 0, W+1){
    //         cout <<dp[i][j] << " ";
    //     }    
    //     cout << endl;
    // }
    cout << dp[n][W];
}



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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    while(true){
        int n; cin >> n;
        if(n == 0)break;
        vector<string> s(n);
        int key[5] ={ 5, 7,5,7,7};
        for(int i = 0; i < n; i++)cin >> s[i];
        for(int i = 0; i < n; i++){
            if(s[i].size() > key[0])continue;
            int c = 0,k = i;
            for(int j = 0; j < 5; j++){
                c = 0;
                while(c < key[j] && k < n){
                    c += s[k].size();
                    k++;
                }
                if(c != key[j]){
                    c = -1;
                    break;
                }
            }
            if(c != -1){
                cout << i+1 << endl;
                break;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3084
def solve(A, B, C):
    A, B, C = max(A, B, C), sum([A, B, C]) - max(A, B, C) - min(A, B, C), min(A, B, C)
    if A % 2 == B % 2 == C % 2:
        ans = 0
    else:
        ans = 1
        if B % 2 == C % 2:
            B += 1
            C += 1
        elif A % 2 == B % 2:
            A += 1
            B += 1
        else:
            A += 1
            C += 1
    ans += (A - B) // 2 + (A - C) // 2
    return ans


if __name__ == "__main__":
    A, B, C = tuple(map(int, input().split(" ")))
    print(solve(A, B, C))


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        char arr[] = nln().toCharArray();
        int res = 0, cnt;
        for(int i = 0; i < 3; i++){
            if(arr[i] == 'S')
                continue;
            cnt = 1;
            while(i + 1 < 3 && arr[i+1] == 'R'){
                i++;
                cnt++;
            }
            res = Math.max(res, cnt);
        }
        pn(res);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36496
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, P, Q;
int C[500010];

signed main() {
    cin >> N >> P >> Q;
    int sum = 0, ans = -INF;
    rep(i,0,N) cin >> C[i], sum += C[i], C[i] += P*i;
    sort(C, C+N);

    repq(i,0,N) {
        chmax(ans, sum + P*Q*i + P*i*(i-1));
        if(i < N) sum -= C[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n, a[305];
	scanf("%d", &n); n <<= 1;
	for(int i = 1; i <= n; ++i) scanf("%d", a + i);
	std::sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i <= n; i += 2) ans += a[i];
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};

signed main(){
  int n,k;cin>>n>>k;
  vector<int> nibeki(50,1);
  Nums lib(n+1);
  rep1(i,49){
    nibeki[i]=nibeki[i-1]*2;
  }
  double res=0.0;
  rep1(i,n){
    int ind=0;
    rep(j,50){
      if(nibeki[j]*i>=k){
        ind=j;
        break;
      }
    }
    res+=1.0/(double)(n*(double)nibeki[ind]);
  }
  printf("%.12lf\n",res);
  return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int K; cin >> K;
	int A, B; cin >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    for(int i = x; i >= 1; i--){
        for(int b = 1; b <= 50; b++){
            for(int p = 2; p <= 10; p++){
                if(pow(b,p) == i){
                    cout << i << endl;
                    return 0;
                }
            }
        }
    }
    cout << 1 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,bool> P;
int n;
vector<vector<P> > p(100005);
int black[100005] = {0};

void paint(int d, bool bl){
    if(black[d]!=0)return;
    if(bl)black[d]=1;
    else black[d]=-1;
    for(int i = 0; i < (int)p[d].size(); i++){
        paint(p[d][i].first, (p[d][i].second==bl));
    }
}
int main(){
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int f, t;
        ll len;
        cin >> f >> t >> len;
        bool ch = bool(!(len%2));
        p[f-1].push_back(P(t-1, ch));
        p[t-1].push_back(P(f-1, ch));
    }
    paint(0, true);
    for(int i = 0; i < n; i++){
        if(black[i] > 0)cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a,b;
	while(cin>>a>>b,a||b){
		vector<int>ma(a);
		rep(i,a)cin>>ma[i];
		vector<int>in(b);
		rep(i,b)cin>>in[i];
		int co=0;
		int now=0;
		while(1){
			now+=in[co++];
			if(a-1<=now)break;
			now+=ma[now];
			if(a-1<=now)break;
		}
		cout<<co<<endl;
	}
}

Measured memory_bytes: 1200
n = input()
l = n.split()
a = int(l[0])
b = int(l[1])
c = int(l[2])
d = int(l[3])

if c%b == 0 and a%d == 0:
    aoki = c//b
    takahasi = a//d
elif c%b == 0 and a%d !=0:
    aoki = c//b
    takahasi = a//d + 1
elif c%b != 0 and a%d == 0:
    aoki = c//b + 1
    takahasi = a//d
else:
    aoki = c//b + 1
    takahasi = a//d + 1            





if aoki > takahasi:
    print("No")
else:
    print("Yes")    


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



int main() 
{
  ll K; cin>>K;
  string S; cin>>S;
  ll N=S.size();
  if(K<N)
  {
    S=S.substr(0,K)+"...";
  }
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint n, mod;
llint dp[6005][2005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> mod;
	
	dp[0][0] = 1;
	for(int i = 0; i < 3*n; i++){
		for(int j = 0; j <= n; j++){
			dp[i+1][j] += dp[i][j], dp[i+1][j] %= mod;
			if(j+1 <= n){
				dp[i+2][j+1] += dp[i][j] * (i+1) % mod;
				dp[i+2][j+1] %= mod;
			}
			if(j+1 <= n){
				dp[i+3][j+1] += dp[i][j] * (i+1) % mod * (i+2) % mod;
				dp[i+3][j+1] %= mod;
			}
		}
	}
	
	/*for(int i = 0; i < 3*n; i++){
		for(int j = 0; j <= n; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	llint ans = 0;
	for(int i = 0; i <= n; i++) ans += dp[3*n][i], ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 94336
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  H,W = readInts()
  LIST = [H//2 + W//3 + 1, W//3 + H//2 + 1, H, W]
  if H%3 == 0 or W % 3 == 0:
    LIST += [0]
  if H % 2 == 0:
    LIST += [H//2]
  if W % 2 == 0:
    LIST += [W//2]
  print(min(LIST))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x, *a = map(int, read().split())
left_cost = len([i for i in a if 0 < i < x])
right_cost = len([i for i in a if x < i < n])

print(min(left_cost, right_cost))


Measured memory_bytes: 9072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

ll N,M,K,ans=0,mn=INF;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>N;
  ll A[N],B[N];
  REP(i,N){
    cin>>A[i]>>B[i];
    ans+=B[i];
    if(A[i]>B[i]) mn=min(mn,B[i]);
  }
  if(mn!=INF) cout<<ans-mn<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll vv[111111];
int vis[111111];
vector< pair<ll, int> > edge[111111];
int n, m;
bool isok=true;

void fuck(void)
{
	cout<<"No"; exit(0);
}

void dfs(int cur)
{
	vis[cur]=1; int i;
	for(i=0 ; i<edge[cur].size() ; i++)
	{
		int nxt=edge[cur][i].second;
		ll add=edge[cur][i].first;
		if(!vis[nxt])
		{
			vv[nxt]=vv[cur]+add;
			dfs(nxt);
		}
		else if(vv[nxt]!=vv[cur]+add) fuck();
	}
}

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m; int i, j, u, v; ll w;
	for(i=1 ; i<=m ; i++)
	{
		cin>>u>>v>>w;
		edge[u].push_back(make_pair(w,v));
		edge[v].push_back(make_pair(-w,u));
	}
	for(i=1 ; i<=n ; i++) if(!vis[i]) dfs(i);
	cout<<"Yes"; return 0;
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin>>n;
  string s; cin>>s;
  string k = "...";
  if(s.size()<=n)cout<<s<<endl;
  else{
    string ans = s.substr(0,n);
    cout<<ans+k<<endl;
  }
  return 0;
}

Measured memory_bytes: 3608
ary = gets.split.map(&:to_i)

a = ary[0]
b = ary[1]
c = ary[2]

3.times do
  if a == b + c
    puts 'Yes'
    exit
  elsif b == a + c
    puts 'Yes'
    exit
  elsif c == a + b
    puts 'Yes'
    exit
  else
    puts 'No'
    exit
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	vector<int> a, b;

	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (x > 0)
			a.push_back(abs(x));
		else
			b.push_back(abs(x));
	}
	a.push_back(0);
	b.push_back(0);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int ans = 1 << 30;
	if (k < a.size())
		ans = min(ans, a[k]);
	if (k < b.size())
		ans = min(ans, b[k]);
	for (int i = 0; i <= k; ++i)
		if (i < a.size() && k - i < b.size())
			ans = min(ans, a[i] + b[k - i] + min(a[i], b[k - i]));
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1020
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    Scanner in = new Scanner(System.in);

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

    void solve(){
        HashSet<String> set = new HashSet<>();
        int n;
        n = in.nextInt();

        for (int i = 0; i < n; i++) {
            set.add(in.next());
        }

        System.out.println(set.size());
    }
}


Measured memory_bytes: 77196
class LazyPropSegmentTree:
	def __init__(self, N):
		self.N = N
		self.LV = (N - 1).bit_length()
		self.N0 = 2 ** self.LV
		self.data = [N - 1] * (2 * self.N0)
		self.lazy = [float('inf')] * (2 * self.N0)

	# 遅延伝播を行うindexを生成
	def gindex(self, l, r):
		L = (l + self.N0) >> 1; R = (r + self.N0) >> 1
		lc = 0 if l & 1 else (L & -L).bit_length()
		rc = 0 if r & 1 else (R & -R).bit_length()
		for i in range(self.LV):
			if rc <= i:
				yield R
			if L < R and lc <= i:
				yield L
			L >>= 1; R >>= 1

	# 遅延伝搬処理
	def propagates(self, *ids):
		for i in reversed(ids):
			v = self.lazy[i - 1]
			if v == float('inf'):
				continue
			self.lazy[2 * i - 1] = min(self.lazy[2 * i - 1], v)
			self.lazy[2 * i] = min(self.lazy[2 * i], v)
			self.data[2 * i - 1] = min(self.data[2 * i - 1], v)
			self.data[2 * i] = min(self.data[2 * i], v)
			self.lazy[i - 1] = float('inf')

	def update(self, l, r, x):
		*ids, = self.gindex(l, r + 1)
		self.propagates(*ids)

		L = self.N0 + l; R = self.N0 + r + 1
		while L < R:
			if R & 1:
				R -= 1
				self.lazy[R - 1] = min(self.lazy[R - 1], x)
				self.data[R - 1] = min(self.data[R - 1], x)
			if L & 1:
				self.lazy[L - 1] = min(self.lazy[L - 1], x)
				self.data[L - 1] = min(self.data[L - 1], x)
				L += 1
			L >>= 1; R >>= 1
		for i in ids:
			self.data[i - 1] = min(self.data[2 * i - 1], self.data[2 * i])

	def point_query(self, k):
		*ids, = self.gindex(k, k + 1)
		self.propagates(*ids)
		return self.data[k + self.N0 - 1]

N, Q = map(int, input().split())
query = [tuple(map(int, input().split())) for i in range(Q)]
row = LazyPropSegmentTree(N+1)
column = LazyPropSegmentTree(N+1)

ans = (N-2) ** 2
for t, x in query:
    if t == 1:
        n = row.point_query(x)
        # print(n)
        ans -= n - 2
        column.update(2, n, x)
    else:
        n = column.point_query(x)
        # print(n)
        ans -= n - 2
        row.update(2, n, x)

print(ans)

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

using namespace std;

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

  vector<int> ans(4);
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;

    if(s == "AC"){
      ans[0]++;
    }
    else if(s == "WA"){
      ans[1]++;
    }
    else if(s == "TLE"){
      ans[2]++;
    }
    else{
      ans[3]++;
    }
  }

  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;

  return 0;
}

Measured memory_bytes: 3624
N,Q = map(int, input().split())
p = []
x = []
c = [0] * (N+1)
AB = [[] for _ in range(N+1)] #graph
for i in range(N-1):
  a,b = map(int, input().split())
  AB[a].append(b)
  AB[b].append(a)

for i in range(Q):
  p,x = map(int, input().split())
  c[p] += x
#print(AB)
#print(*c[1:])

from collections import deque
stack = deque([1])
 
parent = [0] * (N+1)
while stack:
    x = stack.popleft()
    for y in AB[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        c[y] += c[x]

print(*c[1:])

Measured memory_bytes: 56204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
typedef long long LL;
int main() {
	std::string a;
	std::cin >> a;
	if (a[0] == a[1] && a[1] == a[2]) { std::cout << "Yes" << std::endl; }
	else if(a[1] == a[2] && a[3] == a[2]) { std::cout << "Yes" << std::endl; }
	else { std::cout << "No" << std::endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string s[1001];
int d[1001][1001];

signed main(){
	int n;
	while (cin >> n && n) {
		rep(i, 0, n) {
			cin >> s[i];
		}
		rep(i, 0, n + 1) {
			rep(j, 0, n + 1) {
				d[i][j] = 0;
			}
		}
		rep(i, 1, n + 1) {
			rep(j, 1, n + 1) {
				if (s[i - 1][j - 1] == '*') d[i][j] = 1;
			}
		}
		rep(i, 1, n + 1) {
			rep(j, 1, n + 1) {
				d[i][j] += d[i - 1][j];
			}
		}
		rep(i, 1, n + 1) {
			rep(j, 1, n + 1) {
				d[i][j] += d[i][j - 1];
				//cout << d[i][j] << " ";
			}
			//cout << endl;
		}
		int MAX = 0;
		rep(i, 1, n + 1) {
			rep(j, 1, n + 1) {
				int ok = 0, ng = min(n + 1 - i, n + 1 - j) + 1;
				rep(k, 0, 11) {
					int m = (ok + ng) / 2;
					if (d[i + m - 1][j + m - 1] + d[i - 1][j - 1] - d[i - 1][j + m - 1] - d[i + m - 1][j - 1] == 0) ok = m;
					else ng = m;
				}
				MAX = max(MAX, ok);
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 10076
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int A[][] = new int[9][9];
		int N = stdIn.nextInt();
		int ans = 0;

		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				A[i][j] = (i + 1) * (j + 1);
				if(N == A[i][j]){
					ans = 1;
				}
			}
		}
		if(ans == 1){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}

		stdIn.close();
	}
}


Measured memory_bytes: 35180
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int h, a;
    cin >> h >> a;

    cout << ceil((float)h/(float)a) << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

int main() {
  int E, Y; cin >> E >> Y;
  if (E == 0) {
    if (Y >= 1868 && Y <= 1911) cout << "M" << Y - 1867 << endl;
    if (Y >= 1912 && Y <= 1925) cout << "T" << Y - 1911 << endl;
    if (Y >= 1926 && Y <= 1988) cout << "S" << Y - 1925 << endl;
    if (Y >= 1989 && Y <= 2016) cout << "H" << Y - 1988 << endl;
  }
  if (E == 1) cout << Y + 1867 << endl;
  if (E == 2) cout << Y + 1911 << endl;
  if (E == 3) cout << Y + 1925 << endl;
  if (E == 4) cout << Y + 1988 << endl;
  return 0;
}


Measured memory_bytes: 3112
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r :#同じものがある
        if l > 0:#他の色の最大値が上書きできる
            lis[l-1]=a
        elif r ==  len(lis):#全部の色の最大値とaが同じなら追加
            lis.append(a)
        else:#どこかの中に挿入
            lis.appendleft(a)
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))

Measured memory_bytes: 7284
N,M = map(int,input().split())
x = [list(map(int,input().split())) for i in range(N)]
x.sort(key=lambda x:x[0])
ans,cnt = 0,0
for i in range(N):
    if cnt+x[i][1]<M:
        ans += x[i][0]*x[i][1]
        cnt += x[i][1]
    else:
        ans += (M-cnt)*x[i][0]
        break
print(ans)

Measured memory_bytes: 64600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

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

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

#define int long long

int p[70010];
int j[70010];

signed main()
{
   int n;
   while (cin >> n, n) { 
       int a = 0;

       rep(i, n) {
           cin >> p[i];
           a += p[i];
       }

       rep(i, n - 1) {
           cin >> j[i];
       }

       sort(j, j + n - 1, greater<int>());

       int ans = a * n;

       rep(i, n - 1) {
           a += j[i];
           n -= 1;
           int v = a * n;
           ans = max(ans, v);
       }

       cout << ans << endl;
   }
}

Measured memory_bytes: 2196
from collections import Counter
N, M = map(int, input().split())
acdict = {}
wacounter = Counter()

for m in range(M):
    p, s = input().split()
    if s == 'AC':
        acdict[p] = 1
    else:
        if acdict.get(p):
            continue
        wacounter[p] += 1
ans_ac = len(acdict)
ans_wa = sum([wacounter[key] for key in acdict.keys()])
print(ans_ac, ans_wa)

Measured memory_bytes: 64728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll a,b,c,k;
    cin >> a>>b>>c>>k;
    ll ans=0;

    if(a>=k){
        ans=k;
    }else if(a+b>=k){
        ans =a;
    }
    else if(a+b<=k ||a+b+c>=k){
        ans=a-(k-(a+b));
    }else{
        ans=a-c;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stack>
#include <sstream>
#include <vector>
#include <string>
using namespace std;

int main()
{
	stack<int> st;
	string str, s;
	getline(cin, str);
	stringstream ss(str);
	vector<string> v;
	
	while (getline(ss, s, ' ')){
		v.push_back(s);
	}

	for (auto x : v){
		if (x == "+"){
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			st.push(b+a);
		} else if (x == "-"){
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			st.push(b-a);
		} else if (x == "*"){
			int a = st.top(); st.pop();
			int b = st.top(); st.pop();
			st.push(b*a);
		} else {
			st.push(stoi(x));
		}
	}

	cout << st.top() << endl;



}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}

int main(){
  int N , D;
  cin >> N >> D;
  int ret;
  vector<vector<int>> x(N, vector<int>(D, 0));
  
  for(int i=0; i<N; i++){
  	for(int j=0; j<D; j++){
      cin >> x[i][j];
  	}
  }
  
  int count=0;
  float d;
  
  for(int i=0; i<N; i++){
  for(int j=i+1; j<N; j++){
    
    d=0;
  	for(int k=0; k<D; k++){
      d += pow((x[i][k]-x[j][k]),2);
  	}
    d = pow(d,0.5);
    
    //cout << d << endl;
    if( ((float)(int)d - d)==0){
      	count+=1;
    }
  }
  }
  
  cout << count << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define PI 3.14159265358979323846
ll N;
pll yxv[111];
vector<pair<double, ll>> rv;

double ans;
ll i, j, k;
int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        ll x,y,xi,yi;
        scanf("%lld%lld", &x, &y);
        yxv[i] = {y, x};
        rv.push_back({atan2(y, x), i});
    }
    sort(rv.begin(), rv.end());
    
    j = 0;
    fornum(i,0,N){
        pll yx = {0,0};

        double lim = atan2(-yxv[rv[i].second].first, -yxv[rv[i].second].second);
        if(lim<0){
            lim += 2 * PI;
        }
        fornum(j, i, 2 * N){
            double r = rv[j % N].first + (j < N ? 0 : 2 * PI);
            ll jj = rv[j % N].second;
            if(r>lim){
                break;
            }
            yx.first += yxv[jj].first;
            yx.second += yxv[jj].second;
            double aa = (double)yx.first * yx.first + (double)yx.second * yx.second;
            if(aa>ans){
                ans = aa;
            }
        }
    }
    printf("%.12lf", sqrt(ans));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m,q,i,j,l,r;
    cin>>n>>m>>q;
    int a[n+1][n+1]={};
    for(i=0;i<m;i++){cin>>l>>r;a[l][r]++;}
    for(i=0;i<=n;i++)for(j=0;j<n;j++)a[i][j+1]+=a[i][j];
    for(i=0;i<=n;i++)for(j=0;j<n;j++)a[j+1][i]+=a[j][i];
    for(i=0;i<q;i++){cin>>l>>r;cout<<a[r][r]-a[r][l-1]-a[l-1][r]+a[l-1][l-1]<<endl;}
    return 0;
}

Measured memory_bytes: 1920
S = input()

l = len(S)

max_cnt = 0
for i in range(l):
    for j in range(i, l):
        res = [1 if s == "A" or s == "C" or s == "G" or s == "T" else 0 for s in S[i : j + 1]]
        if sum(res) == len(res):
            max_cnt = max(sum(res), max_cnt)
print(max_cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint A, B; cin >> A >> B;
  if (A == B) return cout << 1 << '\n', 0;
  for (int n = 59; n >= 0; --n) if ((A & 1LL << n) != (B & 1LL << n)) {
    A &= ~(~0LL << n);
    B &= ~(~0LL << n);
    lint x = (1LL << n) - A;
    lint y = 1LL << (B ? __lg(B) : -1) + 1;
    lint res = x + y;
    res += x - max<lint>(x + y - (1LL << n), 0);
    cout << res << '\n';
    return 0;
  }
}

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

int N, W, w[100];
long long v[100], dp[100][100001];
int main(){
    scanf("%d%d", &N, &W);
    for(int i=0; i<N; i++) scanf("%d%lld", w+i, v+i);
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            dp[i][j] = max(i!=0 ? dp[i-1][j] : 0LL, j>=w[i] ? (i!=0 ? dp[i-1][j-w[i]] : 0LL)+v[i] : 0LL);
        }
    }
    long long ans = 0;
    for(int i=0; i<=W; i++) ans = max(ans, dp[N-1][i]);
    printf("%lld\n", ans);
}

Measured memory_bytes: 78336
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> c = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
                c.add(sc.nextInt());
        }
        if(c.size() == n)
        System.out.println("YES");
        else
        System.out.println("NO");
    }
}

Measured memory_bytes: 70452
#include <iostream>
#include <math.h>
using namespace std;

int main(){

	int x;
	cin >> x;
	int sum = 1;
	int max = 1;
	int ans = (int)sqrt(x);
//	cout << ans * ans << endl;
	for (int i = 2; i <= ans; i++){
		sum = 1;
		while( sum<=x ){
			sum *= i;
			if (sum >= max && sum <= x){
				max = sum;
			}
		}
	}
	cout << max << endl;
/*
	if (abs(a-c) <= d){
		cout << "Yes" << endl;
	}else if (abs(a-b) <= d && abs(b-c) <= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
*/
	return 0;
}



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

int main() {
    int n,k,q;
    cin >>n>>k>>q;
    vector<int>a(q);
    vector<int>b(n);
    for(int i=0; i<q; ++i){
        cin >> a[i];
        b[a[i]-1] +=1;
    }
    for(int i=0; i<n; ++i){
        if(k-q+b[i]>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" <<endl;
        }
    }

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define REP(i,N) for(ll i = 0; i < N;++i) 

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> H(N);
  REP(i,N){
    cin>>H[i];
  }
  vector<bool> aa(N,true);
  REP(i,M){
    ll A,B;
    cin>>A>>B;
    A--;B--;
    if(H[A]>=H[B]){
      aa[B]=false;
    }
    if(H[B]>=H[A]){
      aa[A]=false;
    }
  }
  ll ans=0;
  REP(i,N){
    if(aa[i]==true)ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef pair <int, int> pii;

vector <pii> V[111];
vector <int> X;
int A[111][111], B[111][111], C[111][111], M[111];
bool chk1[111], chk2[111];
int n, m;

bool match(int p)
{
	chk1[p] = true;
	
	for(pii &t: V[p]){
		if(M[t.first] == -1 || (!chk1[M[t.first]] && match(M[t.first]))){
			M[t.first] = p; return 1;
		}
	}
	
	return 0;
}

int main()
{
	int i, j, k, f;
	
	scanf("%d%d", &n, &m);
	
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d", A[i] + j);
			A[i][j] --;
			V[i].emplace_back(A[i][j] / m, A[i][j]);
		}
	}
	
	for(i=0; i<m; i++){
		for(j=0; j<n; j++){
			chk2[j] = false; M[j] = -1;
		}
		
		for(f=1; f; ){
			for(j=0; j<n; j++){
				chk1[j] = false;
			}
			
			f = 0;
			
			for(j=0; j<n; j++){
				if(!chk1[j] && !chk2[j] && match(j)){
					chk2[j] = true; f = 1;
				}
			}
		}
		
		for(j=0; j<n; j++){
			for(k=0; k<V[j].size(); k++){
				if(M[V[j][k].first] == j) break;
			}
			
			B[j][i] = V[j][k].second;
			swap(V[j][k], V[j].back());
			V[j].pop_back();
		}
	}
	
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			printf("%d ", B[i][j] + 1);
		}
		printf("\n");
	}
	
	for(i=0; i<m; i++){
		X.clear();
		
		for(j=0; j<n; j++){
			X.push_back(B[j][i]);
		}
		
		sort(X.begin(), X.end());
		
		for(j=0; j<n; j++){
			C[j][i] = X[j];
		}
	}
	
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			printf("%d ", C[i][j] + 1);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int N, M;

priority_queue<int> A;

int main() {
    cin >> N >> M;
    REP (i, N) {
        int a;
        cin >> a;
        A.push(a);
    }
    REP (i, M) {
        int a = A.top() / 2;
        A.pop();
        A.push(a);
    }
    LL S = 0;
    while (!A.empty()) {
        S += A.top();
        A.pop();
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 892
from collections import defaultdict as dd
d = dd(int)
d[0] = 1
n,m = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
f = 0
for i in range(1,n+1):
  f = (f + a[i-1])%m
  d[f] += 1
for i in d:
  ans += d[i]*(d[i]-1)//2
print(ans)

Measured memory_bytes: 14912
#include<iostream>
#include<cstring>

using namespace std;

int main()
{
    char ch[200010];
    cin >> ch;
    int n = strlen(ch);
    long long ans = 0;
    long long count = 0;
    for(int i = 0; i < n; i++)
        ch[i] == 'B' ? ++count : ans += count;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


int main(){
    int N; cin>>N;
    vector <double> v(N);
    for(int i=0;i<N;i++) cin>>v[i];
    sort(v.begin(),v.end());

    for(int i=1;i<N;i++){
        v[i] = (v[i] + v[i-1])/double(2);
    }
double ans = v[N-1];

printf("%f",ans);
    

    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double R;
    cin >> R;
    R = 2 * R * 3.14;
    cout << R << endl;
}


Measured memory_bytes: 3780
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] w = new String[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.next();
		}
		sc.close();

		Set<String> set = new HashSet<>();
		set.add(w[0]);
		for (int i = 1; i < n; i++) {
			if (!set.add(w[i]) || w[i - 1].charAt(w[i - 1].length() - 1) != w[i].charAt(0)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int p;
    String S;
    int AC[] = new int[N];
    int WA[] = new int[N];
        
    for(int i=0; i<N; i++){
      AC[i]=0;
      WA[i]=0;
    }
    
    int penalty = 0;
    for(int i=0; i<M; i++){
      p=sc.nextInt()-1;
      S=sc.next();
      
      if(S.equals("WA")){
        WA[p]++;
      }else if(S.equals("AC")){
        if(AC[p]==0){
          penalty = penalty + WA[p];
        }
        AC[p]=1;
      }
    }
    int clear = 0;
    for(int i=0; i<N; i++){
      clear = clear + AC[i];
    }
    System.out.print(clear + " " + penalty);
  }
}
 

Measured memory_bytes: 61076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  a.push_back(0);
  int ans=0;
  vector<bool> p(n,true);
  rep(i,n){
    if(a.at(i)==a.at(i+1)){
      p.at(i)=false;
      p.at(i+1)=false;
      i++;
    }
  }
  rep(i,n){
    if(p.at(i)){
      ans++;
    }
  }
  cout << ans;
}

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

struct Node{
  Node *right;
  Node *left;
  Node *parent;
  int key;
};

Node *root, *NIL;

Node *treeMinimum(Node *x){
  while(x->left != NIL) x=x->left;
  return x;
}

Node *treeMaximum(Node *x){
  while(x->right != NIL) x=x->right;
  return x;
}

Node *Search(Node *u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
    return u;
}
Node *treeSuccessor(Node *x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void Delete(Node *z){
  Node *y; // node to be deleted
  Node *x; // child of y
  if(z->left==NIL||z->right==NIL) y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;
  }
  if(x!=NIL)  x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else{
    if(y==y->parent->left) y->parent->left=x;
    else y->parent->right=x;
  }
  if(y!=z) z->key=y->key;
  free(y);
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else{
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  cout<<" "<<u->key;
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  cout<<" "<<u->key;
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n,x;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s[0]=='f'){
      cin>>x;
      Node *t=Search(root,x);
      if(t!=NIL) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }else if(s[0]=='i'){
      cin>>x;
      insert(x);
    }
    else if(s[0]=='p'){
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
    else if(s[0]=='d'){
      cin>>x;
      delete(Search(root,x));
      
    }
  }
  
  return 0;
}



Measured memory_bytes: 26636