akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

const int MAXN=1005;

int n;
double d[MAXN][MAXN],s[MAXN],t[MAXN],ans=1e18;
bool in[MAXN];
queue<int> q;
pair<int,int> st,ed;
struct node{
    double x,y,r;
}a[MAXN];

double dis(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

void work(){
    memset(in,0,sizeof in);
    for(int i=1;i<=n;i++)
        q.push(i),in[i]=1;
    while(!q.empty()){
        int u=q.front(); q.pop(); in[u]=0;
        for(int v=1;v<=n;v++){
            if(u==v||s[u]+d[u][v]>=s[v]) continue;
            s[v]=d[u][v]+s[u];
            if(!in[v]){
                in[v]=1;
                q.push(v);
            }
        }
    }
    memset(in,0,sizeof in);
    for(int i=1;i<=n;i++)
        q.push(i),in[i]=1;
    while(!q.empty()){
        int u=q.front(); q.pop(); in[u]=0;
        for(int v=1;v<=n;v++){
            if(u==v||t[u]+d[u][v]>=t[v]) continue;
            t[v]=d[u][v]+t[u];
            if(!in[v]){
                in[v]=1;
                q.push(v);
            }
        }
    }
    for(int i=1;i<=n;i++) ans=min(ans,s[i]+t[i]);
}

int main(){
    scanf("%d%d%d%d",&st.first,&st.second,&ed.first,&ed.second);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].r);
    ans=dis(st.first,st.second,ed.first,ed.second);
    for(int i=1;i<=n;i++) s[i]=max(0.0,dis(st.first,st.second,a[i].x,a[i].y)-a[i].r);
    for(int i=1;i<=n;i++) t[i]=max(0.0,dis(ed.first,ed.second,a[i].x,a[i].y)-a[i].r);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            if(i==j) continue;
            d[i][j]=max(0.0,dis(a[i].x,a[i].y,a[j].x,a[j].y)-a[i].r-a[j].r);
        }
    work();
    printf("%.10lf",ans);
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,pm,pe,pj;

int main(){
	while(cin>>n){
		if(!n)return 0;
		while(n--){
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100||pm+pe>179||pm+pe+pj>239)cout<<"A"<<endl;
			else if(pm+pe+pj>209||pm+pe+pj>149&&(pm>79||pe>79))cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int H = sc.nextInt();
			int W = sc.nextInt();
			String[] result = new String[H+2];
			for(int i = 0 ; i < H+2; i++){
				if(i == 0 || i == H+1){
					StringBuilder str = new StringBuilder();
					for(int j = 0; j < W+2; j++){
						str.append("#");
					}
					result[i] = str.toString();
				}else{
					result[i] = "#" + sc.next() + "#";
				}
			}
			for(int i = 0; i < H+2; i++){
				System.out.println(result[i]);
			}
		}catch(Exception e){
			e.getMessage();
		}
	} 
}

