akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
    
    int ans=0;
    int j,k,l,m;
    for (int i=A; i<=B; i++) {
        j = i/10000 % 10;
        k = i/1000 % 10;
        l = i/10 % 10;
        m = i%10;
        if (j == m && k ==l) {
            ans ++;
        }
        //cout << j << k << l << m << endl;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def solve(t, r, s, p):
    ret = 0
    pre = ""
    for c in t:
        if c == "r":
            if pre != "p":
                ret += p
                pre = "p"
            else:
                pre = ""
        elif c == "p":
            if pre != "s":
                ret += s
                pre = "s"
            else:
                pre = ""
        else:
            if pre != "r":
                ret += r
                pre = "r"
            else:
                pre = ""
    return ret


def main():
    N, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input().strip()

    ans = 0
    for i in range(k):
        j = i
        tmp = []
        while j < N:
            tmp.append(t[j])
            j += k
        ans += solve(tmp, r, s, p)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define int long long
using namespace std;
int D[505][505];
int c[32][32];

signed main() {
  int N,C;
  cin>>N>>C;
  int x1=0;
  int x2=0;
  int x3=0;
  int ans=1000000000000;
  for(int i=0;i<C;i++)for(int j=0;j<C;j++)cin>>D[i][j];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if((i+j)%3==0)x1++;
      if((i+j)%3==1)x2++;
      if((i+j)%3==2)x3++;
    }
  }
  std::vector<int> c1(x1),c2(x2),c3(x3);
  int k=0;
  int l=0;
  int m=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if((i+j)%3==0){cin>>c1[k];k++;}
      if((i+j)%3==1){cin>>c2[l];l++;}
      if((i+j)%3==2){cin>>c3[m];m++;}
    }
  }
  std::vector<int> c1to(C,0),c2to(C,0),c3to(C,0);
  for(int i=0;i<C;i++){
    for(int j=0;j<x1;j++){
      c1to[i]+=D[c1[j]-1][i];
    }
  }
  for(int i=0;i<C;i++){
    for(int j=0;j<x2;j++){
      c2to[i]+=D[c2[j]-1][i];
    }
  }
  for(int i=0;i<C;i++){
    for(int j=0;j<x3;j++){
      c3to[i]+=D[c3[j]-1][i];
    }
  }
  for(int i=0;i<C;i++){
    for(int j=0;j<C;j++){
      for(int k=0;k<C;k++){
        if(i!=j&&j!=k&&k!=i)ans=min(ans,c1to[i]+c2to[j]+c3to[k]);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] numbers = new int[n];
		
		for (int i = 0; i < n; i++){
			numbers[i] = Integer.parseInt(br.readLine());;
		}
		
		int ans = 0;
		
		for (int i = 0; i < numbers.length; i++) {
			boolean flag = true; 
			
			int j = 2;
			while(j <= Math.sqrt(numbers[i])){
				if(numbers[i] % j == 0){
					flag = false;
					break;
				}
				j++;
			}
			
			if (flag){
				ans++;
			}
			
		}
		
		System.out.println(ans);
		
	}
	
}

Measured memory_bytes: 22876
n = int(input())
L = [int(i) for i in input().split()]

L.sort()
ans = 0
"""
#二分探索ver　-> import bisectと同じでもTLE.
#importはC言語veっで実行してるらしい．積極的に使おう 
for a in range(len(L)):
    for b in range(a+1,len(L)):
        c_max = L[a]+L[b]-1
        left = b+1
        right = len(L)
        mid = (right+left)//2
        while left<right:
            mid = (right+left)//2
            if c_max < L[mid]:
                right = mid
            else:
                left = mid+1
        ans += left-(b+1)
"""
for i in range(0,n-2):
    j = i+1
    k = j+1
    while j<n-1:
        while(k<n):
            if (L[j]-L[i]<L[k] and L[k]<L[i]+L[j]):
                k+=1
            else:
                break
        ans += k-(j+1)
        j += 1

        
print(ans)

Measured memory_bytes: 3188
#include<iostream>

using namespace std;

const static int MAX_N = 100000;

