akhauriyash/Code-Regression huggingface dataset:
import copy
N = int(input())
X = list(map(int,input().split()))
XX = copy.deepcopy(X)
XX.sort()
X1 = XX[(N//2)-1]
X2 = XX[N//2]
if X1 == X2:
  for i in range(N):
    print(X1)
else:
  Y = float(X1 + X2)
  Y = Y/2
  for i in range(N):
    if X[i] > Y:
      print(X1)
    else:
      print(X2)

Measured memory_bytes: 26068
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <assert.h>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define each(i,n) for(auto &i : n)

#define int long long

signed main() {

	int x, y;
	cin >> x >> y;

	int ans;

	if (x < 0 && y < 0) {
		if (abs(x) < abs(y)) ans = 1 + abs(y) - abs(x) + 1;
		else ans = abs(x) - abs(y);
	}else
	if (x < 0 && y >= 0) {
		if (abs(x) <= abs(y)) ans = 1 + abs(y) - abs(x);
		else 
		if(y != 0)ans = abs(x) - abs(y) + 1;
		else ans = abs(x);
	}else
	if (x >= 0 && y < 0) {
		if (abs(x) <= abs(y)) ans = abs(y) - abs(x) + 1;
		else ans = 1 + abs(x) - abs(y);
	}else
	if (x >= 0 && y >= 0) {
		if (abs(x) < abs(y)) ans = abs(y) - abs(x);
		else 
		if(y != 0) ans = 1 + abs(x) - abs(y) + 1;
		else ans = 1 + abs(x) - abs(y);
	}

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

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

using namespace std;

int main(){
  
  string s;
  cin >> s;
  int n = s.size();
  int p = 2019;
 
  
   long long int ten = 1;
    long long int res = 0;
    
    vector<long long int> u(p,0);
    long long int cnt = 0; 
    u[cnt]++;
    for(int i=n-1;i>=0;i--){
     cnt = (cnt + ((s[i]-'0')*ten) ) % p;
      ten = (ten*10) % p;
      u[cnt]++;
    }
    
    for(int i=0;i<p;i++){
      res += u[i]*(u[i]-1)/2;
    }
    
    cout << res << endl;
    return 0;
  }
  

      
      
    
    


Measured memory_bytes: 3752
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-9;
const int N = 1e5 + 50, M = 1e5 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
int main() {
	fast_in_out();
//	cout << fixed << setprecision(6);
	int n, m;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int x = 1e9;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] < x)cnt++;
		x = min(x, v[i]);
	}
	cout << cnt;
	return 0;
}

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

int main()
{
    int x;
    cin >> x;
    int ans = 0;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6

using namespace std;

int main(){
    string s;
    cin >> s;
    int ans=0;
    int nokori=15-s.size();
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='o') ans++;
    }
    if(ans+nokori>=8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

using namespace std;

map < string, int > mp;

int main()
{
    int n;
  cin >> n;
  string x;
  for ( int i=0; i<n; i++){
    cin >> x, mp[x]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    std::deque<int> deq;
    long long int sum=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
        sum+=a;
    }
    long long int ans=0;
    long long int min=1000000000000;
    for (int j=0;j<n-1;j++) {
        ans+=deq[j];
        long long int tmp=abs(ans-(sum-ans));
        if (tmp<min) {
            min=tmp;
        }
    }
    cout<<min<<endl;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
 	ll n, a, b; cin >> n >> a >> b;

 	ll blue = n / (a+b);
 	ll rem = n % (a+b);

 	if(rem > a) rem = a;

 	cout << blue*a + rem;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>
double solve(double *arr, int n)
{
	// form a dp table in which each state (i,j) represents in i throws , Probability  of finding j heads.
	double dp[n+1][n+1];
	double ans=0.0;
	memset(dp, 0.0, sizeof(dp));
	dp[0][0]=1.000; //it is certain that we have'nt thrown any coin and we dont want any heads

	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(j==0)
				dp[i][j]=dp[i-1][j]*(1-arr[i-1]);
			else
				dp[i][j]=(dp[i-1][j] *(1-arr[i-1]))+(dp[i-1][j-1] *arr[i-1]);
		}

	}
	// for(int i=0;i<=n;i++)
	// {
	// 	for(int j=0;j<=n;j++)
	// 		cout<<dp[i][j]<<"\t";
	// 	cout<<"\n";
	// }
	for(int i=(n+1)/2; i<=n;i++)
	{
		ans+=dp[n][i];
	}
return ans;

}

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


    ll n,x;
    cin>>n;
 	double arr[n];
 	for(int i=0;i<n;i++)
 		cin>>arr[i];

 	double ans=solve(arr,n);
 	cout<<setprecision(10)<<fixed<<ans<<"\n";

return 0;
}


