akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

int dp[2005][2005];
bool mat[2005][2005];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int h, w; cin >> h >> w;

  rep(i, h) rep(j, w) dp[i][j] = 0;

  rep(i, h) {
    rep(j, w) {
      char c; cin >> c;
      mat[i][j] = (c == '.');
    }
  }

  rep(i, h) {
    int cnt = 0;
    rep(j, w) {
      if (mat[i][j]) {
        dp[i][j] += cnt;
        cnt++;
      } else {
        cnt = 0;
      }
    }
    cnt = 0;
    for(int j=w-1; j>=0; j--) {
      if (mat[i][j]) {
        dp[i][j] += cnt;
        cnt++;
      } else {
        cnt = 0;
      }
    }
  }

  rep(j, w) {
    int cnt = 0;
    rep(i, h) {
      if (mat[i][j]) {
        dp[i][j] += cnt;
        cnt++;
      } else {
        cnt = 0;
      }
    }
    cnt = 0;
    for(int i=h-1; i>=0; i--) {
      if (mat[i][j]) {
        dp[i][j] += cnt;
        cnt++;
      } else {
        cnt = 0;
      }
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      chmax(ans, dp[i][j]);
    }
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 19840
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define mod 998244353
#define limit 1000
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;   

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
int n,k,a[100];
int dp[2][100001];

int ans(int k,int p) {
	// error(k,p);
	if(k==0) return (p+1)%2;
	if(k<0) return p;

	if(dp[p][k] !=-1) return dp[p][k] ;

	rep(i,0,n) {
		if(ans(k-a[i] , (p+1)%2) == p) return dp[p][k] = p ;
	}
	return dp[p][k] = (p+1)%2 ;
}

void solve() {
	cin >> n >> k ;
	rep(i,0,n) cin >> a[i];	
	fl(dp,-1);
	rep(i,0,n) {
		if(ans(k-a[i],1)==0) {
			cout << "First" ;
			return;
		}
	}
	cout << "Second" ;
}

int32_t main() {

    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <cmath>
#include <limits>
#include <algorithm>
using namespace std;
using i64 = long long;
int n, i;
int x[20], y[20], p[20], z[20];
i64 ans[20];
char b[20], s[20], c[20];

void ct(int j)
{
    i64 result = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (b[i] != 0)
            continue;
        int t = z[i];
        for (int u = 0; u < j; ++u)
            if (c[u] == 1)
                t = min(t, abs(x[i] - x[s[u]]));
            else
                t = min(t, abs(y[i] - y[s[u]]));
        result += t * (i64)p[i];
    }
    ans[j] = min(ans[j], result);
}

void sk(int i, int j)
{
    if (i > n)
    {
        ct(j);
        return;
    }
    s[j] = i;
    c[j] = b[i] = 1;
    sk(i + 1, j + 1);
    c[j] = b[i] = 2;
    sk(i + 1, j + 1);
    b[i] = 0;
    sk(i + 1, j);
}

int main()
{
    scanf("%d", &n);
    for (i = 1; i <= n; ++i)
    {
        scanf("%d%d%d", &x[i], &y[i], &p[i]);
        z[i] = min(abs(x[i]), abs(y[i]));
    }
    for (i = 0; i <= n; ++i)
        ans[i] = numeric_limits<i64>::max();
    sk(1, 0);
    for (i = 0; i <= n; ++i)
        printf("%lld\n", ans[i]);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto& e : p) cin >> e;
    int min = 1e9;
    int ans = 0;
    for(int i = 0;i < n;i++){
        if(p[i] <= min){
            min = p[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import math
from collections import defaultdict

def main():
    N = int(input())
    fac = defaultdict(int)

    for i in range(2, int(math.sqrt(N))+1):
        while N % i == 0:
            is_p = False
            fac[i] += 1
            N = N // i

    if N != 1:
        fac[N] += 1

    ans = 0
    for k, v in fac.items():
        e = 1
        for i in range(10000000):       
            if e <= v:
                ans += 1
                v -= e
                e += 1
            else:
                break
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9488
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int N;
double dp[301][301][301];
double rec(int a, int b, int c) {
    if (a + b + c == 0) {
        return 0;
    }
    if (dp[a][b][c] >= -0.5) {
        return dp[a][b][c];
    }
    double sum = a + b + c;
    double res = (N - sum) / sum;

    if (a > 0) {
        res += (a / sum) * (rec(a - 1, b, c) + 1);
    }
    if (b > 0) {
        res += (b / sum) * (rec(a + 1, b - 1, c) + 1);
    }
    if (c > 0) {
        res += (c / sum) * (rec(a, b + 1, c - 1) + 1);
    }
    return dp[a][b][c] = res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    int arr[3] = {0};
    REP(i, 0, N) {
        int a;
        cin >> a;
        arr[a - 1]++;
    }
    REP(i, 0, 301) {
        REP(j, 0, 301) {
            REP(k, 0, 301) {
                dp[i][j][k] = -1.0;
            }
        }
    }
    cout << fixed << setprecision(20) << rec(arr[0], arr[1], arr[2]) << endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  char a[H][W];
  rep(i, H) rep(j, W) cin >> a[i][j];
  char red[H][W];
  rep(i, H) rep(j, W) {
    if(j == 0) red[i][j] = '#';
    else if(j == W-1) red[i][j] = '.';
    else if(i%2) red[i][j] = '.';
    else red[i][j] = '#';
  }
  char blue[H][W];
  rep(i, H) rep(j, W) {
    if(j == 0) blue[i][j] = '.';
    else if(j == W-1) blue[i][j] = '#';
    else if(i%2) blue[i][j] = '#';
    else blue[i][j] = '.';
  }
  rep(i, H) {
    rep(j, W) {
      if(red[i][j] == '#' || a[i][j] == '#') cout << '#';
      else cout << '.';
    }
    cout << endl;
  }
  cout << endl;
  rep(i, H) {
    rep(j, W) {
      if(blue[i][j] == '#' || a[i][j] == '#') cout << '#';
      else cout << '.';
    }
    cout << endl;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1536
r,g,b,n = map(int, input().split())
ans = 0
rgb = sorted([r,g,b])
n_rgb = []
for e in rgb:
  n_rgb.append(n//e)
for i in range(n_rgb[2]+1):
  N2 = n-i*rgb[2]
  for j in range(n_rgb[1]+1):
    N = N2 - j*rgb[1]
    if  N>=0 and N%rgb[0]==0:
      ans+=1
      
print(ans)

Measured memory_bytes: 9112
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		if(n % 2 == 0) {
			System.out.println(n/2);
		}else {
			System.out.println(n/2+1);
		}
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    string s;
    deque<char> deq;
    cin >> s;
    rep(i,s.size()) {
        deq.push_back(s[i]);
    }
    int q;
    cin >> q;
    bool rev = false;
    rep(i,q) {
        int t,f;
        char c;
        cin >> t;
        if(t == 1) {
            rev = !rev;
        } else {
            cin >> f >> c;
            if((f == 1 && rev == false) || f == 2 && rev == true) {
                deq.push_front(c);
            } else {
                deq.push_back(c);
            }
        }
    }
    if(rev) reverse(deq.begin(), deq.end());
    for(auto c: deq) {
        cout << c ;
    }
    cout << endl;
}

Measured memory_bytes: 3912
n, m = map(int, input().split())
ls_lr = [[int(_) for _ in input().split()] for _ in range(m)]

mxl = 0
mnr = n

for i in range(m):
	if ls_lr[i][0] > mxl:
		mxl = ls_lr[i][0]
	if ls_lr[i][1] < mnr:
		mnr = ls_lr[i][1]

print(max(mnr - mxl + 1, 0))

Measured memory_bytes: 21156
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
char s[1000];
bool check()
{
	int n=strlen(s+1);
	for(int i=1;i<=n;++i)
		if(i%2==1 && s[i]=='L')
			return false;
		else if(i%2==0 && s[i]=='R')
			return false;
	return true;
}
int main()
{
	scanf("%s",s+1);
	if(check())
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int X = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        if (B <= A) {
            System.out.println("delicious");
        } else if (B - A <= X) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }

    }
}

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

#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 REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int n,y; cin>>n>>y;
  vector<int> m={10000, 5000, 1000};
  vector<int> ans(3,-1);

  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n-i; j++) {
      if (y == m[0]*i + m[1]*j + m[2]*(n-i-j)) {
        ans[0] = i;
        ans[1] = j;
        ans[2] = n-i-j;
      }
    }
  }
  for (int i=0; i<3; i++) {
    cout << ans[i] << endl;
  }
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int n , a , b;
	cin >> n >> a >> b;
	cout << max(0ll ,(n - 2) * (b - a) + 1 );
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
vector<double> a;
vector<vector<vector<double>>> dp(310, vector<vector<double>>(310, vector<double>(310)));

double rec(int i, int j, int k) {
    if (dp[i][j][k] != 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0;

    double res = 0.0;

    if (i >= 1) res += rec(i - 1, j, k) * i;
    if (j >= 1) res += rec(i + 1, j - 1, k) * j;
    if (k >= 1) res += rec(i, j + 1, k - 1) * k;
    res += N;
    res /= (i + j + k);
    return dp[i][j][k] = res;
}

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

    cin >> N;
    a.resize(N);

    REP(i, N) cin >> a[i];

    int one = 0;
    int two = 0;
    int three = 0;


    for (auto x:a) {
        if (x == 1) one++;
        else if (x == 2) two++;
        else if (x == 3) three++;
    }

    double ans = 0.0;

    ans = rec(one, two, three);
    
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 237568
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;


void solve(long long X, long long Y){
    long long tmp=X, cnt=0l;
    while(tmp<=Y){
        tmp<<=1;
        cnt++;
    }
    cout << cnt << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
 
#define west 0
#define east 1
 
int main()
{
	int n, cmin = INT_MAX, count = 0;
	char c;
	bool ew[300000];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> c;
		ew[i] = (c == 'E');
		count += ew[i];
	}
	for(int i = 0; i < n; i++){
		if(ew[i] == east){
			count -= 1;
			cmin = min(count, cmin);
		}
		else{
			cmin = min(count, cmin);
			count += 1;
		}
	}
	cout << cmin << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define INF 10000009
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int longestPath(vector<int> graph[],vector<int> &dp,int s)
{
	if(dp[s]!=0)
	{
		return dp[s];
	}
	int ch=0;
	for(auto v:graph[s])
	{
		ch=max(ch,1+longestPath(graph,dp,v));
	}
	return dp[s]=ch;
}

int main()
{
	fastio
	int n,m,i,u,v;
	cin>>n>>m;
	vector<int> graph[n+1];
	vector<int> dp(n+1,0);
	for(i=0;i<m;i++)
	{
		cin>>u>>v;
		graph[u].pb(v);
	}
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(dp[i]==0)
		{
			ans=max(ans,longestPath(graph,dp,i));
			if(ans==n)
			{
				break;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 11744
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<numeric>
#include<math.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    if ( b < c || a > d ) ans = 0;
    else if ( a >= c && b <= d ) ans = b - a;
    else if ( c >= a && d <= b ) ans = d - c;
    else if ( b >= c && b <= d ) ans = b - c;
    else if ( d >= a && d <= b ) ans = d - a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())
ans = []
flag = 0
counter = 0
for i in range(len(s)):
    if (i == 0 and s[i] == "A"):
        ans.append(1)
        counter = 1
    elif (i == 0 and s[i] != "A" and s[i].isupper()):
        print("WA")
        exit()
    elif (2 <= i <= len(s) - 2 and s[i] == "C" and flag ==0):
        ans.append(1)
        flag = 1
        counter = 1
    elif (2 <= i <= len(s) - 2 and s[i] == "C" and flag == 1):
        print("WA")
        exit()
    elif (counter == 0 and s[i].isupper()):
        print("WA")
        exit()
    counter = 0
if (len(ans) == 2):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA2
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var c = new ConsoleInput(Console.In);

            var a = c.ReadLong;
            long res = (long)(a + Math.Pow(a, 2) + Math.Pow(a, 3));

            sw.WriteLine(res);

            Console.Out.Flush();
        }
        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }


}


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

int main() {
    int N;
    cin >> N;
  
    vector<int> a(N);
    for (int i=0; i<N; i++) {
        cin >> a.at(i);
    }
    int x = 0;
    int num = 0;
    while (num <= N) {
        if ( x == 1) {
            cout << num << endl;
            break;
        }else if( num == N) {
            cout << -1 << endl;
            break;      
        }
        num++;
        x = a.at(x) - 1;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
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;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  ll N, a, b; cin >>N >>a >>b;
  ll ans = 0;
  if ((b-a)%2 == 0){
    ans = (b-a) / 2;
  }else{
    if (N-b > a-1){
      ans = (a-1) + (b-a)/2 + 1;
    }else{
      ans = (N-b) + (b-a)/2 + 1;
    }
  }
  cout <<ans <<endl;
}

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

int N, ans = 1;
string S;

int main() {
  scanf("%d", &N);
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (i > 0 && S.at(i - 1) != S.at(i)) {
      ans++;
    }
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 512
import           Control.Monad
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

main = do
  [sx, sy, tx, ty] <- getIntList
  let w = tx - sx
      h = ty - sy

      ans = replicate w 'R'
        ++  replicate h 'U'
        ++  replicate w 'L'
        ++  replicate h 'D'
        ++  ['D']
        ++  replicate (w+1) 'R'
        ++  replicate (h+1) 'U'
        ++  ['L', 'U']
        ++  replicate (w+1) 'L'
        ++  replicate (h+1) 'D'
        ++  ['R']

  putStrLn ans

Measured memory_bytes: 1020
#include<bits/stdc++.h>//
using namespace std;
int a[202020],n,k,i,c,d;
int le,mi,ri,ans;
int main()
{
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    le=1;
    ri=1000000000;
    while(le<=ri)
    {
        c=0;
        mi=(le+ri)/2;
        for(i=0;i<n;i++)
        {
            d=(a[i]-1)/mi;
            if(d<0)d=0;
            while((double)(1.000*a[i]/(d+1)-mi)>=0.5)
            {
                d++;
            }
            c+=d;
        }

        if(c<=k)
        {
            ri=mi-1;
            ans=mi;
        }

        else if(c>k)
            le=mi+1;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 4620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 円周率
		int x = (int) Math.PI;
		// 半径1の円の面積
		int area1 = 1 * 1 * x;
		// 入力値の円の面積
		int a = sc.nextInt();
		int areaX = a * a * x;
		// 結果
		System.out.println(areaX/area1);
		sc.close();
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int find(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int s;
  cin >> s;
  int sum;
  sum=find(s);
  if(s%sum==0)
    cout << "Yes" <<endl;
  else 
    cout <<"No" <<endl;
  
}

  


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string S;
  cin >> S;

  int length = S.length(), count = 0;
  for(int i = 0, l = S.length() / 2; i < l; i++) {
    if(S[i] != S[length - 1 -i]) {
      ++count;
    }
  }

  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;


int main(){
    string s;
    cin >> s;
    int A = 0;
    int B = 0;
    int C = 0;
    int D = 0;
    for(int a = 0;a < s.size();a++){
        if(a%2 == 0 && s.at(a) == '0')A++;
        if(a%2 == 1 && s.at(a) == '0')B++;
        if(a%2 == 0 && s.at(a) == '1')C++;
        if(a%2 == 1 && s.at(a) == '1')D++;
    }
    cout<<min(A,D)*2+min(B,C)*2<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    int size = S.size();
    int childlen[2][size];
    for(int i = 0; i < size; i++){
        childlen[0][i] = 1;
        childlen[1][i] = 0;
    }
    
    for(int i = 0; i < size-1; i++){
        if(S[i] == 'R' && S[i+1] == 'R'){
            childlen[1][i+1] += childlen[0][i];
            childlen[0][i+1] += childlen[1][i];
            childlen[1][i] = 0;
            childlen[0][i] = 0;
        }
    }
    
    for(int i = size-1; i > 0; i--){
        if(S[i] == 'L' && S[i-1] == 'L'){
            childlen[1][i-1] += childlen[0][i];
            childlen[0][i-1] += childlen[1][i];
            childlen[1][i] = 0;
            childlen[0][i] = 0;
        }
    }
    
    for(int i = 0; i < size; i++){
        if(S[i] == 'R' && S[i+1] == 'L'){
            childlen[0][i+1] += childlen[1][i];
            childlen[0][i] += childlen[1][i+1];
        }
    }
    
    for(int i = 0; i < size; i++){
        cout << childlen[0][i] << " ";
    }
    cout << "\n";
    
    return 0;
}


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

using namespace std;

int main() {
    int w, a, b;
    cin >> w >> a >> b;
    if (a <= b && b <= a + w) 
        cout << 0 <<  endl;
    else
        cout << abs(a - b) - w << endl;
    
    return 0;
}

Measured memory_bytes: 256
//Poll

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
#define nnn "\n"
const int inf = 2147483647;

int main (){
    int n;cin>>n;
    vector<string>s(n);
    map<string,int>m;
    vector<string>e;
    int c = 0;
    rep(i,0,n){
        cin>>s[i];
        m[s[i]]++;
        c=max(m[s[i]],c);
    }
    for(auto it =m.begin();it != m.end();it++){
        if(it->second==c){
            cout << it->first << nnn;
        }
    }
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int64_t ans = 0;
  vector<int64_t> vec(N);
  priority_queue<int64_t> pq;
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
    pq.push(vec.at(i));
  }
  for(int i = 0; i < M; i++){
    pq.push(pq.top() / 2);
    pq.pop();
  }
  for(int i = 0; i < N; i++){
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 2168
n=int(input())
a=[int(x) for x in input().split()]

min=a[0]
max=a[0]
sum=0

for i in range(n):
    if(min>a[i]):min=a[i]
    if(max<a[i]):max=a[i]
    sum+=a[i]

print(min,max,sum)


Measured memory_bytes: 6600
#include<iostream>
  
bool isP(int x){
  if(x==0||x==1)return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}
  
int main(){
  int n,a,cnt=0;
  std::cin>>n;
  for(int i=0;i<n;i++){
    std::cin>>a;
    cnt+=isP(a);
  }
  std::cout<<cnt<<"\n";
}



Measured memory_bytes: 3080
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, Q;

int main() {
  std::cin >> N >> Q;

  atcoder::fenwick_tree<ll> bit( N+10 );

  rep( i, N ) {
    ll a;
    std::cin >> a;
    
    bit.add( i, a );
  }

  rep( q, Q ) {
    ll t, a, b;
    std::cin >> t >> a >> b;

    if( !t ) {
      bit.add( a, b );
    } else {
      std::cout << bit.sum( a, b ) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 8224
#include<stdio.h>
#include<string.h>
int main(){
	
	
	int x, y, i, j, flag, number=0;
	scanf("%d", &x);
	
	for(flag=0, i=1; i<=x; i+=2){
		for(j=1; j<=i; j++){
			if(i%j == 0){
				flag++;
			}
		}
		
		if(flag==8){
				number ++;
		}
		
		flag=0;
	}
	
	printf("%d\n", number);
	

return 0;	
}

Measured memory_bytes: 128
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN],b[MAXN];

void solve(){
    ll m,ans=0;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=1;i<=n;i++)cout<<b[i]<<nl;
}



int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


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

char s[105];

int main(){
	scanf("%s",s);
	bool qaq=1;
	for(int i=0;i<strlen(s);i+=2){
		if(s[i]=='L') {
			qaq=0;break;
		}
	}
	for(int i=1;i<strlen(s);i+=2){
		if(s[i]=='R') {
			qaq=0;break;
		}
	}
	if(qaq) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
import math

a, b, x = map(int, input().split(' '))

if a ** 2 * b / 2 <= x:
    num = (2 * (a ** 2 * b - x)) / (a ** 3)
else:
    num = b ** 2 * a / (2 * x)

print(math.degrees(math.atan(num)))


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] info = new int[4][3][10];
        
        for (int i = 0; i < n; i++) {
            int b = sc.nextInt() - 1;
            int f = sc.nextInt() - 1;
            int r = sc.nextInt() - 1;
            int v = sc.nextInt();
            info[b][f][r] += v;
        }
        
        for (int b = 0; b < 4; b++) {
            for (int f = 0; f < 3; f++) {
                for (int r = 0; r < 10; r++) {
                    System.out.print(" " + info[b][f][r]);
                }
                System.out.println();
            }
            if (b != 3) {
                System.out.println("####################");
            }
        }
    }
}


Measured memory_bytes: 29356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll s;
    cin >> s;
    ll a, b, c, d;
    if (s<1000000000) {
        a=s;
        d=1;
        b=0;
        c=0;
    }
    else {
        a=1000000000;
        d=(s-1)/a+1;
        b=a*d-s;
        c=1;
    }
    cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)
#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)
#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

int main() {
    ll N, M;
    cin>>N>>M;
    
    vector<ll> nums;
    for(ll n=sqrt(M); n>=1; n--){
        if(M%n==0){
            nums.push_back(n);
            nums.push_back(M/n);
        }
    }
    sort(nums.begin(),nums.end());
    ll len=nums.size();
    rep(i,len){
        if(N*nums[len-1-i]<=M){
            cout1(nums[len-1-i]);
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
#x, y = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

if s.islower():
    print("a")
else:
    print("A")

















Measured memory_bytes: 9860
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

import Data.Ratio
import Data.List (maximumBy)

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  as <- getParms
  let (w,s) = maxWS as
  putStrLn $ show w ++ " " ++ show s

type SW = Int -- SugarWater
type S  = Int -- Sugar

percentage :: (SW, S) -> Ratio Int
percentage (a,b) = b % a 

total :: (SW,S) -> Int
total = fst

combinations' :: [Int] -> [(SW,S)]
combinations' [a,b,c,d,_e,f] 
  = [(100*a*na + 100*b*nb + c*nc + d*nd, c*nc + d*nd)
      | let fa = f `div` (100*a)
      , na <- [0 .. fa]
      , let fb = (f-100*a*na) `div` (100*b)
      , nb <- [0 .. fb]
      , let fc = (f-100*(a*na + b*nb)) `div` c
      , nc <- [0 .. fc]
      , let fd = (f-100*(a*na + b*nb)-c*nc) `div` d
      , nd <- [0 .. fd]
      ]

combinations :: [Int] -> [(SW,S)]
combinations as@[a,b,c,d,e,f]
  = filter (\ws -> (percentage ws <= percentage (e+100,e) && total ws <= f)) $ tail $ combinations' as 

maxWS = maximumBy c . combinations
  where
    c :: (SW,S) -> (SW,S) -> Ordering
    a `c` b = compare (percentage a) (percentage b)

Measured memory_bytes: 97276
import bisect
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

#C[i]=パワーがi以下の人数
C=[0]*(10**5*2+1)
for a in A:
    C[a]+=1
for i in range(1,len(C)):
    C[i]+=C[i-1]

#和がx以上になる組み合わせの総数を求める関数
def pattern_num_ge_x(x):
    p=0
    for a in A:
        p+=(N-(C[x-a-1] if x-a-1>=0 else 0))
    return(p)

#pattern_num_ge_x(x)がM未満になる最小のxを探す(=r)
#lはM以上になる最大のx
l=-1
r=10**5*2+1
while r-l>1:
    m=(r+l)//2
    if pattern_num_ge_x(m)<M:
        r=m
    else:
        l=m

#和がr以上になる組み合わせの総和を求める(累積和を使用)
S=[0]+list(reversed(A[:]))
for i in range(1,N+1):
    S[i]+=S[i-1]
ans=0
for a in A:
    idx=bisect.bisect_left(A,r-a)
    ans+=a*(N-idx) + S[N-idx]
    M-=(N-idx)

#回数のあまり分lを足す
ans+=l*M

print(ans)

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

int main(void){
    while(true){
        int n, prev=0, cnt=0;
        char f[110][4];
        cin >> n;
        if(n==0) break;
        for(int i=0;i<n;++i){
            cin >> f[i];
        }
        for(int i=0;i<n;++i){
            if(!strcmp(f[i], "lu")){
                switch(prev){
                    case 0: prev = 1; break;
                    case 1: prev = 0; break;
                    case 2: ++cnt; prev = 0; break;
                }
            }else if(!strcmp(f[i], "ld")){
                switch(prev){
                    case 0: prev = 1; break;
                    case 1: prev = 0; break;
                    case 2: ++cnt; prev = 0; break;
                }
            }else if(!strcmp(f[i], "ru")){
                switch(prev){
                    case 0: prev = 2; break;
                    case 1: ++cnt; prev = 0; break;
                    case 2: prev = 0; break;
                }
            }else if(!strcmp(f[i], "rd")){
                switch(prev){
                    case 0: prev = 2; break;
                    case 1: ++cnt; prev = 0; break;
                    case 2: prev = 0; break;
                }
            }
        }
        cout << cnt << endl;
    }
}


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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

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

  vector<int> d(n);
  rep (i, n) cin >> d[i];

  int ans = 0;
  sort(d.begin(), d.end());
  int prev_ = -1;

  rep (i, n) {
    if (prev_ != d[i]) {
      ans++;
    }
    prev_ = d[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = 0
B = 0
BA = 0
ans = 0
for _ in range(N):
    S = input()
    for i in range(len(S) - 1):
        if S[i : i + 2] == 'AB':
            ans += 1
    if S[0] == 'B' and S[-1] == 'A':
        BA += 1
    elif S[0] == 'B':
        B += 1
    elif S[-1] == 'A':
        A += 1
    # print(S, A, B, BA, ans)

if A == 0 and B == 0 and BA > 0:
        ans += BA - 1
else:
    ans += min(A + BA, B + BA)
    
print(ans)

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

ll a[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	bool ans=true;
	if(n==1){
		cout <<"Yes";
		return 0;
	}
	ll now=a[0]-1;
	for(int i=0;i<n;i++){
		if(a[i]>now){
			a[i]--;
			now=a[i];
			continue;
		}
		if(a[i]==now){
			continue;
		}
		else{
			cout <<"No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	double r,are,circ;  //r,are,circは実数、areは円の面積、circは円周の長さ
	double p;
	p = 3.141592653589;
	scanf("%lf",&r);  //%lfは実数を求めるための入力変換指定子
	are = p * r * r;
	circ = 2 * p * r;
	
	printf("%.5lf %.5lf\n",are,circ);
	
	return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(){
  int a,i,x;

  scanf("%d",&a);

  for(i=1;i<=a;i++){
    x = i;
    if (i%3 == 0) {
      printf(" %d",i);
      continue;
    }
    while(x>0){
      if (x%10 == 3) {
	printf(" %d",i);
	break;
      }
      x /= 10;
    }

   
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int num1, num2;
  char c;

  cin >> num1 >> c >> num2;

  if (c == '+')
  {
    cout << num1 + num2 << endl;
  }
  else
  {
    cout << num1 - num2 << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
using str = string; 
using ll = long long; 
#define REP(i,n) for(int i=0; i<int(n); i++) 
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--) 
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++) 
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--) 
#define ALL(vec) (vec).begin(),(vec).end() 
#define ASORT(vec) sort(ALL(vec)) 
#define DSORT(vec) sort(ALL(vec), greater<int>()); 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl; 
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl; 
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl; 

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

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

int main() {
int n, k, s=0; 
cin >> n >> k; 
vector<int> data(n); 
REP(i, n) cin >> data.at(i); 
ASORT(data); 
REP(i, k) s += data.at(i); 
cout << s << endl; 
} 


Measured memory_bytes: 3604
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<vector<int>> C(N, vector<int>(2));
    REP(i, N)
    {
        cin >> C[i][0] >> C[i][1];
    }

    double sum = 0.0;
    ll count = 0;
    vector<int> P(N);
    iota(ALL(P), 0);
    do
    {
        REP(a, N - 1)
        {
            int j = P[a], i = P[a + 1];
            sum += sqrt(pow(C[i][0] - C[j][0], 2) + pow(C[i][1] - C[j][1], 2));
        }
        count++;
    } while (next_permutation(ALL(P)));

    cout << fixed << setprecision(10) << sum / count << endl;

    return 0;
}


Measured memory_bytes: 3216
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main(){
	int n, m;
	scanf("%d %d",&n,&m);
	if(n%2 == 1){
		int l = 1, r = n-1;
		for(int i=1; i<=m; ++i)
			printf("%d %d\n",l++,r--);
	}
	else if(n%2 == 0){
		int l = n/2, r = n/2+1;
		for(int i=1; i<=m; ++i){
			printf("%d %d\n",l--,r++);
			if((r-l)%2 and r-l >= n/2)
				++ r;
		}
	}
	return 0;
}

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

int main(){
    ll H;
    cin >> H;

    ll x = 1, y = 0;
    while (H > 1) {
        H /= 2;
        y++;
        x += pow(2, y);
    }
    
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 384
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    divisors.sort(reverse=True)
    return divisors

N = int(input())
dev_max = divisors(N)[0]

print(int(dev_max + N/dev_max - 2))


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

vector<int> card;
int n;

void shuffle(int mode){
    vector<int> res;
    if( mode == 0 ){
        for(int i = 0; i < n; i++){        
            res.push_back( card[i] );
            res.push_back( card[i+n] );
        }
    }else{
        for(int i = 0; i < 2*n; i++){
            res.push_back( card[ (i + mode) % (2 * n) ] );
        }
    }
    card = res;
}

int main(){
    cin >> n;
    for(int i = 0; i < 2*n; i++){
        card.push_back(i+1);
    }
    int m;
    cin >> m;
    while( m-- > 0 ){
        int cmd;
        cin >> cmd;
        shuffle( cmd );
    }
    for(int i = 0; i < 2*n; i++){
        cout << card[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1220