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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

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

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

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    mint ans = 1;
    rep(i,n) ans*=i+1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

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

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
ans = 0
cnt = 0
temp = h[0]
for i in range(1,n):
  if temp >= h[i]:
    cnt += 1
  else:
    cnt = 0
  ans = max(cnt,ans)
  temp = h[i]
print(ans)

Measured memory_bytes: 20524
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%lld", &x)
#define pr(x) printf("%d", (x))
#define pr64(x) printf("%lld", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define fill(a,v,n) memset((a),(v),sizeof(a[0])*(n))
#define copy(a,b,n) memcpy((a),(b),sizeof(a[0])*(n))
#define ALL(x) (x.begin(),x.end())
#define prf(x) printf("%.20f", x)
#define for_each_edge(u) for(int i = point[u];i;i=G[i].n)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(int n){
	cnt = 0;
	fill(point,0,n+1);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q;
int main(){
//	freopen("1", "r", stdin);
	sc(n);
	if(n==1){
		puts("Hello World");
	}
	if(n==2){
		sc(n),sc(m);
		pr(n+m),ln;
	}
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


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

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> p(M);
  vector<string> S(M);
  for (ll i=0; i<M; i++) {
    cin >> p.at(i) >> S.at(i);
  }
  vector<bool> check(N, false);
  ll ac = 0;
  vector<ll> wa(N, 0);
  for (ll i=0; i<M; i++) {
    if (S.at(i) == "AC" && !(check.at(p.at(i)-1))) {
      ac++;
      check.at(p.at(i)-1) = true;
    }
    else if (S.at(i) == "WA" && !(check.at(p.at(i)-1))) {
      wa.at(p.at(i)-1)++;
    }
  }
  ll sum_wa = 0;
  for (ll i=0; i<N; i++) {
    if (check.at(i)) sum_wa += wa.at(i);
  }
  cout << ac << " " << sum_wa << endl;
}

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

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

  rep(i, n) a[i] -= i + 1;
  sort(a.begin(), a.end());
  int c = n/2;
  ll ans = 0;
  rep(i,n) ans += abs(a[i] - a[c]);
  cout << ans << endl;
}


Measured memory_bytes: 1024
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let n: u64 = read();
    let mut ans: u64 = 1;
    let waruyatu: u64 = 10_u64.pow(9) + 7;
    for i in 1..n+1 {
        ans *= i;
        ans %= waruyatu;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

void input() {
	CI N >> W;

	int temp;

	for (int i = 0; i < N;i++) {
		CI temp;
		value.push_back(temp);
		CI temp;
		weight.push_back(temp);
	}


	return;
}


int main(void) {
	input();

	for (int i = 0; i < N;i++) {
		for (int j = 0; j <= W;j++) {
			if (weight[i] > j) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = max(dp[i][j], value[i] + dp[i][j - weight[i]]);
			}
		}
	}

	CO dp[N][W] E


	return 0;
}

Measured memory_bytes: 7084
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,c;
int D[505][505],C[505][505];

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> n >> c;

    FORN(i,1,c){
        FORN(j,1,c)
            cin >> D[i][j];
    }

    FORN(i,1,n){
        FORN(j,1,n){
            int x;
            cin >> x;
            C[(i+j)%3][x]++;
        }
    }

    ll res=INT_MAX;

    FORN(i,1,c){
        FORN(j,1,c){
            FORN(k,1,c){
                if(i==j || j==k || i==k)
                    continue;
                ll sum=0;
                FORN(q,1,c)
                    sum+=C[0][q]*D[q][i]+C[1][q]*D[q][j]+C[2][q]*D[q][k];
                res=min(res,sum);
            }
        }
    }

    cout << res << endl;

	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

int solve(string s) {
    int res = 0;

    for (int i = 0, j = s.size()-1; i < j; ) {
        if (s[i] == s[j]) { i++; j--; }
        else if (s[i] == 'x') { res++; i++; }
        else if (s[j] == 'x') { res++; j--; }
        else { return -1; }
    }

    return res;
}