Measured memory_bytes: 70656
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

n = int(input())
S = input()
k = int(input())
t = S[k-1]
res = ""
for s in S:
    if s == t:
        res += s
    else:
        res += '*'
print(res[:-1])

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

using namespace std;

using ll = long long;
using ld = double;
using P = pair<ld, ld>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

ld dp[25][25][11111];

ld calc(ld x1, ld y1, ld x2, ld y2)
{
    // a = (x1, y1), b = (x2,y2) のなす角
    ld a = sqrt(x1 * x1 + y1 * y1), b = sqrt(x2 * x2 + y2 * y2), sum = x1 * x2 + y1 * y2;
    if (abs(sum + a * b) < EPS)
        return 180.0;
    if (abs(sum - a * b) < EPS)
        return 0.0;
    return 180.0 * acos(sum / (a * b)) / acos(-1);
}

ld dist(P p1, P p2)
{
    return sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
}

ld d[30][30];

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

    int n;
    ld r, phi;
    cin >> n >> r >> phi;
    vector<P> v(n);
    for (int i = 0; i < n; i++)
    {
        ld x, y;
        cin >> x >> y;
        v[i] = P(x, y);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            d[i][j] = d[j][i] = dist(v[i], v[j]);
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = 0; k <= 10000; k++)
            {
                dp[i][j][k] = INF;
            }
        }
    }
    bool f = false;
    for (int i = 1; i < n; i++)
    {
        if (d[i][0] + EPS > r)
            continue;
        dp[i][0][1] = d[i][0];
        f = true;
    }
    if (!f)
    {
        cout << 0 << endl;
        return 0;
    }
    for (int k = 1; k <= 10000; k++)
    {
        bool update = false;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                for (int next = 0; next < n; next++)
                {
                    if (next == i || next == j || i == j)
                        continue;
                    if (dp[i][j][k] == INF)
                        continue;
                    ld x1 = v[i].first - v[j].first, y1 = v[i].second - v[j].second;
                    ld x2 = v[next].first - v[i].first, y2 = v[next].second - v[i].second;
                    if (calc(x1, y1, x2, y2) + EPS > phi)
                        continue;
                    if (dp[i][j][k] + d[i][next] + EPS > r)
                        continue;
                    update = true;
                    dp[next][i][k + 1] = min(dp[next][i][k + 1], dp[i][j][k] + d[i][next]);
                }
            }
        }
        if (update)
            continue;
        cout << k << endl;
        break;
    }
}



Measured memory_bytes: 36372
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
import numpy as np