Measured memory_bytes: 22100
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            String A = fs.next();
            String B = fs.next();

            int len = A.length() < B.length() ? B.length() : A.length();

            // 左 N桁 ゼロ埋め
            // %Ns
            // 半角スペースをゼロに置換
            String ptn = "%" + String.valueOf(len) + "s";
            A = String.format(ptn, A).replace(" ", "0");
            B = String.format(ptn, B).replace(" ", "0");

            System.out.println(
                A.compareTo(B) < 0 ? "LESS" :
                0 < A.compareTo(B) ? "GREATER" : "EQUAL");
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include<stdio.h>
#include<algorithm>
using namespace std;
const int inf=2147483647;
int x[100010];
int main(){
	int n,k,i,ans;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",x+i);
	ans=inf;
	for(i=1;i<=n-k+1;i++){
		if(x[i+k-1]<=0)
			ans=min(ans,-x[i]);
		else if(x[i]>=0)
			ans=min(ans,x[i+k-1]);
		else
			ans=min(ans,min(-x[i]*2+x[i+k-1],x[i+k-1]*2-x[i]));
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string a,b;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
for(ll i=0;i<3;i++)
if(a[i]==b[i]){
    n++;
}
cout<<n<<endl;
}






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

int main(void) {
    int n, i;
    cin >> n;
    int ls[n];
    for (i = 0; i < n; i++) {
        cin >> ls[i];
    }
    for (i = n - 1; i >= 0; i--) {
        cout << ls[i];
        if (i) cout << " ";
        else cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <climits>
#include <vector>
#include <map>
#include <stdio.h>
#include <algorithm>
using namespace std;

struct RUP{
  int n;
  vector<int> dat,laz;
  const int def=INT_MAX;
  RUP(){}
  RUP(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
    laz.clear();
    laz.resize(2*n-1,-1);
  }
  inline void eval(int len,int k){
    if(laz[k]<0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=laz[k];
      laz[k*2+2]=laz[k];
    }
    dat[k]=laz[k];
    laz[k]=-1;
  }
  int update(int a,int b,int x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b) return laz[k]=x;
    eval(r-l,k);
    dat[k]=min(update(a,b,x,k*2+1,l,(l+r)/2),
           update(a,b,x,k*2+2,(l+r)/2,r));
    return dat[k];
  }
  int query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  void update(int a,int b,int x){
    update(a,b,x,0,0,n);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};

int N,Q;
int S[200010],T[200010],X[200010];
map<int,int> m;
int main(){
    scanf("%d%d",&N,&Q);
    vector<pair<int,int>> K;
    for(int i=1;i<=N;i++){
        scanf("%d%d%d",&S[i],&T[i],&X[i]);
        K.push_back({X[i],i});
    }
    sort(K.begin(),K.end(),greater<pair<int,int>>());
    vector<int> D(Q+1,-INT_MAX);
    for(int i=1;i<=Q;i++){
        cin >> D[i];
        m[D[i]] = i;
    }
    RUP seg(Q+1);
    for(int i=0;i<N;i++){
        int id = K[i].second;
        int id1 = lower_bound(D.begin(),D.end(),S[id]-X[id])-D.begin();
        int id2 = lower_bound(D.begin(),D.end(),T[id]-X[id])-D.begin();
        seg.update(id1,id2,X[id]);
    }
    for(int i=1;i<=Q;i++){
        int num = seg.query(m[D[i]],m[D[i]]+1);
        printf("%d\n",num!=INT_MAX? num:-1);
    }
}

Measured memory_bytes: 20080
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (Integer.parseInt(scanner.next()) >= K) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 45644
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean hantenFlg = true;
		StringBuilder sb = new StringBuilder();
		sb.append(S);
		int Q = Integer.parseInt(sc.next());
		for(int i=0;i < Q;i++) {
			if(Integer.parseInt(sc.next()) == 1) {
				hantenFlg = hantenFlg ? false: true;
			}  else {
				if(Integer.parseInt(sc.next())==1) {
					if(hantenFlg) {
						sb.insert(0, sc.next());
					} else {
						sb.append(sc.next());
					}
				} else {
					if(hantenFlg) {
						sb.append(sc.next());
					} else {
						sb.insert(0, sc.next());
					}
				}
			}
		}
		sb = hantenFlg ? sb: sb.reverse();
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 51780
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int R, C, in[10][10], out[10][10];
char g[10][10];

bool ok (int r, int c) { return r>=0 && c>=0 && r<R && c<C && g[r][c] == '#'; }
void fail () { puts("Impossible"); exit(0); }

int main () {
        scanf("%d %d", &R, &C);
        fo(i, 0, R) scanf(" %s", g[i]);

        fo(r, 0, R) fo(c, 0, C) if (ok(r, c)) {
                in[r][c] = ok(r-1, c) + ok(r, c-1);
                out[r][c] = ok(r+1, c) + ok(r, c+1);
                if (!r && !c) {
                        if (in[r][c] != 0 || out[r][c] != 1) fail();
                        continue;
                }
                if (r==R-1 && c==C-1) {
                        if (in[r][c] != 1 || out[r][c] != 0) fail();
                        continue;
                }
                if (in[r][c] == 1 && out[r][c] == 1) continue;
                if (in[r][c] == 0 && out[r][c] == 0) continue;
                fail();
        }

        puts("Possible");
        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

enum direction {
    none,
    i,
    j,
    ij
};

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

    string s, t;
    cin >> s >> t;

    vector<vector<li>> dp(s.size() + 1, vector<li>(t.size() + 1));
    vector<vector<direction>> prev(s.size() + 1, vector<direction>(t.size() + 1, none));
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            if (dp[i + 1][j] < dp[i][j + 1]) {
                prev[i + 1][j + 1] = direction::i;
            } else {
                prev[i + 1][j + 1] = direction::j;
            }
            if (s[i] == t[j]) {
                if (dp[i + 1][j + 1] < dp[i][j] + 1) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                    prev[i + 1][j + 1] = direction::ij;
                }
            }
        }
    }

    string ans = "";

    li p = s.size(), q = t.size();

    while (prev[p][q] != none) {
        switch (prev[p][q]) {
            case i:
                p--;
                break;
            case j:
                q--;
                break;
            case ij:
                p--;
                q--;
                ans.push_back(s[p]);
                break;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 105984
def num2alpha(num):
    if num <= 26:  return chr(64 + num)
    elif num % 26 == 0:  return num2alpha(num // 26 - 1) + chr(90)
    return num2alpha(num // 26) + chr(64 + num % 26)

N = int(input())
ans = num2alpha(N).lower()
print(ans)

Measured memory_bytes: 61540
n = int(input())
A = list(map(int, input().split()))
num = [0] * (10 ** 5 + 1)

for a in A:
    num[a] += 1
_sum = sum(A)

result = []
q = int(input())
for i in range(q):
    b, c = list(map(int, input().split()))
    _sum += (c - b) * num[b]
    num[c] += num[b]
    num[b] = 0
    result.append(str(_sum))
print('\n'.join(result))

Measured memory_bytes: 23780
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using pii=pair<int,int>;
bool isvalidpos(pii p, int h, int w){
    return p.first>=0 && p.first<h && p.second>=0 && p.second<w;
}
int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    vector<int> dy={0,0,1,-1};
    vector<int> dx={1,-1,0,0};
    int answer=0;
    for(int i=0; i<h; i++) cin>>s[i];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=='.'){
                vector<vector<int>> check(h,vector<int>(w));
                queue<pair<pii,int>> q;
                pii start;
                int maxdist=0;
                q.push({{i,j},0});
                check[i][j]=2;
                while(!q.empty()){
                    auto now=q.front();
                    q.pop();
                    if(maxdist<now.second){
                        maxdist=now.second;
                        start=now.first;
                    }
                    for(int k=0; k<4; k++){
                        pii nxt=now.first;
                        nxt.first+=dy[k];
                        nxt.second+=dx[k];
                        if(isvalidpos(nxt,h,w) && s[nxt.first][nxt.second]=='.' && check[nxt.first][nxt.second]!=2){
                            check[nxt.first][nxt.second]=2;
                            q.push({nxt,now.second+1});
                        }
                    }
                }
                q.push({start,0});
                maxdist=0;
                check[start.first][start.second]=1;
                while(!q.empty()){
                    auto now=q.front();
                    q.pop();
                    maxdist=max(maxdist,now.second);
                    for(int k=0; k<4; k++){
                        pii nxt=now.first;
                        nxt.first+=dy[k];
                        nxt.second+=dx[k];
                        if(isvalidpos(nxt,h,w) && s[nxt.first][nxt.second]=='.' && check[nxt.first][nxt.second]!=1){
                            check[nxt.first][nxt.second]=1;
                            q.push({nxt,now.second+1});
                        }
                    }
                }
                answer=max(answer,maxdist);
            }
        }
    }
    cout<<answer;

    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if(a == b) {
        if(a != c) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else if(b == c) {
        if(b != a) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else if(a == c) {
        if(a != b) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
}

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


def solve(N: int, s: "List[str]", t: "List[int]", X: str):
    neta=False
    neteru=0
    for i in range(N):
        if neta:
            neteru+=t[i]
        if s[i]==X:
            neta=True
    print(neteru)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [str()] * (N)  # type: "List[str]"
    t = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        s[i] = next(tokens)
        t[i] = int(next(tokens))
    X = next(tokens)  # type: str
    solve(N, s, t, X)

if __name__ == '__main__':
    main()


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

int n, m;
vector<int> G[200000];
bool used[100000];
void rec(int from) {
  if (used[from]) return;
  used[from] = true;
  for (int to : G[from]) {
    rec(to);
  }
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    ++cnt;
    rec(i);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 11264
#include <stdio.h>

int main(void) {

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

Measured memory_bytes: 600
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    var(int, N);
    vector<int> h(N);
    rep(i, N) input(h[i]);

    vector<int> dp(N);
    dp[N - 1] = 0;

    int res = 0;
    for (int i = N - 2; i >= 0; --i) {
        if (h[i] >= h[i + 1]) {
            dp[i] = dp[i + 1] + 1;
        } else {
            dp[i] = 0;
        }
        chmax(res, dp[i]);
    }

    print(res);

    return 0;
}


Measured memory_bytes: 1024
s = input().rstrip().split(' ')
H = int(s[0])
W = int(s[1])
a = [[0] * W for i in range(H)]
for i in range(H):
  t = input().rstrip().split(' ')
  for j in range(W):
    a[i][j] = int(t[j])
b = []
for k in range(W):
  c = int(input())
  b.append(c)
for l in range(H):
  sum = 0
  for m in range(W):
    x = int(a[l][m])
    y = int(b[m])
    sum += x * y
  print(sum)


Measured memory_bytes: 6016
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 a[] = new int[n];
      
      int b[] = new int[n];
      
      for (int g = 0; g < n; g++) {
         a[g] = sc.nextInt();
      }
      
      for (int h = 0; h < n; h++) {
         b[h] = 0;
      }
      
      for (int i = 0; i < m; i++) {
         int x = sc.nextInt();
         int y = sc.nextInt();
         if (a[x-1] > a[y-1]) {
            b[y-1] = 1;
         } else if (a[x-1] == a[y-1]) {
            b[x-1] = 1;
            b[y-1] = 1;
         } else {
            b[x-1] = 1;
         }
      }
      
      int count = 0;
      
      for (int l = 0; l < n; l++) {
         if (b[l] == 0) {
            count++;
         }
      }
      
      System.out.println(count);
   }
}


Measured memory_bytes: 60128
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll A, B; cin >> A >> B;
    if(A > B) swap(A,B); 
    if(A == 1 && B == 2) print(3);
    else if(A == 2 && B == 3) print(1);
    else print(2);
    return 0;
}

Measured memory_bytes: 256
/* ex 7_3
   riverstone */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    
    int row, column, i, j;
    //多次元配列の定義
    //black_rowとblack_colは各行と各列に1つ以上の黒が存在するかを記録
    char **block;
    int *black_row, *black_col;
 
    //入力の受け取り
    scanf("%d %d", &row, &column);

    //列の分のメモリ領域
    block = (char**)calloc(row, sizeof(char*));
    if(block == NULL){
        exit(1);
    }

    // 各行のメモリ領域の確保
    for(i = 0; i < row; i++){
        block[i] = (char*)calloc(column, sizeof(char));
        if(block[i] == NULL){
            exit(1);
        }
    }

    black_row = (int*)calloc(row, sizeof(int));
    if(black_row == NULL){
            exit(1);
    }

    black_col = (int*)calloc(column, sizeof(int));
    if(black_col == NULL){
            exit(1);
    }

 
//行列の各マスを読み取る
    //各行と各列に1つ以上の黒が存在するかをblack_rowとblack_colに記録
    for(i = 0; i < row; i++){
        for(j = 0; j < column; j++){
            scanf(" %c", &block[i][j]);
            if(block[i][j] == '#'){
                //マス(i,j)が黒のとき,black_row[i],black_col[j]を1にする
                black_row[i] = 1;
                black_col[j] = 1;
            }
        }   
    }
    
    //black_rowとblack_colを見て共に1であるようなマスの場合のみ出力
    for(i = 0; i < row; i++){
        if(black_row[i] == 1){
            for(j = 0; j < column; j++){
                if(black_col[j] == 1){
                    //black_row[i] = 1かつblack_col[j] = 1のときblock[i][j]を表示
                    printf("%c", block[i][j]);
                }
            }
            printf("\n"); //1行の処理が全て終わると改行する
 
        } 
    }

    //各メモリの開放
    for(i=0; i<row; i++){
        free(block[i]);
    }
    free(block);
 
    free(black_col);
    free(black_row);

    return 0;
}



Measured memory_bytes: 1636
#include <stdio.h>
 
#define N 2000
#define M 2000
 
int solve(int,int);
 
int n,q,A[N],m[M];
 
int main(){
 
  int i,j;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
 
    scanf("%d",&A[i]);
 
  }
 
  scanf("%d",&q);
 
  for(i=0;i<q;i++){
 
    scanf("%d",&m[i]);
 
  }
 
  for(i=0;i<q;i++){
 
    j=0;
 
    if(solve(j,m[i])==1) printf("yes\n");
    if(solve(j,m[i])==0) printf("no\n");
 
  
 
    }
   
  return 0;
}
 