int main() {
    string s;
    cin >> s;
    
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << max({A * 2 - 1, A + B, B * 2 - 1}) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;
  bool dp[30010][4][1000]={0};


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  dp[0][0][0]=true;
  dp[0][1][s[0]-'0']=true;
  repi(i,1,s.size() ){
    rep(j,4){
      rep(k,1000){
	if(dp[i-1][j][k]){
	  dp[i][j][k]=true;
	  if(j<3) dp[i][j+1][(k*10)+s[i]-'0']=true;
	}
      }
    }
  }
  int ans=0;
  rep(i,1000){
    if(dp[s.size()-1][3][i]) ans++;
  }
  cout<<ans<<endl;
 
  
  return 0;
}


Measured memory_bytes: 117504
#include <iostream>
#include <vector>
#include <cinttypes>
#include <cstring>

using namespace std;

int n;
vector<int16_t> x, y, r, c;
int8_t memo[1 << 24];

int rec(int bits) {
  int ret = 0;
  if (memo[bits] != 0) {
    return memo[bits];
  }
  vector<bool> tops(n, true);
  for (int i = 0; i < n; i++) {
    if (bits & (1 << i)) {
      continue;
    }
    for (int j = i + 1; j < n; j++) {
      if (bits & (1 << j)) {
        continue;
      }
      int distance2 = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
      if (distance2 < (r[i] + r[j]) * (r[i] + r[j])) {
        tops[j] = false;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (bits & (1 << i)) {
      continue;
    }
    if (!tops[i]) {
      continue;
    }
    for (int j = i + 1; j < n; j++) {
      if (bits & (1 << j)) {
        continue;
      }
      if (!tops[j]) {
        continue;
      }
      if (c[i] != c[j]) {
        continue;
      }
      int r = 2 + rec(bits | (1 << i) | (1 << j));
      if (r > ret) {
        ret = r;
      }
    }
  }

  return memo[bits] = ret;
}

int main() {
  while (true) {
    cin >> n;
    if (n == 0) {
      break;
    }
    x.resize(n);
    y.resize(n);
    r.resize(n);

    c.resize(n);

    for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> r[i] >> c[i];
    }

    memset(memo, 0, sizeof(memo));
    cout << rec(0) << endl;

  }

  return 0;
}

Measured memory_bytes: 19444
#include "bits/stdc++.h"
using namespace std;

bool isPrime(long long X) {
	if (X <= 1) return false;
	for (long long i = 2; i * i <= X; i++) {
		if (X % i == 0) return false;
	}
	return true;
}

int main() {
	long long X;
	cin >> X;
	for (long long Y = X; ; Y++) {
		if (isPrime(Y)) {
			cout << Y << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void counting_sort(vector<int> a,vector<int> &ans,int k);
void print_vector(vector<int> a);
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int tmp;
        cin>>a[i];
    }
    vector<int> ans(a.size());
    for(int i=0;i<ans.size();i++){
        ans[i]=-1;
    }
    int max=*std::max_element(a.begin(),a.end());
    // cout<<"max:"<<max<<"\n";
    counting_sort(a,ans,max);
    print_vector(ans);
}
void counting_sort(vector<int> a,vector<int> &ans,int k){
    // cout<<"-----sorting-----\n";
    vector<int> c(k+1);
    vector<int> offset(k+1);
    for(int i=0;i<=k;i++){
        c[i]=0;
    }
    // cout<<"----- step1 -----\n";
    for(int i=0;i<a.size();i++){
        c[a[i]]++;
    }
    // print_vector(c);
    // cout<<"----- step2 -----\n";
    offset[0]=0;
    for(int i=1;i<=k;i++){
        offset[i]=offset[i-1]+c[i-1];
    }
    // print_vector(offset);
    // cout<<"----- step3 -----\n";
    for(int i=0;i<a.size();i++){
        ans[offset[a[i]]]=a[i];
        offset[a[i]]++;
    }
    // print_vector(offset);
    // cout<<"----- sorted -----\n";
}
void print_vector(vector<int> a){
    for(int i=0;i<a.size();i++){
        cout<<a[i];
        if(i!=a.size()-1)cout<<" ";
    }
    cout<<"\n";
}


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

int main(void){
  long int N;
  std::vector<long int> count(100001,0);
  std::cin >> N;
  for(long int i=0;i<N;i++){
    long int tmp;
    std::cin>>tmp;
    count[tmp]+=1;
  }
  long int max_counts=-1;
  for(long int i=0;i<=1e5;i++){
    long int icount = 0;
    if(i==0){
      icount = count[0]+count[1];
    }else if(i==100000){
      icount = count[i-1]+count[i];      
    }else{
      icount = count[i-1]+count[i]+count[i+1];            
    }
    if(icount >=max_counts){
      max_counts=icount;
    }
  }
  std::cout << max_counts;
  return 0;
}


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

int N;
vector<int> L;

int main(){
    int ans = 0;
    cin >> N;
    L.resize(N);
    for(int i = 0; i < L.size(); ++i) cin >> L[i];
    for(int i = 0; i < L.size(); ++i){
        for(int j = i+1; j < L.size(); ++j){
            if(L[j] != L[i]){
                for(int k = j+1; k < L.size(); ++k){
                    if(L[k] != L[i] && L[k] != L[j] && L[k] < L[i] + L[j] && L[i] < L[j]+L[k] && L[j] < L[k]+L[i]) ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


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

  int ans=0;
  for(ll i=2;i*i<=N;i++){
    if(N%i!=0)  continue;
    int cnt=0;
    while(N%i==0){
      N/=i;
      cnt++;
    }
    for(int j=1;j<=cnt;j++){
      ans++;
      cnt-=j;
    }
  }
  if(N!=1)  ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3644
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    
    static char[][] grid;
    static int [][] dp_x;
    static int [][] dp_y;
    static int H;
    static int W;

    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] HW = br.readLine().split(" ");
        H = Integer.parseInt(HW[0]);
        W = Integer.parseInt(HW[1]);
        
        grid = new char[H][W];
        dp_x = new int[H][W];
        dp_y = new int[H][W];
        
        for(int i = 0; i < H; i++){
            grid[i] = br.readLine().toCharArray();
        }
        
        int max = 0; 
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if ( grid[i][j] == '.' ){
                    max = Math.max(max, dfs(i, j));
                } else if (grid[i][j] == '#' ){
                    dp_x[i][j] = -1;
                    dp_y[i][j] = -1;
                }
            }
        }
        
        System.out.println(max);
    }
    
    static int dfs(int x, int y){
        int X = 1;
        int Y = 1;
        int rx = x;
        int ry = y;
        if ( x - 1 >= 0 && dp_x[x-1][y] != -1 ){
            X = dp_x[x-1][y];
            dp_x[x][y] = dp_x[x-1][y];
        } else {
            while ( rx < H && grid[rx][y] == '.' ){
                rx++;
            }
            X = rx - x;
            dp_x[x][y] = X;
        }
        
        if ( y - 1 >= 0 && dp_y[x][y-1] != -1 ){
            Y = dp_y[x][y-1];
            dp_y[x][y] = dp_y[x][y-1];
        } else {
            while ( ry < W && grid[x][ry] == '.' ){
                ry++;
            }
            Y = ry - y;
            dp_y[x][y] = Y;
        }
        
        return X + Y - 1;
    }
}


Measured memory_bytes: 94016
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int a, b, c;
    for (int i=0; i<N; i++) {
        cin >> a >> b >> c;
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        cout << (c*c == a*a+b*b ? "YES" : "NO") << endl;
    }
    return 0;
}

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

void dfs(int s,vector<int>*adj,bool * visited,int * dp){
	visited[s] = true;
	dp[s] = 0;
	for(auto u : adj[s]){
		if(!visited[u]) dfs(u,adj,visited,dp);
		dp[s] = max(dp[s],1+dp[u]);
	}
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>adj[n];
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		adj[a].emplace_back(b);
	}
	bool visited[n];
	int dp[n];
	memset(visited,false,n);
	for(int i=0;i<n;i++){
		if(!visited[i]){
			dfs(i,adj,visited,dp);
		}
	}
	cout<<*max_element(dp,dp+n);
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

const ll md = 998244353;

ll inv(ll a, ll b = md){
	return a>1 ? b - inv(b%a, a)*b / a : 1;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	ll n, a, b, k;
	cin >> n >> a >> b >> k;

	vector<ll> fs(n+1, 1), ifs(n+1);
	rep(i,1,n+1) fs[i] = fs[i-1] * i % md;
	rep(i,0,n+1) ifs[i] = inv(fs[i]);

	auto bin = [&](int n, int k){
		if(k < 0 || k > n) return 0LL;
		return fs[n] * ifs[k] % md * ifs[n-k] % md;
	};
	ll ans = 0;

	rep(i,0,n+1){
		if( (k-i*a)%b ) continue;

		int j = (k-i*a) / b;

		ans += bin(n, i) * bin(n, j);
		ans %= md;
	}

	cout << ans << endl;
}

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

int main(void)
{
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);

  int p[200100];
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &p[i]);
  }

  int temp = 0;
  for (int i = 0; i < K; i++)
  {
    temp += p[i];
  }
  int maxP = 0;
  maxP = temp;

  int left = 0;
  int right = K;
  while (right < N)
  {
    temp = temp + p[right] - p[left];
    maxP = max(maxP, temp);
    left++;
    right++;
  }

  double result = ((double)(maxP + K)) / 2.0;
  printf("%lf\n", result);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi ans(n + 1);
    int a;
    REP(i, n - 1) {
        cin >> a;
        ans[a]++;
    }
    REP1(i, n - 1) cout << ans[i] << endl;
    cout << 0 << endl;
}