def main():
	n=int(input())
	A=np.array(read().split(), np.int64)
	n=len(A)
	ans=0
	
	for i in range(62):
		B=A%2
		k=np.count_nonzero(B)
		A=A//2
		ans+=(2**i)*(k*(n-k))
		ans%=mod
	print(ans)
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 36636
/*
 * Created by Dipta Das on 14-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

string s;
const char red = '0';
const char blue = '1';

bool match (int i, int j) {
    return (s[i] == blue && s[j] == red) || (s[i] == red && s[j] == blue);
}

bool matchChar (char i, char j) {
    return (i == blue && j == red) || (i == red && j == blue);
}

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

    cin >> s;
    int  n = (int) s.size();
    int cnt = 0;
    stack <char> st;

    for (int i = 0; i < n; ++i) {
        if (st.empty()) st.push(s[i]);
        else if (matchChar(s[i], st.top())) {
            cnt += 2;
            st.pop();
        } else {
            st.push(s[i]);
        }
    }

    cout << cnt << endl;


    return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();
        long[] a = new long[N];
        for(int i = 0;i < N;i++){
            a[i] = sc.nextInt();
        }
        long count = 0;
        for(int i = 0;i < N-1;i++){
            long box2 = a[i] + a[i+1];
            long y = box2 - x;
            if(y < 0){
                continue;
            }
            if(a[i+1] - y >= 0){
                a[i+1] -= y;
                count += y;
                continue;
            }
            if(a[i+1] - y < 0 && box2 - y >= 0){
                a[i] -= y - a[i+1];
                a[i+1] = 0;
                count += y;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 61004
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin>>n;
    int a[n],b[n],flag=2;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        cin>>b[i];
        if(flag==2){
            if(a[i]<b[i]) flag=1;
            else if(a[i]>b[i]) flag=0;
        }
    }
    if(flag==2){
        cout<<0<<endl;
        return 0;
    }
    int ans=0;
    if(flag==1){
        while(1){
            next_permutation(a,a+n);
            bool x=1;
            ans++;
            for(int i=0;i<n;i++){
                if(a[i]!=b[i]) x=0;
            }
            if(x==1) break;
        }
    }
    else if(flag==0){
        while(1){
            next_permutation(b,b+n);
            bool x=1;
            ans++;
            for(int i=0;i<n;i++){
                if(a[i]!=b[i]) x=0;
            }
            if(x==1) break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}


int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    vector<int> ans(0);
    ll maxNum = 1;
    ll tmp = min(A,B);
    ll tmp2 = max(A,B);
    A = tmp2;
    B = tmp;
    for(ll i = 1; i <= A; i++){
        if(A % i == 0){
            if(B % i ==0)ans.push_back(i);
        }        
    }
    reverse(all(ans));
    cout << ans[K - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int dp[n];
int arr[n];
for(int i=0; i<n; ++i)
{
cin>>arr[i];
dp[i]=10000000000;
}
dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
for(int i=2; i<n; ++i)
{
for(int kk=1; kk<=k; ++kk)
{
if(i-kk>=0)
dp[i]=min(dp[i],dp[i-kk]+abs(arr[i-kk]-arr[i]));
}
}
cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X, Y;
  cin >> N;
  X = 1;
  for (int i = 0 ; i < N ; i++){
  string S;
  cin >> S;
  if (S == "P" || S == "W" || S == "G"){
  X = X * 1;
  }
  if (S == "Y"){
  X = X * 2;
  }
  }
  if (X % 2 == 1){
  cout << "Three" << endl;
  }
  else if (X % 2 == 0){
  cout << "Four" << endl;
  }
}


Measured memory_bytes: 3532
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(b/a >= c){
		printf("%d\n",c);
		/*
		if(b%a!=0){
			printf("%d\n",c);
		}
		*/
	}else{
		printf("%d\n",b/a);
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<int> adj[1000001];
ll dp1[1000001], dp2[1000001];
//ll sums[(1<<16)];
ll M;

ll solve(int node, vector<bool>& vis)
{
    ll ans = 1;
    vis[node] = 1;
    for(int child : adj[node])
    {
        if(!vis[child])
        {
            ans = (ans*(1 + solve(child, vis)))%M;
        }
    }
    return dp1[node] = ans%M;
}

void finalSolve(int node, vector<bool>& vis, ll parentAns)
{
    ll ans = 1;
    vis[node] = 1;
    vector<ll> val;

    for(int child : adj[node])
    {
        if(!vis[child])
        {
            ans = (ans*(1+dp1[child]))%M;
            val.push_back(dp1[child]);
        }
    }
    ans = (ans*(1+parentAns))%M;
    dp2[node] = ans%M;
    vector<ll> pre, suf(val.size()+1);
    pre.push_back(1);
    suf[val.size()] = (1+parentAns)%M;
    for(int i=0;i<val.size();i++)
        pre.push_back(1LL*((pre[i])*(1+val[i]))%M);
    for(int i=val.size()-1;i>=0;i--)
        suf[i] = (1LL*(suf[i+1])*(1+val[i]))%M;

    int cno = 0;
    for(int child : adj[node])
    {
        if(!vis[child])
        {
            //assert((pre[cno]*suf[cno]) == ans);
            finalSolve(child, vis, (1LL*pre[cno]*suf[cno+1])%M);
            cno++;
        }
    }

}

int main(){
    ll i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n>>m;
        M = m;
        for(int i=0;i<n-1;i++)
        {
            ll u,v;
            cin>>u>>v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        vector<bool> vis(n+1, 0);
        solve(1, vis);
        vis = vector<bool>(n+1, 0);
        finalSolve(1, vis, 0);

        for(int i = 1; i <= n; i++)
            cout<<dp2[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 52224
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst, n;
  Weight weight;
  Edge(int src, int dst, Weight weight, int n) :
    src(src), dst(dst), weight(weight), n(n) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int l;

// ¹öª¢çÈ¢ê
int dijkstra2(const Graph &g, int s) {
  int n = g.size();
  Weight dist[n][l+1];
  REP(i,n) {
    REP(j,l+1)
      dist[i][j] = INF;
  }
  dist[s][l] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0, l)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst][e.n] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (e.n >= f->weight && dist[f->dst][e.n-f->weight] > e.weight) { // Ù¤
        dist[f->dst][e.n-f->weight] = e.weight;
        Q.push(Edge(f->src, f->dst, e.weight, e.n-f->weight));
      }
      if (dist[f->dst][e.n] > e.weight + f->n) { // ÙíÈ¢
        dist[f->dst][e.n] = e.weight+f->n;
        Q.push(Edge(f->src, f->dst, e.weight+f->n, e.n));
      }
    }
  }
  int res = INF;
  REP(i,l+1) {
    res = min(res, dist[n-1][i]);
  }
  return res;
}


