akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int cnt[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}
	int ans = 0;
	for (int i = 1; i + 5 < N; i++)
	{
		ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> H >> W;
	vector<vector<int>>dis(H, vector<int>(W, MOD));
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	queue<pair<int, int>>Q;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				dis[i][j] = 0;
				Q.push({ i,j });
			}
		}
	}
	int dir[] = { 1,0,-1,0,1 };
	while (!Q.empty()) {
		auto cn = Q.front();
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int ny = cn.first + dir[i];
			int nx = cn.second + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			if (dis[ny][nx] > dis[cn.first][cn.second] + 1) {
				dis[ny][nx] = dis[cn.first][cn.second] + 1;
				Q.push({ ny,nx });
			}
		}
	}
	int ans = 0;
	for (auto i : dis)for (auto j : i)ans = max(ans, j);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13456
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 998244353LL
#define MOD2 996491788296388609LL
#define MODL 7971934306371108872LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    inline constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};
 
ModFact<300000, ll, MOD> fact;

int main() {
    fastio();
    ll N, A, B, K, ans = 0;
	cin >> N >> A >> B >> K;
    ll g = gcd(A, B);
    if(K%g==0) {
        ll ca=B/g, cb=A/g;
        ll oa=min(N, K/A), ob=min(N, K/B);
        ll i=0, j=ob;
        while(i<=oa) {
            while (i*A+j*B>K) j--;
            if (i*A+j*B==K) break;
            i++;
        }
        while(i<=oa && j>=0) {
            ans += fact.comb(N,i)*fact.comb(N,j);
            if(ans >= MODL) ans -= MODL;
            i += ca; j -= cb;
        }
    }
    cout << ans%MOD << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Stream;

public class Main
{
    private static int f(int[] xs, int pos, int max, int count) {
        if (pos >= xs.length) {
            return count;
        }

        if (xs[pos] < max) {
            return Math.max(
                    f(xs, pos + 1, xs[pos], count + 1),
                    f(xs, pos + 1, max, count));
        }
        else {
            return f(xs, pos + 1, max, count);
        }
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }

//        System.out.println(f(xs, 0, Integer.MAX_VALUE, 0));
        Set<Integer> set = new HashSet<>();
        for (int i : xs) {
            set.add(i);
        }
        System.out.println(set.size());
   }
}