int N, K;
int A[MAX_N];
int main() {
  cin >> N  >> K;

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

  int num_del = K - 1;

  int cnt = (N - 1) / num_del;
  if ((N - 1) % num_del != 0)
    cnt += 1;

  cout << cnt << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    int lenS = S.length();
    int m = lenS/2;
    int l = m, r = m;
    if(lenS % 2 == 0) l--;

    if(lenS == 1) cout << 1 << endl;
    else{
        if(S[l] == '1' && S[r] == '1'){
            rep(i, lenS){
                if(S[i] == '0') S[i] = '1';
                else S[i] = '0';
            }
        }
        while(l >= 0 && S[l] == '0') l--;
        while(r < lenS && S[r] == '0') r++;
        if(l == -1 && r == lenS) cout << lenS << endl;
        else{
            if(l == -1){
                cout << r << endl;
            }
            else if(r == lenS){
                cout << lenS - (l+1) << endl;
            }
            else{
                cout << min(lenS - (l+1), r) << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        x: u128,
    }

    let mut cnt = 0;
    let mut money = 100;
    loop{
        money = money * 101 / 100;
        cnt += 1;
        if money >= x{
            break;
        }
    }
    println!("{}", cnt);
    return;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
  int k,n,ans;
  cin>>k>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  ans = a[1] - a[0];
  rep(i,n-1) ans = max(ans,a[i+1]-a[i]);
  ans = max(ans,k+a[0]-a[n-1]);
  cout<<k-ans<<endl;
}

Measured memory_bytes: 4416
def main():
    M=10**9+7
    n,k=map(int,input().split())
    r1=k*(k+1)//2%M
    r2=k*(k-1)//2%M
    *a,=map(int,input().split())
    ans=0
    for i,t in enumerate(a):
        tem=0
        for j,u in enumerate(a):
            if u<t:
                if j<i:tem+=r2
                else:tem+=r1
        ans+=tem
        ans%=M
    print(ans)
main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N;
	cin>>N;
	vector<int> a(N);
	rep(i,N) cin>>a[i];
	vector<ll> S(N+1);
	vector<int> X(N+1);
	rep(i,N){
		S[i+1] = S[i] + a[i];
		X[i+1] = X[i] ^ a[i];
	}

	ll ans = 0;
	int r = 1;
	rep(l,N){
		while(r<N && (S[r+1]-S[l] == (X[r+1]^X[l]))) r++;
		ans += r-l;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#define N 10000
#define Q 500
int main()
{
    int i = 0, j, a[N], b[Q], n, q, c=0;
    scanf("%d",&n);
    while(i<n)
    {
        scanf("%d ",&a[i]);
        i++;
    }
    i=0;
    scanf("%d",&q);
    while(i<q)
    {
        scanf("%d ",&b[i]);
        i++;
    }
    for(i = 0; i < q; i++)
    {
        j = 0;
        a[n] = b[i];
        while(a[j] != b[i])
        {
            j++;
        }
        if(j != n) c++;
    }
    printf("%d\n",c);
    

    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
    map<string, int> m;
    int n;
    char comma;
    string type;
    while(cin >> n >> comma >> type) 
        m[type]++;
    cout << m["A"] << endl;
    cout << m["B"] << endl;
    cout << m["AB"] << endl;
    cout << m["O"] << endl;
    return 0;
}

Measured memory_bytes: 0
x, n = map(int, input().split())
p = list(map(int, input().split()))


q = list(range(x-n,x+n+1))


for i in range(len(p)):
    if p[i] in  q:
        q[q.index(p[i])] = 0




a = [0]*len(q)
for i in range(len(q)):
    a[i]  = abs(q[i] - x)


print(q[(a.index(min(a)))])



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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int f = 1;
    for (int i = 0; i < n; i+=2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            f = 0;
            break;
        }
    }
    if (n & 1) f = 0;
    cout << (f ? "Yes" : "No") << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(a) (int)(a).size()
#define all(a) (a).begin() , (a).end()
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define name(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int N=(int)1e6+7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n + 2 , 0);
    int cost = 0;
    for(int i = 1; i <=n; i++){
        cin >> a[i];
        cost += abs(a[i] - a[i -1]);
    }
    cost += abs(a[n]);
    debug() << name(a);
    for(int i = 1; i <=n; i++){
        int ans = -abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1])
        + abs(a[i + 1] - a[i - 1]);
        debug() << name(ans);
        cout << cost + ans << '\n';
    }
    return 0;
}



Measured memory_bytes: 1664
# 度からラジアンを求める
def radian(degree)
  degree * Math::PI / 180
end

# ラジアンから度を求める
def degree(radian)
  radian * 180 / Math::PI
end

a, b, h, m = gets.split.map(&:to_i)

h_degree = 30 * h + m / 2.0
m_degree = 6 * m

hour_x = a * Math.cos(radian(h_degree))
hour_y = a * Math.sin(radian(h_degree))
minute_x = b * Math.cos(radian(m_degree))
minute_y = b * Math.sin(radian(m_degree))
puts Math.sqrt((hour_x - minute_x).abs ** 2 + (hour_y - minute_y).abs ** 2)