int main() {
  int n,m;
  while(cin>>n>>m>>l,n) {
    Graph g(n);
    REP(i,m) {
      int a,b,d,e;
      cin >>a>>b>>d>>e;
      a--;b--;
      g[a].push_back(Edge(a,b,d,e));
      g[b].push_back(Edge(b,a,d,e));
    }
    cout << dijkstra2(g, 0) << endl;
  }
}

Measured memory_bytes: 1576
#include<stdio.h>

int cheap(int a,int b){
  if(a<=b){
    return a;
  }else{
    return b;
  }
}

int main(void){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  printf("%d\n",cheap(n*a,b));
  return 0;
}

Measured memory_bytes: 1704
#include<stdio.h>
main(){
int a,b;
int c=0;
int i=0;
double f,g,h,j=0;
while(scanf("%d,%d",&a,&b)!=EOF){
c=c+a*b;
h=h+b;
j=j+1;
}
f=h/j;
i=h/j;
g=f-i;
if(g>=0.5){
i=i+1;
}
printf("%d\n%d\n",c,i);
return 0;
}

Measured memory_bytes: 592
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

cnt = [0]*(n+1)
cnt[0] = 3

ans = 1
for aa in a:
  ans *= cnt[aa]
  ans %= mod
  cnt[aa] -= 1
  cnt[aa+1] += 1
  
print(ans)

Measured memory_bytes: 14020
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll d[3010][3010];
ll a[3010];
ll sum=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i],sum+=a[i];
	for (int len=1;len<=n;len++)
	{
		for (int i=0;i<n;i++)
		{
			int j=i+len-1;
			if (i==j) d[i][j]=a[i];
			else
				d[i][j]=max(min(d[i+1][j-1],d[i+2][j])+a[i],min(d[i+1][j-1],d[i][j-2])+a[j]);
		}
	}
	cout <<d[0][n-1]-(sum-d[0][n-1]);
	return 0;
}