Measured memory_bytes: 23892
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int a, b; cin >> a >> b;
    string p = "Positive", n = "Negative", z = "Zero";
    if(a == 0 || b == 0) cout << z << ln;
    else if(a > 0 && b > 0) cout << p << ln;
    else if(a < 0 && b > 0) cout << z << ln;
    else if(a < 0 && b < 0){
        if((b-a)%2==1) cout << p << ln;
        else cout << n << ln;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const long long mod=1e9+7;
long long matmod(long long val,long long k){
	long long ret=1ll;
	for(;k;k>>=1){
		if(k&1) ret=(val*ret)%mod;
		val=(val*val)%mod;
	}
	return ret;
}
void add(long long &des,long long sor){des+=sor;des%=mod;return ;}
char s[5005];
int n;
long long f[2][5005];
int main(){
	//freopen("keyboard.in","r",stdin);
	//freopen("keyboard.out","w",stdout);
	scanf("%d",&n);
	scanf("%s",s);
	int len=strlen(s);
	if(len>n){puts("0");return 0;}
	long long mul=matmod(2ll,len);
	f[0][0]=1ll;
	long long ans=f[0][len];
	for(int i=1;i<=n;i++){
		memset(f[i&1],0,sizeof(f[i&1]));
		f[i&1][0]=(f[(i-1)&1][0]+f[(i-1)&1][1])%mod;
		for(int j=1;j<=i;j++){
			add(f[i&1][j],f[(i-1)&1][j-1]*2ll);
			add(f[i&1][j],f[(i-1)&1][j+1]);
		}
		add(ans,f[i&1][len]);
	}
	long long tmp=matmod(mul,mod-2ll);
	long long newans=f[n&1][len]*tmp%mod;
	printf("%lld\n",newans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s;
    int ans = 0;
    while(cin >> s){
        bool c = true;
        int len = s.size();
        rep(i,len / 2){
            if(s[i] != s[len - i - 1]){
                c = false;
            }
        }
        if(c) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
 
int main(){
    int n,i,j,l;
    cin>>n;
    ld dp[n+1][n+1];
    ld a[n+1];
    for(i=0;i<n;i++) cin>>a[i+1];
    dp[0][0]=(ld)1;
    for(i=1;i<=n;i++){
        dp[i][0]=dp[i-1][0]*a[i];
    }
    for(i=1;i<=n;i++){
        dp[0][i]=(1.0 - a[i])*dp[0][i-1];
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n-i;j++){
            dp[i][j]=dp[i-1][j]*(a[i+j]) + dp[i][j-1]*(1.0 - a[j+i]);
        }
    }
    ld ans=0;
    int x;
    x=n/2 + 1;
    for(i=n;i>=x;i--){
        j=n-i;
        ans=ans+dp[i][j];
    }
 
 
    cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}

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

int main(void) {
  int R;
  cin >> R;

  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  };

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100
#define SIZE 100

int stack[SIZE];
int stack_size = 0;

int pop(){
    stack_size--;
    return stack[stack_size+1];
}

void push(int x){
    stack_size++;
    stack[stack_size] = x;
}

int main(){
  int stock,x,a,b,i;
  char s[MAX];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        a = pop();
        b = pop();
        stock = a + b;
        push(stock);
    } else if ( s[0] == '-' ){
        a = pop();
        b = pop();
        stock = b - a;
        push(stock);
    } else if ( s[0 ] == '*' ){
        a = pop();
        b = pop();
        stock = a * b;
        push(stock);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}






Measured memory_bytes: 2084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n, int mod) {
    if (n == 0) { return 1 % mod; }
    int x = rui(a, n / 2, mod);
    x *= x; x %= mod;
    if (n % 2 == 1) { x *= a; x %= mod; }
    return x;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
vel uni(vel x) {
    if (x.size() == 0) { return x; }
    sor(x);
    int n = x.size();
    vel ans(1, x[0]);
    for (int j = 1; j < n; j++) {
        if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
    }
    x = ans;
    return x;
}
void pr(vel& v) {
    int n = v.size();
    if (n != 0) {
        cout << v[0];
        rep(i, n - 1) {
            cout << " " << v[i + 1];
        }
        cout << endl;
    }
}
signed main(){
    int n; cin >> n;
    int ans = 0;
    vel a(n);
    rep(i, n) { cin >> a[i]; }
    rep(j, n - 1) {
        if (a[j] < a[j + 1]) { ans++; }
    }
    cout << n - ans <<endl<< n << endl;
    return 0;
}



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

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

    int ans = 1;
    for(int i = 0; i < 8; i++){
        if(pow(2, i) <= n){
            ans = pow(2, i);
        }
        else{
            break;
        }
    }

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

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = 60 * h1 + m1;
    int t2 = 60 * h2 + m2;
    int t = t2 - t1;
    if (t < 0) t += 24 * 60;
    print(t - k);

    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,e,t;
    t = 0;
    cin >> a >> b >> c >> d >>e;
    if(a > 0){
        t = (b - a)*e;
    }
    else{
        t = d + (-a)*c + b*e;
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
ll inv(ll a, ll b){ return a<2 ? a : ((a-inv(b%a,a))*b+1)/a %b; }
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

int N,a[100010];
map<int,int> mp;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	
	int i;
	for (i=1; i<=N; i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	
	ll res=0;
	for (auto it : mp){
		int val=it.fi;
		int cnt=it.se;
		
		if (cnt<val) res+=cnt;
		else res+=cnt-val;
	}
		
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 5120
n = int(input())
a = list(map(int, input().split()))

a.sort()
a_set = set(a)
for i in range(n-1):
    if a[i] == a[i + 1]:
        if a[i] in a_set:
            a_set.remove(a[i])

ma = max(a)

dp = [True for _ in range(ma + 1)]
ans = 0
y = -1
for x in a:
    if x == y:
        continue
    y = x

    if x in a_set:
        ans += 1 if dp[x] else 0

    while y <= ma:
        dp[y] = False
        y += x

print(ans)


Measured memory_bytes: 195680
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	int N,x;
	cin >> N >> x;
	int a[N];
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	sort(a,a+N);
	int count=0;
	for(int i=0;i<N;i++){
		if(a[i]<=x){
			x = x-a[i];
			count++;
		}else{
			break;
		}
	}
	if(count==N&&x>0)count-=1;
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if(x1==0) cout << 1 << endl;
  if(x2==0) cout << 2 << endl;
  if(x3==0) cout << 3 << endl;
  if(x4==0) cout << 4 << endl;
  if(x5==0) cout << 5 << endl;
  
return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007
struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int friend_cnt[100005] = {};
  int blocks_cnt[100005] = {};
  UnionFind friends(n);

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    friend_cnt[a - 1]++;
    friend_cnt[b - 1]++;
    friends.unite(a - 1, b - 1);
  }
  REP(i, k) {
    int a, b;
    cin >> a >> b;
    if (friends.same(a - 1, b - 1)) {
      blocks_cnt[a - 1]++;
      blocks_cnt[b - 1]++;
    }
  }

  REP(i, n) {
    if (i != n - 1) {
      cout << friends.size(i) - 1 - friend_cnt[i] - blocks_cnt[i] << " ";
    } else {
      cout << friends.size(i) - 1 - friend_cnt[i] - blocks_cnt[i] << endl;
    }
  }
}

Measured memory_bytes: 4396
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, P = map(int, input().split())
    S = str(input())

    def main():
        if P == 2:
            res = 0
            for i in range(N):
                if int(S[N - 1 - i]) % 2 == 0:
                    res += N - i
        elif P == 5:
            res = 0
            for i in range(N):
                if int(S[N - 1 - i]) == 0 or int(S[N - 1 - i]) == 5:
                    res += N - i

        else:
            mods = [0] * P  # mods[i]はPで割ったあまりがiである連続部分列の個数
            tenfactor = 1
            mod = 0
            mods[mod] += 1

            for i in range(N):
                mod = (mod + int(S[N - i - 1]) * tenfactor) % P
                tenfactor = (tenfactor * 10) % P
                mods[mod] += 1

            res = 0
            for p in range(P):
                res += mods[p] * (mods[p] - 1) // 2

        return res

    print(main())


resolve()

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

int K;

int main() {
    cin>>K;
    long ans=0;
    for (int i=1; i<=K; i++) {
        for (int j=1; j<=K; j++) {
            int codiv;
            codiv=gcd(i,j);
            for (int k=1; k<=K; k++) {
                int codiv2;
                codiv2=gcd(codiv,k);
                ans+=codiv2;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3596
import re


pattern = "AB"
num_input = int(input())

total_ab = 0

num_ab = 0
num_end_with_a = 0
num_start_with_b = 0
num_both = 0

prints = []

for i in range(0, num_input):
    input_string = input()
    num_ab += len(re.findall(pattern, input_string))
    start_with_b = (input_string[0] == 'B')
    end_with_a = (input_string[-1] == 'A')

    if start_with_b and end_with_a:
        num_both += 1
    elif start_with_b:
        num_start_with_b += 1
    elif end_with_a:
        num_end_with_a += 1

# print(num_ab, num_both, num_start_with_b, num_end_with_a)

# add in-string 'AB'
total_ab += num_ab

# consume both first

# do setup, for case of '--A's or 'B--'s not exist
if num_end_with_a == 0 and num_start_with_b == 0:
    if num_both >= 2:
        num_both -= 2
        num_end_with_a += 1
        num_start_with_b += 1

elif min(num_end_with_a, num_start_with_b) == 0:
    if num_both >= 1:
        if num_end_with_a == 0:
            num_both -= 1
            num_end_with_a += 1
        
        if num_start_with_b == 0:
            num_both -= 1
            num_start_with_b += 1

# then consume
if num_both > 0:
    total_ab += (num_both+1)
    num_end_with_a -= 1
    num_start_with_b -= 1

# then consume other '--A's  and 'B--'s
total_ab += min(num_start_with_b, num_end_with_a)

print(total_ab)
exit(0)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;

int main() {
  int N;
  cin>>N;
  
  vector<pair<pair<string,int>,int>> p(N);
  
  for(int i=0;i<N;++i){
    string S;
    int t;
    cin>>S>>t;
    
    p[i]=make_pair(make_pair(S,-t),i);	// tは-をかけることで降順にソート
  }
  
  // pを昇順にソート
  sort(p.begin(),p.end());
  
  for(int i=0;i<N;++i){
    cout<<p[i].second+1<<endl;
  }
  
}

Measured memory_bytes: 256
import sys


Stack = []

def push(x):
    Stack.append(x)

def pop():
    Stack.pop(-1)


def cul(exp):
    for val in exp:
        if val in ["+", "-", "*"]:
            a = int(Stack[-2])
            b = int(Stack[-1])
            if val == "+":
                x = a + b
            elif val == "-":
                x = a - b
            elif val == "*":
                x = a * b
            for i in range(2):
                pop()
            push(x)
        else:
            push(val)

    return Stack[0]


if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
vector<int> v[400][5];
ll mod=1e9+7;
inline void adjust(ll &x)
{
	if(x>=mod)
	{
		x-=mod;
	}
}
ll dp[305][305][305];
inline void set_it(int new_i,int new_j,int new_k,int i,int j,int k)
{
	bool flag=true;
	if(!v[new_i][1].empty())
	{
		int sz=new_i-v[new_i][1][0]+1;
		if(new_j<sz)
		{
			flag=false;
		}
	}
	if(!v[new_i][2].empty())
	{
		int size_v=v[new_i][2].size();
		int sz=new_i-v[new_i][2][size_v-1]+1;
		if(sz<=new_j)
		{
			flag=false;
		}
		else
		{
			sz=new_i-v[new_i][2][0]+1;
			if(sz>new_k)
			{
				flag=false;
			}
		}
	}
	if(!v[new_i][3].empty())
	{
		int size_v=v[new_i][3].size();
		int sz=new_i-v[new_i][3][size_v-1]+1;
		if(sz<=new_k)
		{
			flag=false;
		}
	}
	if(flag)
	{
		dp[new_i][new_j][new_k]+=dp[i][j][k];
		adjust(dp[new_i][new_j][new_k]);
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,x;
		cin>>l>>r>>x;
		v[r][x].pb(l);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			sort(v[i][j].begin(),v[i][j].end());
		}
	}
	if((!v[1][2].empty())||(!v[1][3].empty()))
	{
		cout<<"0\n";
		return 0;
	}
	dp[1][1][n+1]=3;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			for(int k=j+1;k<=n+1;k++)
			{
				if(!dp[i][j][k])
				{
					continue;
				}
				int new_i=i+1;
				int new_j=j+1;
				int new_k=k+1;
				if(new_k>n)
				{
					new_k=n+1;
				}
				set_it(new_i,new_j,new_k,i,j,k);
				new_j=1;
				new_k=k+1;
				if(new_k>n)
				{
					new_k=new_i;
				}
				set_it(new_i,new_j,new_k,i,j,k);
				new_j=1;
				new_k=j+1;
				set_it(new_i,new_j,new_k,i,j,k);
			}
		}
	}
	ll ans=0;
	// for(int i=1;i<=n;i++)
	// {
	// 	for(int j=1;j<=n+1;j++)
	// 	{
	// 		for(int k=1;k<=n+1;k++)
	// 		{
	// 			if(dp[i][j][k])
	// 			{
	// 				cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<"\n";
	// 			}
	// 		}
	// 	}
	// }
	for(int j=1;j<=n+1;j++)
	{
		for(int k=1;k<=n+1;k++)
		{
			ans=ans+dp[n][j][k];
			adjust(ans);
		}
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 217472
#include <stdio.h>
// #include <math.h>
// #include <stdlib.h>

int main(void) {

    int h, w;
    scanf("%d %d", &h, &w);

    do {
        for(int i=1; i<=h; i++) {
            for (int j=1; j<=w; j++) {
                if (i==1 || i==h) {
                    printf("#");
                } else {
                    if (j==1 || j==w) {
                        printf("#");
                    } else {
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        scanf("%d %d", &h, &w);
        printf("\n");
    } while (!(h==0 && w==0));
    return 0;
}


Measured memory_bytes: 2612
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int solve(ll n){
    int res = 0;
    while (n != 1){
        if (n & 1) n = n * 3 + 1;
        else n >>= 1;
        res++;
    }
    return res;
}

int main(){
    int n;
    while (cin >> n && n){
        cout << solve(n) << endl;
    }
}

Measured memory_bytes: 1156
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;

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

typedef long long ll;
const int Mod = static_cast<int>(1e9 + 7);

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

	int i, j;
	bool ans = false;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			if (n - i - j >= 0 && 10 * i + 5 * j + n - i - j == y / 1000) {
				ans = true;
				break;
			}
		}
		if (ans) break;
	}
	if (ans)  cout << i << " " << j << " " << n - i - j << endl;
	else  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
ll seen[55][55];
ll W, H;
void dfs(int h, int w) {
    seen[h][w] = 0;
    
    for (ll dir = 0; dir < 8; dir++) {
        ll nh = h + dx[dir];
        ll nw = w + dy[dir];
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (seen[nh][nw] == 0) continue;
        
        
        dfs(nh, nw);
            
    }
}


int main(){
    while(1 > 0){
        ll ans = 0;
        cin >> W >> H;
        if(W == 0 && H == 0) break;

        for (ll i = 0; i < H; i++) {
            for (ll j = 0; j < W; j++) {
                cin >> seen[i][j];
            }
        }

        for (ll i = 0; i < H; i++) {
            for (ll j = 0; j < W; j++) {
                if(seen[i][j]){
                    dfs(i,j);
                    ans++ ;
                }
            }
        }
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 3236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N, ans = 0;
        Integer[] d;

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            d = new Integer[N];
            for (int i = 0; i < N; ++i) d[i] = in.nextInt();
            Arrays.sort(d);
            for (int i = 1; i <= d[d.length - 1]; ++i) {
                if (Bisect.lowerBound(i, d) == N / 2) ans++;
            }
            out.println(ans);
        }
    }

    static class Bisect {
        static int lowerBound(int x, Integer[] arr) {
            int low = 0, high = arr.length;
            while (low < high - 1) {
                int mid = (low + high) / 2;
                if (x <= arr[mid]) {
                    high = mid;
                } else if (x > arr[mid]) {
                    low = mid;
                }
            }
            return arr[low] < x ? high : low;
        }

        static int higherBound(int x, Integer[] arr) {
            int low = 0, high = arr.length;
            while (low < high - 1) {
                int mid = (low + high) / 2;
                if (x < arr[mid]) {
                    high = mid;
                } else if (x >= arr[mid]) {
                    low = mid;
                }
            }
            return arr[high] > x ? low : high;
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 36704
# include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 10, mod = 1e9 + 7;
int r[N], c[N];
long long ans = 1, sr, sc, cnt;
int main() {
	int n, m;
	cin >> n >> m;
	memset(r, -1, sizeof(r));
	memset(c, -1, sizeof(c));
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		if (r[x] != -1) {
			cout << 0;
			return 0;
		}
		r[x] = i;
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		x--;
		if (c[x] != -1) {
			cout << 0;
			return 0;
		}
		c[x] = i;
	}
	for (int i = n * m - 1; i >= 0; i--) {
		if (r[i] >= 0 && c[i] >= 0) {
			cnt++, sr++, sc++;
			continue;
		}
		if (r[i] == -1 && c[i] == -1) {
//			cout << "rc : i = " << i<< " : " << ans << " : : ";
			if (sr * sc - cnt <= 0) {
				cout << 0;
				return 0;
			}
			ans = (ans * (sr * sc - cnt)) % mod;
//			cout << ans << endl;
			cnt++;
			continue;
		}
		if (r[i] == -1) {
			if (!sc) {
				cout << 0;
				return 0;
			}
//			cout << "r : i = " << i << " : " << ans << " : : ";
			ans = ans * sc % mod;
//			cout << ans << endl;
			cnt++, sr++;
			continue;
		}
		if (c[i] == -1) {
			if (!sr) {
				cout << 0;
				return 0;
			}
//			cout << "c : i = " << i << " : " << ans << " : : ";
			ans = ans * sr % mod;
//			cout << ans << endl;
			cnt++, sc++;
			continue;
		}
	}
	cout << ans;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n;

int main() {
    while (cin >> n) {
        if (n == 0) break;
        int res = 1<<29;
        for (int a = 0; a <= 25; ++a) for (int b = 0; b <= 20; ++b) for (int c = 0; c <= 10; ++c) {
            int tot = a * 200 + b * 300 + c * 500;
            if (tot != n) continue;
            int s1 = 380 * (a / 5) * 5 * 4/5 + 380 * (a % 5);
            int s2 = 550 * (b / 4) * 4 * 17/20 + 550 * (b % 4);
            int s3 = 850 * (c / 3) * 3 * 22/25 + 850 * (c % 3);
            
            //cout << a << ", " << b << ", " << c << " : " << s1+s2+s3 << endl;
            
            chmin(res, s1+s2+s3);
        }
        cout << res << endl;
    }
    return 0;
}


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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define all(v) v.begin(),v.end()
#define vll vector<ll>
#define vs vector<string>

#define mapll map<ll,ll>
#define mapss map<string,string>
#define mapsl map<string,ll>
#define mapls map<ll,string>

#define pll pair<ll,ll>
#define pss pair<string,string>
#define psl pair<ll,string>
#define pls pair<string,ll>

#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
const ll mod=1e9 + 7;


ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

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

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}


signed main() 
{
    fast_cin();
    ll n;
    cin>>n;
    string s;
    cin>>s;
    unordered_map<ll,ll> umap1;
    For(i,0,s.length())
    {
        if(umap1.find(s[i]-'a')==umap1.end())
            umap1[s[i]-'a']=2;
        else
            umap1[s[i]-'a']++;
    }
    ll ans=1;
    for( auto i=umap1.begin();i!=umap1.end();i++)
    {
        ans=(ans*(i->second))%mod;
    }
    ans=(ans-1+mod)%mod;
    cout<<ans<<endl;
    return 0;    
}

Measured memory_bytes: 512
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    println!("{}", std::cmp::min(n * a, b));
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
#define ll long long int
int main()
{
     ll n,k,sum=0;
     cin>>n>>k;
     vector<ll>v(n);
     for(ll i=0; i<n; i++)cin>>v[i];
      sort(v.begin(),v.end());
    for(ll i=0; i<k; i++)
      sum+=v[i];
    cout<<sum<<endl;

}

Measured memory_bytes: 3604
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();

        for (int i = 1; i <= 360; i++)
        {
            if ((i * x) % 360 == 0)
            {
                Console.WriteLine(i);
                return;
            }
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27348
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
        return 1;
    int res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b+c>=22)
    {
        cout<<"bust";
    }
    else
    {
    cout<<"win";
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]
    ws, vs = zip(*wv)

    dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

    for i in range(n):
        for sum_w in range(w + 1):
            if sum_w - ws[i] >= 0:
                dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - ws[i]] + vs[i])
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])

    res = max(dp[-1])
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 217800
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;


vector<int> A(1000000) ;

int cnt;

// 今回はa.secondで比較したいので比較関数を定義する
bool compare_by_b(pair<int, string> a, pair<int, string> b) {
	return a.second < b.second; // 昇順に単純に比較するだけ(これを逆にすると降順になる)
}

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

	int N;
	cin >> N;

	vector<pair<int, string>> S(N);

	rep(i, N) {
		cin >> S[i].second;
	}

	int maxx = 0;
	sort(S.begin(), S.end(), compare_by_b);
	rep(i, S.size()-1) {
		if (S[i].second == S[i+1].second) {
			S[i + 1].first = S[i].first + 1;
			if (maxx < S[i + 1].first) maxx = S[i + 1].first;
		}
	}


	rep(i, S.size()) {
		if (S[i].first == maxx ) {
			cout << S[i].second << endl;
		}
	}



	return 0;
}


Measured memory_bytes: 18432
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		ArrayList<String> strInput = new ArrayList<String>();
		Scanner scanner = new Scanner(System.in);

		// 検索する単語を入力
		String strWord = scanner.next();

		int intLineNum = 0;
		// 検索対象の文章を入力
		while (true) {
			String strLine = scanner.next();
			// END_OF_TEXTで終了
			if (("END_OF_TEXT").equals(strLine)) {
				break;
			}

			strInput.add(strLine);
			intLineNum++;
		}

		int intCount = 0;
		for (int intI = 0; intI < intLineNum; intI++) {
			if (strWord.equalsIgnoreCase(strInput.get(intI))) {
				intCount++;
			}
		}
		System.out.println(intCount);
	}

}



Measured memory_bytes: 26324
#include <stdio.h>
#define MAX 101

int main(void) {
    int i, j, r, c, v, tbl[MAX][MAX] = {};
    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++) {
        for(j = 0; j < c; j++) {
            scanf("%d", &v);
            tbl[i][j] += v;
            tbl[i][c] += v;
            tbl[r][j] += v;
            tbl[r][c] += v;
        }
    }
    for(i = 0; i <= r; i++) {
        for(j = 0; j <= c; j++) {
            printf("%d%s", tbl[i][j], j != c ? " " : "\n");
        }
    }
    return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
#include<stdlib.h>
#define MAX_N 101

struct TEdge{
  int a,b,w;
};

typedef struct TEdge Edge;

Edge *edge;

int par[MAX_N];
int rank[MAX_N];

//Union Find Tree?????????????????????
//????????¶?????§??????????????????????????§???
//?????¨??????????´???????????????????
void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}


//x?????????????´?????±??????????????????£??¨????????????
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return par[x] = find(par[x]);
  }
}

