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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const double PI = 2.0*atan2(1,0);
double a,b,x;

int main()
{
  fastio();

  cin >> a >> b >> x;

  double l = a*a*b/2.0;

  if (l <= x) {
    double ans = atan2(2.0*(a*a*b-x), a*a*a);
    printf("%.10f\n", ans * 180.0 / PI);
  } else {
    double ans = atan2(a*b*b, 2*x);
    printf("%.10f\n", ans * 180.0 / PI);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
    int N, M, cnt = 0; cin >> N >> M;
    unordered_map<int, int> Map;
    for (int i = 0; i < N; ++i) {
        int K; cin >> K;
        for (int j = 0; j < K; ++j) {
            int a; cin >> a; Map[a]++;
        }
    }
    for (int i = 0; i < M; ++i) if (Map[i + 1] == N) cnt++;
    printf("%d\n", cnt);
}


Measured memory_bytes: 3696
fun main(args: Array<String>) {
    val inputs = readLine()?.split(" ")?.map { it.toLong() } ?: return
    val div = inputs[0] / inputs[1]
    val mod = inputs[0] % inputs[1]
    val flo: String
    if (mod != 0L) {
        flo = String.format("%1$.6f", inputs[0].toDouble() / inputs[1].toDouble())
    }else {
        flo = "${inputs[0] / inputs[1]}"
    }
    println("$div $mod $flo")
}


Measured memory_bytes: 32028
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N, K;
  cin >> N >> K;

  map<ll,ll> cnt;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  ll sum = 0;
  FOR(it,cnt){
    if(sum <= K && K <= sum + it->second){
      cout << it->first << endl;
      break;
    }
    sum += it->second;
  }
  
  return 0;
}



Measured memory_bytes: 4224
#include <iostream>

#define ll long long

int main(){
    ll x,k,d;
    std::cin>>x>>k>>d;
    x=std::abs(x);
    ll m=x%d,q=x/d;
    if(q>=k){
        std::cout << x-k*d << std::endl;
        return 0;
    }
    k-=q;
    if(k%2==0)
        std::cout<<m<<std::endl;
    else
        std::cout<<std::abs(m-d)<<std::endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int n; cin >> n;
	vector<string> s(n);
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		mp[s[i]] += 1;
	}

	int m; cin >> m;
	vector<string> t(m);
	for (int i = 0; i < m; i++) {
		cin >> t[i];
		mp[t[i]] -= 1;
	}
	int ans = 0;

	for (auto x : mp) {
		ans = max(ans, x.second);
	}

	cout << ans << endl;

	return 0;
}

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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll = long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

  int results = 0;
  loop(1, N+1, n) {
    if (n%2 == 0) continue;

    int count = 0;
    int duplicated = 0;
    for (int i=1; i*i<=n; i++) {
      if (n%i == 0) {
        count++;
      }
      if (i*i == n) {
        duplicated = 1;
      }
    }
    count *= 2;
    count -= duplicated;
    if (count == 8) {
      results++;
    }
  }
  print(results);

}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
    {
	int i,x;
	i=0;
	scanf("%d",&x);
	while(x!=0){
	if(x==0) break;
	i++;
	printf("Case %d: %d\n",i,x);
	scanf("%d",&x);
	}
	return 0;
}	
 

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000000;
ll INF=1e18;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}
vector<ll> par(2005),sz(2005,1);

ll froot(ll x)
{
     if(x==par[x])
          return x;
     return par[x]=froot(par[x]);
}
void solve()
{
     ll n;
     cin>>n;
     vector<pll> v(n);
     ll i;
     for(i=0;i<n;i++)
          cin>>v[i].F>>v[i].S;
     for(i=0;i<n-2;i++)
     {
          if(v[i].F==v[i].S)
          {
               if(v[i+1].F==v[i+1].S && v[i+2].F==v[i+2].S)
               {
                    cout<<"Yes\n";
                    return ;
               }
          }
     }
     cout<<"No\n";
     
}

int main()
{
    ios;
    ll t;
     // cin>>t;
     t=1;
     while(t--)
     {
          solve();
     }
}