Measured memory_bytes: 70784
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>


#define DEBUG if(false)

using namespace std;

int main(){
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double alpha = (double)M / 2.0 + 30.0*(double)H;
  double beta  = 6.0*(double)M;
  double sita;
  if(alpha > beta){
    sita = alpha - beta;
  }else{
    sita = beta - alpha;
  }

  if(sita > 180.0){ sita = 360.0-sita; }
  //printf("sita : "); cout << sita << endl;
  double x = sqrt(A*A + B*B - 2*A*B*cos(M_PI*sita/180.0));

  printf("%0.20lf\n", x);
  return 0;
}


Measured memory_bytes: 4136
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
vector< pair<ll,ll> > vc[N]; ll n,ans[N],mx=0,fl[N];
void dfs(ll i,ll dnt){
	fl[i]=1;

	ll cl=1;
	for(auto it:vc[i]){
		if(fl[it.fs]) continue;
		if(cl==dnt) cl++;
		ans[it.sc]=cl;
		dfs(it.fs,cl);
		mx=max(mx,cl);
		cl++;
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	for(i=1;i<n;i++){
		cin>>k>>l;
		vc[k].ps({l,i});
		vc[l].ps({k,i});
	}

	dfs(1,0);
	cout<<mx<<endl;
	for(i=1;i<n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 81408
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	double t, a;
	cin >> n;
	cin >> t >> a;
	vector<int> h(n);
	for (int i = 0; i < n; i++)cin >> h.at(i);
	int ans = 0;
	double gap = 100000;
	double x = (t - a) / 0.006;
	for (int i = 0; i < n; i++) {
		double g = abs(x - h.at(i));
		if (g < gap) {
			ans = i + 1;
			gap = g;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
 
 
ll n, m, i, j, k, t,r, a, b, c, d, l, w, tmp, g, ans, sum, cnt, neg1, flag, mn, mx, neg2;
ll arr[MAX], sz[MAX], crr[MAX];
vector<ll> v[MAX];
vector<ll> centroid;

int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
        cin>>n;
        ans = 1;
        m = 1;
        t=1;
        a =1;
        for(i=1;i<=n;i++)
            ans = (ans*10)%MOD;
        for(i=1;i<=n;i++)
            m = (m*8)%MOD;
        for(i=1;i<=n;i++)
            t = (t*9)%MOD;
        for(i=1;i<=n;i++)
            a = (a*8)%MOD;
        t = (t-a)%MOD;
        m += 2*t;
        m%=MOD;
        cout<<((ans-m)%MOD+MOD)%MOD;

    return 0;   
}

Measured memory_bytes: 50540
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    N = int(input())
    adjL = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        adjL[a].append((b, i))
        adjL[b].append((a, i))

    def dfs(vNow, vPar, clrPar):
        clr = 1
        for v2, i in adjL[vNow]:
            if v2 == vPar: continue
            if clr == clrPar:
                clr += 1
            anss[i] = clr
            dfs(v2, vNow, clr)
            clr += 1

    anss = [0] * (N-1)
    dfs(0, -1, 0)

    print(max(anss))
    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 86524
import math
N = int(input())
point_table = []
for _ in range(N):
  a,b,c = map(int, input().split())
  point_table.append([a, b, c])

dp_list = [[0] * 3 for _ in range(N)]
dp_list[0] = point_table[0].copy()

for i in range(N - 1):
  for j in range(3):
    for k in range(3):
      if j != k:
        cost = dp_list[i][j] + point_table[i + 1][k]
        if cost > dp_list[i + 1][k]:
          dp_list[i + 1][k] = cost

print(max(dp_list[-1]))

Measured memory_bytes: 103612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int a,b,count=0;
  scanf("%d %d",&a,&b);
  if(a == b){
    printf("%d",0);return 0;
  }
  for(int i=a;i<=b;i++){
    int flag=0;
    int keta = log10(i);int tmp = i;
    int num[keta];
    for(int j=0;j<=keta;j++){
      num[j]=tmp%10;
      tmp = (tmp-num[j])/10;
    }
    for(int k=0;k<keta;k++){
      if((k == keta-k || k+1 == keta - k)&&flag==0){
        count++;break;
      }
      if(num[k] != num[keta-k])flag=1;
    }
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mx,mn,sum;
int main(){
	ll a,b,x;
	cin>>a>>b>>x;
	if(a%x==0) ans=(a/x)-1;
	else ans = a/x;
	sum=b/x;
	cout<<sum-ans<<endl;
} 

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cout << setprecision(10);

	cin >> n ;
	vector<string> S(n);
	ll AB = 0;
	rep(i,n){
		cin >> S[i];
		for(int j = 0 ; j < S[i].size()-1 ; j++){
			if(S[i][j] == 'A' &&S[i][j+1]=='B'){
				AB ++;
			}
		}
	}
	int beginB = 0 , endA = 0 , joker = 0 ;	

	rep(i,n){
		char begin = S[i][0];
		char end = S[i][S[i].size()-1];

		if(begin =='B' && end =='A'){
			joker ++; 
		}
		else if(begin == 'B'){
			beginB++;
		}
		else if(end =='A'){
			endA++;
		}
	}

	int k = abs(beginB - endA); //k個足してやればよい
	
	AB += max(0,joker - 1);
	if(joker>0 &&beginB >= 1){
		AB ++ ;
		beginB --;
	}
	if(joker>0 && endA >= 1){
		AB ++;
		endA --;
	}
	int pl = min(beginB,endA);
	AB += pl;

	cout << AB << endl;
	
}


Measured memory_bytes: 768
import java.util.*;

public class Main{
	public static void main(String[] args){
   		Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();
        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 27056
from collections import deque

N, u, v, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

def solve(s):
    D = [-1] * (N + 1)
    D[s] = 0

    Q = deque([s])
    while Q:
        a = Q.popleft()
        for b in E[a]:
            if D[b] != -1:
                continue
            D[b] = D[a] + 1
            Q.append(b)

    return D[1:]

T = solve(u)
A = solve(v)

print(-1 + max(a for t, a in zip(T, A) if t < a))

Measured memory_bytes: 31732
use proconio::input;

fn main() {
    input! {
        x: i32,
    }

    for i in x.. {
        if is_prime(i) {
            println!("{}", i);
            return;
        }
    }
}

fn is_prime(n: i32) -> bool {
    for i in (2..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            return false;
        }
    }
    true
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const ll LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=200050;
vector<int> G[MAXN];
int vis[MAXN];
int dfs(int now){
	int sum=1;
	vis[now]=1;
	for(int i=0;i<G[now].size();i++){
		if(vis[G[now][i]])continue;
		sum+=dfs(G[now][i]);
	}
	return sum;
}
void solve(int T){
	int n,m,u,v,ans=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		if(vis[i])continue;
		ans=max(ans,dfs(i));
	}
	printf("%d",ans);
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 24728
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var n = Read();
            var a = Reads();
            var count = new long[9];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (400 * j <= a[i] && a[i] < 400 * (j + 1)) count[j]++;
                }
                if (a[i] >= 3200) count[8]++;
            }
            long ans = 0;
            for (int i = 0; i < 8; i++)
            {
                if (count[i] != 0) ans++;
            }
            if (ans != 0)
                Console.WriteLine("{0} {1}", ans, ans + count[8]);
            else
                Console.WriteLine("{0} {1}", 1, ans + count[8]);
         
            Console.Out.Flush();
        }
    }
}




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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int h, w;
bool a[1002][1002];
int dp[1002][1002];

int solve(int i, int j)
{
	if (i == h && j == w) // standing on the last cell
	{
		return 1;
	}
	else if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	
	int op1 = 0, op2 = 0;

	op1 = (a[i][j + 1] || j + 1 > w) ? 0 : solve(i, j + 1);
	op2 = (a[i + 1][j] || i + 1 > h) ? 0 : solve(i + 1, j);

	return dp[i][j] = (op1 + op2) % mod;

}

int32_t main()
{
	FIO();
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			char ch; cin >> ch;
			if (ch == '.')
			{
				a[i][j] = 0;
			}
			else
			{
				a[i][j] = 1;
			}
		}
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(1, 1) << '\n';
	return 0;
}