//x,y????±?????????????????????¨??????
void unite(int x,int y){
  x =find(x);
  y =find(y);
  if(x==y){
    return ;
  }
  if(rank[x] < rank[y]){
    par[x] = y;
  }else {
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}

//x,y????±?????????????????????????????????????
int same(int x,int y){
  return find(x)==find(y);
}

//?????????????????????(Edge.w?????????)
void EdgeSort(int s,int e,Edge* array){
  int i,j,k;
  i=s-1;
  j=e;
  while(i<j){
    while(++i<e&&array[i].w<array[e].w);
    while(--j>=s&&array[j].w>=array[e].w);
    if(i<j){
      //??¢??°????????¨??????????????????
      //?????????operator????????????
      array[i].w+=array[j].w;
      array[j].w=array[i].w-array[j].w;
      array[i].w-=array[j].w;

      array[i].a+=array[j].a;
      array[j].a=array[i].a-array[j].a;
      array[i].a-=array[j].a;

      array[i].b+=array[j].b;
      array[j].b=array[i].b-array[j].b;
      array[i].b-=array[j].b;

    }
  }
  if(i<e){
    //?????????????????????

    array[e].w+=array[i].w;
    array[i].w=array[e].w-array[i].w;
    array[e].w-=array[i].w;

    array[e].a+=array[i].a;
    array[i].a=array[e].a-array[i].a;
    array[e].a-=array[i].a;

    array[e].b+=array[i].b;
    array[i].b=array[e].b-array[i].b;
    array[e].b-=array[i].b;

    i++;
  }
  if(s<j)EdgeSort(s,j,array);
  if(e>i)EdgeSort(i,e,array);
}

int main(){
  int n,m;
  char s[16];
  int i,j,k,a,b,w;
  long long int res;
  while(1){
    if(!fgets(s,16,stdin))break;
    sscanf(s,"%d %d",&n,&m);
    if(n==0)break;
    edge=(Edge*)malloc(sizeof(Edge)*m);
    for(i=0;i<m;i++){
      fgets(s,16,stdin);
      sscanf(s,"%d %d %d",&a,&b,&w);
      edge[i].a=a;
      edge[i].b=b;
      edge[i].w=w;
    }
    
    EdgeSort(0,m-1,edge);
    res=-1;
    if(n==1)res=0;
    else for(k=0;k<=m-n+1;k++){
      init(n+1);
      i=0;
      for(j=0;k+j<m;j++){
        if(!same(edge[k+j].a,edge[k+j].b)){
          unite(edge[k+j].a,edge[k+j].b);
          i++;
          if(i>=n-1)break;
        }
      }
      if(k+j<m){
        if(res==-1||edge[k+j].w-edge[k].w<res)res=edge[k+j].w-edge[k].w;
      }
    }
    //return 0;
    free(edge);
    printf("%lld\n",res);
  }
  return 0;
}

Measured memory_bytes: 672
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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 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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int a, b, h, m; cin >> a >> b >> h >> m;
    ld s1 = pi * 2.0 * (ld)m / (ld)60.0;
    ld s2 = pi * 2.0 * (ld)(60 * h + m) / (ld)(12 * 60);
    ld s = abs(s1 - s2);
    ld c = (ld)a * (ld)a + (ld)(b * b) - 2.0 * (ld)a * (ld)b * cos(s);
    cout << sqrt(c) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(14);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4184