Measured memory_bytes: 3972
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
#include<stdio.h>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
double dp[200][100];//動的計画法
int main(){
    int a,b;
    while(cin>>a>>b,a){
        for(int i=0;i<a;i++){
            for(int j=0;j<a;j++){
                cin>>dat[i][j];
            }
        }
        for(int i=0;i<a;i++)dp[0][i]=1;
        for(int i=1;i<b;i++){
            for(int j=0;j<a;j++){
                double max=0;
                for(int k=0;k<a;k++){
                    if(max<dp[i-1][k]*dat[k][j]){
                        max=dp[i-1][k]*dat[k][j];
                    }
                }
                dp[i][j]=max;
            }
        }
        double ret=0;
        for(int i=0;i<a;i++){
            if(ret<dp[b-1][i])ret=dp[b-1][i];
        }
        printf("%.2lf\n",ret);
    }
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    int mx = (n - 1) * (n - 2) / 2;
    if (mx < k) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> ans;
    // 頂点nを真ん中にするスター型のツリー
    rep(i, n - 1) {
        ans.push_back(make_pair(i + 1, n));
    }
    // 追加するedgeの候補を列挙
    int add = mx - k;
    vector<pair<int, int>> edge;
    rep(i, n - 1) {
        rep(j, i) {
            edge.push_back(make_pair(i + 1, j + 1));
        }
    }
    // ansに追加
    rep(i, add) {
        ans.push_back(edge[i]);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------


int main(){
    int N=IN_int();
    vi p(N);
    rep(i,N) p[i]=IN_int();
    vi check(N);
    rep(i,N) check[i]=i+1;
    int count=0;
    rep(i,N) if(p[i]!=check[i]) count++;
    printf(count<=2?"YES":"NO");
    
    return 0;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
A_matrix = []
for i in range(n):
    tmp_row = list(map(int, input().split()))
    A_matrix.append(tmp_row)
#print(A_matrix)
B_matrix = []
for i in range(m):
    tmp_row = list(map(int,input().split()))
    B_matrix.append(tmp_row)

#print(B_matrix)
C_matrix =  [[0]*l for i in range(n)] 
for i in range(n):
    for j in range(l):
        for k in range(m):
            C_matrix[i][j] +=  A_matrix[i][k]*B_matrix[k][j]


for row in range(n):
    print(" ".join(list(map(str,C_matrix[row]))))


Measured memory_bytes: 6900
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

char A[200000];
int group[200000];
vector<int> index_list[26];

signed main()
{
	cin >> A;
	int len = strlen(A);

	int cnt = 0;
	int g = 0;

	bool flg[26] = {};
	for (int i = len - 1; i >= 0; i--)
	{
		char n = A[i] - 'a';
		index_list[n].push_back(i);
		if (!flg[n])
		{
			cnt++;
		}
		flg[n] = true;
		group[i] = g;
		if (cnt == 26)
		{
			memset(flg, 0, sizeof(flg));
			cnt = 0;
			g++;
		}
	}

	for (int c = 0; c < 26; c++)
	{
		REVERSE(index_list[c]);
	}

	string ans = "";
	int index = -1;

	for (int i = g; i >= 0; i--)
	{
		for (int c = 0; c < 26; c++)
		{
			auto it = UPPER_BOUND(index_list[c], index);
			if (i > 0)
			{
				int n = *it;
				int gg = group[n];
				if (gg == i - 1)
				{
					ans += (char)(c + 'a');
					index = n;
					break;
				}
			}
			else
			{
				if (it == index_list[c].end())
				{
					ans += (char)(c + 'a');
					break;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<ll> asum(N + 1);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        asum[i + 1] = asum[i] + a;
    }

    vector<vector<ll>> dp(N + 3, vector<ll>(N + 3, 1e15));
    for (int i = 0; i <= N; ++i) {
        for (int l = 0; l <= N - i; ++l) {
            int r = l + i;
            if (r - l < 2) {
                dp[l][r] = 0;
                continue;
            }
            ll tmp = asum[r] - asum[l];
            for (int mid = l; mid <= r; ++mid)
                dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid][r] + tmp);
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}


Measured memory_bytes: 1536
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&x)

	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i + 100*j + 50*k == x {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<String> said = new List<String>();
            char last_char = 'a';
            string output = "Yes";
            string[] word = new string[N];
            for (int i = 0; i < N; i++)
            {
                word[i] = Console.ReadLine();

            }

            for (int i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    last_char = word[i][0];
                }
                if (word[i][0] != last_char)
                {
                    output = "No";
                    break;
                }
                if (said.Contains(word[i]))
                {
                    output = "No";
                    break;
                }
                said.Add(word[i]);
                last_char = word[i][word[i].Length - 1];
            }
            Console.WriteLine(output);
            
        }

    }
}


Measured memory_bytes: 13024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int dp[101][100002];
int n;
vector<int> a;
 
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);cout.tie(NULL);
	int k;
  	ll mod=1e9+7;
	cin>>n>>k;
	a.resize(n);
 
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	dp[0][0] = 1;
	for(int i=1;i<=n;++i){
		vector<int> ps(k+1);
		ps[0] = 1;
		for(int j=1;j<=k;++j)
			ps[j] = (dp[i-1][j]+ps[j-1])%mod;
		for(int j=0;j<=k;++j){
			dp[i][j] = ps[j];
			if(j-a[i-1]>0){
				dp[i][j] = (mod-ps[j-a[i-1]-1]+dp[i][j])%mod;
			}
		}
	}
	cout<<dp[n][k];
	return 0;
}