Measured memory_bytes: 12528
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		Map<Integer,Integer>map = new TreeMap<>();
		for(int i = 0; i < n ; i++) {
			int d = stdIn.nextInt();
			if(map.containsKey(d)) {
				map.put(d,map.get(d)+1);
			}else {
				map.put(d,1);
			}
		}
		
		int m = stdIn.nextInt();
		
		int [] t = new int[m];
		
		for(int i = 0; i < m; i++) {
			t[i] = stdIn.nextInt();
		}


		for(int i = 0; i < m; i++) {
			if(map.containsKey(t[i]) && map.get(t[i])>= 1) {
				map.put(t[i],map.get(t[i])-1);
			}else {
				System.out.println("NO");
				return;
			}	
			
			
		}
		
		System.out.println("YES");
	}

}


Measured memory_bytes: 140748
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	a := make([]int, n)
	cnt := make(map[int]int)
	for i := range a {
		a[i] = readInt()
		cnt[a[i]]++
	}

	tot := 0
	for _, v := range cnt {
		if v < 2 {
			continue
		}
		tot += v * (v - 1) / 2
	}

	for i := range a {
		v := cnt[a[i]]
		if v < 2 {
			fmt.Println(tot)
		} else {
			fmt.Println(tot - (v*(v-1)-(v-1)*(v-2))/2)
		}
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

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

    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = min(ans * 2, ans + k);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
# abc1622_b.py
# https://atcoder.jp/contests/abc162/tasks/abc162_b

# B - FizzBuzz Sum /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# FizzBuzz列 a1,a2,...を次のように定めます。
#     iが 3 でも 5 でも割り切れるなら、ai=FizzBuzz
# そうではなく iが 3 で割り切れるなら、ai=Fizz
# そうではなく iが 5 で割り切れるなら、ai=Buzz
# そうではないなら、ai=i
# FizzBuzz列の N項目までに含まれる数の和を求めてください。

# 制約
#     1≤N≤106

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N

# 出力
# FizzBuzz列の N項目までに含まれる数の和を出力せよ。

# 入力例 1
# 15

# 出力例 1
# 60

# FizzBuzz列の 15項目までは次の通りです。
# 1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz
# 15項目までには 1,2,4,7,8,11,13,14 が含まれ、これらの和は 60です。

# 入力例 2
# 1000000

# 出力例 2
# 266666333332

# オーバーフローに注意してください。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    q, mod = divmod(N, 15)
    log(f'q=[{q}], mod=[{mod}]')

    # 15単位で割り切れるところまで
    s1 = (q*15+1)*(q*15)/2*1
    s3 = (q*5+1)*(q*5)/2*3
    s5 = (q*3+1)*(q*3)/2*5
    s15 = (q*1+1)*(q*1)/2*15
    result = s1 - s3 - s5 + s15
    log(f's1=[{s1}], s3=[{s3}], s5=[{s5}], s15=[{s15}]')

    for m in range(1, mod+1):
        if m % 3 == 0:
            pass
        elif m % 5 == 0:
            pass
        else:
            result += q*15 + m
            log(f'log=[{result}]')

    return [int(result)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['15']
        lines_export = [60]
    if pattern == 2:
        lines_input = ['1000000']
        lines_export = [266666333332]
    if pattern == 3:
        lines_input = ['7']
        lines_export = [14]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9324
#include<stdio.h>
#include<string.h>
int main(){
  int a,b,i,cnt=0;
  char s[12];
  scanf("%d%d",&a,&b);
  scanf("%s",s);
  for(i=0; i<a; i++){
    if(s[i]=='-'){
      cnt++;
    }
  }
  for(i=a+1; i<a+b+1; i++){
    if(s[i]=='-'){
      cnt++;
    }
  }
  if(cnt==0 && s[a]=='-'){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace ConsoleApp1AtCoder_Beginner_Contest_132
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var Dn = Slist();
            Dn.Sort();
            WriteLine(Dn[(int)N / 2] - Dn[(int)N / 2 - 1]);
        }
    }
}

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

signed main(){
  int N,C=100;
  cin>>N;
  int Y=0;
  while(C<N){
    C*=1.01;
    Y+=1;
  }
  cout<<Y<<endl;
}

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

int main()
{
	int W, H, N;
	cin >> W >> H >> N;
	int area = W * H;
	vector<int> x(N);
	vector<int> y(N);
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	int lW = 0;
	int lH = 0;
	int rW = W;
	int rH = H;
	for (int i = 0; i < N; i++) {
		if(a[i] == 1) {
			if (lW < x[i]) lW = x[i];
		}
		else if(a[i] == 2) {
			if (rW > x[i]) rW = x[i];
		}
		else if(a[i] == 3) {
			if (lH < y[i]) lH = y[i];
		}
		else if(a[i] == 4) {
			if (rH > y[i]) rH = y[i];
		}
	}
	if (lW >= rW || lH >= rH) area = 0;
	else area = (rW - lW) * (rH - lH);
	cout << area << endl;
}

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

using namespace std;

const int maxn = 1e5 + 5;
int ans[maxn];
set <int> s;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &ans[i]);
    }
    for(int i=n;i>=1;i--)
    {
        if(!m)break;
        if(!s.count(ans[i]))
        {
            s.insert(ans[i]);
            printf("%d\n",ans[i]);
        }
        m--;
    }
    getchar();
    getchar();
    return 0;
}


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

