akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int N, M, C, i, j, c = 0;
  cin >> N >> M >>C;
  int A[N][M], B[M], AB[N];
  
  for (i = 0; i < M; i++)
    cin >> B[i]; //Bk = B[k - 1]
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++)
      cin >> A[i][j]; //Amn = A[m - 1][n - 1]
  }
  
  for (i = 0; i < N; i++) {
    AB[i] = C;
    for (j = 0; j < M; j++)
      AB[i] += A[i][j] * B[j];
    if (AB[i] > 0)
      c++;
  }
  
  cout << c;
  
  return 0;
}


Measured memory_bytes: 256
// ABC164
// c.cs

using System;

class C
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] S = new string[N];

        for (int i = 0; i < N; i++)
        {
            S[i] = Console.ReadLine();
        }

        Array.Sort(S);
        int num = 0;
        
        for (int i = 0; i < N - 1; i++)
        {
            if(string.Compare(S[i], S[i + 1]) == 0)
            {
                num++;
            }
        }
        Console.WriteLine(N - num);

    }
}

Measured memory_bytes: 38448
/*
*
*   解説見てないお
*
*/
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    string s, t; cin >> s >> t;
    int q; cin >> q;
    vector<pair<int, int>> cnts(s.size()+1),cntt(t.size()+1);
    cnts[0] = cntt[0] = {0,0};
    REP(i, s.size()) {
        if (s[i] == 'A') {
            cnts[i + 1] = {cnts[i].first + 1, cnts[i].second};
        }
        else {
            cnts[i + 1] = {cnts[i].first, cnts[i].second + 1};
        }
    }
    REP(i, t.size()) {
        if (t[i] == 'A') {
            cntt[i + 1] = {cntt[i].first + 1, cntt[i].second};
        }
        else {
            cntt[i + 1] = {cntt[i].first, cntt[i].second + 1};
        }
    }
    REP(i, q) {
        int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);
        pair<int, int> sd = {cnts[b].first - cnts[a - 1].first,cnts[b].second - cnts[a - 1].second}; 
        pair<int, int> td = {cntt[d].first - cntt[c - 1].first,cntt[d].second - cntt[c - 1].second};
        int sc = sd.first - sd.second;
        int tc = td.first - td.second;
        if (sc > 0) {
            sc %= 3;
        }
        else {
            sc = (3 - ((-sc) % 3)) % 3;
        }
        if (tc > 0) {
            tc %= 3;
        }
        else {
            tc = (3 - ((-tc) % 3)) % 3;
        }
        if (sc == tc) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a, a+n, greater<int>());
    int al=0, bo=0;
    for (int i=0;i<n;i++)
    {
        if (i%2==0)
        {
            al+=a[i];
        }
        else
        {
            bo+=a[i];
        }
    }
    cout<<al-bo;
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split("");

		int red = 0;
		for (int i = 0; i < n; i++) {
			if (str[i].equals("R")) {
				red++;
			}
		}

		int ans = 0;
		for (int i = 0; i < red; i++) {
			if (str[i].equals("W")) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

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

using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x) { cout << setprecision(16) << x << endl; }
template<class T, class... A> void print(const T& first, const A& ... rest) { cout << first << " "; print(rest...); }
struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); } } premain;

#define N_MAX (200100)
vector<vector<ll>> graph(N_MAX);
vector<ll> X(N_MAX, 0);

void dfs(ll x, ll p) {
	for (auto e : graph[p]) {
		X[e] += x;
		dfs(X[e], e);
	}
}

