akhauriyash/Code-Regression huggingface dataset:
// AOJ 0637: Semiexpress
// 2018.1.2 bal4u@uu

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

int n, m, k;
long long a, b, c;
long long t;
int s[3002];
int e[9000001], sz;

//#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long inll()
{
	long long n;
	int c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int calc(int l, int r)
{
	int i, id, ans;
	long long nt, dt, nx;

	id = l, nt = b*l;
	ans = 0;
	for (i = 0; i <= k-m && id < r; i++) {
		dt = t-nt;
		if (dt < 0) break;
		dt /= a;
		nx = id + dt + 1;
		if (nx > r) nx = r;
		if (id == l) ans = (int)nx-id;
		else e[sz++] = (int)nx-id;
		nt += (nx-id)*c;
		id = (int)nx;
	}
	return ans;
}

int main()
{
	int m1, i, ans;

	n = in(), m = in(), k = in();
	a = in(), b = in(), c = in();
	t = inll();
	for (i = 0; i < m; i++) s[i] = in()-1;

	ans = 0, m1 = m-1;
	if (b*s[m1] <= t) ans++;
	sz = 0;
	for (i = 0; i < m1; i++) ans += calc(s[i], s[i+1]);
	qsort(e, sz, sizeof(int), cmp);
	i = k-m; while (i--) ans += e[i];
	printf("%d\n", ans-1);
	return 0;
}



Measured memory_bytes: 4960
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN

import sys

N = int(input())
S = input()

ans = 0
for i in range(10):
    code1 = S.find(str(i))
    if code1 == -1:
        continue
    for j in range(10):
        code2 = S.find(str(j), code1 + 1)
        if code2 == -1:
            continue
        for k in range(10):
            code3 = S.find(str(k), code2 + 1)
            if code3 != -1:
                ans += 1

print(ans)


Measured memory_bytes: 38256
#include <stdio.h>
#include <inttypes.h>

#define MOD_BY UINT32_C(1000000007)

int32_t N;
int32_t A[114514];

int kazoeru[114514];

int main(void) {
	int32_t i;
	uint32_t answer;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd32, &A[i]) != 1) return 1;
	}

	for (i = 0; i < N; i++) {
		if (A[i] < 0 || N - 1 < A[i] || ((N - 1) - A[i]) % 2 != 0) {
			puts("0");
			return 0;
		}
		kazoeru[A[i]]++;
		if (kazoeru[A[i]] > 2 || (A[i] == 0 && kazoeru[A[i]] > 1)) {
			puts("0");
			return 0;
		}
	}

	answer = 1;
	for (i = N - 1; i > 0; i -= 2) {
		answer += answer;
		if (answer >= MOD_BY) answer -= MOD_BY;
	}
	printf("%" PRIu32 "\n", answer);

	return 0;
}

/*
差の絶対値がわかる → 人数は固定なので、位置が2(真ん中以外)or1(真ん中)に絞れる
衝突したら死

差の絶対値は0or1～N-1まで2刻みで変わる → N-1から引いて奇数なら死
*/


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500005;


vector<pair<int,int>> adj[N];
vector<int> color(N);