int main() {
  int h, w;
  while (cin >> h >> w, h | w) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i != 0 && i != h - 1 && j != 0 && j != w - 1) cout << ".";
        else cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3056
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

ll N;
vector<ll> As;
unordered_map<ll, unordered_map<ll, ll>> memo;

ll solve(ll i, ll n) {
    if (memo[i].find(n) != memo[i].end()) {
        return memo[i][n];
    }
    if (n == 0) {
        return 0;
    }
    ll left = N - i;
    if (left % 2 == 0 && n > left / 2) {
        return numeric_limits<ll>::min();
    }
    if (left % 2 == 1 && n > left / 2 + 1) {
        return numeric_limits<ll>::min();
    }
    ll ret = max(solve(i+1, n), As[i]+solve(i+2, n-1));
    memo[i][n] = ret;
    return ret;
}

int main() {
    cin >> N;
    As.resize(N);
    rep(i,0,N) {
        cin >> As[i];
    }
    cout << solve(0, N/2) << endl;
}


Measured memory_bytes: 49856
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    S = sorted(S)
    if S == ['a','b','c']:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8840
n = int(input())
h = [int(i) for i in input().split()]
tinpo = [0]
count = 0

for i in range(n-1):
  if h[i] >= h[i+1]:
    count += 1
  else:
    tinpo.append(count)
    count = 0
  if i == n-2:
    tinpo.append(count)

print(max(tinpo))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

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

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<bool> a(n);
    int now = 0;
    int ans = 0;
    while(1) {
        ans++;
        now = now * 10 + 7;
        now %= n;
        if(now == 0) {
            cout << ans << endl;
            return 0;
        }
        if(a[now]) {
            cout << -1 << endl;
            return 0;
        }
        a[now] = true;
    } 
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(){
	int data_num;
	int rec_a, rec_b, rec_c;

	scanf("%d", &data_num);

	int i;
	int temp;
	for(i = 0; i < data_num; ++i){
		scanf("%d %d %d", &rec_a, &rec_b, &rec_c);
		if(rec_a > rec_c){
			temp = rec_a;
			rec_a = rec_c;
			rec_c = temp;
		}
		if(rec_b > rec_c){
			temp = rec_b;
			rec_b = rec_c;
			rec_c = temp;
		}
		if(rec_a*rec_a + rec_b*rec_b == rec_c*rec_c){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580