int main() {
	int N, Q;
	cin >> N >> Q;
	
	REP(i, N-1) {
		ll a, b;
		cin >> a >> b;
		graph[a].push_back(b);
	}

	REP(i, Q) {
		ll p, x;
		cin >> p >> x;
		X[p] += x;
	}

	dfs(X[1], 1);

	REP(i, N) {
		cout << X[i+1] << " ";
	}
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using State = string::const_iterator;
class ParseError {};
using P = pair<int, int>;

//-------------------------------------

P orExpr(State &);
P andExpr(State &);
P term(State &);

P orExpr(State &now) {
    P a = andExpr(now);
    P res = P(-1, a.second);
    int tmp = a.first;
    while(*now == '|') {
        now++;
        P aa = andExpr(now);
        chmin(res.second, tmp + aa.second);
        tmp += aa.first;
    }
    res.first = tmp;
    return res;
}

P andExpr(State &now) {
    P t = term(now);
    P res = P(t.first, -1);
    int tmp = t.second;
    while(*now == '&') {
        now++;
        P tt = term(now);
        chmin(res.first, tmp + tt.first);
        tmp += tt.second;
    }
    res.second = tmp;
    return res;
}

P term(State &now) {
    if(*now == '(') {
        now++;
        P res = orExpr(now);
        now++;
        return res;
    } else {
        now++;
        return P(1, 1);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    State now = s.begin();
    P ans = orExpr(now);
    cout << ans.first << ' ' << ans.second << endl;
}


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

using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; //処理早くするためのおまじない
int main(){

string Sa,Sb,Sc;
cin>>Sa>>Sb>>Sc;

string next;
next.push_back(Sa[0]);

	while(true)
	{
		if(next == "a")
		{
			if(Sa.empty())
			{
				cout<<"A"<<endl;
				break;
			}
			next=*Sa.begin();
			Sa.erase(Sa.begin());
	 	}
	 	if(next == "b")
	 	{
			if(Sb.empty())
			{
				cout<<"B"<<endl;
				break;
			}
		next=*Sb.begin();
		Sb.erase(Sb.begin());
	 	}
	 	if(next == "c")
	 	{
			if(Sc.empty())
			{
				cout<<"C"<<endl;
				break;
			}
		next=*Sc.begin();
		Sc.erase(Sc.begin());
	 	}
	}
	return 0;
}




Measured memory_bytes: 3596
while True:
    l = input().split()
    if l[1] == '?':
        break
    elif l[1] == '+':
        print(int(l[0])+int(l[2]))
    elif l[1] == '-':
        print(int(l[0])-int(l[2]))
    elif l[1] == '*':
        print(int(l[0])*int(l[2]))
    elif l[1] == '/':
        print(int(l[0])//int(l[2]))

Measured memory_bytes: 7676
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long W_3 = W /3;
		long W_31 = W_3 + 1;
		long H_3 = H / 3;
		long H_31 = H_3 + 1;
		long W_2 = W / 2;
		long W_21 = W_2 + 1;
		long H_2 = H / 2;
		long H_21 = H_2 + 1;

		List<Long> areaList = new ArrayList<Long>();
		areaList.add(area(H * W_3, H * W_3, H * (W - 2 * W_3)));
		areaList.add(area(H * W_31, H * W_31, H * (W - 2 * W_31)));
		areaList.add(area(W * H_3, W * H_3, W * (H - 2 * H_3)));
		areaList.add(area(W * H_31, W * H_31, W * (H - 2 * H_31)));
		areaList.add(area(H * W_3, H_2 * (W - W_3), (H - H_2) * (W - W_3)));
		areaList.add(area(H * W_31, H_2 * (W - W_31), (H - H_2) * (W - W_31)));
		areaList.add(area(H * W_3, H_21 * (W - W_3), (H - H_21) * (W - W_3)));
		areaList.add(area(H * W_31, H_21 * (W - W_31), (H - H_21) * (W - W_31)));
		areaList.add(area(W * H_3, W_2 * (H - H_3), (W - W_2) * (H - H_3)));
		areaList.add(area(W * H_31, W_2 * (H - H_31), (W - W_2) * (H - H_31)));
		areaList.add(area(W * H_3, W_21 * (H - H_3), (W - W_21) * (H - H_3)));
		areaList.add(area(W * H_31, W_21 * (H - H_31), (W - W_21) * (H - H_31)));

		System.out.println(areaList.stream().min(Comparator.naturalOrder()).get());
	}

	private long area(long a, long b, long c) {
		if (a <= b && b <= c) {
			return c - a;
		}
		if (a <= c && c <= b) {
			return b - a;
		}
		if (b <= a && a <= c) {
			return c - b;
		}
		if (b <= c && c <= a) {
			return a - b;
		}
		if (c <= a && a <= b) {
			return b - c;
		}
		if (c <= b && b <= a) {
			return a - c;
		}
		return 0;
	}
}

Measured memory_bytes: 29012
import Data.Maybe

radToDeg :: Double -> Double
radToDeg x = x / pi * 180

trapezoid a b x
	| c >= 0    = Just $ atan $ (b - c) / a
	| otherwise = Nothing
	where c = 2 * x / a - b

triangle b x = atan $ b / a
	where a = 2 * x / b

calc' a b x = triangle b x `fromMaybe` trapezoid a b x

calc a b x = calc' a b (x / a)

main :: IO ()
main = do
	[a, b, x] <- map read . words <$> getLine
	print $ radToDeg $ calc a b x


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll a,b; cin>>a>>b;
  if(a<=0 && b>=0)cout<<"Zero"<<endl;
  else if(a<0){
		ll p=min(b,(ll)0);
        if(abs(a-p)%2==0)cout<<"Negative"<<endl;
    	else cout<<"Positive"<<endl;
  }
  else cout<<"Positive"<<endl;

    


	
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int A,B,C;
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C;
	if(C>=A && C<=B) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
//#define DEBUG
using namespace std;
 
struct WORD
{
    char s[128];
    int num;
};
 
bool cmp(const WORD A, const WORD B)
{
    if (A.num != B.num) return (A.num > B.num);
    return (strcmp(A.s, B.s) < 0);
}
 
int main()
{
    WORD word[2048];
     
    int n;
    while (scanf("%d%*c", &n), n){
        int num = 0;
         
        for (int i = 0; i < n; i++){
            char str_line[2048];
            char str_word[2048];
            fgets(str_line, 2048, stdin);
            int p = 0;
            while (sscanf(&str_line[p], "%s", str_word), str_line[p] != '\0'){
                int j;
                for (j = 0; j < num; j++){
                    if (strcmp(str_word, word[j].s) == 0){
                        word[j].num++;
                        break;
                    }
                }
                if (j == num){
                    strcpy(word[j].s, str_word);
                    word[j].num = 1;
                    num++;
                }
                 
                p += strlen(str_word) + 1;
            }
        }
         
        sort(word, word + num, cmp);
         
        #ifdef DEBUG
        for (int i = 0; i < num; i++){
            printf("%s\n", word[i].s);
        }
        #endif
         
        char k;
        scanf(" %c", &k);
        int f = 0;
        for (int i = 0; i < num && f < 5; i++){
            if (word[i].s[0] == k){
                if (f > 0){
                    printf(" ");
                }
                printf("%s", word[i].s);
                f++;
            }
        }
        if (f == 0){
            printf("NA");
        }
        puts("");
    }
     
    return 0;
}

Measured memory_bytes: 1112
#include <iostream>
#include <vector>

using namespace std;

vector<long long> sum;

long long calc_cost(bool ps) {
	long long res,dis;
	res = dis = 0;
	for (int i = 0; i < sum.size(); ++i) {
		long long temp = sum[i] + dis;
		if (i%2 == 0) {
			if (temp == 0) {
				++res;
				if (ps) {
					++dis;
				}
				else {
					--dis;
				}
			}
			else if (ps && temp < 0) {
				res += -temp+1;
				dis += -temp+1;
			}
			else if (!ps && temp > 0) {
				res += temp+1;
				dis -= temp+1;
			}
		}
		else {
			if (temp == 0) {
				++res;
				if (ps) {
					--dis;
				}
				else {
					++dis;
				}
			}
			else if (ps && temp > 0) {
				res += temp+1;
				dis -= temp+1;
			}
			else if (!ps && temp < 0)  {
				res += -temp+1;
				dis += -temp+1;
			}
		}
	}
	return res;
}

int main(void) {
	int n;
	cin >> n;
	sum = vector<long long>(n,0);
	for (int i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		if (i == 0) {
			sum[i] = a;
		}
		else {
			sum[i] += sum[i-1] + a;
		}
	}

	cout << min(calc_cost(true),calc_cost(false)) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
		cout<<s<<"es"<<endl;
	}else{
		cout<<s<<"s"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, k, x, dp[100001];
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for(int i = 0 ; i < n && cin >> x ; i++)
        a.push_back(x);
    for(int i = 1 ; i < n ; i++){
        dp[i] = 1e9;
        for(int j = i - 1 ; j >= max(0, i - k) ; j--)
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1144
//Sinhov : "Hi stalker!"
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1];
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(0, a + 1):
    for j in range(0, b + 1):
        for k in range(0, c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count = count + 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int n;
	cin >> n;
	long long int a[n]; 
	for(int i=0;i<n;i++){
    cin >> a[i];
}  
	long long int b[n];
	for(int i=0;i<n;i++){
    b[a[i]]=i;
}
	long long int c;
	long long int d;
	c=1;
	d=1;
	for(int i=1;i<n;i++){
	if(b[i] < b[i+1]){
	c=c+1;
}
	if(b[i] > b[i+1]){
	if(c>d){
	d=c;
}
	c=1;
}
	if(c>d){
	d=c;
}
}
	cout << (n-d) << endl;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionA
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());

			var max = 0L;

			for(int i = 1; max <= n; i++) {
				var temp = i * i;

				if(temp > n) {
					break;
				}

				max = temp;
			}

			Console.WriteLine(max);
		}
	}
}