Measured memory_bytes: 3572
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    LinkedList<Integer> stack = new LinkedList<Integer>();
    while(sc.hasNext()){
      String inp = sc.next();
      if('0' <= inp.charAt(0) && inp.charAt(0) <= '9'){
        int num = Integer.parseInt(inp);
        stack.push(num);
      }else{
        int b = stack.pop();
        int a = stack.pop();
        int c;
        if('+' == inp.charAt(0)){
          c = a + b;
        }else if('*' == inp.charAt(0)){
          c = a * b;
        }else{
          c = a - b;
        }
        stack.push(c);
      }
    }

    System.out.println(stack.pop());
  }
}

Measured memory_bytes: 18756
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int>> PP;


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

const ll MOD = 1000000007;
const ll INF = 1000000000;

int h[105];
ll ans = 0;



int main(void){
    ll K, A, B;
    ll ans;
    cin >> K >> A >> B;
    if (B - A <= 2 || A >= K + 1) ans = K + 1;
    else ans = A + (K - A + 1) / 2 * (B - A) + (K - A + 1) % 2;

    cout << ans << endl;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private int n;
    private int[] num;

    public Main(int n, int[] num) {
        this.n = n;
        this.num = num;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
        }
        Main test = new Main(n, num);
        int count = test.selectionSort();
        for (int i = 0; i < n; i++) {
            System.out.print(num[i]);
            if (i < n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
        System.out.println(count);
    }

    private int selectionSort() {
        int count = 0;
        for (int i = 0; i < n; i++) {
            int mini = i;
            for (int j = i; j < n; j++) {
                if (num[j] < num[mini]) {
                    mini = j;
                }
            }
            swap(i, mini);
            if (i != mini) count++;
        }
        return count;
    }

    private void swap(int a, int b) {
        int temp = num[a];
        num[a] = num[b];
        num[b] = temp;
    }
}


Measured memory_bytes: 26336
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, X, Y, Z;
int dp[44][1 << 16];
const int mod = 1000000007;
int memo[1 << 16][11];
const int UNKNOWN = 0;
const int TRU = 1;
const int FAL = 2;

void add(int &x, int y) {
    (x += y) %= mod;
}

//XYZになるならtrue

bool checkXYZ(int j, int k) {
    if (memo[j][k] != UNKNOWN) {
        return memo[j][k] == TRU;
    }
    int cnt = 0;
    queue<int> st;
    st.push(k);
    int j2 = j;
    while (j2) {
        cnt++;
        if (j2 & 1) {
            st.push(cnt);
            cnt = 0;
        }
        j2 >>= 1;
    }
    int z = 0;
    while (z < Z && !st.empty()) {
        z += st.front();
        st.pop();
    }
    if (z != Z) {
        memo[j][k] = FAL;
        return false;
    }
    int y = 0;
    while (y < Y && !st.empty()) {
        y += st.front();
        st.pop();
    }
    if (y != Y) {
        memo[j][k] = FAL;
        return false;
    }
    int x = 0;
    while (x < X && !st.empty()) {
        x += st.front();
        st.pop();
    }
    if (x != X) {
        memo[j][k] = FAL;
        return false;
    }
    memo[j][k] = TRU;
    return true;
}

template<typename... Args>
void debug(Args... args) {
    for (auto arg:{args...})cerr << arg << " ";
    cerr << endl;
}

signed main() {
    cin >> N >> X >> Y >> Z;
    dp[0][0] = 1;
    int S = X + Y + Z;
    int mask = (1 << (S - 1)) - 1;
    rep(i, N) {
        rep(j, 1 << (S - 1)) {
            for (int k = 1; k <= 10; ++k) {
                if (checkXYZ(j, k))continue;
                int k2 = 1ll << (k - 1);
                int j2 = ((j << k) | k2) & mask;
                add(dp[i + 1][j2], dp[i][j]);
            }
        }
    }
    int ans = 1;
    rep(i, N) {
        (ans *= 10) %= mod;
    }
    rep(j, 1 << (S - 1)) {
        add(ans, -dp[N][j]);
    }
    (ans += mod) %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26880
dice = list(map(int, input().split()))
dice2 = list(map(int, input().split()))
 
slist = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"
 
for s in slist:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")
 
    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n)-1]
 
    dice = tmp
 
    if dice == dice2:
        print("Yes")
        exit()
 