int solve(int i ,int m){
 
  int res;
 
 
  if(m==0) return 1;
 
  if(i>=n) return 0;
 
  res=solve(i+1,m) || solve(i+1,m-A[i]);
 
}
  

Measured memory_bytes: 588
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    
    for (int i = 0; i < N; i++) {
        std::cin >> v[i];
    }
    
    int swap = 0;
    for (int i = 0; i < N; i++) {
       if (v[i] == i + 1) {
           continue;
       }
       if (v[v[i] - 1] == i + 1) {
           swap = swap + 1;
           continue;
       } else {
           swap = 100;
       }
    }
    
    if (swap <= 2) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
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 main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i,n) cin >> t[i];

    sort(t.begin(), t.end());
    int people = 0;
    int start = 0;
    int res = 0;
    for(int i = 0; i < n; i++){
        if(people > 0 && t[i] - start > k){
            res++;
            people = 0;
            start = t[i];
        }
        if(people == 0){
            start = t[i];
        }
        people++;
        if(people == c){
            res++;
            people = 0;
        }
    }
    if(people > 0) res++;
    cout << res << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int a[1000],b[1000],j,k,l;
    int i=0;
    while(1){
        scanf("%d %d",&a[i],&b[i]);
        if(a[i]==0 && b[i]==0){
            break;
            }
        i++;
        }
    for(j=0;j<i;j++){
        for(k=0;k<a[j];k++){
            for(l=0;l<b[j];l++){
                if((k+l)%2!=0){
                printf(".");
            }else{
                printf("#");
            }
            }
        printf("\n");
            
    }
    printf("\n");
    
}    
    return 0;
}
    


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll nax = 2e5 + 7;
ll s[nax];
ll par[nax];
int find_set(int v) {
	if (v == par[v])return v;
	return par[v] = find_set(par[v]);
}
void clear() {
	for (int i = 0; i < nax; i++) {
		par[i] = i;
		s[i] = 1;
	}
}
void union_sets(int a, int b) {
	a = find_set(a);
	b = find_set(b);
	if (a == b)return ;
	if (s[a] < s[b])
		swap(a, b);
	par[b] = a;
	s[a] += s[b];
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clear();
	ll n, k;
	cin >> n >> k;
	for (ll i = 0; i < k; i++) {
		ll u, v;
		cin >> u >> v;
		union_sets(u, v);
	}
	ll ans = 0;
	for (ll i = 0; i <= n; i++) {
		ans = max(ans, s[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6736
#include <stdio.h>

int main(void)
{
	int a,b,c,money;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b&&a>c){
		money=a*10+b+c;
	}else if(b>c){
		money=b*10+a+c;
	}else{
		money=c*10+a+b;
	}
	
	printf("%d",money);
	
	return 0;
}
	

Measured memory_bytes: 128
#include<bits/stdc++.h>
main(){
  int n,a,b;scanf("%d%d%d",&n,&a,&b);
  int ans=0;
  for(int i=1;i<=n;i++){
    int c=0,s=i;
    for(;s>0;)c+=s%10,s/=10;
   	ans+=(a<=c&&c<=b)?i:0;
  }
  printf("%d",ans);
}

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

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

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

	long long ans = 0;
	long long sum = 0;

	stack<int> stk;
	stk.push(-1);

	for (int i = 0; i < n; i++) {
		while (stk.size() >= 2 && a[stk.top()] >= a[i]) {
			int j = stk.top();
			stk.pop();
			sum -= (j - stk.top()) * a[j];
		}
		sum += a[i] * (i - stk.top());
		stk.push(i);
		ans += sum;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String a = sc.next(), b = sc.next(), c = sc.next();
		System.out.println(a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0) ? "YES" : "NO");
	}
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<vector<int>> last_two(2, vector<int>(2));
    int cur = 0;
    bool ans = false;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (i >= 2) {
            int count = 0;
            if (a == b && last_two[0][0] == last_two[0][1] && last_two[1][0] == last_two[1][1])
                ans = true;
        }
        last_two[cur][0] = a;
        last_two[cur][1] = b;
        cur = (cur + 1) % 2;
    }
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3660
def resolve():
    N, K = map(int, input().split(" "))
    Xs = list(map(int, input().split(" ")))
    ans = 10**9
    for i in range(N-K+1):
        cnt = Xs[i+K-1] - Xs[i] + min(abs(Xs[i+K-1]), abs(Xs[i]))
        ans = min(cnt, ans)
    print(ans)



if '__main__' == __name__:
    resolve()

Measured memory_bytes: 57940
import java.util.Scanner;
 public class Main{
 public static void main(String args[]){
   Scanner sc=new Scanner(System.in);
   int X=sc.nextInt();
   int A=sc.nextInt();
   int B=sc.nextInt();
           int left= X-A;
     while(left>=B)
   {
left-=B;

   }

           System.out.println(left);


   sc.close();
 }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int n, a[100000];

bool binarySearch(int l, int r, int v) {
    if (l == r)
        return false;
    int mid = (l + r) / 2;
    if (v == a[mid]) {
        return true;
    }
    if (v < a[mid]) {
        return binarySearch(l, mid, v);
    }
    else {
        return binarySearch(mid + 1, r, v);
    }
}

int main() {
    int q, v, ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    cin >> q;
    while (q--) {
        cin >> v;
        if (binarySearch(0, n, v))
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3408
from collections import defaultdict

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

dic = defaultdict(list)

for a, b in ab:
  dic[a-1].append(b-1)
  dic[b-1].append(a-1)

for i in range(N):
  print(len(dic[i]))


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll a,b,n;

void solve(){
    cin >> n >> a >> b;
    if(a+b==0){
        cout << 0 << endl;
        return;
    }
    ll ans=0;
    ans+=(n/(a+b))*a;
    if(n%(a+b)<=a){
        ans+=(n%(a+b));
    }
    else ans+=a;
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  ll k;
  cin>>s>>k;
  vector<string> v;
  rep(i,s.size()){
    Rep(j,k+1){
      string tmp=s.substr(i,j);
      v.push_back(tmp);
    }
  }
  sort(ALL(v));
  v.erase(unique(ALL(v)),v.end());
  cout<<v[k-1]<<endl;
  
}

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

int main(void){
  int N,K;
  cin >> N >> K;
      int d;
      int m;
  vector<bool> sunuke(N,false);
  for(int a=0;a<K;a++){
    cin >> d;
        for(int p=0;p<d;p++){
            cin >>m;
            sunuke[m-1]=true;
        }
    }
    int ans=0;
    for(int a=0;a<N;a++){
        if(!sunuke[a])ans++;
    }
    cout << ans<<endl;
}

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

typedef long long i64;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  while (k--) {
    if (count(a.begin(), a.end(), n) == n) break;
    vector<int> b(n + 1);
    for (int i = 0; i < n; ++i) {
      ++b[max(0, i - a[i])];
      --b[min(n, i + a[i] + 1)];
    }
    for (int i = 1; i < n; ++i)
      b[i] += b[i - 1];
    b.pop_back();
    a = b;
  }
  for (int i = 0; i < n; ++i) cout << a[i] << " ";
}


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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  vi v;
  rep(i,3){
    int a; cin >> a;
    v.pb(a);
  }
  sort(v.begin(),v.end());

  int k;cin >> k;
  int ans = v[0] + v[1];
  int a = v[2];
  rep(i,k) a*=2;
  ans += a;

  pr(ans);

return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	ll n, k;
	scanf("%lld %lld", &n, &k);
	ll ans=k;
	for(int i=0; i<n-1; i++){
		ans*=(k-1);
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  if(s=="Rainy"){
    cout<<"Sunny"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int n; // 整数

    while(cin >> n){
        int x[n]; // n次元のベクトル
        int y[n]; // n次元のベクトル

        for(int i = 0; i < n; i++){
            cin >> x[i];
            // cout << x[i] << " ";
        }
        // cout << endl;

        for(int i = 0; i < n; i++){
            cin >> y[i];
            // cout << y[i] << " ";
        }
        // cout << endl;

        double a1 = 0;
        for(int i = 0; i < n; i++){
            // cout << (x[i] - y[i]) << endl;
            a1 += fabs(x[i] - y[i]);
        }

        double a2 = 0;
        for(int i = 0; i < n; i++){
            a2 += pow(fabs(x[i] - y[i]), 2);
        }
        a2 = sqrt(a2);

        double a3 = 0;
        for(int i = 0; i < n; i++){
            a3 += pow(fabs(x[i] - y[i]), 3);
        }
        // cout << a3 << endl;
        a3 = pow(a3, 1.0 / 3.0);

        double a4 = 0;
        for(int i = 0; i < n; i++){
            if(a4 < fabs(x[i] - y[i])){
                a4 = fabs(x[i] - y[i]);
            }
        }

        printf("%lf\n", a1);
        printf("%lf\n", a2);
        printf("%lf\n", a3);
        printf("%lf\n", a4);
    }

    return 0;
}


Measured memory_bytes: 3316
import java.io.*;

public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        while (true) {
            final String[] lines = br.readLine().split(" ");
            final int x = Integer.parseInt(lines[0]);
            final int y = Integer.parseInt(lines[1]);
            if (x == 0 && y == 0) break;
            sb.append(x < y ? x + " " + y : y + " " + x).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25048
n,m = gets.chomp.split.map(&:to_i)
p = []
s = []
flag = Array.new(n){0}
ac = 0
wa = 0

for i in 0..m-1
    a,b = gets.chomp.split
    a = a.to_i
    p << a
    s << b
end

for i in 0..m-1
    if s[i] == 'AC'
        flag[p[i]-1] = 1
    end
end

for i in 0..m-1
    if flag[p[i]-1]==1
        if s[i]=='WA'
            wa += 1
        else
            ac += 1
            flag[p[i]-1]=0
        end
    end
end

puts "#{ac} #{wa}"

Measured memory_bytes: 13052
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;


#define int long long
// #define double ld
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}


signed main() {
    srand(time(0));
    accell();
    int n, a;
    cin >> a >> n;
    int s = 0;
    vector<int>b(n);
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        s += b[i];
    }
    if (s >= a) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std ;

#define ll long long
#define N 100010

char s[ N ] ;
int cur1 , cur2 , ans ;

//rock和paper，paper赢
//同样则不加分 
//rock-g , paper-p

int main() {
	scanf( "%s" , s + 1 ) ;
	int n = strlen( s + 1 ) ;
	if( s[ 1 ] == 'p' ) ans = -1 ;
	cur2 = 1 ;
	for( int i = 2 ; i <= n ; i ++ ) {
		if( s[ i ] == 'p' ) {
			if( cur1 < cur2 ) {
				cur1 ++ ;
			}else ans -- , cur2 ++ ;
		}else {
			if( cur1 < cur2 ) {
				cur1 ++ ;
				ans ++ ;
			}else cur2 ++ ;
		}
	}
	printf( "%d\n" , ans ) ;
	return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,x,n) for(long long i=(long long)(x);i<(long long)(n);i++)
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
/*#define cin fin
#define cout fout
ifstream cin("input.in");ofstream cout("output.out");*/
int main() 
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n,x,s=0,q=0;
    map<long long,long long> p;
    p[0]=1;
    cin>>n;
    while(n--)
    {
        cin>>x;
        s+=x;
        q+=p[s];
        p[s]++;
    }
    cout<<q;
}

Measured memory_bytes: 12800
require "prime"

class Integer
  def divisors
    prime_division.inject([1]) do |ary, (p, e)|
      (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
    end.sort
  end
end

n, m = gets.split.map(&:to_i)

d = m.divisors

d.each do |k|
  next if k < n
  puts m / k
  exit
end

Measured memory_bytes: 4088
fn main() {
    let n: usize = read_line_as_value();
    let input: Vec<usize> = read_line_as_vector();
    let mut ans: Vec<usize> =  vec![0; n];

    for i in 0..n {
        ans[input[i]-1] = i+1;
    }
    println!("{}", ans.into_iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

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



int main() {
  int n, m, sum=0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  
  
  string ans="No";
  int cnt=0;
  rep(i,n){
    if(a[i]*4*m >= sum) cnt++;
    if(cnt >= m){
      ans="Yes";
      break;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3568
import numpy as np

n = int(input())
v = np.array(list(map(int,input().split())))
v_sort = np.sort(v)
temp = 0

for index in range(n-1):
  temp = (v_sort[0]+v_sort[1])/2
  v_sort = np.delete(v_sort,0)
  v_sort = np.delete(v_sort,0)
  v_sort = np.append(v_sort,temp)
  v_sort = np.sort(v_sort)

print(v_sort[0])

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

int h[1000000];

int main()
{
	int n;
	cin>>n;
	int maxn=0;
	for(int i=0; i<n; i++)
		scanf("%d",&h[i]);
//	for(int i=0; i<n; i++)
//		printf("%d",h[i]);
	int temp;
	for(int i=0; i<n; i++)
	{
		temp=0;
		int j=i+1;
		while(h[j] <= h[j-1] && j < n)
		{
			temp++;
			j++;
		}
		i=j-1;
		maxn = max(maxn, temp);
	}
	cout<<maxn;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long max = 0;
    for (long i = 1; i <= N; i++) {
      if (i * i <= N) {
        max = i * i;
      }
    }
    System.out.println(max);
  }

  public static void primeFactorization(int num) {
    int Z = 0;
    for (int i = 2; num > i; i++) {
      while (num % i == 0) {
        System.out.println(i);
        num /= i;
        Z = num;
      }
    }
    System.out.println(Z);
  }

  public static boolean isPrime(int num) {
    if (num < 2)
      return false;
    else if (num == 2)
      return true;
    else if (num % 2 == 0)
      return false;

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int d[4] = {0,3,5,7};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll N; cin >> N;

	vector<ll> num; num.clear();

	for (int i = 0; i < 1048576; ++i){
		int curr = i;
		vector<int> mod; mod.clear();
		while(curr > 0){
			mod.push_back(curr%4);
			curr /= 4;
		} // end while

		if ((int)mod.size() < 3){
			continue;
		} // end if

		set<int> same; same.clear();
		rep (i, (int)mod.size()){
			same.insert(mod[i]);
		} // end rep

		if (same.count(0) || (int)same.size() != 3){
			continue;
		} // edn if

		ll cand = 0LL;
		rep (j, (int)mod.size()){
			cand *= 10LL;
			cand += (ll)d[mod[j]];
		} // end rep
		if (cand <= N){
//			cerr << "cand: " << cand << endl;
			num.push_back(cand);
		} // end if
	} // end for

	cout << (int)num.size() << endl;

	return 0;
}

Measured memory_bytes: 640