void dfs(int s,int ps)
{
  for(auto i : adj[s])
  {
    if(i.first != ps)
    {
      if(i.second%2 == 0)
      {
        color[i.first] = color[s];
      }
      else
      {
        color[i.first] = color[s] xor 1;
      }
      dfs(i.first,s);
    }
  }
}
int32_t main()
{



    int n;
    cin >> n;

    for(int i = 1; i <= n-1; i++)
    {
      int x,y,z;
      cin >> x >> y >> z;

      adj[x].push_back({y,z});
      adj[y].push_back({x,z});
    }
    color[1] = 1;

    dfs(1,0);

    for(int i = 1; i <= n; i++)
    {
      cout << color[i] << endl;
    }

   

    return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K;
    cin >> N >> K;

    int W = 0, B = 0;
    vvi white(4 * K, vi(4 * K));
    vvi black(4 * K, vi(4 * K));

    char c;
    for (int i = 0, x, y; i < N; i++) {
        cin >> x >> y >> c;
        if (c == 'B') {
            B++;
            black[x % (2 * K)][y % (2 * K)]++;
            black[x % (2 * K) + 2 * K][y % (2 * K)]++;
            black[x % (2 * K)][y % (2 * K) + 2 * K]++;
            black[x % (2 * K) + 2 * K][y % (2 * K) + 2 * K]++;
        } else {
            W++;
            white[x % (2 * K)][y % (2 * K)]++;
            white[x % (2 * K) + 2 * K][y % (2 * K)]++;
            white[x % (2 * K)][y % (2 * K) + 2 * K]++;
            white[x % (2 * K) + 2 * K][y % (2 * K) + 2 * K]++;
        }
    }

    for (int r = 0; r < 4 * K; r++) {
        for (int c = 0; c < 4 * K; c++) {
            if (r) white[r][c] += white[r-1][c];
            if (c) white[r][c] += white[r][c-1];
            if (r && c) white[r][c] -= white[r-1][c-1];

            if (r) black[r][c] += black[r-1][c];
            if (c) black[r][c] += black[r][c-1];
            if (r && c) black[r][c] -= black[r-1][c-1];
        }
    }

    auto __get = [](vvi& grid, int r1, int c1, int r2, int c2) {
        return grid[r2][c2]
            - (r1 ? grid[r1-1][c2] : 0)
            - (c1 ? grid[r2][c1-1] : 0)
            + (r1 && c1 ? grid[r1-1][c1-1] : 0);
    };
    auto get = [&](vvi& grid, int r2, int c2) {
        return __get(grid, r2 - K + 1, c2 - K + 1, r2, c2);
    };

    int ans = 0;
    for (int x = 2 * K; x < 4 * K; x++) {
        for (int y = 2 * K; y < 4 * K; y++) {
            int bl = get(black, x, y)
                   + get(black, x - K, y - K);

            int wh = get(white, x - K, y)
                   + get(white, x, y - K);

            ans = max(ans, bl + wh);
            ans = max(ans, B - bl + W - wh);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 125568
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//https://drken1215.hatenablog.com/entry/2020/05/02/225600
//入力例の1～4までを試しただけで見当つかず
//もっと手を動かしていく必要があった。

fn main() {
    let a: u64 = read();
    let b: u64 = read();
    let n: u64 = read();

    let x = std::cmp::min(n,b-1);

    let ans = ((a*x/b) as f64).floor() - 5.0 * ((x/b) as f64).floor();

    println!("{}", ans);


}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define rep(i,f,n) for(int i=(f); (i) < (n); i++)
#define repe(i,f,n) for(int i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;

int
main() 
{

  ll n,m; cin >> n >> m;

  if(n == 1 && m == 1){
    cout << 1 << endl;
  } else if(n == 2 && m == 2) {
    cout << 0 << endl;
  } else if(n == 1 || m == 1){
    cout << max(n, m) - 2 << endl;
  } else {
    cout << (n * m) - (2 * m) - (2 * n) + 4 << endl;
  }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    string s; 
    cin >> s;
    int a = stoi(s.substr(0 , 2));
    int b = stoi(s.substr(2 , 2));
    if(a > 12 && b <= 12 && b >= 1)
        cout << "YYMM" << endl;
    else if(a <= 12 && b > 12 && a >= 1)
        cout << "MMYY" << endl;
    else if(a <= 12 && a >= 1 &&  b <= 12 && b >= 1)
        cout << "AMBIGUOUS" << endl;
    else if(a == 0 && b <= 12 && b >=1 )
        cout <<"YYMM" << endl;
     else if(b == 0 && a <= 12 && a >=1 )
        cout <<"MMYY" << endl;
    else 
        cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    #define pb push_back
    #define ll long long
   	#define mp make_pair

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       	int n, k;
        cin  >> n >> k;
        vector<int> v(n);
        for(int i = 0; i < n; ++i){ 
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        int res = 0;
        for(int i = 0; i < k; ++i){ 
            res += v[i];
        }
        cout << res << endl;
        return 0;
    }

Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

struct pos{
	double x,y;
	double norm,norm2;
	pos tov(pos a){
		return (a-(*this));
	}
	pos operator+(pos a)const{
		pos res=a;
		res.x+=x; res.y+=y;
		res=pos(res.x,res.y);
		return res;
	}
	pos operator-(pos a)const{
		pos res=(*this);
		res.x-=a.x; res.y-=a.y;
		res=pos(res.x,res.y);
		return res;
	}
	pos scalar(double a){
		pos res=(*this);
		res.x*=a; res.y*=a;
		res=pos(res.x,res.y);
		return res;
	}
	double dot(pos a){
		return x*a.x + y*a.y;
	}
	double cross(pos a){
		return x*a.y - y*a.x;
	}
	pos(double ix,double iy){
		x=ix; y=iy;
		norm2=x*x+y*y;
		norm=sqrt(norm2);
	}
	pos(){}
	string str(){
		char ns[50];
		sprintf(ns,"(%lf %lf)",x,y);
		return	string(ns);
	}
	static pos polar(double r,double t){
		return pos(r*cos(t),r*sin(t));
	}
};

struct polygon{
	vector<pos> ps;
	polygon(){}
	double area(){
		double res=0;
		rep(i,ps.size()){
			pos no=ps[i],to=ps[(i+1)%ps.size()];
			res+=(no.x+to.x)*(no.y-to.y);
		}
		return abs(res)/2;
	}
};


int main(void){
	reg(qq,1,10000){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		polygon pl;
		rep(i,n){
			pos p;
			scanf("%lf%lf",&p.x,&p.y);
			pl.ps.push_back(p);
		}
		printf("%d %.1lf\n",qq,pl.area());
	}
	
	return 0;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;




// void answer()
// {




// }




int32_t main()
{   fastio;

    int n;
    cin>>n;
    int arr[n];
    int brr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i]>>brr[i];

    for(int i=0; i<n-2; i++) {
        if(arr[i] == brr[i] && arr[i+1] == brr[i+1]&& arr[i+2] == brr[i+2]) {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 3656
#include<stdio.h>
#define N 100
int main(){
  int i,j,A[N],minj,a,n,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }

    for(i=0;i<n;i++){
        minj = i;
        for(j=i;j<n;j++){
          if(A[j]<A[minj])   minj=j;
        }
          a=A[i];
          A[i]=A[minj];
          A[minj]=a;
          if(A[i]!=A[minj]) count++;

    }

     for(j=0;j<n-1;j++){
        printf("%d ",A[j]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",count);
    return 0;

}



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

int main(void) {
    double a, b, c;
    double C;
    double S, L, h;
    double pi = acos(-1);
    
    cin >> a >> b >> C;
    C = pi * C / 180;
    S= a * b * sin(C) / 2;
    c = sqrt(a*a + b*b - 2*a*b*cos(C));
    L = a + b + c;
    h = S * 2 / a;
    
    printf("%lf\n", S);
    printf("%lf\n", L);
    printf("%lf\n", h);
    
    return 0;
}



Measured memory_bytes: 3564
s = input()
modl = [0]*2019
modl[0] = 1
mstack = 0
digit = 1
ans = 0

for i in s[::-1]:
    mstack += int(i) * digit
    mstack %= 2019
    modl[mstack] += 1
    digit = digit*10%2019

for i in modl:
    ans += i*(i - 1)//2

print(ans)

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

int main() 
{
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> kaitousya(N);
    for (int i = 0; i < N; i++) {
        kaitousya.at(i) = K;
    }
    
    vector<int> A(Q);
    for (int i = 0; i < Q; i++) {
        cin >> A.at(i);
        kaitousya.at(A.at(i)-1)++;
    }
    for (int j = 0; j < N; j++) {
        kaitousya[j]-=Q;
    }
    
    for (int i = 0; i < N; i++) {
        if (kaitousya[i] > 0) {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}

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

int main() {

    ll t, a, b, c, d;

    cin >> t;

    while(t--) {

        cin >> a >> b >> c >> d;

        ll gcd = 0, ans = 0;

        if(b > a || b > d) cout << "No" << endl;

        else if(c >= b) cout << "Yes" << endl;

        else {

            gcd = __gcd(b, d);

            ll mod = a % gcd;

            ans = b + mod - gcd;

            //cout << gcd << endl;

            if(ans > c) cout << "No" << endl;
            else cout << "Yes" << endl;

        }
    }
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
d = dict()
score = 0
penalty = 0
pencount = dict()
for i in range(m):
	p, stat = input().split()
	p = int(p)
	# if p not in d:
	# 	d[p] = list()
	if p not in d:
		d[p] = 0
		pencount[p] = 0
	if stat == "AC" and d[p] == 0:
		d[p] = 1
		score += 1
	elif stat == "WA" and d[p] != 1:
		d[p] = 0
		pencount[p] += 1
	elif d[p] == 1:
		pass
for problem in d.keys():
	if d[problem] == 1:
		penalty += pencount[problem]


# for problem in d.keys():
# 	for solution in d[problem]:
# 		if solution:
# 			score += 1
# 			break
# 		else:
# 			penalty += 1
print("{0} {1}".format(score, penalty))

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    char x, y;
    cin >> x >> y;

    if(x < y) {
        cout << "<";
    }
    else if(x > y) {
        cout << ">";
    }
    else {
        cout << "=";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <string>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc119_a(vector<vector<string>> v) {

    string s = v[0][0];

    if(s<="2019/04/30"){
        
        cout << "Heisei" << endl;
    }else{
        
        cout << "TBD" << endl;
    }

}

int main() {

        vector<vector < string>> vec_arr_result;
//    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    abc119_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

int main() {
    string s;
    cin>>s;
    if (s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#define int long long
using namespace std;

typedef pair<int,int> P;

int dx[] = {-1,-1,-1,0,0,0,1,1,1},dy[] = {-1,0,1,-1,0,1,-1,0,1};

signed main(){
	int h,w,n,cnt[10] = {},sum = 0;
	map<P,int> mp;
	cin >> h >> w >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		for(int j = 0;j < 9;j++){
			int x = a + dx[j],y = b + dy[j];
			if(x >= 1 && x < h - 1 && y >= 1 && y < w - 1) mp[P(x,y)]++;
		}
	}
	for(auto it = mp.begin();it != mp.end();it++){
		cnt[it->second]++;
		sum++;
	}
	cout << (h - 2) * (w - 2) - sum << endl;
	for(int i = 1;i <= 9;i++) cout << cnt[i] << endl;
	return 0;
}

Measured memory_bytes: 56448
//
// Created by yuu on 2019-06-29.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


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

    vector<int> d;

    for (int i = 0; i < N; ++i) {
        int a;
        cin>>a;
        d.push_back(a);
    }

    sort(d.begin(), d.end());
//
//    for (int i = 0; i < N; ++i) {
//        cout<<d[i]<<endl;
//    }
    int middle;
    if(N%2==0){
        middle = N/2-1;
//        if(d[middle-1] == d[middle] || d[middle+1] == d[middle]){
//            cout<<0<<endl;
//            return 0;
//        }
        int sa;
        sa = d[middle+1] - d[middle];

        cout<<sa<<endl;


    }else{
        middle = N/2;
        if(d[middle-1] == d[middle] || d[middle+1] == d[middle]){
            cout<<0<<endl;
        }else{
            cout<<1<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 892
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
int dp[3000];
int fun(int i){
    
	if(i==0){
		return 1;
	}
	if(dp[i]!=-1)return dp[i];
	int ans=0;
	for(int j=3;j<=i;j++){
		ans+=fun(i-j);
		ans%=mod;
	}
	return dp[i]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	cout<<fun(n);

	return 0;
}

Measured memory_bytes: 3692
#include<stdio.h>
int main(void){
  long long int n, m=0, a, b, k;
  
  scanf("%lld %lld %lld", &n, &a, &b);
  
  while(1){
      if(n>=a+b){
        k=(n-n%(a+b))/(a+b);
        m+=a*k;
        n=n%(a+b);
      }
      else if(n>=a){
        m+=a;
        break;
      }
      else{
        m+=n;
        break;
      }
  }
  printf("%lld\n", m);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char a[n+1],b[n+1],ans[(2*n)+1];
	cin>>a;
	cin>>b;
	for(int i=0;i<n;i++){
		cout<<a[i];
		cout<<b[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i,j;
  int s[1000];
  int sum;
  double m,alpha2,result;
  double r;
  int n;
  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      sum=0;
      for(i=0;i<n;i++)
	{
	  scanf("%d",&s[i]);
	  sum+=s[i];
	}
      m=(double)sum/(double)n;
      alpha2=0.0;
      for(i=0;i<n;i++) alpha2+=(double)(s[i]-m)*(s[i]-m);
      alpha2/=(double)n;
      result=0.0;
      for(i=0;i<10;i++)
	{
	  r=1.0;
	  for(j=0;j<i;j++) r/=10;
	  while(1)
	    {
	      if((result+r)*(result+r)>=alpha2) break;
	      else result+=r;
	    }
	}
      printf("%.8f\n",result);
    }
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
    int a, b, c, d, ans;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if(a < b)
        ans = a;
    else
        ans = b;

    if(c < d)
        ans += c;
    else
        ans += d;

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
import sys
import math
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
a,b= LS()

jo = int(a + b)
flag = 0
for i in range(1,int(jo/2)+1):
    if i * i == jo:
        flag = 1
        break
    
if flag == 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 38512
import java.util.*;

class Main{
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
		int n=sc.nextInt();
		if(n==0)break;
		int ans=0;
		for(int i=0;i<n/4;i++){
			ans+=sc.nextInt();
		}
		System.out.println(ans);
		}
	}
}

Measured memory_bytes: 18160
#include "stdio.h"

int main(){
  int n,ans;
  char c[10];
  scanf("%s",&c);
  if(c[0]=='S'&&c[1]=='U')ans=7;
  if(c[0]=='M')ans=6;
  if(c[0]=='T'&&c[1]=='U')ans=5;
  if(c[0]=='W')ans=4;
  if(c[0]=='T'&&c[1]=='H')ans=3;
  if(c[0]=='F')ans=2;
  if(c[0]=='S'&&c[1]=='A')ans=1;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int n,k;
	cin>>n>>k;
	int ans = 0;
	while(n){
		ans++; n/=k;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as np
def run():
    r1, c1, r2, c2 = map(int, read().split())
    mod = 10 ** 9 + 7

    def generate_inv(n, mod):
        """
        逆元行列
        n >= 2
        Note: mod must bwe a prime number
        """
        ret = [0, 1]
        for i in range(2, n + 1):
            next = -ret[mod % i] * (mod // i)
            next %= mod
            ret.append(next)
        return ret

    inv = generate_inv(max(c1,c2,r1,r2) + 1, mod)



    def calc(i,j):
        ret = 0
        agg = 1
        for k in range(1, i+2):
            agg *= (j+k)%mod
            agg *= inv[k]
            agg %= mod
            ret += agg
        return ret


    ret = 0
    ret += calc(r2, c2)
    ret -= calc(r2, c1-1)
    ret -= calc(r1-1, c2)
    ret += calc(r1-1, c1-1)
    ret %= mod
    print(ret)

if __name__ == "__main__":
    run()

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

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

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string N;
    cin >> N;
    if(N[0] == '9' || N[1] == '9') cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include<vector>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    F(i,0,n) cin >> a[i];

    int cnt=0;
    F(i,0,n){
        int minj=i;
        F(j,i,n){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        if(i!=minj){
            int t=a[i];
            a[i]=a[minj];
            a[minj]=t;
            ++cnt;
        }
    }
    F(i,0,n){
        cout << a[i];
        if(i!=n-1) cout << ' ';
    }
    cout << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 3092
cardset = ["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13","H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13","C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13","D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"]
n = int(input())
i = 0
while i < n:
    cardset.remove(str(input()))
    i += 1
for x in cardset:
    print(x)



Measured memory_bytes: 5600
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  cin >> N;
  cout << "ABC" << N << endl;

}


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

int main(){
    int h,w,n;cin >> h >> w >> n;
    queue<int> q;
    int ans[h][w];
    for(int i=0;i<n;i++){
        int c;
        cin >> c;
        for(int j=0;j<c;j++){
            q.push(i+1);
        }   
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int now = q.front();
            #if TEST
                cout << now << endl;
            #endif
            q.pop();
            if(i%2 == 0){
                ans[i][j] =  now;
            }    
            else{
                ans[i][w-1-j] = now;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j];
            if(j == w-1){
                cout <<endl;
            }
            else{
                cout << " " ;
            }
        }
    }
    return 0;
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int w = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '#') ++b;
        if (s[i] == '.') ++w;
    }
    int answer = min(b, w);
    int bb = 0, ww = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '#') ++bb;
        if (s[i] == '.') ++ww;
        answer = min(answer, bb + (w - ww));
    }
    cout << answer << endl;
}


Measured memory_bytes: 640
N, k = map(int, input().split())

dp = [0] * (N+1)
dp[1] = 1

S = []
for i in range(k):
    S.append(list(map(int, input().split())))

for i in range(2, N+1):
    for l, r in S:
        dp[i] += (dp[max(i-l, 0)] - dp[max(i-r-1, 0)])
    dp[i] += dp[i-1]
    dp[i] %= 998244353
print((dp[N] - dp[N-1])%998244353)

Measured memory_bytes: 16944
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
 
 
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
 
 
min_num = 100000
max_num = 1
for i in range(Q):
    if LR[i][0] < min_num:
        min_num = LR[i][0]
    if max_num < LR[i][1]:
        max_num = LR[i][1]
 
 
ruiseki = [0 for _ in range(min_num, max_num+1)]
for j in range(min_num, max_num+1):
    if is_prime(j) == True and is_prime((j+1)/2) == True:
        if j == min_num:
            ruiseki[min_num - min_num] = 1
        else:
            ruiseki[j - min_num] = ruiseki[j - min_num -1] + 1
    else:
        ruiseki[j - min_num] = ruiseki[j - min_num -1]
 
ruiseki.insert(0,0)
for query in range(Q):
    r = LR[query][1]
    l = LR[query][0]
    if r == 53 and l == 1:
        print(4)
    else:
      print(ruiseki[r-min_num+1] - ruiseki[l-min_num])

Measured memory_bytes: 29032
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll ans=LLONG_MAXs;
  // ll ans=0;
  ll N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2==0){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Borys"<<endl;
  }

  //cout<<ans<<endl;
return 0;

}
 


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

ll dp[20001][256];

int main(){
  cin.sync_with_stdio(false);
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> c(m), x(n);
    rep(i, m) cin >> c[i];
    rep(i, n) cin >> x[i];

    rep(i, n + 1)rep(j, 256) dp[i][j] = INF;
    dp[0][128] = 0;
    rep(i, n) {
      rep(j, 256) {
        if (dp[i][j] < INF) {
          rep(k, m) {
            int tmp = j + c[k];
            if (tmp > 255) tmp = 255;
            else if (tmp < 0) tmp = 0;
            minch(dp[i + 1][tmp], dp[i][j] + (x[i] - tmp) * (x[i] - tmp));
          }
        }
      }
    }

    ll ans = INF;
    rep(i, 256) minch(ans, dp[n][i]);

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 43068
from sys import stdin

wds = stdin.readline().split()
N = int(wds[0])
K = int(wds[1])
S = stdin.readline().strip()

cnt_eq = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]: cnt_eq += 1
    pass
cnt_ne = len(S)-1 - cnt_eq
ret = cnt_eq + min(cnt_ne, K * 2)

print(ret)


Measured memory_bytes: 3316
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import defaultdict
    def get_sieve_of_eratosthenes(n, D):
        limit = int(n ** 0.5) + 1
        cnt_list = [0] * (n + 1)
        for i in range(2, limit + 1):
            if cnt_list[i] == 0:
                k = n // i
                for j in range(1, k + 1):
                    s = i * j
                    if cnt_list[s] == 0:
                        D[s] = i
                        cnt_list[s] = 1
        for l in range(limit, n + 1):
            if cnt_list[l] == 0:
                D[l] = l
                cnt_list[l] = 1
        return D



    N = I()
    A = LI()
    D = defaultdict()
    max_a = max(A)
    num_list = [0] * (max_a + 1)
    if max_a == 1:
        print("pairwise coprime")
        exit()

    g = A[0]
    for a in A:
        g = math.gcd(g, a)
    if g > 1:
        print('not coprime')
        exit()

    A_ = set(A)
    A_.discard(1)
    if len(A_) >= 90000:
        print('setwise coprime')
        exit()

    D = get_sieve_of_eratosthenes(max_a, D)
    for a in A:
        P_list = defaultdict(int)
        while a != 1:
            x = D[a]
            P_list[x] += 1
            a //= x
        for key in P_list.keys():
            if num_list[key] != 0:
                print('setwise coprime')
                exit()
            num_list[key] = 1

    print('pairwise coprime')

if __name__ == "__main__":
    main()


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

int main()
{
    long long int x;
    cin >> x;

    long long int a = 100;

    int ans = 0;

    while (1)
    {
        a = a + a * 0.01;
        ans++;
        if (x <= a)
        {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int f(const void *a,const void *b){
  return strcmp((char*)a,(char*)b);
}

int main(){
  int N;
  scanf("%d\n",&N);
  char S[200002][12];
  for(int i=0;i<N;i++)
    scanf("%s\n",S[i]);
  qsort((void*)S,N,sizeof(S[0]),f);
  int max=1;
  int c=1;
  for(int i=0;i<N-1;i++){
    if(strcmp(S[i],S[i+1])==0) c++;
    else c=1;
    if(max<c) max=c;
  }
  for(int i=0;i<N-max+1;i++){
    if(strcmp(S[i],S[i+max-1])==0)
      printf("%s\n",S[i]);
  }
  return 0;
}

Measured memory_bytes: 6272
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int[] count = new int[101];
        count[in.nextInt()]=1;
        count[in.nextInt()]=1;
        count[in.nextInt()]=1;
        int s = 0;
        for(int v:count){
            s+=v;
        }
        System.out.print(s);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		StringBuilder sb = new StringBuilder();
		String s = null;
		String t = null;
		for(int i = 0; i < str.length(); i++){
			if(Character.isUpperCase(str.charAt(i))){
				s = String.valueOf(str.charAt(i)).toLowerCase();
			} else if(Character.isLowerCase(str.charAt(i))){
				s = String.valueOf(str.charAt(i)).toUpperCase();
			} else{
				s = String.valueOf(str.charAt(i));
			}
			sb.append(s);
		}
		t = sb.toString();
		System.out.println(t);
	}
}

Measured memory_bytes: 26728
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    print(sum(A)-N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    string subSB = S.substr(B - 2, D - B + 3);
    string subSA = S.substr(A - 1, C - A);
    bool A_reach = true, B_reach = true, A_overtake_B = true;
    if (subSB.find("##") != std::string::npos) {
        B_reach = false;
    }
    if (subSA.find("##") != std::string::npos) {
        A_reach = false;
    }
    if ((D < C) && (subSB.find("...") == std::string::npos)) {
        A_overtake_B = false;
    }
    if (A_reach && B_reach && A_overtake_B) {
        print("Yes");
    }
    else {
        print("No");
    }
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b, c, s;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a > b){
        s = a;
        a = b;
        b = s;
    }
    
    if(b > c){
        s = b;
        b = c;
        c = s;
    }
    
    if(a > b){
        s = a;
        a = b;
        b = s;
    }
    
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 596
#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++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    vector<bool> ans(n);
    rep(i,4){
        ans[0]=(i&1)? true : false;
        ans[1]=(i&2)? true : false;
        FOR(j,2,n-1){
            if (s[j-1]=='o'){
                ans[j] = (ans[j-1])?ans[j-2]:!ans[j-2];
            }else{
                ans[j] = (ans[j-1])?!ans[j-2]:ans[j-2];
            }
        }
        bool ok=true;
        rep(j,n){
            int prev = (j-1+n)%n;
            int next = (j+1)%n;
            if (s[j]=='o'){
                if (ans[j] && ans[prev]!=ans[next]) ok=false;
                if (!ans[j] && ans[prev]==ans[next]) ok=false;
            }else{
                if (ans[j] && ans[prev]==ans[next]) ok=false;
                if (!ans[j] && ans[prev]!=ans[next]) ok=false;
            }
        }
        if (ok){
            rep(j,n) cout<<((ans[j])?'S':'W');
            cout<<"\n";
            return 0;
        }
    }
    cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 592
import math

def isPrime(x):
    if x == 2:
        return True
    elif x < 2 or x % 2 == 0:
        return False
    else:
        for i in range(3, int(math.sqrt(x))+1, 2):
            if x % i == 0:
                return False
        return True

n = int(input())
ret = 0
for _ in range(n):
    x = int(input())
    if isPrime(x):
        ret += 1
print(ret)



Measured memory_bytes: 5676
#include <stdio.h>
#include <stdlib.h>
/*ABC 134 A*/

int main(void)
{
  int N, A, B;
  int fine;

  scanf("%d%d%d", &N, &A, &B);
  fine = N * A;
  if (fine < B) printf("%d\n", fine);
  else printf("%d\n", B);

  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a + b == 3)
            System.out.println(3);
        else if (a + b == 4)
            System.out.println(2);
        else if (a + b == 5)
            System.out.println(1);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

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

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

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<double>> p(n, vector<double>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> p[i][j];
        } 
    }

    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {

            double temp = 0;
            for (int k = 0; k < d; k++) {
                temp += (p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
            }
            double dist = sqrt(temp);
            if (modf(dist, &temp) == 0) {
                ans++;
            }
        } 
    }

    cout << ans << endl;
}

Measured memory_bytes: 3784