print("No")


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    int t[N], x[N], y[N];
    for (int i = 0; i < N; ++i) cin >> t[i] >> x[i] >> y[i];

    bool can = t[0] >= x[0] + y[0] && (t[0] - x[0] - y[0]) % 2 == 0;
    for (int i = 1; i < N; ++i) {
        int dt = t[i] - t[i-1];
        int dx = abs(x[i] - x[i-1]);
        int dy = abs(y[i] - y[i-1]);
        can = dt >= dx + dy && (dt - dx - dy) % 2 == 0;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <list>
using namespace std;
int main(void){
    // Your code here!
    long long n,k,a[1024];
    list<long long> l;
    cin>>n>>k;
    a[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            l.push_back(a[j]-a[i-1]);
        }
    }
    /*
    for(auto x=l.begin();x!=l.end();x++){
        cout<<*x<<endl;
    }
    */
    long long p=0;
    for(long long i=40;i>=0;i--){
        int c=0;
        list<long long> b;
        for(auto x=l.begin();x!=l.end();x++){
            if((1&(*x>>i))==1){
                c++;
                b.push_back(*x);
            }
        }
        if(c>=k){
            l=b;
            long long x=1;
            p+=(x<<i);
        }
        /*
        cout<<"["<<i<<"]"<<endl;
        for(auto x=l.begin();x!=l.end();x++){
            cout<<*x<<endl;
        }
        cout<<endl;
        */
    }
    cout<<p<<endl;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  vector<ll> a(n),p(40);
  rep(i,n)cin>>a[i];
  rep(i,40)p[i]=(1<<i);
  map<ll,ll> m;
  sort(all(a),greater<ll>());
  rep(i,n){
    if(m[a[i]]==0)m[a[i]]=1;
    else m[a[i]]++;
  }
  rep(i,n){
    if(m[a[i]]){
      if(m[p[digit(a[i],2)]-a[i]]){
        if(a[i]==p[digit(a[i],2)]-a[i]){
          if(m[a[i]]>=2){
            m[a[i]]-=2;
          }
        }
        else{
          m[p[digit(a[i],2)]-a[i]]--;
          m[a[i]]--;
        }
      }
    }
  }
  int ans=0;
  for(auto i:m){
    ans+=i.se;
  }
  cout<<(n-ans)/2<<endl;
}


