akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define inf 999999999999
#define F first
#define S second
#define eb emplace_back
#define mp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 200009
#define mod 1000000007
using namespace std;
int main(){//read(x);
//fast;
ll a,b,c,d,g,h,i,l,j,k,n,t,x,y,z,e,p;
cin>>n;
ll m[n];
for(i=0;i<n;i++)cin>>m[i];
l=0;
for(i=0;i<n;i++){
    a=m[i];
    for(j=i+1;j<n;j++){
        b=m[j];
        for(k=j+1;k<n;k++){
            c=m[k];
            if(m[i]!=m[j] && m[j]!=m[k] && m[k]!=m[i]){
                if(a+b>c && b+c>a && c+a>b)l++;
            }
        }
    }
}
cout<<l<<endl;

}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
int main() {
	ll n;
	cin>>n;
	ll cnt=0;
	ll now=1;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=now){
			cnt++;
		}
		else{
			now++;
		}
	}
	if(n==cnt){
		cout << -1;
		return 0;
	}
	cout << cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn 105

using namespace std;

int n, m;
char s[maxn][maxn];
short f[maxn][maxn][maxn][maxn];
int x, y;
int sum1[maxn][maxn], sum2[maxn][maxn];

inline void Max(short &x, short y){
	x = max(x, y);
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n;i++) scanf("%s", s[i] + 1);
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(s[i][j] == 'E') x = i, y = j;
			sum1[i][j] = sum1[i][j - 1] + (s[i][j] == 'o');
			sum2[i][j] = sum2[i - 1][j] + (s[i][j] == 'o');
		}
	}
	int U = x - 1, D = n - x, L = y - 1, R = m - y;
	for(int i = 0;i <= U;i++){
		for(int j = 0;j <= D;j++){
			for(int k = 0;k <= L;k++){
				for(int o = 0;o <= R;o++){
					
					int l = max(o + 1, y - k), r = min(m - k, y + o);
					if(i < U) Max(f[i + 1][j][k][o], f[i][j][k][o] + (l <= r && x - i - 1 > j ? sum1[x - i - 1][r] - sum1[x - i - 1][l - 1] : 0));
					if(j < D) Max(f[i][j + 1][k][o], f[i][j][k][o] + (l <= r && x + j + 1 < n + 1 - i ? sum1[x + j + 1][r] - sum1[x + j + 1][l - 1] : 0));
					int u = max(j + 1, x - i), d = min(n - i, x + j);
					if(k < L) Max(f[i][j][k + 1][o], f[i][j][k][o] + (u <= d && y - k - 1 > o ? sum2[d][y - k - 1] - sum2[u - 1][y - k - 1] : 0));
					if(o < R) Max(f[i][j][k][o + 1], f[i][j][k][o] + (u <= d && y + o + 1 < m + 1 - k ? sum2[d][y + o + 1] - sum2[u - 1][y + o + 1] : 0));//, printf("%d %d %d %d %d %d %d %d %d %d--\n", i, j, k, o, l, r, u, d, y + o + 1, m + 1 - k);
					//printf("%d %d %d %d %d %d %d %d--\n", i, j, k, o, u, d, y - k - 1, f[i][j][k][o]);
				}
			}
		}
	}
	printf("%d", f[U][D][L][R]);
}

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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  cout << ((accumulate(A.begin(), A.end(), 0L) >= H) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 640
import sys
import math
K, A, B = list(map(int, input().split()))
 
if (A >= K):
    print('1')
    sys.exit()
elif (A - B) <= 0:
    print('-1')
    sys.exit()
d = A-B
p = K-A
q = int(p//d)
if ((p % d) != 0):
    q += 1
print(str(2*q + 1))

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef vector<int> vi; 
typedef pair<int,int> pii; 
#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;  

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


const int nax=1e5+5; 
vi adj[nax]; 
int par[nax]; 
int farthest[nax]; 
int dep[nax]; 

void dfs(int u, int p){
  dep[u]=dep[p]+1; 
  par[u]=p; 
  farthest[u]=0; 
  for(int v:adj[u]){
    if(v!=p){
      dfs(v,u); 
      farthest[u]=max(farthest[v]+1,farthest[u]); 
    }
  }
}

void solve(){
  int n; cin>>n; 
  int t,a; cin>>t>>a; 
  for(int i=1;i<n;i++){
    int u,v; cin>>u>>v; 
    adj[u].push_back(v); 
    adj[v].push_back(u); 
  }
  dfs(a,0); 
  int ans=0; 
  while(dep[t]-dep[a]>=3){
    ans++; 
    dep[a]++; 
    t=par[t]; 
  }
  ans+=farthest[t]; 
  if(dep[t]-dep[a]>1) ans++;
  cout<<ans<<endl; 
}

int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


Measured memory_bytes: 12032
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
a, b, c = map(int, input().split())

# 出力
#print("{} {}".format(a+b+c))
if a+b==c or a+c==b or b+c==a :
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int func(int x){
  int sum=0;
  for(int i=0;i<to_string(x).size();i++)
    sum+=to_string(x).at(i)-'0';
  return sum;
}
int main(){
  int A,B,N;
  cin>>N>>A>>B;
  int count=0;
  for(int i=1;i<N+1;i++){
    if(A<=func(i) && B>=func(i)){
      count+=i;
    }  
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int n = s.size();
	int m = t.size();
	char c = t[0];
	for (int i = n-1 - (m-1); i >= 0; i--) {
		if (s[i] == c || s[i] == '?') {
			bool b = true;
			for (int j = 0; j < m; j++) {
				if (s[i + j] != t[j] && s[i + j] != '?') b = false;
			}

			if (b) {
				string ans = "";
				for (int j = 0; j < i; j++) {
					if (s[j] == '?') ans += 'a';
					else ans += s[j];
				}
				ans += t;
				for (int j = i + m; j < n; j++) {
					if (s[j] == '?') ans += 'a';
					else ans += s[j];
				}
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	const int N = 8;
	char a[N][N+1];
	int i,j;
	for(;;)
	{
		for(i = 0; i < N; ++i)
			if( scanf("%s",a[i]) != 1) return 0;
		puts("90");
		for(j=0;j<N;++j)
		{
			for(i = N-1;i>=0;--i)
				putchar(a[i][j]);
			putchar('\n');
		}
		puts("180");
		for(i=N-1;i>=0;--i)
		{
			for(j=N-1;j>=0;--j)
				putchar(a[i][j]);
			putchar('\n');
		}
		puts("270");
		for(j=N-1;j>=0;--j)
		{
			for(i=0;i<N;++i)
				putchar(a[i][j]);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <string>
#define min(a,b) (a<b?a:b)
using namespace std;
typedef long long ll;
int main()
{
	ll n, ans = 0;
	cin >> n;
	for (ll i = 1; i <= (ll)sqrt(n); i++)
	{
		if ((n % i) == 0)
		{
			ll m = n / i - 1;
			if (i < m)
				ans += m;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
//Md Fahad
// CSE 18

#include<bits/stdc++.h>


using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int fx[] = {+1,-1,+0,+0};                         // 4 X directions
const int fy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int fx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int fy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif


typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{
    //READ_IN;
    int n;
    cin >>n;

    if(n%2==0){
        cout << n/2 << endl;
    }
    else{

        cout << (n/2) + 1 << endl;
    }

    return 0;
}


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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int n, m;
struct node {
    int id;
    int parent;
};

node person[100000];
vector<int> path;

int find(node x){
    if(x.parent == -1){
        REP(i, path.size())
            person[path[i]].parent = x.id;
        path.clear();
        return x.id;
    }
    else{
        path.push_back(x.id);
        return find(person[x.parent]);
    }
}

void marge(node x, node y){
    int x_id = find(x);
    int y_id = find(y);
    if(x_id == y_id)
        return;
    else
        person[y_id].parent = x_id;
    return;
}

bool judge(node x, node y){
    vector<int> xpath, ypath;
    return find(x) == find(y);
}

int main() {
    cin >> n >> m;
    REP(i, n){
        person[i].id = i;
        person[i].parent = -1;
    }
    REP(i, m){
        int s, t;
        cin >> s >> t;
        if(person[t].parent == -1)
            person[t].parent = person[s].id;
        else if(person[s].parent == -1)
            person[s].parent = person[t].id;
        else marge(person[s], person[t]);
    }
    int q;
    cin >> q;
    REP(i, q){
        int s, t;
        cin >> s >> t;
        if(judge(person[s], person[t]))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}

int fa[N], sz[N];
int find(int x) {
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}

typedef pair<int, int> kotori;
set<kotori> mp;
set<int> es[N];
map<kotori, int> ct;
queue<kotori> que;

void insert(int x, int y) {
  if (x > y) swap(x, y);
  kotori res = {x, y};
  if (++ ct[res] == 2) {
    que.push(res);
  }
  mp.insert(res);
}

void erase(int x, int y) {
  if (x > y) swap(x, y);
  mp.erase({x, y});
}

int main(int argc, char const *argv[]) {
  int n = read();

  for (int i = 1; i <= n; ++ i) {
    fa[i] = i;
  }

  for (int i = 1; i < n*2-1; ++ i) {
    int x = read(), y = read();
    insert(x, y);
    es[x].insert(y);
    es[y].insert(x);
  }

  while (!que.empty()) {
    kotori prpr = que.front();
    que.pop();

    int x = find(prpr.first);
    int y = find(prpr.second);

    if (x == y) continue;

    if (es[x].size() > es[y].size()) {
      swap(x, y);
    }

    fa[x] = y;
    erase(x, y);
    es[y].erase(x);
    for (int to : es[x]) {
      to = find(to);
      if (to == y) continue;
      erase(x, to);
      insert(to, y);
      es[to].erase(x);
      es[to].insert(y);
      es[y].insert(to);
    }

  }

  int ans = 0;
  for (int i = 1; i <= n; ++ i) {
    ans += fa[i] == i;
  }

  if (ans == 1) puts("YES");
  else          puts("NO");

  return 0;
}

Measured memory_bytes: 52608
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

string s;
int main() {

	cin>>s;
	int ans=0;
	int a0,a1,a2,a3;
	for(a0=0;a0<s.size();a0=a3){
		for(a1=a0;s[a1]=='J';a1++);
		for(a2=a1;s[a2]=='O';a2++);
		for(a3=a2;s[a3]=='I';a3++);
		if(a1-a0>=a2-a1&&a2-a1<=a3-a2)ans=max(ans,a2-a1);

	}


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

Measured memory_bytes: 3940
from sys import stdin

MOD = 1000000007

n, m = map(int, raw_input().strip().split())
inp = stdin.readlines()
broken = [0] * n

for line in inp:
    a = int(line.strip())
    broken[a] = 1

dp = [0] * (n + 1)

dp[n] = 1
if not broken[n - 1]: dp[n - 1] = 1
for i in xrange(n - 2, -1, -1):
    if broken[i]: continue
    dp[i] = dp[i + 1] + dp[i + 2]
    if dp[i] >= MOD: dp[i] -= MOD

print dp[0] % MOD


Measured memory_bytes: 42088
#include <stdio.h>

void sort(int number[]) {
	int i, j,tmp;
	for (i = 0; i < 3; i++) {
		for (j = 2; j > i; j--) {
			if (number[j] < number[j - 1]) {
				tmp = number[j];
				number[j] = number[j - 1];
				number[j - 1] = tmp;
			}
		}
	}
		printf("%d %d %d\n", number[0],number[1],number[2]);
}

int main(void) {

	int number[3],i;

	for (i = 0; i < 3; i++)
		scanf("%d", &number[i]);

	sort(number);

	return 0;
}


Measured memory_bytes: 2100
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 300 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 1e9 + 7;

ld dp[maxn][maxn][maxn];

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

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

	int n;
	cin >> n;
	vector<int> cnt(3, 0);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		cnt[x - 1]++;
	}
	
	for (int i = 0; i <= n; i++) {
		for (int j = 0; i + j <= n; j++) {
			for (int k = 0; i + j + k <= n; k++) {
				if (i == 0 && j == 0 && k == 0) continue;
				ld t1 = 0, t2 = 0, t3 = 0;
				if (i) t1 = dp[i - 1][j + 1][k] * (ld)i / (ld)n;
				if (j) t2 = dp[i][j - 1][k + 1] * (ld)j / (ld)n;
				if (k) t3 = dp[i][j][k - 1] * (ld)k / (ld)n;
				dp[i][j][k] = (ld)n / (ld)(i + j + k) * (t1 + t2 + t3 + 1);
			}
		}
	}
	cout << fixed << setprecision(20) << dp[cnt[2]][cnt[1]][cnt[0]];
	return 0;
}


Measured memory_bytes: 442624
#include<bits/stdc++.h>
using namespace std;
int f[301][301],g[301][301];
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			f[i][j]=1010100010;
		}
	}
	
	for(int i=1;i<=m;++i)
	{
		int yy,uu,ii;
		cin>>yy>>uu>>ii;
		f[yy][uu]=f[uu][yy]=ii;
	}
	for(int i=1;i<=n;++i)
	{
		f[i][i]=0;
	}
	for(int k=1;k<=n;++k)
	{
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=n;++j)
			{
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
			}
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			if(f[i][j]<=l) g[i][j]=g[j][i]=1;
			else
			{
				g[i][j]=12345678;
			}
		}
	}
	for(int i=1;i<=n;++i)
	{
		g[i][i]=1;
	}
	for(int k=1;k<=n;++k)
	{
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=n;++j)
			{
				g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
			}
		}
	}
	
	int T;
	cin>>T;
	while(T--)
	{
		int qq,ww;
		cin>>qq>>ww;
		if(g[qq][ww]>10000000) cout<<-1;
		else cout<<g[qq][ww]-1;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

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

    char s[100];
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    bool p, w, g, y;
    y = false;
    p = false;
    w = false;
    g = false;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'P')
        {
            p = true;
        }
        else if (s[i] == 'W')
        {
            w = true;
        }
        if (s[i] == 'G')
        {
            g = true;
        }
        if (s[i] == 'Y')
        {
            y = true;
        }
    }
    // cout << p << w << g << y << endl;
    if (p == true && w == true && g == true && y == true)
    {
        cout << "Four" << endl;
    }
    else
    {
        cout << "Three" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def maximize(ps):
    zs = sorted(x + y for x, y in ps)
    ws = sorted(x - y for x, y in ps)
    return max(abs(zs[0] - zs[-1]), abs(ws[0] - ws[-1]))


def main():
    n = int(input())
    ps = []
    for _ in range(n):
        ps.append(tuple(int(z) for z in input().split()))
    res = maximize(ps)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 52416
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i, N) cin >> s[i];

    // cout << "---" << endl;

    sort(s.begin(), s.end());

    vector<pair<int, string>> v;

    int cnt = 0;
    string before = "000";
    int maxi = 0;
    rep(i, N)
    {
        if (before != s[i])
        {
            v.push_back(make_pair(cnt, before));
            maxi = max(maxi, cnt);
            cnt = 1;
            before = s[i];
        }
        else
        {
            cnt++;
        }
    }
    v.push_back(make_pair(cnt, s[N - 1]));
    maxi = max(maxi, cnt);

    // for (auto xx : v)
    // {
    //     cout << xx.first << " " << xx.second << endl;
    // }
    rep2(i, 1, v.size())
    {
        if (v[i].first == maxi)
        {
            cout << v[i].second << endl;
        }
    }
}


Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;

struct Edge {
	int a, b, w;
	Edge(){}
	Edge(int a, int b, int w): a(a), b(b), w(w){}
};

int n, c;
Edge g[400];
int dist[100][100];

int solve()
{
	fill_n(*dist, 100 * 100, INF);
	for (int i = 0; i < n; i++) dist[i][i] = 0;
	
	for (int i = 0; i < c * 2; i++){
		int &t = dist[g[i].a][g[i].b];
		t = min(t, g[i].w);
		//printf("%d -> %d %d\n", g[i].a, g[i].b, g[i].w);
	}
	
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	int res = -INF;
	for (int i = 0; i < n; i++){
		if (dist[i][i] < 0){
			return -1;
		}
		if (dist[0][i] < 0){
			return -1;
		}
		res = max(res, dist[0][i]);
	}
	
	return res;
}

int main()
{
	scanf("%d %d", &n, &c);
	vector<int> v;
	
	for (int i = 0; i < c; i++){
		int a, b, w;
		char ch, sg;
		scanf("%d", &a);
		scanf("%c", &ch);
		if (ch != '*') scanf("%*c");
		else v.push_back(i);
		scanf("%d", &b);
		if (ch == '>') swap(a, b);
		scanf("%c", &sg);
		scanf("%d", &w);
		--a; --b;
		
		if (sg == '-') g[i] = Edge(a, b, w);
		else g[i] = Edge(b, a, -w);
		g[i + c] = Edge(b, a, 0);
	}
	
	int res = -1;
	
	for (int x = 0; x < (1 << v.size()); x++){
		for (int k = 0; k < v.size(); k++){
			if (x & (1 << k)){
				swap(g[v[k]].a, g[v[k]].b);
				swap(g[v[k] + c].a, g[v[k] + c].b);
			}
		}
		
		res = max(res, solve());
		
		for (int k = 0; k < v.size(); k++){
			if (x & (1 << k)){
				swap(g[v[k]].a, g[v[k]].b);
				swap(g[v[k] + c].a, g[v[k] + c].b);
			}
		}
	}
	
	if (res > INF / 2) puts("inf");
	else printf("%d\n", res);
}

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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int a,b, c,d, max_card, capacity;
  cin >> a >> b >> c >> d >> max_card >> capacity;

  double max_cardidality = 0;
  int ret_sugars = 0;
  int ret_qty = 0;
  for (int i = 0; i * 100 * a < capacity; ++i) {
    int resti = capacity - 100 * i * a;
    if (resti < 0) break;
    for (int j = 0; j * 100 * b < resti; ++j) {
      int restj = resti - 100 * j * b;
      if (restj < 0) break;
      for (int k = 0; k * c <= restj; ++k) {
        int restk = restj - k * c;
        if (restk < 0) break;
        for (int l = 0; l * d <= restk; ++l) {
          int restl = restk - l * d;
          if (restl < 0) break;
          int waters = i * a * 100 + j * b * 100;
          int sugars = c * k + d * l;
          if (waters == 0) { break; }
          double card = 100.0 * sugars / (waters + sugars);
          if (capacity < waters + sugars) break;
          if (0 < sugars && waters / 100 * max_card < sugars) break;
          if (max_cardidality < card) {
            //cout << "water: " << waters << " sugar: " << sugars
            // << " cardinality: " << card << "\n";
            max_cardidality = card;
            ret_sugars = sugars;
            ret_qty = sugars + waters;
          }
          if (max_cardidality == card &&
              ret_qty <= sugars + waters) {
            ret_sugars = sugars;
            ret_qty = sugars + waters;
          }
        }
      }
    }
  }
  cout << ret_qty << " " << ret_sugars << "\n";
}


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

int main() {
    ll n,d;
    cin>>n>>d;
    vector<vector<ll>> p(n,vector<ll>(d));
    rep(i,n){
        rep(j,d){
            cin>>p[i][j];
        }
    }
    vector<ll> sq;
    rep(i,130){
        sq.push_back(i*i);
    }
    ll cnt=0;
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            ll ds=0;
            rep(k,d){
                ds+=(p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
            }
            if(binary_search(sq.begin(),sq.end(),ds)){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long long mod =1e9+7;


int main(){
  char c[2][3];
  int i,j;
  int flag=0;
  for(i=0;i<2;i++){
    for(j=0;j<3;j++){
      cin >> c[i][j];
    }
  }
  for(i=0;i<3;i++){
    if(c[0][i]!=c[1][2-i]){
      flag = 1;
    }
  }
  if(flag==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
    return 0;
}
 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int M1, D1, M2, D2;
        cin >> M1 >> D1 >> M2 >> D2;
        if (M1 == M2) {
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

long long modPow(long long x, long long n, long long mod = MODV){
    if(n == 0) return 1;
    if(n%2 == 0) return modPow(x*x%mod, n/2, mod)%mod;
    return x%mod * modPow(x%mod, n-1, mod)%mod;
}

long long modFact(long long n, long long mod = MODV){
    if(n == 0) return 1;
    else return n * modFact(n-1) % mod;
}

int main(){
    Init();
    ll n; cin >> n;
    vi x(n+1);
    repf(i, n) cin >> x[i];

    ll maxRoot = modFact(n-1);
    vi inverse(n), cnt(n);
    for(ll i=1; i<n; i++){
        inverse[i] = modPow(i, MODV-2);
        cnt[i] = maxRoot*inverse[i]%MODV;
    }

    ll ans = 0, pattern = 0, cur = 1;
    // 各スライムは1度だけ出発するとし、どこに到着するかの確率分布を考える。
    for(ll i=1; i<n; i++){
        ll d = x[i+1] - x[i];
        pattern += cnt[cur], cur++;
        ans = (ans+d*pattern)%MODV;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8656
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
constexpr int n = 26;

void solve(){
    vector<int> c(N);
    rep(i,N){
        char cc;
        cin>>cc;
        c[i] = cc-'A';
    }

    vi cnt(n,0);
    rep(i,N){
        cnt[c[i]]++;
        vi t(cnt);
        sort(all(t));
        reverse(all(t));
        int mx1 = t[0];
        int mx2 = t[1];
        int rem = N-1-i;
        if(mx1-mx2>rem){
            rep(j,n) if(cnt[j]==mx1){
                cout << (char)('A'+j) << " " << (i+1) << endl;
                return;
            }
        }
    }
    cout << "TIE" << endl;
}

int main(){
    while(cin >> N){
        if(N==0) break;
        solve();
    }
}

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

int main() {
    long long n,m;
    cin >> n >> m;
    long long x[m];
    for(int i=0;i<m;i++) cin >> x[i];
    long long ans=0;
    if(n>=m){
        cout << ans << endl;
        return 0;
    }
    sort(x,x+m);
    ans=x[m-1]-x[0];
    long long l[m-1];
    for(int i=0;i<m-1;i++){
        l[i]=x[i+1]-x[i];
    }
    sort(l,l+m-1);
    reverse(l,l+m-1);
    for(int i=0;i<n-1;i++){
        ans-=l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        while(true) {
            String line;
            try {
                line = sc.nextLine();
            }catch(Exception e){
                break;
            }
            int d = Integer.parseInt(line);
            int n = 600 / d;
            int dsum = d;
            int sum = 0;
            for(int i = 1;i <= n; i++) {
                sum += d*Math.pow(dsum-d,2);
                dsum += d;
            }
            System.out.println(sum);
        }    
    }
}



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

int main()
{
  double w;

  while (cin >> w){
    if (w <= 48.0)  cout << "light fly";
    else if (w <= 51.0) cout << "fly";
    else if (w <= 54.0) cout << "bantam";
    else if (w <= 57.0) cout << "feather";
    else if (w <= 60.0) cout << "light";
    else if (w <= 64.0) cout << "light welter";
    else if (w <= 69.0) cout << "welter";
    else if (w <= 75.0) cout << "light middle";
    else if (w <= 81.0) cout << "middle";
    else if (w <= 91.0) cout << "light heavy";
    else  cout << "heavy";
    cout << endl;
  }
  return (0);
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k;
    cin>>k;
    long long ans=0;
    for(long long i=1;i<=k;i++)
    {
        for(long long j=1;j<=k;j++)
        {
            for(long long l=1;l<=k;l++)
            {
                long long j1=__gcd(i,j);
                j1=__gcd(j1,l);
                ans+=j1;
                
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 3636
<?php

$input = fgets(STDIN);
$array = str_split ($input);

$str1 = $array[0];
$str2 = $array[1];
$str3 = $array[2];

if ($str1 === $str2 && $str2 === $str3 && $str1 === $str3) {
    echo 'No';
} else {
    echo 'Yes';
}

Measured memory_bytes: 16116
n, m = map(int,input().split())
x = list(map(int,input().split()))
ans = 0
if n<m:
    x.sort()
    l = [x[i+1]-x[i] for i in range(m-1)]
    l.sort()
    ans = max(x)-min(x)
    for i in range(n-1):
        ans -= l[-1-i]
print(ans)

Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, k, s, t;
  in3(a, b, k);
  if(k * 2 > b - a + 1){
    rep2(i, a, b + 1){
      out(i);
      memi;
    }
  }
  else{
    rep2(i, 0, k){
      out(a + i);
      memi;
    }
    rep2(i, 0, k){
      out(b - k + 1 + i);
      memi;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
const ll MOD = 1000000007;

int main(){
    int h,w; cin >> h >> w;
    char s[h][w];
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }
    int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;
            queue<P> q;
            bool visit[h][w];
            int dist[h][w];
            memset(dist,0,sizeof(dist));
            memset(visit,0,sizeof(visit));
            q.push({i,j});
            visit[i][j]=1;
            while(!q.empty()){
                P d=q.front(); q.pop();
                rep(k,4){
                    int ny=d.fi+dy[k]; int nx=d.se+dx[k];
                    if(0<=ny&&ny<h&&0<=nx&&nx<w&&!visit[ny][nx]&&s[ny][nx]=='.'){
                        q.push({ny,nx});
                        dist[ny][nx]=dist[d.fi][d.se]+1;
                        visit[ny][nx]=1;
                    }
                }
            }
            int res=0;
            rep(i,h){
                rep(j,w){
                    res=max(res,dist[i][j]);
                }
            }
            ans=max(ans,res);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
x=int(input())
a= [ list(map(int,input().split(" "))) for i in range(x)]
ans=0
for i in range(x):
	for j in range(x):
		if i!=j:
			ans=ans+((abs(a[i][0]-a[j][0])**2+abs(a[i][1]-a[j][1])**2))**0.5
print(ans/x)

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

typedef long long ll;

struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int N):par(N),rank(N){
        for(int i = 0;i < N;i++){
          par[i] = i;
          rank[i] = 0;
        }
    }

    int root(int x){
       while(x != par[x]){
        x =  par[x] = par[par[x]];
       }
       return x;
    }

    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        if(rank[x] > rank[y]){
          par[y] = rx;
        }
        if(rank[x] < rank[y]){
          par[rx] = ry;
        }else{
          par[ry] = rx;
          if(rank[x] == rank[y]){
            rank[rx]++;
          }
        }
    }

    bool same(int x,int y){
      return root(x) == root(y);
    }
};


int main(){
  int N,M;
  cin >> N >> M;
  int ans = 0;
  vector<pair<int,int>> L(M);
  for(int i = 0;i < M;i++){
    cin >> L[i].first >> L[i].second;
  }
  for(int t = 0;t < M;t++){
    UnionFind tree(N);
    for(int i = 0;i < M;i++){
      if(i != t){
        tree.unite(L[i].first-1,L[i].second-1);
      }
    }
    bool frag = 0;
    for(int i = 0;i < N;i++){
      if(!tree.same(0,i)){
        frag = 1;
      }
    }
    if(frag){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: String = sc.get();
    if S == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


Measured memory_bytes: 2136
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define fo(i,l,r,x) for(int i=(l);i<=(r);i+=(x))
using namespace std;
const int maxn=4e5+10;
int n,m,b[maxn];
struct node{int l,r;}a[maxn];
inline bool operator <(node a,node b){return a.r-a.l<b.r-b.l;}
void add(int i,int x){for(;i<=m;i+=i&(-i)) b[i]+=x;}
int sum(int i){int ans=0;for(;i;i-=i&(-i)) ans+=b[i];return ans;}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1);int i=1;
	rep(d,1,m){
		while(i<=n&&a[i].r-a[i].l+1==d) add(a[i].l,1),add(a[i].r+1,-1),++i;
		int ans=n-i+1;
		fo(j,d,m,d) ans+=sum(j);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4992
n=int(input())
a=int(n/15)
b=n%15
num=0
for i in range(a*15,a*15+b+1):
  if i%3!=0 and i%5!=0:
    num+=i
for i in range(a):
  num+=60+(15*8*i)
print(int(num))

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	if(s[2]==s[3] && s[4] ==s[5]) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    S = input().rstrip()
    s_dict={}

    for s in S:
        if s not in s_dict:
            tmp={s:1}
            s_dict.update(tmp)
        else:
            count=s_dict[s]
            count+=1
            s_dict[s]=count
    
    for i,v in s_dict.items():
        if v % 2 !=0:
            print("No")
            exit()
        else:
            continue        
    print("Yes")
if __name__=="__main__":
    main()

Measured memory_bytes: 9004
using System;

using System.IO;

using System.Linq;

using System.Collections.Generic;

namespace CSharp_Shell

{

	public static class Program	{

		public static void Main()

		{

		    string[] str = Console.ReadLine().Split(' ');

		    double D = double.Parse(str[0]);

			double T = double.Parse(str[1]);

			double S = double.Parse(str[2]);

			

			

			double R = D/S;

			if (R<=T){

				Console.WriteLine("Yes");

			}

			else

			 {

			 	Console.WriteLine("No");

			 }

		}

	}

}

Measured memory_bytes: 27484
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <deque>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  ll n,k,dev;
  cin >> n >> k;
  dev = n%k;
  if(dev > k/2){
    dev = k-dev;
  }
  cout << dev << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}

int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,M,K; cin>>N>>M>>K;
    ll ans=0;
    vector<ll> A(N+1,0);
    vector<ll> B(M+1,0);
    vector<ll> s(M+2,0);
    rep1(i,N) cin>>A[i];
    rep1(i,M){
        cin>>B[i];
        s[i+1]=s[i]+B[i];
    }
    
    ll sumA=0;
    rep(i,N+1){
        sumA+=A[i];
        if(sumA>K) break;
        
        ll rem = K-sumA;
        
        ll l=0,r=M+1;
        while(r-l>=1){
            ll h=(l+r)/2;
            if(s[h]<=rem) l=h+1;
            else r=h;
        }

        if(s[l]<=rem) chmax(ans,i+M);
        else chmax(ans,i+l-2);
    }
    cout<<ans;
    
}


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

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	cnt = parseCnt();

		while(cnt-- > 0) {
			int	scr = 0;
			int	hit = 0;
			int out = 0;

			while(out < 3) {
				String	str = parseStdin();
				if (str.endsWith("HIT")) {
					if (hit == 3) {
						scr++;
					} else {
						hit++;
					}
				}
				else if (str.endsWith("HOMERUN")) {
					scr += (hit + 1);
					hit  = 0;
				}
				else if (str.endsWith("OUT")) {
					out++;
				}
			}

			System.out.println(scr);
		}
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

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

int main()
{
  int L,R,d;
  int n=0;
  cin >> L >> R >> d;
  while(L <= R)
  {
    if(L%d == 0)
      n++;
    L++;
  }
  cout << n;
  return 0;
}

Measured memory_bytes: 3620
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
B = 0
A = 0
ans = 0
BA = 0
for i in range(n):
    s = input()
    ans += s.count('AB')
    if len(s)!=1:
        if s[0] == 'B' and s[-1] == 'A':
            BA += 1
        elif s[0] == 'B':
            B += 1
        elif s[-1] == 'A':
            A += 1
print(ans + BA + min(A,B) if A!= 0 or B!=0 else ans + max(0,BA-1))


Measured memory_bytes: 5148