Measured memory_bytes: 27448
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	string str = "";
	while (N != 0) {
		int r = N % 2;
		if (r < 0)r += 2;
		N = (N - r) / (-2);
		str += ('0' + r);
	}
	reverse(str.begin(), str.end());
	if (str == "")str = "0";
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<char,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

int main(){
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    vector<vector<char>> field(H+2, vector<char>(W+2, '#'));
    for(ll i=0;i<H;i++){
     for(ll j=0;j<W;j++){
         cin>>field[i+1][j+1]
     ;}
    ;}
    vector<vector<ll>> wallh(H+2, vector<ll>(0));
    vector<vector<ll>> wallw(W+2, vector<ll>(0));
    vector<vector<ll>> rwallh(H+2, vector<ll>(0));
    vector<vector<ll>> rwallw(W+2, vector<ll>(0));    
    for(ll i=0;i<=H+1;i++){
     for(ll j=0;j<=W+1;j++){
         if(field[i][j]=='#'){
             wallh[i].emplace_back(j);
             wallw[j].emplace_back(i);
             rwallh[i].emplace_back(-j);
             rwallw[j].emplace_back(-i);
         }
     ;}
    ;}
    for(ll i=0;i<=H+1;i++){
        reverse(rwallh[i].begin(), rwallh[i].end());
    ;}
    for(ll i=0;i<=W+1;i++){
        reverse(rwallw[i].begin(), rwallw[i].end());
    ;}
    ll ans=0;
    for(ll i=1;i<=H;i++){
     for(ll j=1;j<=W;j++){
         if(field[i][j]=='.'){
             ll a,b,c,d;
             a=*upper_bound(wallh[i].begin(), wallh[i].end(), j);
             b=-(*upper_bound(rwallh[i].begin(), rwallh[i].end(), -j));
             c=*upper_bound(wallw[j].begin(), wallw[j].end(), i);
             d=-(*upper_bound(rwallw[j].begin(), rwallw[j].end(), -i));
             ans=max(ans,a-b+c-d-3);
         }
     ;}
    ;}
    cout<<ans<<endl;
return 0;
}


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