Measured memory_bytes: 14736
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
template<class T> inline bool chmax(T& a, T b) { bool ret = (a < b); if (ret) { a = b; } return ret; }
template<class T> inline bool chmin(T& a, T b) { bool ret = (b < a); if (ret) { a = b; } return ret; }
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int INF = 1e9;
const LL INFL = 1e18;
const int MOD = 1000000007;

int solve(int h, int w) {
  int ret = INF;
  int left = w / 3;
  rep(i, 3) {
    if (0 < left && 0 < w-left) {
      vector<int> v = { left * h, (w-left)*(h/2), (w-left)*(h-(h/2)) };
      sort(v.begin(), v.end());
      ret = min(ret, v[2] - v[0]);
    }
    ++left;
  }
  return ret;
}

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

  int h, w;
  cin >> h >> w;
  int ans = 0;
  if (h % 3 != 0 && w % 3 != 0) {
    ans = min({ h, w, solve(h, w), solve(w, h)});
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
const int maxn=5005;
const int mod=1e9+7;
int n;
int h[maxn],mem;
struct
{
    int v,next;
}e[maxn<<1];
void init()
{
    memset(h,-1,sizeof(h));
    mem=0;
}
void add(int u,int v)
{
    e[mem].v=v;
    e[mem].next=h[u];
    h[u]=mem++;
    e[mem].v=u;
    e[mem].next=h[v];
    h[v]=mem++;
}
long long fac[maxn];
long long inv[maxn];
void pre()
{
    fac[0]=fac[1]=inv[1]=inv[0]=1;
    for(int i=2;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-mod/i*inv[mod%i]%mod;
    }
    for(int i=2;i<maxn;i++)
        inv[i]=inv[i]*inv[i-1]%mod;
}
long long C(int a,int b)
{
    if(b<0||b>a) return 0;
    return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
long long A(int a,int b)
{
    if(b<0||b>a) return 0;
    return fac[a]*inv[a-b]%mod;
}
int sz[maxn];
vector<int> q;
void dfs(int u,int fa)
{
    sz[u]=1;
    int mx=0;
    for(int i=h[u];i+1;i=e[i].next)
    {
        int v=e[i].v;
        if(v==fa) continue;
        dfs(v,u);
        sz[u]+=sz[v];
        mx=max(mx,sz[v]);
    }
    mx=max(mx,n-sz[u]);
    if(mx<=n/2){
        q.clear();
        for(int i=h[u];i+1;i=e[i].next)
        {
            int v=e[i].v;
            if(v==fa) continue;
            q.push_back(sz[v]);
        }
        q.push_back(n-sz[u]);
    }
}
long long dp[2][maxn];
int main()
{
    init();
    pre();
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    dfs(1,1);
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    int cnt=0;
    int now=1;
    for(int i=0;i<q.size();i++)
    {
        int tsz=q[i];
        cnt=cnt^1;
        memset(dp[cnt],0,sizeof(dp[cnt]));
        for(int j=0;j<now;j++)
        {
            for(int k=0;k<=tsz;k++)
            {
                dp[cnt][j+k]=(dp[cnt][j+k]+dp[cnt^1][j]*C(tsz,k)%mod*A(tsz,k))%mod;
            }
        }
        now+=tsz;
    }
    long long ans=0;
    for(int i=0;i<now;i++)
    {
        int fu;
        if(i&1) fu=-1;
        else fu=1;
        ans=(ans+fu*dp[cnt][i]*fac[n-i])%mod;
    }
    printf("%lld\n",(ans%mod+mod)%mod);
    return 0;
}


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


#define ll long long
#define pll pair <ll,ll>
#define fi first
#define se second
#define endl "\n"
#define sqr(b) (b)*(b)


using namespace std;

int in_edg[111111], length[111111];
bool f[111111];
vector <int> ss[111111];

void dfs(int v) {
    f[v] = 1;

    for (auto j : ss[v]) {
        length[j] = max(length[j], length[v] + 1);
        in_edg[j]--;

        if (in_edg[j] == 0) {
            dfs(j);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    int n, m;
    cin >> n >> m;
    while (m--) {
        int x, y;
        cin >> x >> y;
        ss[x].push_back(y);
        in_edg[y]++;
    }

    for (int i = 1; i <= n; i++) {
        if (!f[i] && in_edg[i] == 0) {
            dfs(i);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, length[i]);

    cout << ans << endl;

    return 0;
}


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

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

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> x(N), d(N);
	rep(i,N) cin >> x[i];
	rep(i,N) d[i]=abs(X-x[i]);
	int ans=d[0];
	rep(i,N-1) ans=__gcd(ans,d[i+1]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{ 
    int S,h,m,s;  
    scanf("%d",&S);  
    h=S/3600;  
    m=(S-(h*3600))/60;  
    s=S-(h*3600)-(m*60);  
    printf("%d:%d:%d\n",h,m,s);  
    return 0;
    
}



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

int main()
{
	int n, x = 0;
	cin >> n;
	int a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
		x ^= a[i];
	}

	for(int i=0; i<n; i++){
		cout << (x^a[i]) << ' ';
	}

    return 0;
}


Measured memory_bytes: 4340
#include<stdio.h>
int main(){
  int n,m,s,e,w,i,j,l,mi,min,a,b,r;
  while(scanf("%d %d %d %d %d",&w,&n,&m,&s,&e),w){
    int d[110][110]={0};
    while(m--){
      scanf("%d %d %d",&a,&b,&r);
      d[a][b]=d[b][a]=r;
    }
    int c[12][110]={0};
    for(i=0;i<=w;i++){
      mi=s;
      int f[110]={0};
      for(l=0;l<n;l++){
	f[mi]=1;
	for(j=1;j<=n;j++){
	  if(d[mi][j]==0)continue;
	  if(c[i][j]==0||c[i][j]>c[i][mi]+d[mi][j]){
	    c[i][j]=c[i][mi]+d[mi][j];
	  }
	  if(c[i+1][j]==0||c[i+1][j]>c[i][mi]+d[mi][j]/2){
	    c[i+1][j]=c[i][mi]+d[mi][j]/2;
	  }
	}
	min=2100000000;
	for(j=1;j<=n;j++){
	  if(f[j]||c[i][j]==0)continue;
	  if(min>c[i][j])min=c[i][mi=j];
	}
      }
    }
    min=2100000000;
    for(i=0;i<=w;i++){
      if(c[i][e]==0)continue;
      if(min>c[i][e])min=c[i][e];
    }
    printf("%d\n",min);
  }
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll x,a,b;cin >>x>>a>>b;
    x-=a;
    x%=b;
    cout <<x<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	if (N == 1) {
		cout << 1;
		return 0;
	}
	sort(A.begin(), A.end());
	vector<bool>v(1000001, false);
	int ans = 0;
	rep(i, N) {
		bool b = false;
		if (i == N - 1) {
			if (A[i] == A[i - 1])b = true;
		}
		else{
			if (A[i] == A[i + 1])b = true;
		}
		if (v[A[i]])continue;
		if (b) {
			for (int j = A[i]; j <= 1000000; j += A[i])v[j] = true;
		}
		else {
			ans++;
			for (int j = A[i]; j <= 1000000; j += A[i])v[j] = true;
		}
	}
	cout << ans;
}

Measured memory_bytes: 4844
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std; 
int main()
{
    int x,n,i,a[55],max;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
    {
    	if(i%2==0)
     	a[i]=24-a[i];
    }        
    sort(a+1,a+n+1);
    max=100;
    for(i=1;i<=n;i++)
    max=min(max,a[i]-a[i-1]);
    printf("%d\n",max);
}

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

int main()
{
  int n;
  std::cin>>n;
  int a;
  int i,count=0;
  vector<int> v;
  for(i=1;i<=n;i++)
  {
    std::cin>>a;
    v.push_back(a);
  }
  for(i=0;i<n;i++)
  {
    if(v[i]%2==0)
    {
      if(v[i]%3!=0&&v[i]%5!=0)
      {
        std::cout<<"DENIED";
        return 0;
      }
    }
  }
    std::cout<<"APPROVED";
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        List<R> list = new ArrayList<>();

        for(int i=0; i<n; i++) {
            list.add(new R(i+1, sc.next(), sc.nextInt()));
        }
        Collections.sort(list);
        for(R r : list) {
            System.out.println(r.num);
        }
    }

    static class R implements Comparable<R>{
        int num;
        String s;
        int p;
        public R(int num, String s, int p) {
            this.num = num;
            this.s = s;
            this.p = p;
        }
        public int compareTo(R o) {
            int a = s.compareTo(o.s);
            if(a != 0) return a;
            return o.p - p;
        }

    }

}


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;

int main(void){ 
    IOS;
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    ans += min(k, a);
    k -= min(k, a);
    if (k){
        k -= min(k, b);
    }
    ans -= k;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h, vector<char>(w));
  rep(i, h) {
    string tmp;
    cin >> tmp;
    rep(j, w) c[i][j] = tmp[j];
  }

  int n = h + w;

  // {0, 1, ..., n-1} の部分集合の全探索
  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    set<int> red_h;
    set<int> red_w;
    for (int r = 0; r < n; ++r) {
      if (bit & (1 << r)) {  // 列挙に i が含まれるか
        if (r < h)
          red_h.insert(r);
        else
          red_w.insert(r - h);
      }
    }

    int cnt = 0;
    rep(i, h) {
      rep(j, w) {
        if (red_h.count(i) == 0 && red_w.count(j) == 0 && c[i][j] == '#') cnt++;
      }
    }

    if (cnt == k) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,q,i,t,x,ansa[200005],ansb[200005],mna,mnb;
long long ans;
set<int> a,b;
set<int>::iterator it;
int main()
{
	cin>>n>>q;
	mna=mnb=n-2;
	ans=n-2;
	ans*=(n-2);
	while(q--){
        cin>>t>>x;
        if(t==1){
            it=a.lower_bound(x);
            if(it==a.begin()){
                ansa[x]=mnb;
                mna=x-2;
            }
            else{
                it--;
                ansa[x]=ansa[*it];
            }
            ans-=ansa[x];
            a.insert(x);
        }
        else{
            it=b.lower_bound(x);
            if(it==b.begin()){
                ansb[x]=mna;
                mnb=x-2;
            }
            else{
                it--;
                ansb[x]=ansb[*it];
            }
            ans-=ansb[x];
            b.insert(x);
        }
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 14396
<?php

$N = trim(fgets(STDIN));

for($i = 0;$i < $N;$i++) {
  $hoge = str_split(trim(fgets(STDIN)));
  sort($hoge);

  $array[] = implode("", $hoge);
}

$count = array_count_values($array);

$ans = 0;
foreach($count as $k => $v) {
  for($i = 1;$i < $v;$i++) {
    $ans += $i;
  }
}

echo $ans."\n";

Measured memory_bytes: 43764
#include <stdio.h>

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

    scanf("%s", input);
    switch(input[0]) {
        case 'S':
            printf("Cloudy\n");
            break;
        case 'C':
            printf("Rainy\n");
            break;
        case 'R':
            printf("Sunny\n");
            break;
    }
    return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n, ans = 0, tmp = 0;
  vector<int> h(100000);

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> h[i];
  for (int i = 1; i < n; i++)
  {
    if (h[i - 1] >= h[i])
      tmp++;
    else
    {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  cout << max(ans, tmp) << endl;
}

Measured memory_bytes: 3748
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, M = map(int, input().split())

ans = 0
if N >= 2:
    ans += N * (N - 1) // 2
if M >= 2:
    ans += M * (M - 1) // 2
print(ans)





Measured memory_bytes: 8008
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i+M-1<N;i++){
			for(int j=0;j+M-1<N;j++){
				bool chk = true;
				
				for(int k=0;k<M;k++){
					for(int l=0;l<M;l++){
						chk &= A[i+k][j+l] == B[k][l];
					}
				}
				
				if(chk) {
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		
		Console.WriteLine("No");
		
		
	}
	int N,M;
	String[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new String[N];
		B = new String[M];
		for(int i=0;i<N;i++) A[i] = rs();
		for(int i=0;i<M;i++) B[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int M,N;
  cin >> N >> M;
  
  int A[N];
  long long all = 0;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    all += A[i];
  }
  
  sort(A,A + N,greater<int>());
  if(A[M-1] >= (double)all/(4*M))  cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
A,B,C,K = map(int,input().split())
ans = 0
if A<K:
    ans += A
    K -= A
else:
    print(K)
    K = 0
if not K:
    pass
elif B<K:
    K -= B
else:
    print(ans)
    K = 0
if not K:
    pass
else:
    print(ans-K)


Measured memory_bytes: 9184
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    map<char, int> d;
    string w;
    cin >> w;
    rep(i,w.length()){
        d[w[i]]++;
    }
    bool flag = true;
    for (auto it : d)
    {
        if(it.second%2!=0)
            flag = false;
    }
    if(flag)cout<<"Yes"<<endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int N, M;
  cin >> N >> M;

  vector<vector<int>> s(M);
  vector<int> k(M);
  vector<int> p(M);

  int tmp;
  REP(i, M){
    cin >> k[i];
    REP(j, k[i]) {
      cin >> tmp;
      tmp--;
      s[i].push_back(tmp);
    }
  }
  REP(i, M) cin >> p[i];

  int count = 0;
  REP(i, pow(2, N)){
      vector<int> on;
      int tmp = i;
      int tmp1;
      REP(j, N){
        on.push_back(tmp % 2);
        tmp /= 2;
      }
      bool flag = true;
      REP(j, M){
        tmp = 0;
        for(auto iter : s[j]) tmp += on[iter];
        if (tmp % 2 != p[j]) {
          flag = false;
        }
        //cout <<  tmp << " " << j << " " <<(tmp % 2) << endl;

      }
      if (flag) count++;
  }

  cout << count << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
	int n;
	std::cin >> n;
	if (n == 1) {
		std::cout << 1 << std::endl;
		return 0;
	}

	std::vector<int> primes;
	for (int i = 2; i <= n; ++i) {
		bool isPrime = true;

		for (int j = 2; j*j <= i; ++j) {
			if (i % j == 0) {
				isPrime = false;
				break;
			}
		}

		if (isPrime)
			primes.push_back(i);
	}

	std::vector<int64_t> count(primes.size());
	for (int i = 2; i <= n; ++i) {
		int m = i;
		for (int j = 0; j < primes.size(); ++j)
			while (m % primes[j] == 0)
				++count[j], m /= primes[j];
	}

	int64_t ans = 1;
	for (auto&& e : count)
		ans = (ans * (e + 1)) % 1000000007;

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)

int n, a[100005], dp[100005], dp2[3][100005], ans;
int main(){
    cin >> n;
    fox(l, n) cin >> a[l];
    fox(l, n){
        if (l==0 || a[l-1]==a[l]) dp[l]=1;
        else dp[l]=dp[l-1]+1;
        ans=max(ans, dp[l]);
    }
    foxr(l, n){
        if (l==n-1 || a[l+1]==a[l]){
            fox(l2, 3) dp2[l2][l]=1;
            if (l!=n-1)
            fox1(l2, 2) dp2[l2][l]=max(dp2[l2][l], dp2[l2-1][l+1]+1);
        } else {
            fox(l2, 3) dp2[l2][l]=dp2[l2][l+1]+1;
        }
        fox(l2, 3) ans=max(ans, dp2[l2][l]);
        //fox(l2, 3) cout << dp2[l2][l] << ' '; cout << endl;
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
  int n,h[1000],flag=0,ans=0,v;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  while(flag==0){
    for(int i=0;i<n;i++){
      if(h[i]==0){
        ans++;
      }
      if(h[i-1]==0 && h[i]==0){
        ans--;
      }


    }
    ans++;
    if(h[0]==0){
      ans--;
    }
    if(h[n-1]==0){
      ans--;
    }
    v=0;
    for(int i=0;i<n;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
        if(h[i]!=0){
          v++;
        }
      }
    }
if(v==0){
  flag=1;
}


  }
  cout << ans << endl;
}


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

typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
bool D[10];
ll n, k,d;
signed main() {
	cin >> n>>k;
	rep(i,k) {
		cin >> d;
		D[d] = 1;
	}
	for (ll i = n;;i++) {
		ll a = i; 
		bool flag = true;
		while (a) {
			if (D[a % 10])flag = false;
			a /= 10;
		}
		if (flag) {
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int H,W,i,j;
  while(1){
    scanf("%d%d",&H,&W);
    if(H==0 && W==0) break;
    for(i=1;i<=H;i++){
      for(j=1;j<=W;j++){
        if(i%2==1&&j%2==1) printf("#");
        else if (i%2==0&&j%2==0) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, P>;
#define FOR(t, a, b) for (int t = (a); t < (b); ++t)
#define REP(t, n) FOR(t, 0, n)

int main()
{
    int N, X;
    int M[100];
    cin >> N >> X;
    int min = 10000;
    REP(i, N)
    {
        int temp;
        cin >> temp;
        M[i] = temp;
        X -= temp;
        if (min > temp)
        {
            min = temp;
        }
    }
    cout << N + X / min << endl;

    return 0;
}


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

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

const int maxn = 200005;

int n, a[maxn], pmax[maxn], suf[maxn], res[maxn];
int len[2], p[2][maxn], Pmax[2][maxn], sum[2];

int rt[2][maxn], lch[maxn * 60], rch[maxn * 60], Max[maxn * 60], tot;

#define mid ((l + r) >> 1)

void insert(int &s, int l, int r, int p, int v)
{
	++tot;
	lch[tot] = lch[s]; rch[tot] = rch[s]; Max[tot] = Max[s];
	s = tot;
	if (l == r) return Max[s] = v, void();
	if (p <= mid) insert(lch[s], l, mid, p, v);
	else insert(rch[s], mid + 1, r, p, v);
	Max[s] = max(Max[lch[s]], Max[rch[s]]);
}

int query(int s, int l, int r, int ql, int qr)
{
	if (ql <= l && r <= qr) return Max[s];
	int res = 0;
	if (ql <= mid) res = max(res, query(lch[s], l, mid, ql, qr));
	if (qr >= mid + 1) res = max(res, query(rch[s], mid + 1, r, ql, qr));
	return res;
}

inline int check(int Id, int pos)
{
	int tmp = sum[Id] - sum[Id ^ 1] + suf[pos];
	if (tmp < 0) return 0;
	int res = query(rt[tmp & 1][pos], 1, n, Pmax[Id ^ 1][len[Id ^ 1]] + 1, n);
	return res >= tmp;
}

int main()
{	
	n = gi();
	for (int i = 1; i <= n; ++i) a[i] = gi(), pmax[i] = max(pmax[i - 1], a[i]);
	for (int i = n; i >= 1; --i) suf[i] = suf[i + 1] + (pmax[i] == a[i]);

	for (int i = n; i >= 1; --i) {
		int g0 = query(rt[0][i + 1], 1, n, a[i] + 1, n), g1 = query(rt[1][i + 1], 1, n, a[i] + 1, n);
		//printf("%d %d\n", g0, g1);
		if (pmax[i] == a[i]) {
			insert(rt[0][i] = rt[0][i + 1], 1, n, a[i], g0 + 2);
			if (g1) insert(rt[1][i] = rt[1][i + 1], 1, n, a[i], g1 + 2); else rt[1][i] = rt[1][i + 1];
		} else {
			insert(rt[1][i] = rt[1][i + 1], 1, n, a[i], g0 + 1);
			if (g1) insert(rt[0][i] = rt[0][i + 1], 1, n, a[i], g1 + 1); else rt[0][i] = rt[0][i + 1];
		}
	}

	fill(res + 1, res + n + 1, -1);
	for (int i = 1; i <= n; ++i) {
		for (int d = 0; d < 2; ++d) {
			p[d][++len[d]] = a[i];
			Pmax[d][len[d]] = max(Pmax[d][len[d] - 1], a[i]);
			sum[d] += Pmax[d][len[d]] == p[d][len[d]];

			if (check(0, i + 1)) {res[i] = d; break;}
			if (check(1, i + 1)) {res[i] = d; break;}

			sum[d] -= Pmax[d][len[d]] == p[d][len[d]];
			--len[d];
		}
		if (!~res[i]) return puts("-1"), 0;
	}

	for (int i = 1; i <= n; ++i) printf("%d", res[i]);
	
	return 0;
}


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

#define int long long

#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,t[100010],M,p[100010],x[100010];


signed main() {
    IOS();
    /*シフト演算は(1ll<<x)*/
    int sum=0;
    cin>>N;
    rep(i,0,N){
        cin>>t[i];
        sum+=t[i];
    }
    cin>>M;
    rep(i,0,M){
        cin>>p[i]>>x[i];
        cout<<sum-t[p[i]-1]+x[i]<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
import sys,math
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

t=inp()
number=set()
for _ in range(t):
	x=input()
	number.add(x)
print(len(number))


Measured memory_bytes: 31132
import java.util.*;
import java.lang.*;
import java.math.*;

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

	void run() {
		for (;;) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			int d = sc.nextInt();
			if ((a | b | d) == 0) {
				break;
			}

			int min = Integer.MAX_VALUE;
			int min2 = Integer.MAX_VALUE;
			int aa = 0;
			int ba = 0;
			for (int i = -100000; i < 100001; i++) {
				int a2 = a * i;
				int b2 = a2 - d;
				if (b2 % b == 0) {
					if (min > (Math.abs(i) + Math.abs(b2 / b))) {
						aa = Math.abs(i);
						ba = Math.abs(b2 / b);
						min = ba + aa;
						min2 = aa*a+ba*b;
					}else if(min == (Math.abs(i) + Math.abs(b2 / b))) {
						
						int aaa = Math.abs(i);
						int aba = Math.abs(b2 / b);
						if(min2 >aaa*a+aba*b){
							aa = aaa;
							ba = aba;
							min2 = aa*a+ba*b;
						}
						min = ba + aa;
						
					}
				}

				int b3 = a2 + d;
				// sc.next();
				if (b3 % b == 0) {
					if (min > (Math.abs(i) + Math.abs( b3 / b))) {
						aa = Math.abs(i);
						ba = Math.abs(b3 / b);
						min = aa + ba;
					}else if(min == (Math.abs(i) + Math.abs(b3 / b))) {
						
						int aaa = Math.abs(i);
						int aba = Math.abs(b3 / b);
						if(min2 >aaa*a+aba*b){
							aa = aaa;
							ba = aba;
							min2 = aa*a+ba*b;
						}
						min = ba + aa;
						
					}
				}
			}

			System.out.println(aa + " " + ba);
		}

	}

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

Measured memory_bytes: 12000
N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(str, input().split()))
  a=int(a)
  if not list_Flag[a-1] == 1:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    elif b=='AC':
      list_Flag[a-1]=1
penalty = [0] * N
for p in range(N):
    penalty[p]=list_WA[p]*list_Flag[p]
PE=sum(penalty)
AC=sum(list_Flag)
print(AC,PE)

Measured memory_bytes: 5492
#include <iostream>
using namespace std;
#define ll long long
int main () {
    ll N, A;
    cin >> N >> A;
    ll x[N];
    for (ll i = 0; i < N; i++) {
      cin >> x[i];
      x[i] -= A;    
    }       
    ll dp[N][5001];
    for (ll i = 0; i < N; i++) {
      for (ll j = 0; j <= 5000; j++) {
        dp[i][j] = 0;  
      }  
    }
    for (ll i = 0; i < N; i++) {
      for (ll j = 0; j <= 5000; j++) {
        if (i == 0) {
          dp[0][x[i] + 2500]++;  
          break;
        }
        else {
          if (j == 0) {
            dp[i][x[i] + 2500]++;  
          }
          if (dp[i - 1][j] != 0) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j + x[i]] += dp[i - 1][j];
          }    
        }
      }   
    }
    cout << dp[N - 1][2500] << endl;
}

Measured memory_bytes: 2176
'use strict'

const Main = (input) => {
  const tmp = input.trim().split('\n')
  const N = parseInt(tmp[0].split(' ')[0])
  const L = parseInt(tmp[0].split(' ')[1])

  const Sarr = []
  for (let i = 1; i < tmp.length; i++) {
    Sarr.push(tmp[i])
  }

  let result = Sarr.sort().join('')

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std ;
int main () {
    string S;
    cin>>S;
    int n = S.size();
    int ans = 1000;
    for(int i=0; i <= n - 3; i++){
      int num = (S[i] - '0')*100 + (S[i+1] - '0')*10 + S[i+2] - '0';
      ans = min(ans, abs(num - 753));
    }
  cout<<ans<<endl;
}

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

int main(){

  int n;
  char c;

  while(cin>>n>>c){
    if(1<=n && n<=9){
      switch(n){
      case 1 : break;
      case 2 : cout<<'k'; break;
      case 3 : cout<<'s'; break;
      case 4 : cout<<'t'; break;
      case 5 : cout<<'n'; break;
      case 6 : cout<<'h'; break;
      case 7 : cout<<'m'; break;
      case 8 : cout<<'y'; break;
      case 9 : cout<<'r'; break;
      }
      switch(c){
      case 'T' : cout<<'a'; break;
      case 'L' : cout<<'i'; break;
      case 'U' : cout<<'u'; break;
      case 'R' : cout<<'e'; break;
      case 'D' : cout<<'o'; break;
      }
    }
    else if(n==0){
     switch(c){
     case 'T' : cout<<'w'<<'a'; break;
     case 'L' : break;
     case 'U' : cout<<'n'<<'n'; break;
     case 'R' : break;
     case 'D' : cout<<'w'<<'o'; break;
     }
   }
  }
  puts("");
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};


int main(){
  int rgb[] = {0,0,0};
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  const ll mod = 1000000007;
  modint<mod> ans = 1;
  for(int i = 0; i < n; ++i){
    int cnt = 0;
    for(int j = 0; j < 3; ++j)if(rgb[j] == v[i])cnt++;
    for(int j = 0; j < 3; ++j)if(rgb[j] == v[i]){rgb[j]++;break;}
    ans *= cnt;
  }
  cout << ans << endl;
  return 0;
}


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

#include <atcoder/dsu>
using ll = long long;
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n, q;
	int ans = 0;
	cin >> n >> q;
	dsu d(n);
	int t, u, v;
	rep(i, q) {
		cin >> t >> u >> v;
		if (t == 0) {
			d.merge(u, v);
		} else {
			cout << d.same(u, v) << endl;
		}
	}
}

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

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

    ll ans = -1e18;
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

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

Measured memory_bytes: 3616