Measured memory_bytes: 39676
// WeirdBugsButOkay

#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
using namespace std;

ll pow3(ll a,ll b,ll m=1000000007)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

void solve()
{
    ll n,k;
    cin>>n>>k;
    n=n%k;
    ll ans=min(n,k-n);
    cout<<ans<<endl;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q=1;
    //cin>>q;
    for(ll i=0;i<q;i++)
    {
        solve();
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  int size = 1;
  
  for (int i = 0; i <= N - 2; i++) {
    if (d.at(i) < d.at(i + 1)) size++;
  }
  cout << size;
}

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

int main(){
  int n;
  int i;
   while(scanf("%d",&n)!=EOF){

    if(n==0)break;
    
      int m = (int)sqrt(n);
      int s = 0;

      for(i=1;i<=m;i++){
        if(n%i==0){
          s += i ;
          //printf("s1 =  %d\n",s);
          s += (n/i);
          //printf("s2 =  %d\n",s);
        }
      }


       if(n==m*m){s-=m;}

        s -= n;
        //printf("s4 =  %d\n",s);

      
    //printf("s =  %d\n",s);
      if(s<n){printf("deficient number\n");}
      else if(s==n){printf("perfect number\n");}
      else{printf("abundant number\n");}
   }
   return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int days = Integer.parseInt(sc.next());
    int[][] action = new int[days][3];
    int[][] happiness = new int[days+1][3];
    for(int i = 0; i <= days; i++) {
      for(int j = 0; j < 3; j++) {
        happiness[i][j] = 0;
      }
    }
    for(int i = 0; i < days; i++) {
      for(int j = 0; j < 3; j++) {
        action[i][j] = Integer.parseInt(sc.next());
      }
    }
    for(int i = 0; i < days; i++) {
      for(int j = 0; j < 3; j++) {
        for(int k = 0; k < 3; k++) {
          if(j == k) continue;
          happiness[i+1][j] = Math.max(happiness[i+1][j], happiness[i][k] + action[i][j]);
        }
      }
    }
    int answer = maxThree(happiness[days][0], happiness[days][1], happiness[days][2]);
    System.out.println(answer);
  }

  public static int maxThree(int a, int b, int c) {
    int ans = a;
    if(ans < b) ans = b;
    if(ans < c) ans = c;
    return ans;
  }
}