int main() {
  int N;
  int K;
  cin >> N >> K;
  
  int sum =0;
  
  for(int i=0; i<N; i++){
   int x;
    cin >> x;
    int y;
    
    if(K-x>x){
      y=x;
    }
    else{
     y=K-x;
    }
    
    sum +=y;
  }
  
  cout << 2*sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
ll n ;
vector<ll>v[N] ;
ll ans ;
ll dfs(ll ii,ll p)
{
    vector<ll>a ;
    ll sum =0 ;
    for(ll j:v[ii])
    {
        if(j==p)
            continue ;

        ll x=dfs(j,ii) ;
        sum+=x ;
        a.pb(x) ;
    }
    ll sz=a.size() ;
    ll dp[sz+1][3] ;
    for(ll i=0;i<=sz;i++)
    {
        dp[i][0]=0 ;
        dp[i][1]=0 ;
        dp[i][2]=0 ;
    }

    dp[0][0]=1 ;

    for(ll i=0;i<sz;i++)
    {
        cout<<ii<<": "<<a[i]<<endl ;
       for(ll j=0;j<3;j++)
       {
           ll w=(a[i]*power(2,a[i]-1))%maa ;
           dp[i+1][min(j+1,(ll)2)]=( dp[i+1][min(j+1,(ll)2)]+(dp[i][j]*(w-1))%maa)%maa ;
            dp[i+1][min(j,(ll)2)]=( dp[i+1][min(j,(ll)2)]+(dp[i][j]*(1))%maa)%maa ;

       }


    }
    cout<<ii<<" "<<dp[sz][0]<<" "<<dp[sz][2]<<endl ;
    ans+=(dp[sz][0]+dp[sz][2])%maa  ;
    ans%=maa ;

    a.clear() ;

    return sum+1 ;

}
int main()
{
   fast ;
   ///Mission-500
  /* cin>>n ;
   for(ll i=0;i<n-1;i++)
   {
       ll a,b ;
       cin>>a>>b ;
       v[a].pb(b) ;
       v[b].pb(a) ;
   }
   ans=0 ;
   dfs(1,-1) ;

   ll p=power(2,n) ;
   p=power(p,maa-2) ;

   //ans=(ans*p)%maa ;

   cout<<ans ;*/

   ll pr[100009] ;
   for(ll i=0;i<100009;i++)
    pr[i]=1 ;

   pr[0]=0 ;
   pr[1]=0 ;
   for(ll i=2;i<100009;i++)
   {
       for(ll j=2*i;j<100009;j+=i)
       {
           pr[j]=0 ;
       }
   }
   ll x ;
   cin>>x ;
   for(ll i=x;i<=100008;i++)
   {
        if(pr[i])
        {
            cout<<i ;
            exit(0) ;
         }
   }




}


Measured memory_bytes: 5760
#include <stdio.h>

int main(void){
  int a, b;
  int i, j, k;
  int h = 0;
  scanf("%d %d", &a, &b);
  for(i = 1; i <= b - a - 1; i++){
    h += i;
  }
  printf("%d\n", h - a);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N;
    cin >> N;
    
    string line;
    getline(cin, line);
    
    int index;

    for (int n = 0; n != N; ++n) {
        getline(cin, line);
        while (line.find("Hoshino") != string::npos) {
            index = line.find("Hoshino");
            line.replace(index, 7, "Hoshina");
        }
        cout << line << endl;
    }

    return 0;
}

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

int main(){
    int N;

    cin >> N;

    vector<int> V(N);

    double ans = 0.0;

    for(int i = 0;i < N;i++){
        cin >> V.at(i);
    }
    sort(V.begin(),V.end());

    ans += (V[0] + V[1]) / 2.0;

    for(int i = 2;i < N;i++){
        ans = (ans + V[i]) / 2.0;
    }

    cout << setprecision(16) << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e18;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
     ll ans = -inf;
     if( (a<0 && b>=0) && (c<0 && d>=0) ){ ans = max( ans , b*d) ; ans = max( ans , a*c) ;}
     else if( (a>=0 && b>=0) && (c<0 && d>=0)){ ans = max( ans , b*d );  }
     else if( ((a<0 && b>=0) && (c>=0 && d>=0))) { ans = max( ans , b*d) ;}
    else if( (a<0 && b>=0) && (c<0 && d<0) ){ ans = max( ans , c*a ) ;}
    else if( (a>=0 && b>=0) && (c>=0 && d>=0 ) ) { ans = max( ans , b*d ) ; }
    else if ( (a>=0 && b>=0) && (c<0 && d<0) ) { ans = max( ans, d*a ) ;}
    else if( (a<0 && b<0) && (c<0 && d>=0) ){ ans = max( ans , a*c) ;}
    else if( (a<0 && b<0) && (c>=0 && d>=0) ) { ans = max( ans , b*c ) ; }
    else if( (a<0 && b<0) && (c<0 && d<0 )) { ans = max( ans , a*c ) ; }


  cout<<ans;
  }

 return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#define N 100
#define M 1000
int main(void){
    int i,n,j,jj,flag;
    char x[N][M],y[N][M];
    int xdigi,ydigi,ldigi;
    char sum[M];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s%s",x[i],y[i]);
    for(i=0;i<n;i++){
        for(j=0;;j++)
            if(x[i][j]==0){
                xdigi=j;
                break; 
            } 
            for(j=0;;j++) 
                if(y[i][j]==0){
                    ydigi=j;
                    break;
                }
                if(xdigi>=ydigi)
                    ldigi=xdigi; 
                else   
                    ldigi=ydigi; 
                if(ldigi>80){    
                    printf("overflow\n"); 
                }else{ 
                    for(j=0;j<ldigi+2;j++) 
                        sum[j]=0;  
                    for(j=xdigi-1,jj=0;j>=0;j--,jj++)     
                        sum[jj]+=x[i][j]-'0';   
                    for(j=ydigi-1,jj=0;j>=0;j--,jj++)   
                        sum[jj]+=y[i][j]-'0';       for(j=0;j<ldigi;j++)    
                        if(sum[j]>9){         
                            if(j==ldigi-1)        
                                ldigi++;     
                            sum[j]-=10;   
                            sum[j+1]++;  
                        }     
                        if(ldigi>80){
                            printf("overflow\n"); 
                        }else{  
                            for(j=ldigi-1;j>=0;j--){ 
                                printf("%c",sum[j]+'0');
                            }  
                            printf("\n"); 
                        }   
                } 
    } 
    return 0;
}

Measured memory_bytes: 620
#include <iostream>

int cal(long long n) {
  int retv = 0;
  while(true) {
    if ( n % 2 == 0 ) retv++;
    else return retv;

    n /= 2;
  }
  return retv;
}

int main()
{
  int N;
  std::cin >> N;
  long long a[N];
  int ans = 100;
  for ( long long i = 0; i < N; i++ ) {
    std::cin >> a[i];
    int m = cal(a[i]);
    if ( m < ans) {
      ans = m;
    }
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
maze = []
visited = [[0]*(w) for _ in range(h)]
mx = 0
for _ in range(h):
    s = input()
    mx += s.count('.')
    maze.append(list(s))
sy,sx = 0, 0
gy, gx = h-1, w-1
que = deque([(sy,sx,1)])

while que:
    y,x,c = que.popleft()
    if visited[y][x] != 0:
        continue
    visited[y][x] = c
    for dy,dx in zip((1,-1,0,0), (0,0,1,-1)):
        ny,nx = y+dy, x+dx
        if 0<=ny<h and 0<=nx<w:
            if maze[ny][nx]=='.':
                que.append((ny,nx,c+1))

print(mx-visited[gy][gx] if visited[gy][gx]!=0 else -1)
                

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
using namespace std;
int main(){
	
	vector<int> s(3);
	int n;
	int r;
	while(cin>>s[0]>>s[1]>>s[2],s[0]!=0&&s[1]!=0&&s[2]!=0){
		sort(s.begin(),s.end());
		double a=sqrt(pow(s[0],2)+pow(s[1],2));
		cin>>n;
		double r;
		for(int i=0;i<n;i++){
			cin>>r;
			if(a<2*r)
				cout<<"OK"<<endl;
			else
				cout<<"NA"<<endl;
		}
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
struct node {
    map <int, int> s;
    inline void clear(int x) {
        while (s.size() && (--s.end()) -> first >= x) s.erase(--s.end());
    }
    inline int& operator [] (int x) {
        if (!s.count(x)) s[x] = 0;
        return s[x];
    }
} s;
int n, a[200010];
inline int check(int x) {
    s.clear(0);
    for (int i = 2; i <= n; i++) {
        if (a[i] > a[i - 1]) continue;
        s.clear(a[i]);
        int now = a[i] - 1;
        while (now >= 0) {
            if (++s[now] != x) break;
            s[now] = 0;
            now--;
        }
        if (now < 0) return 0;
    }
    return 1;
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    int tag = 1;
    for (int i = 2; i <= n; i++) if(a[i] <= a[i - 1]) tag = 0;
    if (tag) return puts("1"), 0;
    int l = 2, r = n, ans;
    while (l <= r) {
        int mid = l + r >> 1;
        if (check(mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    return cout << ans << endl, 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int k,x;
    cin >> k >> x;

    for (int i = k-1; i > 0; --i)
        cout << (x - i) << " ";

    for (int i = 0; i < k; ++i)
        cout << (x + i) << " ";
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};


const int MAX_V = 1e5;
vector<int> G[MAX_V];

set<int> used_v;
int ord[MAX_V], lowlink[MAX_V], parent[MAX_V];
int k = 0;

void calc_lowlink(int v)
{
    used_v.insert(v);
    ord[v] = lowlink[v] = k++;

    for (auto u : G[v]) {
        if (!used_v.count(u)) {
            parent[u] = v;
            calc_lowlink(u);
            lowlink[v] = min(lowlink[v], lowlink[u]);
        } else if (u != parent[v]) {
            // backward edge
            lowlink[v] = min(lowlink[v], ord[u]);
        }
    }
}

vector<int> articulation_points(int N)
{
    vector<int> res;

    parent[0] = -1;
    calc_lowlink(0);

    int root_deg = 0;
    for (int i=1; i<N; i++) {
        int p = parent[i];
        if (p == 0) root_deg++;
        else if (ord[p] <= lowlink[i]) {
            res.push_back(p);
        }
    }

    if (root_deg > 1) res.push_back(0);
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());

    return res;
}

int main()
{
    int N, M;
    cin >> N >> M;

    rep(i, M) {
        int U, V;
        cin >> U >> V;
        // U--, V--;
        G[U].push_back(V);
        G[V].push_back(U);
    }

    vector<int> ap = articulation_points(N);
    for (auto a : ap) cout << a << endl;
}

Measured memory_bytes: 7140
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(1, n):
  if a[i] == a[i - 1] + 1:
    ans += c[a[i - 1] - 1]

print(ans)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
ans = "DENIED"
count = 0
for i in a:
  if i % 2 == 0 and i % 3 != 0 and i % 5 != 0:
    count += 1
if count == 0:
  ans = "APPROVED"
print(ans)

Measured memory_bytes: 9168
#include <stdio.h>
#include <string.h>

int main() {
  char s[200001];
  scanf("%s", s);
  int len=strlen(s), A, Z, i;

  for (i=0; i<len; i++) {
    if (s[i]=='A') {
      A=i;
      break;
    }
  }

  for (i=len-1; i>=0; i--) {
    if (s[i]=='Z') {
      Z=i;
      break;
    }
  }

  printf("%d\n", Z-A+1);
  return 0;
}

Measured memory_bytes: 512
# Code for C - : (Colon)
# Use input() to fetch data from STDIN
import math

[a, b, h, m] = map(int, input().split())

ht = 360 * h / 12 + 360 * m / 60 / 12
mt = 360 * m / 60

t = abs(ht - mt) if abs(ht - mt) <= 180 else 360 - abs(ht - mt)

print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(t))))


Measured memory_bytes: 9504
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        x: u32
    }
    let res = match x {
        400 ... 599  => 8,
        600 ... 799  => 7,
        800 ... 999  => 6,
        1000 ... 1199 => 5,
        1200 ... 1399 => 4,
        1400 ... 1599 => 3,
        1600 ... 1799 => 2,
        1800 ... 1999 => 1,
        _ => panic!()
    };
    println!("{}", res);
}


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

int main() {
  int N, K,init;
  int l = 1;
  cin >> N >> K;
  init = K;
  if(N >= K){
    while(N >= K){
      K = K * init;
      l++;
    }
  }
  
  cout << l << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    vector<vector<int>> dp((1<<n),vector<int>(51,1e9));
    dp[0][0]=0;
    for(int i=0;i<(1<<n);i++){
        int t=0;
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                t++;
            }
        }
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                continue;
            }
            int p=0;
            for(int k=0;k<j;k++){
                if(!((i>>k)&1)){
                    p++;
                }
            }
            for(int k=0;k<=50;k++){
                if(dp[i][k]==1e9){
                    continue;
                }
                if(abs(t-j)%2==0){
                    if(a[j]>=k){
                        dp[i|(1<<j)][a[j]]=min(dp[i|(1<<j)][a[j]],dp[i][k]+p);
                    }
                }
                else{
                    if(b[j]>=k){
                        dp[i|(1<<j)][b[j]]=min(dp[i|(1<<j)][b[j]],dp[i][k]+p);
                    }
                }
            }
        }
    }
    int ans=1e9;
    for(int i=0;i<=50;i++){
        ans=min(ans,dp[(1<<n)-1][i]);
    }
    if(ans==1e9){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 65792
#include<iostream>
using namespace std;
int main() {
	int a, b, c, x;
	int ans = 0;
	cin >> a >> b >> c >> x;
	x /= 50;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 10 + j * 2 + k == x)ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	ll sum=0;
	rep(i,1,n+1)
	{
		ll x = i;
		if(x%3==0 || x%5==0) continue;
		else sum+=x;
	}

	cout<<sum<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}