Measured memory_bytes: 26752
S = list(input())
N = len(S)
flag = 'Yes'
for i in range((N-1)//2):
    if S[i] != S[N-1-i]:
        flag = 'No'
        break
if flag == 'Yes':
    for i in range((N-1)//2):
        if S[i] != S[(N-1)//2 - 1 - i]:
            flag = 'No'
            break
if flag == 'Yes':
    for i in range((N-1)//2):
        if S[(N+3)//2 - 1 + i] != S[-1-i]:
            flag = 'No'
            break
print(flag)

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n;
    cin >> n;
    cout << (n + 1) / 2 << '\n';
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int ans = INF;

    rep(div, 1 << (H - 1)) {
        int g = 0;
        vector<int> id(H);
        rep(i, H) {
            id[i] = g;
            if (div >> i & 1) g++;
        }
        g++;

        int cur = g - 1;
        vector<int> now(g, 0);
        auto add = [&](int j) {
            rep(i, H) {
                now[id[i]] += S[i][j] - '0';
                if (now[id[i]] > K) return false;
            }
            return true;
        };
        rep(j, W) {
            if (!add(j)) {
                cur++;
                rep(i, g) now[i] = 0;
                if (!add(j)) {
                    cur = INF;
                    break;
                }
            }
        }
        chmin(ans, cur);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>

using namespace std;

int maxLength(const int &len1, const int &len2) {
	return len1 > len2 ? len1 : len2;
}


int main()
{
	int N;

	cin >> N;

	for (int i = 0; i < N; i++) {
		string s1, s2;
		cin >> s1 >> s2;
		//cout << s1 << endl << s2 << endl;
		int len1 = s1.size();
		int len2 = s2.size();
		int max = maxLength(len1, len2);
		if (max > 80) {
			cout << "overflow" << endl;
			continue;
		}

		int str[100] = {0};
		int acc = 0;
		for (int i = 0; i < max; i++) {
			if (len1 > i && len2 > i) {
				str[i] = (s1[len1-1-i] - '0') + (s2[len2-1-i] - '0') + acc;
			}
			else if(len1 > i) {
				str[i] = (s1[len1 - 1 - i] - '0') + acc;
			}
			else if (len2 > i) {
				str[i] = (s2[len2 - 1 - i] - '0') + acc;
			}
			acc = 0;
			if (str[i] > 9) {
				acc = 1;
				str[i] %= 10;
			}
		}
		if (max == 80 && acc == 1) {
			cout << "overflow" << endl;
			continue;
		}

		str[max] = acc;

		for (int i = acc == 1? max:max-1; i > -1; i--) {
			cout << str[i];
		}
		cout << endl;
	}

	return 0;
}


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

int main()
{
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >>c;
    int d;
    d = c-b;
    if(b >= c)
    {
        cout << "delicious" <<endl;
    }
    else if(d <= a)
    {
        cout << "safe" <<endl;
    }
    else
    {
        cout << "dangerous" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll md = 1000000007;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
vl p, fac(2, 1), ifac(2, 1);

ll add(ll a, ll b) {
    return (a%md + b%md + md) % md;
}

ll mul(ll a, ll b) {
    return ( (a%md) * (b%md) ) % md;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = ((res%mod) * (x%mod))%mod;
        n = (n >> 1);
        x = ((x%mod) * (x%mod))%mod;
    }
    return res;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(int n, int r) {
    if(n < r) return 0;
    return mul(fac[n], mul(ifac[r], ifac[n-r]));
}

ll P(int n, int r) {
	if(n < r) return 0;
	return mul(fac[n], ifac[n-r]);
}

ll mod_fac(ll n, ll p) {
	return fac[n] * power(power(p, n/p), md - 2) % md * power(fac[n/p], md - 2) % md;
}

void sieve(ll n) {
	vector<bool> prime(n+1, true);
    for(int i = 2; i*i <= n; i++) {
        if(prime[i]) {
            for(int j = 2*i; j <= n; j += i) {
                prime[j] = false;
            }
        }
    }
    p.push_back(2);
    for(int i = 3; i <= n; i += 2) {
        if(prime[i]) {
            p.push_back(i);
        }
    }
}

ll Phi(ll n) {
    ll res = n;
    for (int i = 0; p[i]*p[i] <= n; i++) {
    	short cnt = 0;
        while (n%p[i]== 0) {
           	n /= p[i];
           	cnt++;
        }
        if(cnt) res -= (res / p[i]);
    }
    if (n > 1) res -= (res / n);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    int j = n-1, cnt = 0;
    for(int i = 0; i < j; i++) {
    	if(s[i] == 'W') {
    		while(j > i && s[j] != 'R') {
    			j--;
    		}
    		if(s[j] == 'R') {
    			s[i] = 'R';
    			s[j] = 'W';
    			cnt++;
    		}
    	}
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=1;i<=(n);++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
char s[50];
int main(){
	ios::sync_with_stdio(false);
	cin>>s+1;int n=strlen(s+1);
	if (n&1) cout<<"No\n";
	else{
		for (int i=1;i<n;i+=2){
			if (s[i]!='h'||s[i+1]!='i'){
				cout<<"No\n";return 0;
			}
		}
		cout<<"Yes\n";
	}
	return 0;
}

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

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

using namespace std;

int main(){
	int h,w,d; scanf("%d%d%d",&h,&w,&d);
	int a[300][300];
	rep(i,h) rep(j,w) scanf("%d",a[i]+j), a[i][j]--;

	pair<int,int> pos[300*300];
	rep(i,h) rep(j,w) pos[a[i][j]]={i,j};

	vector<int> sum[300*300];
	rep(i,d){
		sum[i].emplace_back(0);
		for(int x=i+d;x<h*w;x+=d){
			sum[i].emplace_back(sum[i].back()+abs(pos[x].first-pos[x-d].first)+abs(pos[x].second-pos[x-d].second));
		}
	}

	int q; scanf("%d",&q);
	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--; r--;
		printf("%d\n",sum[l%d][r/d]-sum[l%d][l/d]);
	}

	return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
const int N = 100009;
int a[100001], b[100001], c[100001];
long long f[100001];

inline int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
    register int n=read(),i;
    for(i=0;i<n;i++)a[i]=read();
	for(i=0;i<n;i++)b[i]=read();
	for(i=0;i<n;i++)c[i]=read();
    sort(a,a+n);sort(b,b+n);sort(c,c+n);
    long long ans = 0;
 
    for(i=0;i<n;i++)
    {
        if(b[i] >= c[n-1]) break;
        f[i+1] = 1ll*n - (upper_bound(c, c+n, b[i]) - c);
    }
    f[0] = 0;
    for(int i = 1; i <= n; i++) f[i] += f[i-1];
    for(int i = 0; i < n; i++)
    {
        if(a[i] >= b[n-1]) break;
        int s = upper_bound(b, b+n, a[i]) - b;
        ans += f[n] - f[s];
    }
    printf("%lld\n", ans);
    return 0; 
}

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

int main() {
  int x1, x2, x3, x4, y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3=x2-y2+y1;
  y3=y2+x2-x1;
  x4=x3-y3+y2;
  y4=y3+x3-x2;
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 256
import Data.Foldable
import Data.List

main :: IO ()
main = getContents >>= traverse_ (putStrLn.solve.map read.words).takeWhile (/="0 0").lines

solve       :: [Int] -> String
solve [x,y] = unlines $ f x (f y '#' '.') (f y '.' '#')
    where f n a b = take n $ intersperse b $ repeat a

Measured memory_bytes: 4556
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn kougo(len: usize) -> (Vec<char>, Vec<char>) {
    let mut vec0 = Vec::<char>::with_capacity(len);
    for x in 0..len {
        if x % 2 == 0 {
            vec0.push('0');
        } else {
            vec0.push('1');
        }
    }
    
    let mut vec1 = Vec::<char>::with_capacity(len);
    for x in 0..len {
        if x % 2 == 0 {
            vec1.push('1');
        } else {
            vec1.push('0');
        }
    }

    (vec0, vec1)
}

fn tile_num(input: &Vec<char>, compare: &Vec<char>) -> usize {
    let len = std::cmp::min(input.len(), compare.len());
    let mut count = 0;
    for x in 0..len {
        if input[x] != compare[x] {
            count += 1;
        }
    }

    count
}

fn main() {
    let vec = read_vec::<String>();
    let mut input = Vec::<char>::new();
    for c in vec[0].chars() {
        input.push(c)
    }

    let kougo = kougo(input.len());
    let num = std::cmp::min(
        tile_num(&input, &kougo.0),
        tile_num(&input, &kougo.1),
    );

    println!("{}", num);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

int main(){
	string a,b,c;
	int num1,num2;
	
	cin>>a>>b;
	cin>>num1>>num2;
	cin>>c;
	
	if(a==c) cout<<num1-1<<' '<<num2;
	else cout<<num1<<' '<<num2-1;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+5;
ll f(ll x){
	if(x%4==0)return x;
	if(x%4==1)return 1ll;
	if(x%4==2)return x+1ll;
	return 0;
}
void solve(){
	ll a,b; 
	cin>>a>>b;
	ll ans = f(a-1);
	ans^=f(b);
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3604
#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[i];
    }
    int w=0;
    int h=0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            if(w==0) w=a[i];
            else {
                h=a[i];
                break;
            }
            a[i]=0;
            a[i+1]=0;
        }
    }
    if(w==0||h==0) cout<<0<<endl;
    else cout<<(long)h*w<<endl;
    

    
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

int main() {
 UL N;scanf("%u",&N);
 int A[1000]; rep(i,N) scanf("%d",&A[i]);
 UL Q; scanf("%d",&Q);
 rep(q,Q){
  UL b,e,t; scanf("%u%u%u", &b,&e,&t);
  rep(k,e-b)swap(A[b+k],A[t+k]);
 }
 rep(i,N) {if(i)printf(" "); printf("%d",A[i]);}
 printf("\n");
 return 0;
}




Measured memory_bytes: 3176
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
int main()
{
	scanf("%d %d",&n,&k);
	long long nl=1;
	nl=k;
	for(int i=2;i<=n;i++)
	nl*=(k-1);
	printf("%lld",nl);
}

Measured memory_bytes: 128
import java.io.*;

public class Main{

    public static void main(String[]args)throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String strS = br.readLine();
        String strP = br.readLine();

        strS = strS + strS;
        if(strS.indexOf(strP) != -1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> max_height(n,-1);
	vector<int> height(n);
	for(int i=0; i<n; ++i){
		cin>>height[i];
	}
	int ans = 0;
	for(int i=0; i<m; ++i){
		int a,b;
		cin>>a>>b;
		a--; b--;
		max_height[a] = max( max_height[a], height[b] );
		max_height[b] = max( max_height[b], height[a] );
	}
	for(int i=0; i<n; ++i){
		if( max_height[i] < height[i] ){ ++ans; }
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3988
import itertools


def solve(a, b):
    if b == 1:
        return 0
    cur_num = 1
    for i in itertools.count(1):
        cur_num += a - 1
        if cur_num >= b:
            return i


def main():
    a, b = (int(z) for z in input().split())
    res = solve(a, b)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define int long long
#define inf 1000000007 
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	char a,b,c,d,e,f,g,h,i;
	cin>>a>>b>>c;
	cin>>d>>e>>f;
	cin>>g>>h>>i;
	cout<<a<<e<<i<<endl;
}
	

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

using namespace std;

//#define MD 10

int main(){
   int a,b,c;
   cin>>a>>b>>c;
    int ans=3;
    if(a==b){
        ans--;
    }
    if(a==c || b==c){
        ans--;
    }

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int[] arrays;
		int youso=0;
		int counter=0;
		try {
			str=bfr.readLine();
			youso=Integer.parseInt(str);
			arrays=new int[youso];

			str=bfr.readLine();
			stk=new StringTokenizer(str," ");

			while(stk.hasMoreTokens()) {
				arrays[counter]=Integer.parseInt(stk.nextToken());
				counter++;
			}
			Bubble(arrays);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	static void Bubble(int[] a) {
		int tmp1,tmp2=0;
		int ookisa=a.length;
		int kaisu=0;

		for(int i=0; i<ookisa-1; i++) {
			for(int j=ookisa-1; j>=i+1; j--) {
				if(a[j]<a[j-1]) {
					tmp1=a[j];
					tmp2=a[j-1];
					a[j]=tmp2;
					a[j-1]=tmp1;
					kaisu++;
				}
			}
		}
		String moji="";
		for(int i=0; i<ookisa-1; i++) {
			moji=moji+a[i]+" ";
		}
		moji=moji+a[ookisa-1];
		System.out.println(moji);
		System.out.println(kaisu);


	}
}




Measured memory_bytes: 24200
#include<stdio.h>

int main(void){
    int h,w,i,j;

    while(1){
        scanf("%d %d",&h,&w);
        if( h == 0 && w == 0)
            break;
        for(i = 0;i < h;i++){
            for(j = 0;j < w;j++)
                printf("#");
            printf("\n");
        }
        printf("\n");
    }
    return 0;
} 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll x, t;

	cin >> x >> t;

	if (x <= t) Out(0);
	else Out(x - t);
	
	return 0;
}


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

using namespace std;

int main()
{
    int n,m,u,v,i,res=0,ctr;
    cin>>n>>m;
    vector<vector<int> > g(n,vector<int>());
    set<pair<int,int> > edges;
    for(i=0;i<m;i++)
    {
        cin>>u>>v;
        if(u>v)
            swap(u,v);
        edges.insert({u,v});
    }
    for(auto p:edges)
    {
        u=p.first;
        v=p.second;
        g[u-1].push_back(v-1);
        g[v-1].push_back(u-1);
    }
    vector<bool> visited(n,false);
    for(i=0;i<n;i++)
    {
        if(visited[i])
            continue;

        queue<int> q;
        q.push(i);
        visited[i]=true;
        ctr=1;
        while(!q.empty())
        {
            u=q.front();
            q.pop();
            for(int v: g[u])
                if(!visited[v])
                {
                    q.push(v);
                    visited[v]=true;
                    ctr++;
                }
        }
        res=max(res,ctr);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 23840
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k, q;
	cin >> n >> k >> q;
	vector<lli> s(n+1, k-q);

	rep(i,q){
		lli A;
		cin >> A;
		s[A]++;
	}
	
	loop(i, 1, n+1){
		if(s[i] <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
def solve()
  l, r = gets.split.map!(&:to_i)
  min_num = 2018
  (l..r-1).each do |i|
    (i+1..r).each do |m|
      res = (i*m) % 2019
      if min_num > res then
        min_num = res
      end
      if min_num.zero? then
        return min_num
      end
    end
  end
  return min_num
end
print(solve())

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


 bool pirminis(int x)
 {

     if (x<=1)return false;
     for(int i = 2; i*i<=x; i++)
        if(x%i==0)return false;
     return true;


 }

 int main()
 {
     int x;
     cin >> x;
     int p = x;
     while(!pirminis(p))p++;
     cout << p;


 }


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int now;
    int max = 0;
    int min = 123;
    int k;

    for(int i = 0; i < 5; i++){
        scanf("%d",&now);
        if(max < now)max = now;
        if(min > now)min = now;
    }
    scanf("%d",&k);
    if(k >= (max - min))printf("Yay!\n");
    else{printf(":(\n");}
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnta = 0;
    int cntb = 1;
    int cnt = 0;
    rep(i,n){
        if(s[i] == 'a'){
            cnta++;
            if(cnt < a + b){ 
                cnt++;
                cout << "Yes\n";
            }
            else cout << "No\n";
        }
        else if(s[i] == 'b'){
            if(cnt < a + b && cntb <= b){ 
                cnt++;
                cout << "Yes\n";
            }
            else cout << "No\n";
            cntb++;
        }
        else cout << "No\n";
    }   
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

queue<int> q[1010];
bool finished[1010];
int counter[1010][1010];

struct Data {
	int day;
	pair<int, int> p;
	Data(int day, pair<int, int> p) : day(day), p(p) {}
	bool operator<(Data rhs) const {
		return day < rhs.day;
	}

	bool operator>(Data rhs) const {
		return day > rhs.day;
	}
};

signed main()
{
	int N; cin >> N;
	
	queue<Data> qq;

	rep(i, N) {
		rep(j, N - 1) {
			int a; cin >> a;
			--a;
			q[i].push(a);
		}
	}

	rep(i, N) {
		int a = q[i].front();
		counter[i][a]++;
		counter[a][i]++;

		if (counter[i][a] == 2) {
			qq.push(Data(1, pair<int, int>(i, a)));
		}
	}

	int zan = N*(N-1);

	int ans = 0;

	while (not qq.empty()) {
		Data d = qq.front();
		qq.pop();

		zan -= 2;

		int day = d.day;
		pair<int, int> p = d.p;

		ans = day;

		counter[p.first][p.second] = counter[p.second][p.first] = 0;

		q[p.first].pop();
		q[p.second].pop();

		if (not q[p.first].empty()) {
			int op = q[p.first].front();
			counter[p.first][op]++;
			counter[op][p.first]++;

			if (counter[p.first][op] == 2) {
				qq.push(Data(day + 1, pair<int, int>(p.first, op)));
			} 
		}

		if (not q[p.second].empty()) {
			int op = q[p.second].front();
			counter[p.second][op]++;
			counter[op][p.second]++;

			if (counter[p.second][op] == 2) {
				qq.push(Data(day + 1, pair<int, int>(p.second, op)));
			}
		}
	}

	if (zan == 0) {
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}
}


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n,t=0,maxn=0;
	cin>>n; 
	cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
			t++;
		else if(s[i]=='D')
			t--;
		if(t>maxn)
			maxn=t;
	}
	cout<<maxn<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main() {
    int i, count[26];
    char str[1200];
    for (i = 0; i < 26; i++) {
        count[i] = 0;
    }
    i = 0;
    while (fgets(str, 1200, stdin) != NULL) {
        for (i = 0; str[i]; i++) {
            if (isalpha(str[i])) {
                count[tolower(str[i]) - 97]++;
            }
        }
    }
    for (i = 0; i < 26; i++) {
        printf("%c : %d\n", i + 97, count[i]);
    }
    return 0;
}

Measured memory_bytes: 524
from sys import exit
H, W, h, w = map(int, input().split())
if not H % h and not W % w:
    print('No')
    exit()
print('Yes')
G = [[1000]*W for _ in range(H)]
if H % h:
    for i in range(H//h):
        t = (i+1)*h - 1 
        for j in range(W):
            G[t][j] = -(h-1)*1000 - 1
else:
    for i in range(W//w):
        t = (i+1)*w - 1
        for j in range(H):
            G[j][t] = -(w-1)*1000 - 1
for g in G:
    print(*g)

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

using namespace std;
const int MAXN = 200 * 1000 + 7;
int a[MAXN];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int l = 0, r = n + 1;
	while (r - l > 1)
	{
		int m = (l + r) / 2;
		bool ok = true;
		vector<pair<pair<int, int>, int> > st;
		st.push_back(make_pair(make_pair(1, a[1]), 1));
		for (int i = 2; i <= n; i++)
		{
			if (a[i] > a[i - 1])
			{
				if (st.back().second == 1)
				{
					st.back().first.second = a[i];
				}
				else
				{
					st.push_back(make_pair(make_pair(a[i - 1] + 1, a[i]), 1));
				}
			}
			else
			{
				while (st.back().first.first > a[i]) st.pop_back();
				st.back().first.second = a[i];
				if (st.back().second == m)
				{
					st.pop_back();
					if (st.empty())
					{
						ok = false;
						break;
					}
					int x = st.back().first.second, y = st.back().second + 1;
					st.back().first.second--;
					if (st.back().first.second < st.back().first.first) st.pop_back();
					if (!st.empty() && st.back().second == y)
					{
						st.back().first.second = y;
					}
					else
					{
						st.push_back(make_pair(make_pair(x, x), y));
					}
					if (x < a[i])
					{
						st.push_back(make_pair(make_pair(x + 1, a[i]), 1));
					}
				}
				else
				{		
					int x = st.back().first.second, y = st.back().second + 1;
					st.back().first.second--;
					if (st.back().first.second < st.back().first.first) st.pop_back();
					if (!st.empty() && st.back().second == y)
					{
						st.back().first.second = y;
					}
					else
					{
						st.push_back(make_pair(make_pair(x, x), y));
					}
				}
			}
		}
		if (ok)
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
	printf("%d\n", r);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,ans[5];
string s;
int main()
{
cin>>n;
memset(ans,0,sizeof(ans));
for(int i=1;i<=n;i++)
	{
	cin>>s;
	if(s[0]=='A')ans[1]++;
	if(s[0]=='W')ans[2]++;
	if(s[0]=='T')ans[3]++;
	if(s[0]=='R')ans[4]++;
	}
cout<<"AC x "<<ans[1]<<endl;
cout<<"WA x "<<ans[2]<<endl;
cout<<"TLE x "<<ans[3]<<endl;
cout<<"RE x "<<ans[4]<<endl;
}

Measured memory_bytes: 3644
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

class range {
  class Index {
    int x;
  public:
    Index(int x) : x(x) {}
    int operator*() const { return x; }
    bool operator!=(Index &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  Index i, n;
public:
  range(int n) : i(0), n(n) {}
  range(int i, int n) : i(i), n(n) {}
  Index &begin() { return i; }
  Index &end() { return n; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  string s;
  cin >> s;
  const int n = s.size();
  for (int i: range(n-1)) {
    if (s[i] == s[i+1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
  for (int i: range(n-2)) {
    if (s[i] == s[i+2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int l, r, d;
    cin >> l >> r >> d;
    int rr = r / d;
    if (l == 1) return cout << rr, 0;
    int ll = (l - 1) / d;
    cout << rr - ll << endl;
    return 0;
}

Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m, k = map(int, input().split())
a = list( map(int, input().split()))
b = list( map(int, input().split()))

from itertools import accumulate
aacc = [0] + a
aacc = list(accumulate(aacc))
bacc = [0] + b
bacc = list(accumulate(bacc))

from bisect import bisect_right
ans = 0
for cnta, ac in enumerate(aacc):
    if k-ac>=0:
        cntb = bisect_right(bacc, k-ac) - 1
        ans = max(ans, cnta+cntb)

print(ans)


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 200007;

int n;char s[_];

int main()
{
	n=ts(s+1);
	int cntb=0;
	lint ans=0;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='B')cntb++;
		else ans+=cntb;
	}
	printf("%lld\n",ans);

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n, ans=0, tmp;
	map<int, int> m;
	
	cin >> n;
	REP(i, 0, n){
		cin >> tmp;
		++m[tmp];
		if(m[tmp] == 4 && tmp*tmp > ans) ans = tmp*tmp;
	}
	ll f=0, s=0;
	for(auto it=m.begin(); it != m.end(); it++){
		if(it-> second >= 2){
			if(it->F >f){
				s = f;
				f = it->F;
			}
			else if(it->F > s) s = it->F;
		}
	}
	cout << max(ans, f*s);
	
}


Measured memory_bytes: 4992