Measured memory_bytes: 70896
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
k,x = map(int, input().split())


for i in range(x-k+1,x+k):
    if i >= -1000000 and i <= 1000000:
        print(i,end=" ")

print("")




Measured memory_bytes: 18624
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int[] read = inta();
        WriteLine(lcm(read[0],read[1]));
        
        
        
        
        
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long gcd(long big,long small){
        if(big < small){
            long temp = big;
            big = small;
            small = temp;
        }
        if(big % small == 0){
            return small;
        }else{
            big %= small;
            return gcd(small,big);
        }
    }
    static long lcm(long big,long small){
        long temp = big * small;
        long gcds = gcd(big,small);
        temp /= gcds;
        return temp;
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(a <= c && a + b >= c ? "YES" : "NO");
	}
}

Measured memory_bytes: 22740
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int **line;
    line=new int*[n];
    for(int i=0;i<n;++i){
        line[i]=new int[2]{0};
        cin>>line[i][0];
    }
    for(int i=0;i<m;++i){
        int d;
        cin>>d;
        int place=0;
        while(d<line[place++][0]);
        ++line[place-1][1];
    }
    int ans[2];
    ans[0]=0;
    for(int i=0;i<n;++i){
        if(line[i][1]>ans[0]){
            ans[0]=line[i][1];
            ans[1]=i;
        }
    }
    cout<<ans[1]+1<<endl;
    return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll, pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 5;