Measured memory_bytes: 3648
import math

N, K = map(int, input().split())
p = 0

count = 1
while True:
    p += max(0, min(N + 1, math.ceil(K / 2 ** (count - 1))) - math.ceil(K / 2 ** count)) * 0.5 ** count
    count += 1
    if K / 2 ** count < 0.5:
        break

p += max(0, N - K + 1)
print(p / N)


Measured memory_bytes: 38512
#include<iostream>
#include<string>
using namespace std;
int main(){
long n,i,j;
string s[10];
while(cin>>n,n){
for(j=0;j<10;j++)s[j]="";
for(i=0;i<n;i++){
cin>>j;
s[j]+="*";
}
for(j=0;j<10;j++){
if(s[j]=="")cout<<"-"<<endl;else cout<<s[j]<<endl;
}
}
return 0;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int input,sum=0,X,N,D;
  int interval[100]={0};

  cin>>N;
  cin>>D;
  cin>>X;
  FOR(i,0,N){
    cin>>interval[i];
  }

  sum+=X;
  FOR(i,0,N){
    sum+=1 + (D-1)/interval[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
    n = II()
    a = LI()
    d = [0]*2
    for c in a:
        d[c%2]+=1
    if d[1] % 2 == 0:
        return 'YES'
    return 'NO'


print(main())


Measured memory_bytes: 19188
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) ll(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 2e5 + 5;

int a[N];

signed main(){
    fastio;
    int i,n,ans=-1;
    cin>>n;
    map<int,int> mp;
    for(i=0;i<n;++i){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(auto it:mp){
        ans=max(ans,it.s);
    }
    if(ans==1)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 11648
N,M = map(int,input().split())
prob = [0]*N
WA = [0]*N
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if S == "AC":
        prob[p-1] = 1
    elif prob[p-1] == 0:
        WA[p-1] += 1
sumWA = 0
for i in range(N):
    if prob[i] == 1:
        sumWA += WA[i]
print(sum(prob),sumWA)


Measured memory_bytes: 4596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//nedan
		int k = sc.nextInt();//kosuu
		int num[] = new int[k];
		int ord;
		int ordnum;
		int ans = n;
		boolean flg = true;
		for (int i = 0; i < k; i++) {
			num[i] = sc.nextInt();
		}
		for (int i = n; i <= 99999; i++) {
			flg = true;
			ord = Integer.toString(i).length();
			for (int j = 0; j < ord; j++) {
				ordnum = i % (int) (Math.pow(10, (j + 1))) / (int) (Math.pow(10, j));
				for (int l = 0; l < k; l++) {
					if (ordnum == num[l]) {
						flg = false;
						break;
					}
				}
				if (flg == false) {
					break;
				}
			}
			if (flg == true) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23156
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = []

if n == 0:
    print(x)
    exit()

x1 = x
while x1 in p:
    x1 += 1

x2 = x
while x2 in p:
    x2 -= 1

if abs(x-x1) < abs(x-x2):
    print(x1)
else:
    print(x2)

Measured memory_bytes: 61744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  if(n/b == 0){
    cout << a * n / b << endl;
  }
  else{
    cout << a * (b-1) / b << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
    constexpr int len[5] = {5, 7, 5, 7, 7};
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> l(n);
        for (int i = 0; i < n; i++) {
            string s;
            cin >> s;
            l[i] = s.size();
        }

        for (int i = 0; i < n; i++) {
            int ind = 0;
            int sum = 0;
            for (int j = i; j < n; j++) {
                if (ind == 5) {
                    break;
                }
                sum += l[j];
                if (sum > len[ind]) {
                    break;
                } else if (sum == len[ind]) {
                    ind++;
                    sum = 0;
                }
            }
            if (ind == 5) {
                cout << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int> a, pair<int,int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
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;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	vpllint a(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	map < pair<llint, llint>, int > b;
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			if (i == j)continue;
			pair<llint, llint>tmp;
			tmp.first = a[j].first - a[i].first;
			tmp.second = a[j].second - a[i].second;
			b[tmp]++;
			ans = max(b[tmp], ans);
		}
	}
	cout << n - ans << endl;
	return 0;
}

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

int main()
{
	int64_t n, mod = 1000000007;
	string s;
	cin >> n >> s;

	vector<int64_t> cnt(26, 0);
	for (auto &c : s)
	{
		cnt[c - 'a']++;
	}

	int64_t ans = 0;

	for (int i = 0; i < 26; i++)
	{
		int64_t tmp = cnt[i];
		for (int j = i + 1; j < 26; j++)
		{
			(tmp *= cnt[j] + 1) %= mod;
		}
		(ans += tmp) %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if (s=="Cloudy")
        cout<<"Rainy"<<endl;
    else
        cout<<"Sunny"<<endl;


    return 0;
}




Measured memory_bytes: 256