ll i,a,j,k,n,b,ans;
ll fact[N], s[N], arr[N];
ll ncr(ll n,ll r)
{
    if(n < r) return 0;
    return ((fact[n] * modexp(fact[n - r], mod - 2)) % mod * modexp(fact[r], mod - 2)) % mod;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    fact[0] = 1;
    rep(i,1,N) fact[i] = (fact[i - 1] * i) % mod;
    cin>>n>>k;
    rep(i,1,n + 1) cin>>arr[i];
    sort(arr + 1,arr + n + 1);
    rep(i,1,n + 1) s[i] = (s[i - 1] + arr[i]) % mod;
    for(i = k;i <= n;i += 1){
        j = n - i + 1;
        b = s[n] - s[i - 1];
        a = s[j];
        ans = (ans + (ncr(i - 2, k - 2) * ((b - a + mod) % mod)) % mod) % mod; 
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
def mi():
    return map(int, input().split())

def main():
    S = input()
    if S[0] != 'A':
        print('WA')
        return

    if S[2:-1].count('C') != 1:
        print('WA')
        return

    if S[0].replace('A', 'a')+S[1]+S[2:-1].replace('C', 'c')+S[-1:] != S.lower():
        print('WA')
        return

    print('AC')

if __name__ == '__main__':
    main()

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

long long N;
long long C;
priority_queue<pair<long long, long long>,
		vector<pair<long long, long long> >,
		greater<pair<long long, long long> > >ST[33];

int main(){
	cin >> N >> C;
	for(long long i = 0; i < N; i++){
		long long tmps, tmpt, tmpc;
		cin >> tmps >> tmpt >> tmpc;
		tmpc--;
		ST[tmpc].push(make_pair(tmps, tmpt));
	}

	long long ans = 0;
	for(long long i = 1; i <= 100000; i++){
		long long num = 0;
		for(long long j = 0; j < 30; j++){
			if(ST[j].size() > 0){
				if(ST[j].top().first <= i){
					num++;
				}
			}
		}
		ans = max(ans, num);


		for(long long j = 0; j < 30; j++){
			if(ST[j].size() > 0){
				if(i == ST[j].top().second){
					ST[j].pop();
				}
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 2688
k=gets.to_i
h={}
s=0
f=->x{
  h[x]||=(1..k).reduce(0){|t,i|
    t+x.gcd(i)
  }
}
(1..k).each{|a|
  s+=f[a]
  (a+1..k).each{|b|
    g=a.gcd(b)
    s+=f[g]*2
  }
}
puts s


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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B - A > X) {
        cout << "dangerous" << endl;
    }
    else if (B - A > 0) {
        cout << "safe" << endl;
    }
    else {
        cout << "delicious" << endl;
    }
}

Measured memory_bytes: 384
import math
a, b, x = map(float,input().split())
y = x / a
if y < a * b / 2:
    t = math.atan(b*b/y/2)
else:
    t = math.atan((a*b-y)/ (a*a) * 2)
print (t / math.pi  * 180)


Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <string>
#include <memory.h>
#include <bitset>
#include <stack>
#include <assert.h>
using namespace std;
#define ll long long
#define ppi pair<int, int>
#define mp make_pair
#define inf 2e16
const int N = 2e5 + 11, K = 20 , S = 1e3 + 11;
const int mod = 1e9 + 7;
ll dp[N][101];
int weg[N], v[N];
void clear()
{
	for (int i = 0; i < N; i++)
		for (int j = 0; j < 101; j++)
			dp[i][j] = inf;
}
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("inp.txt", "r", stdin);
#endif
	clear();
	int n , w;
	cin >> n >> w;
	for (int i =0 ; i < n ; i++)
		scanf("%d%d", weg + i, v + i);
	int mx = (w >= weg[0] ? v[0] : 0);
	dp[v[0]][0] = weg[0];
	for (int i = 1; i < n; i++)
	{
		dp[v[i]][i] = weg[i];
		for (int j = 0; j < N; j++)
		{
			dp[j][i] = min(dp[j][i], dp[j][i - 1]);
			if (j >= v[i]) 
			{
				dp[j][i] = min(dp[j][i], dp[j - v[i]][i - 1] + weg[i]);
			}
			if (dp[j][i] <= w)
			{
				mx = max(mx, j);
			}
		}
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 158080
n = int(input())
arr = []
for i in range(0, n):
	arr.append(list(map(str, input().split())))

# print(arr)
a, b = 0, 0
for s in arr:
	if s[0] > s[1]:
		a += 3
	elif s[0] == s[1]:
		a += 1
		b += 1
	elif s[0] < s[1]:
		b += 3

print('{0} {1}'.format(a, b))



Measured memory_bytes: 5604
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
double fie[51][10101]={1};
int main(){
    while(1){
        int X,Y,Z;
        int V[6];
        int E[53][2]={0};
        for(int i=0;i<51;i++){
            for(int j=0;j<10101;j++){
                fie[i][j]=0;
            }
        }
        fie[0][0]=1;
        cin>>X>>Y>>Z;
        if(X==0&&Y==0&Z==0)break;
        for(int i=0;i<X;i++)cin>>V[i];
        for(int i=0;i<Z;i++){
            int a,b,c;
            cin>>a>>b>>c;
            E[a][0]=b,E[a][1]=c;
        }
        for(int i=0;i<Y;i++){
            for(int j=0;j<=5000;j++){
                for(int k=0;k<X;k++){
                    if(Y<=i+V[k]||(E[i+V[k]][0]==1&&Y<=i+V[k]+E[i+V[k]][1]))fie[Y][j]+=fie[i][j]/X;
                    else if(E[i+V[k]][0]==0)fie[i+V[k]][j]+=fie[i][j]/X;
                    else if(E[i+V[k]][0]==1)fie[i+V[k]+E[i+V[k]][1]][j]+=fie[i][j]/X;
                    else if(E[i+V[k]][0]==2)fie[i+V[k]][j+E[i+V[k]][1]]+=fie[i][j]/X;
                    else if(E[i+V[k]][0]==3)fie[i+V[k]][max(0,j-E[i+V[k]][1])]+=fie[i][j]/X;
                }
            }
        }
        double ans=0;
        for(int i=0;i<=5100;i++)ans+=fie[Y][i]*i;
        cout<<(int)ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 5184
#include <cstddef>
#include <limits>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstdlib>
#include <new>
#include <typeinfo>
#include <exception>
#include <initializer_list>
#include <stdexcept>
#include <cassert>
#include <cerrno>
#include <system_error>
#include <string>

#if __has_include(<string_view>)
#   include <string_view>
#endif

#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>

#if __has_include(<filesystem>)
#   include <filesystem>
#endif

#include <cstdio>
#include <cinttypes>


#include <regex>
#include <atomic>
#include <thread>
#include <mutex>
#include <shared_mutex>
#include <condition_variable>
#include <future>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i,N) cin >> P[i];
  int ans = 0;
  int curmin = 1e9;
  rep(i,N){
    curmin = min(curmin,P[i]);
    if(curmin == P[i]) ans++;
  }
  cout << ans << endl;























}


Measured memory_bytes: 1024