akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}


const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);


int main(){
    ll n,k;cin >> n >> k;
    rep(i,k){
        cout << comb(n-k+1,i+1)*comb(k-1,i) <<endl;
    }
}

Measured memory_bytes: 3328
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n>=m:
    print(0)
else:
    x.sort()
    y=[0 for _ in range(len(x)-1)]
    for i in range(len(x)-1):
        y[i]=x[i+1]-x[i]
    y.sort(reverse=True)
    ans=0
    for i in range(n-1):
        ans+=y[i]-1
    print(max(x)-min(x)+1-n-ans)



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

int main()
{
	int n,c;
	int h[100005];
	int dif;
	while(cin>>n>>c)
	{
		dif=1000000001;
		for(int i=0;i<n;i++)
		{
			cin>>h[i];
		}
		sort(h,h+n);
		for(int i=c-1;i<n;i++)
		{
			dif=min(dif,h[i]-h[i-c+1]);
		}
		cout<<dif<<endl;
	}
	return 0;
}

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

const int INF = 10000000;
int main(){
  int n,p[15];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  
  int res = -INF;                     // ここをマイナス INF に
  for (int i = 0; i < n; ++i) {
        if (res < p[i]) res = p[i]; // さっきと不等号の向きが反対に
  }
  int wa = 0;
  for(int i = 0; i < n; i++){
    wa = wa + p[i];
  }
  
  cout <<  wa-res/2 << endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    A,B = map(int, input().split())
    uf.union(A-1,B-1)
ans = 0
for i in range(N):
    ans = max(ans,uf.size(i))

print(ans)

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

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;
int n,m,x,y,mx = 400000000,cnt,sum,c,a;
set <int> st;
vector <bool> v;
string s;
const double P = acos(-1.0);
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("collect.in", "r", stdin);
    //freopen("collect.out", "w", stdout);
    cin >> n >> m;
    x = (n * (n + 1) / 2 - n);
    y = (m * (m + 1) / 2 - m);
    cout << x + y;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
last = np.zeros(26, dtype=np.int32)
# print(s)
# print(s.shape)

ans = []
point = 0
for i in range(D):
    down = (i+1-last)*c
    loss = down + s[i,:]*3
    idx = np.argmax(loss)
    ans.append(idx+1)
    point += s[i, idx] - down.sum()
    last[idx] = i+1
    # print(loss)

for i in range(D):
    print(ans[i])

Measured memory_bytes: 27568
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<cstring>
using namespace std;
typedef long long int ll;
const int MAX=20000;
class disjointset
{
public:
	vector<int> rank;
	vector<int> p;
	
	void makeset(int x)
	{
		p[x]=x;
		rank[x]=0;
		return;
	}
	disjointset(int s)
	{
		rank.resize(s);
		p.resize(s);
		for(int i=0;i<s;i++)makeset(i);
		return;
	}
	int findset(int x)
	{
		if(x!=p[x])p[x]=findset(p[x]);
		return p[x];
	}
	void link(int x,int y)
	{
		if(rank[x]>rank[y])p[y]=x;
		else
		{
			p[x]=y;
			if(rank[x]==rank[y])rank[y]++;
		}
		return;
	}
	bool same(int x,int y)
	{
		return findset(x)==findset(y);
	}
	void unite(int x,int y)
	{
		link(findset(x),findset(y));
		return;
	}
};

int V;

int main()
{
	int k,l;
	cin>>V>>k>>l;
	disjointset d1=disjointset(V);
	int u,v;
	for(int i=0;i<k;i++)
	{
		cin>>u>>v;
		u--;v--;
		d1.unite(u,v);
	}
	disjointset d2=disjointset(V);
	for(int i=0;i<l;i++)
	{
		cin>>u>>v;
		u--;v--;
		d2.unite(u,v);
	}
	map<pair<int,int>,int> m;
	for(int i=0;i<V;i++)
	{
		m[make_pair(d1.findset(i),d2.findset(i))]++;
	}
	for(int i=0;i<V;i++)
	{
		if(i)cout<<" ";
		cout<<m[make_pair(d1.findset(i),d2.findset(i))];
	}
	return 0;
}


Measured memory_bytes: 15104
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  int group[H][W];
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      group[i][j] = -1;
    }
  }
  queue<pair<int, int> > que;
  pair<int, int> state;
  int tmpgroup = 0;
  int x, y;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(group[i][j]==-1) {
        que.push(mp(i, j));
        while(!que.empty()) {
          state = que.front();que.pop();
          x = state.fi;
          y = state.se;
          if(group[x][y]>-1) continue;
          group[x][y] = tmpgroup;
          if(x>0 && S[x-1][y]!=S[x][y] && group[x-1][y]==-1) que.push(mp(x-1, y));
          if(y>0 && S[x][y-1]!=S[x][y] && group[x][y-1]==-1) que.push(mp(x, y-1));
          if(x<H-1 && S[x+1][y]!=S[x][y] && group[x+1][y]==-1) que.push(mp(x+1, y));
          if(y<W-1 && S[x][y+1]!=S[x][y] && group[x][y+1]==-1) que.push(mp(x, y+1));
        }
        tmpgroup++;
      }
    }
  }
  map<int, ll> white, black;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(S[i][j]=='.') white[group[i][j]]++;
      else black[group[i][j]]++;
    }
  }
  ll ans = 0;
  for(int i=0;i<tmpgroup;++i) ans += black[i]*white[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 21800
#include <iostream>
#include <queue>
#include <vector>


int n, quantum;

std::queue < std::pair<std::string, int> > que;
std::vector< std::pair<std::string, int> > v;


void solve() {
    int total_time = 0;
    while ( !que.empty() ) {
        int time = quantum;
        while (time > 0 && !que.empty()) {
            std::pair<std::string, int> f = que.front();
            que.pop();
            if (time >= f.second) {
                time = 0;
                total_time += f.second;
                v.push_back( std::make_pair(f.first, total_time) );
            } else { // time < f.second
                total_time += time;
                que.push( std::make_pair(f.first, f.second - time) );
                time = 0;
            }
        }
    }
    
    std::vector< std::pair<std::string, int> >::iterator itr = v.begin();
    while (itr != v.end()) {
        std::cout << itr->first << ' ' << itr->second << std::endl;
        ++itr;
    }
}


int main() {
    std::cin >> n >> quantum;
    for (int i=0; i<n; i++) {
        std::string p;
        int time;
        std::cin >> p >> time;
        // std::cin.ignore();
        que.push( std::make_pair(p, time) );
        // std::cout << "PROCESS :" << p << ", TIME :" << time << std::endl;
    }
    
    solve();

    return 0;
}



Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll n,k;cin >>n>>k;
    ll now=1;
    for (int i = 0; i < n; ++i) {
        now=min(now+k,now*2);
    }
    cout <<now<<endl;
}



Measured memory_bytes: 3624
/* AtCoder Beginner Contest abc139
 * Problem E
 * Au: SJoshua
 */
#include <bits/stdc++.h>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector <queue <int>> order(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++) {
			int p;
			cin >> p;
			order[i].emplace(p);
		}
	}
	unordered_set <int> list;
	for (int i = 1; i <= n; i++) {
		// cout << "[" << order[i].front() << "] " << order[order[i].front()].front() << endl;
		if (i == order[order[i].front()].front()) {
			list.emplace(i);
		}
	}
	int cnt = 0;
	for (int day = 1; ; day++) {
		// cout << "day " << day << endl;
		unordered_set <int> next;
		for (auto e: list) {
			// cout << "battle: " << e << endl;
			order[e].pop();
			cnt++;
		}
		auto safe_front = [&](int id) {
			if (order[id].empty()) {
				return 0;
			} else {
				return order[id].front();
			}
		};
		for (auto e: list) {
			int k = safe_front(e);
			// cout << "battled " << e << " 's front is " << k << " now. " << endl;
			if (k && k == safe_front(safe_front(k))) {
				next.emplace(k);
				next.emplace(safe_front(k));
			}
		}
		list = next;
		if (list.empty()) {
			if (cnt == n * (n - 1)) {
				cout << day << endl;		
			} else {
				cout << -1 << endl;
			}
			break;
		}
	}
	return 0;
}


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

#define int long long
#define f first

#define s second
using namespace std;

template<typename T> using vc = vector<T>;
using pii=pair<int, int>;

void xmax(int & a, int b){
    a=max(a, b);
}
void xmin(int& a, int b){
    a=min(a, b);
}

void print(vc <int> & a, string s){
    cerr << s << " : ";
    for (int i=0; i<a.size(); i++){
        cerr <<a[i] << " ";
    }
    cerr << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL_RUN
    freopen("input.txt", "r", stdin);
    int ttt;
    cin >> ttt;
    while(ttt--){
    #endif // LOCAL_RUN
    int n, r;
    cin >> n >> r;
    if (n>=10){
        cout << r << "\n";
    }else{
        cout << r + 100*(10-n) << "\n";
    }


    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=1e6+50;
int prime[maxn];
bool sf[maxn];
int cnt[maxn];
int num=0;
void sushu(){
    memset(sf,true,sizeof(sf));
    for(int i=2;i<=maxn;i++){
        if(sf[i]) prime[++num]=i;
        for(int j=1;j<=num;j++){
            if(i*prime[j]>maxn) break;
            sf[i*prime[j]]=false;
            if(i%prime[j]==0) break;
        }
    }
    sf[1]=false;
    sf[0]=false;  //1 0 特判
}
int main()
{
    memset(cnt,0,sizeof cnt);
    sushu();
    ll n,x;
    scanf("%lld",&n);
    x=sqrt(n);
    ll res=0;
    for(int i=1;prime[i]<x&&i<=n;i++){
        if(n%prime[i]==0){
            while(n%prime[i]==0){
                cnt[i]++;
                n/=prime[i];
            }
            int j=1;
            while(cnt[i]>=j){
                cnt[i]-=j++;
                res++;
            }
        }
    }
    if(n!=1)
        res++;
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
 
long long  gcd(long long a, long long b) {
  return b ? gcd(b, a%b) : a;
}
 
int main(){
  long long A, B;
  cin >> A >> B;
  
  cout << A * B / gcd(A, B) << endl; 
 
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}


int main() {
	llint n,k;
	cin >> n>>k;
	hei(Pint) a(n);
	rep(i, 0, n)cin >> a[i].first>>a[i].second;
	sort(a.begin(), a.end());
	llint x = 0;
	rep(i, 0, n) {
		x += a[i].second;
		if (x >= k) {
			cout << a[i].first << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    Int ans = 0;
    map<int, Int> lef;
    map<int, Int> rig;
    rep(i,n) {
        lef[i + a[i]]++;
        rig[i - a[i]]++;
    }
    for(auto itr = lef.begin(); itr != lef.end(); itr++) {
        ans += itr->second * rig[itr->first];
    }
    cout << ans << endl;
}

Measured memory_bytes: 38624
#include<stdio.h>
int main()
{
    long long int x,y,i,p;
    scanf("%lld %lld",&x,&y);
    for(i=2;;i++)
    {
        if(x==0)
        {
            printf("0\n");
            break;
        }
        if(y==0)
        {
            printf("%lld\n",x);
            break;
        }
        if(x==y||x%y==0)
        {
            printf("-1\n");
            break;
        }
        p=x*i;
        if(p%y!=0)
        {
            printf("%lld\n",p);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 long l,r;
  cin >> l >> r;
            
  
   if(r-l+1<2019){
  
     long res=2018*2018;
    for(long i=0;i<r-l;i++) {
      for(long j=i+1;j<r-l+1;j++){
       res=min(res,((l+i)*(l+j))%2019); 
      }
       }
      cout << res << endl;
       
   }
  
   else{
    cout << 0 << endl;
   }
  
  
}

Measured memory_bytes: 256
x, y = map(int,input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if (x in a) and (y in a):
    print('Yes')
elif (x in b) and (y in b):
    print('Yes')
else:
    print('No')

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

using namespace std;

int tab[3007][3007];

void LCS(string a, string b)
{
    int x=a.size();
    int y=b.size();
    for(int i=1;i<=x;i++)
    {
        for(int j=1;j<=y;j++)
        {
            if(a[i-1]==b[j-1])
            {
                tab[i][j]=tab[i-1][j-1]+1;
            }
            else
            {
                tab[i][j]=max(tab[i-1][j],tab[i][j-1]);
            }
        }
    }
    vector<char>v;
    while(x>0 || y>0)
    {
        if(x > 0 && tab[x][y] == tab[x-1][y])
        {
            x--;
        }
        else if(y > 0 && tab[x][y] == tab[x][y-1])
        {
            y--;
        }
        else if(x >0 && y > 0 && tab[x][y] == tab[x-1][y-1]+1)
        {
            v.push_back(a[x-1]);
            x--;
            y--;
        }
        else
        {
            break;
        }
    }
    for(int i=v.size()-1; i>=0; i--)
        cout << v[i];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string a,b;
    cin >> a >> b;
    LCS(a,b);
}

Measured memory_bytes: 35584
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val N = readLine().toInt
    val SP: Array[(Int, (String, Int))] = (0 until N). map { i =>
      val Array(s, p) = readLine().split(" ")
      (i+1, (s, p.toInt))
    }. toArray. sortBy(_._2)(Ordering.Tuple2(Ordering.String, Ordering.Int.reverse))

    // 市名を辞書順, 同じ市に複数レストラン
    SP.map(_._1).foreach(println)
  }
}

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

int main(){
  int n;
  int b,f,r,v;
  //??\?±??????°???????¬??????????
  int numbers[4][3][10] = {};

  cin >> n;

  //0???????????????????????????????????\?±??????°?????\???????????????
  for (int x = 1; x<=n; x++){
    cin >> b >> f >> r >> v;
    numbers[b-1][f-1][r-1] += v;
  }

  for (int i = 0; i<4; i++){
    for (int j = 0; j<3; j++){
      for (int k = 0; k<10; k++){
        cout << " " << numbers[i][j][k];
      }
      if (j != 2) {
        cout << endl;
      }
    }
    if (i != 3){
      cout << endl << "####################" << endl;
    }
    else cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		StringBuilder ss = new StringBuilder();
		for (int i = 0; i < s.length(); i += 2) {
			ss  = ss.append(s.charAt(i));
		}
		System.out.println(ss);
	}
}


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

int n, a[2005], d[2005][2005][2];
int f(int p, int q, int w) {
	if(d[p][q][w] != -1) return d[p][q][w];
	int k = max(p, q);
	if(k == n+1) return abs(a[p] - a[q]);
	if(p == 0) return d[p][q][w] = f(k+1, q, 0);
	if(w == 0) return d[p][q][w] = max(f(k+1, q, 0), f(p, k+1, 1));
	else return d[p][q][w] = min(f(k+1, q, 0), f(p, k+1, 1));
}

int main() {
	cin>>n>>a[0]>>a[1];
	for(int i=2; i<n+2; i++) scanf("%d", &a[i]);
	memset(d, -1, sizeof(d));
	cout<<f(0, 1, 0);
	return 0;
}

Measured memory_bytes: 31744
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int Sint = int.Parse(input[0]);
        int Wint = int.Parse(input[1]);
        string result = "unsafe";
        if(Wint >= Sint)
		{
            result = "unsafe";
		}
		else
		{
            result = "safe";
		}

        
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 27524
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n;cin>>n;
  set<char>se;
  rep(i,0,n){
    char c;cin>>c;
    se.insert(c);
  }
  if(se.size()==3)out("Three")
  else if(se.size()==4)out("Four")

  return 0;
}


Measured memory_bytes: 256
a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections

# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    # divisorsを使い回せるようにする。
    #   - 二度生成した場合にかかる時間が許容できない場合
    #   - エラトステネスの篩などで素数テーブルを既に持っている場合
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        # divisorsを引数で与えた場合のみ起こりうる
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

#divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
#small_factors = set(prime_factorization(small, divisors))
#big_factors = set(prime_factorization(big, divisors))
small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))

print(len(small_factors.intersection(big_factors)) + 1)


Measured memory_bytes: 116208
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    string s;cin>>s;
    ll n =s.length();
    ll ans =n*(n-1)/2;
    map<char,ll>m;
    rep(i,n){
        m[s[i]]++;
    }
    for(auto x:m){
        ll y =x.second;
        ans-=y*(y-1)/2;
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 3712
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
cnt=0
maxa=max(a)
while 2**cnt<2*maxa:
    cnt+=1
    # print(2**cnt)

lsta=[0]*n
for i in range(1,cnt+1)[::-1]:
    dic=defaultdict(list)
    for j in range(n):
        if 2**i>a[j] and lsta[j]==0:
            if dic[a[j]]!=[]:
                lsta[j]=-1
                lsta[dic[a[j]].pop()]=-1
            else:
                dic[2**i-a[j]].append(j)
    # print(dic)
# print(lsta)
ans=-sum(lsta)//2
print(ans)

Measured memory_bytes: 192652
local h,w=io.read("n","n")
local a={}
for i=1,h do
    a[i]={}
    for j=1,w do
        a[i][j]=io.read("n")
    end
end

local bit=require("bit")
local operation={}
for i=1,h do
    for j=1,w do
        if bit.band(a[i][j],1)>0 then
            if j<w then
                a[i][j+1]=a[i][j+1]+1
                a[i][j]=a[i][j]-1
                table.insert(operation,{i,j,i,j+1})
            elseif i<h then
                a[i+1][j]=a[i+1][j]+1
                a[i][j]=a[i][j]-1
                table.insert(operation,{i,j,i+1,j})
            end
        end
    end
end

local n=#operation
print(n)
for i=1,n do
    print(table.concat(operation[i]," "))
end

Measured memory_bytes: 20116
using System;
using System.Collections.Generic;
using System.Linq;

class G
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		// 多重辺および自己ループを除去。
		var es = new int[h[1]].Select(_ => Read()).Select(e => (v0: e[0], v1: e[1])).Where(e => e.v0 != e.v1).Distinct().ToArray();

		var map = Array.ConvertAll(new int[n], _ => new List<int>());
		var map_r = Array.ConvertAll(new int[n], _ => new List<int>());
		foreach (var (v0, v1) in es)
		{
			map[v0].Add(v1);
			map_r[v1].Add(v0);
		}

		var u = new bool[n];
		var order = new int[n];
		var c = n;
		var gs = new List<List<int>>();
		List<int> lg = null;

		void Dfs(int v)
		{
			u[v] = true;
			foreach (var nv in map[v]) if (!u[nv]) Dfs(nv);
			order[--c] = v;
		}
		for (int v = 0; v < n; v++) if (!u[v]) Dfs(v);

		void Dfs_r(int v)
		{
			u[v] = true;
			foreach (var nv in map_r[v]) if (!u[nv]) Dfs_r(nv);
			lg.Add(v);
		}
		Array.Clear(u, 0, n);
		foreach (var v in order) if (!u[v]) { gs.Add(lg = new List<int>()); Dfs_r(v); }

		Console.WriteLine(gs.Count);
		Console.WriteLine(string.Join("\n", gs.Select(g => string.Join(" ", g.Prepend(g.Count)))));
	}
}


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

    int N, C;
    cin >> N >> C;

    vector<vector<int>> v(31, vector<int>(100005, 0));
    FOR(i, 0, N) {
        int s, t, c;
        cin >> s >> t >> c;

        v[c][s] += 1;
        v[c][t] -= 1;
    }

    FOR(c, 0, v.size()) {
        FOR(i, 0, v[c].size() - 1) {
            v[c][i + 1] += v[c][i];
        }
    }
    FOR(c, 0, v.size()) {
        FOR(i, 0, v[c].size() - 1) {
            if (v[c][i] == 0 and v[c][i + 1] == 1) {
                v[c][i] = 1;
            }
        }
    }

    int ans = 0;
    FOR(i, 0, v[0].size() - 1) {
        int t = 0;
        FOR(c, 0, v.size()) {
            t += v[c][i];
        }
        ans = max(ans, t);
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 12800
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x/GCD(x,y)*y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{

int N,M,C;
cin >> N >> M >> C;

vector<vector<int> > A(N,vector<int>(M));
vector<int> B(M);

rep(i,M) cin>>B[i];
rep(i,N) rep(j,M) cin>>A[i][j];

int k=0;

rep(i,N) {
int S=0;
rep(j,M) S+=A[i][j]*B[j];
if(S+C>0){++k;}
}

cout<<k<<endl;

}

Measured memory_bytes: 256
import bisect
x=int(input())
a=[1]
b=2
i=2
while b<=997:
    while b**i<=1000:
        a.append(b**i)
        i+=1
    b+=1
    i=2
a=sorted(list(set(a)))
print(a[bisect.bisect(a,x)-1])

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

int n, M[100][100];

int prim()
{
	int i,u,v,min_v,sum;
	int d[100],p[100],c[100];
	
	for(i=0;i<=n-1;i++)
	{
		d[i]=(1<<21);
		p[i]=-1;
		c[i]=0;
	}
	
	d[0]=0;
	
	while(1)
	{
		min_v=(1<<21);
		u=-1;
		for(i=0;i<=n-1;i++)
		{
			if(min_v > d[i] && c[i] != 2)
			{
				u=i;
				min_v=d[i];
			}
		}
		if(u==-1) break;
		c[u]=2;
		for(v=0;v<=n-1;v++)
		{
			if(c[v] != 2 && M[u][v] != (1<<21))
			{
				if(d[v] > M[u][v])
				{
				    d[v]=M[u][v];
				    p[v]=u;
				    c[v]=1;
				}
			}
		}
	}
	sum=0;
	for(i=0;i<=n-1;i++)
	{
		if(p[i] != -1) sum+=M[i][p[i]];
	}
	return sum;
}

int main()
{
	int i,j,e;
	cin >> n;
	
	for(i=0;i<=n-1;i++)
	{
		for(j=0;j<=n-1;j++)
		{
			cin >> e;
			if(e == -1) M[i][j]=(1<<21);
			else M[i][j]=e;
		}
	}
	
	cout << prim() << endl;
	return 0;
}

Measured memory_bytes: 3108
import sys
input = sys.stdin.readline
N=int(input())
s=[input().strip() for i in range(N)]
M=int(input())
t=[input().strip() for i in range(M)]
from collections import defaultdict
a=defaultdict(int)
for i in range(N):
    a[s[i]]+=1
for i in range(M):
    a[t[i]]-=1
print(max(0,max(a.values())))


Measured memory_bytes: 38384
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int main ()
{
  int n ;
  cin >> n ;
  cout << n /3 <<"\n";

  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, int> DIP;
typedef pair<DIP, P> PP;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int n, l[10], a[3];

int rec(int i, int m, vector<int> &v){
    int res = IINF;
    if(m==0){
        int tmp = 0;
        REP(j,3) tmp += abs(a[j]-v[j]);
        tmp += (i-3)*10;
        res = min(res, tmp);
    }
    if(i>=n) return res;
    else{
        v.push_back(l[i]);
        res = min(res, rec(i+1,m-1,v));
        v.pop_back();
        if(m<3){
            v.back() += l[i];
            res = min(res, rec(i+1,m,v));
            v.back() -= l[i];
        }
    }
    return res;
}

int main() {
    cin >> n;
    REP(i,3) cin >> a[i];
    REP(i,n) cin >> l[i];
    sort(a,a+3);
    sort(l,l+n);
    int ans = IINF;
    vector<int> v;
    while(1){
        ans = min(ans, rec(0,3,v));
        if(!next_permutation(l,l+n))break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void)
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >>  x2 >> y2;
    cout << setprecision(10) << sqrt(pow(x1-x2, 2) + pow(y1-y2, 2)) << endl;
    return 0;
}



Measured memory_bytes: 3268
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int A, B, C, D;
	int E[3];
	int N, M;
	int Ans;

	cin >> A >> B >> C;

	E[0] = abs(A - B);
	E[1] = abs(B - C);
	E[2] = abs(A - C);

	sort(E, E + 3);

	cout << E[0]+E[1];

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 777777753
using namespace std;
typedef long long ll;

int main(){
  string s = "Christmas";
  int N; cin >> N;
  rep(i, 0, 25-N){
    s += " Eve";
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int N, M;

signed main(){
	cin >> N >> M;
	cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}

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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> n;

    if(n % 10 == 3)
    {
        cout << "bon" << endl;
    }
    else if( n% 10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
    {
        cout << "pon" <<endl;
    }
    else
    {
        cout << "hon" <<endl;
    }
    


    //cout << 0 << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
l = list(map(int, input().split()))
a, b, c = 0, 0, 0

for i in l:
    if i % 4 == 0:
        c += 1
    elif i % 2 == 0:
        b += 1
    elif not i % 2 == 0:
        a += 1

if b >= 1:
    if c >= a:
        print("Yes")
    else:
        print("No")
else:
    if c+1 >= a:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15020
import itertools

N, M, Q = map(int, input().split())

A = []
B = []
C = []
D = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

l = [i+1 for i in range(M)]

Max_amount = 0
for v in itertools.combinations_with_replacement(l, N):
    L = list(v)
    amount = 0
    for i in range(Q):
        if L[B[i]-1] - L[A[i]-1] == C[i]:
            amount += D[i]
    if Max_amount < amount:
        Max_amount = amount

print(Max_amount)


Measured memory_bytes: 9212
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		if(a<=0&&b>=0) {
			p("Zero");
		}else if(a<0&&b<0) {
			if((b-a)%2==0)p("Negative");
			else p("Positive");
		}else if(a>0&&b>0) {
			p("Positive");
		}
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
import Data.Ratio
main = getContents >>= mapM_ (putStrLn . parallelism . map (read::String->Float) . words) . tail . lines
parallelism [x1,y1,x2,y2,x3,y3,x4,y4]
 | (x1==x2) && (x3==x4) = "YES"
 | (x1==x2) || (x3==x4) = "NO"
 | otherwise = if dab == dcd then "YES" else "NO"
  where
   dab = approxRational ((y2-y1)/(x2-x1)) 1e-7
   dcd = approxRational ((y4-y3)/(x4-x3)) 1e-7

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	string s; cin >> s;
	int ans = 0;
	int cnt = 0;

	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'R')
		{
			cnt++;
		}
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
s = input()

W = [0] * n
B = [0] * n

for i in range(n):
    if i == 0:
        if s[-1] == '.':
            W[-1] = 1
    elif s[-i-1] == '.':
        W[-i-1] = W[-i] + 1
    else:
        W[-i-1] = W[-i]

#print(W)

for i in range(n):
    if i == 0:
        B[i] = 0
    elif s[i-1] == '#':
        B[i] = B[i-1] + 1
    else:
        B[i] = B[i-1]

#print(B)

if W[0] == n:
    print(0)
else:
    ans = n
    for i in range(n):
        c = W[i] + B[i]

        ans = min(ans, c)

    ans = min(ans, s.count('#'))

    print(ans)


Measured memory_bytes: 12800
import numpy as np
import numba
import math

@numba.njit
def main(N, K, steps):

    dpt = [10**9] * (N)
    dpt[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if i + j > N - 1:
                break
            ij = i + j
            x = dpt[i] + abs(steps[i] - steps[ij])
            if x < dpt[ij]:
                dpt[ij] = x

    print(dpt[N-1])

if __name__ == "__main__":
    N, K = map(int, input().split())
    steps = np.array(list(map(int, input().split())), dtype=np.int32)
    main(N, K, steps)


Measured memory_bytes: 112376
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int prime[n];
    int num[n][m];
    rep(i,n){
        cin >> prime[i];
        rep(j,m){
            cin >> num[i][j];
        }
    }
    int best_price = 1e9;
    int sum_price = 0;
    rep(bit,(1<<n)){
        int sum_effort[m] = {0};
        sum_price = 0;
        rep(i,n){
            if(bit & (1<<i)){
                sum_price += prime[i];
                rep(j,m){
                    sum_effort[j] += num[i][j];
                }
            }
        }
        bool check = true;
        rep(i,m){
            if(x > sum_effort[i]){check = false;}
        }
        if(check){
            best_price = min(best_price,sum_price);
        }
    }
    if(best_price != 1e9){cout << best_price << endl;}
    else{cout << -1 << endl;}
}

Measured memory_bytes: 3588
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, ), cache=True)
def popcount(n):
    ret = 0
    while n:
        ret += n & 1
        n >>= 1
    return ret


@njit((i8, ), cache=True)
def f(n):
    t = 0
    while n:
        t += 1
        n %= popcount(n)
    return t

@njit(cache=True)
def main(X):

    popX = X.sum()
    MOD1 = popX + 1
    MOD2 = popX - 1
    if popX == 1:
        MOD2 = 1
    pow1 = np.ones_like(X)
    pow2 = np.ones_like(X)
    for n in range(1, len(X)):
        pow1[n] = 2 * pow1[n - 1] % MOD1
        pow2[n] = 2 * pow2[n - 1] % MOD2

    X1, X2 = 0, 0
    for x in X:
        X1 = (2 * X1 + x) % MOD1
        X2 = (2 * X2 + x) % MOD2

    ans = np.empty(N, np.int64)
    for i in range(N):
        x = X[N - 1 - i]
        if x == 0:
            nxt = (X1 + pow1[i]) % (popX + 1)
            ans[i] = 1 + f(nxt)
        elif x == 1:
            if popX == 1:
                ans[i] = 0
            else:
                nxt = (X2 - pow2[i]) % (popX - 1)
                ans[i] = 1 + f(nxt)
    return ans[::-1]

N = int(readline())
X = np.array(list(read().rstrip()), np.int64) - ord('0')
ans = main(X)
print('\n'.join(map(str, ans.tolist())))


Measured memory_bytes: 138228
n = int(input())
sl = list(input())
ss = []

if n == 1:
    print(1)
else:
    for i in range(1, n):
        if sl[i] != sl[i-1]:
            ss.append(sl[i-1])
        if i == n-1:
            ss.append(sl[i])
    print(len(ss))


Measured memory_bytes: 4648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  vector<ll>vec(a+1);
  for(ll i=0;i<a+1;i++){
    cin>>vec.at(i);
    b+=vec.at(i);
  }
  for(ll i=0;i<a;i++){
    ll c;
    cin>>c;
    if(vec.at(i)>c){
      vec.at(i)-=c;
    }
    else if(vec.at(i)<=c){
      
      ll g=0;
      vec.at(i+1)=max(g,vec.at(i+1)-c+vec.at(i));
      vec.at(i)=0;
    }
  }
    
  ll s=0;
  for(ll i=0;i<a+1;i++){
    s+=vec.at(i);
  }
  cout<<b-s<<endl;
  return 0;
}

  
  
    
  


Measured memory_bytes: 3992
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;cin >> n;
	
	
	
	vector<int> x(n);
	vector<int> y(n);
	vector<int> t(n);
	
	REP(i,n)cin >> t[i] >> x[i] >> y[i];
	
	
	bool flag = true;
	int nx = 0;
	int ny = 0;
	int nt = 0;
	REP(i,n)
	{
		int a = abs(nx - x[i]);
		int b = abs(ny - y[i]);
		int c = t[i] - nt;
		
		c -= (a+b);
		if(c < 0 || c % 2 != 0)
		{
			flag = false;
			break;
		}
		nx = x[i];
		ny = y[i];
		nt = t[i];
	}
	
	if(flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  int N, P;
  cin >>N>>P;
  int t;
  int even=0,odd=0;
  ll ans=0;
  for(int i=1;i<=N;i++){
    cin >> t;
    if(t%2==0){
      even++;
    }
    else{
      odd++;
    }
  }
  if(P==1 && odd==0){
    cout << ans;
    return 0;
  }
  if(P==0 && odd==1 && even==0){
    cout << ans;
    return 0;
  }
  if(odd==0){
    ans=pow(2,even);
    cout << ans;
    return 0;    
  }
  ans=pow(2,even)*pow(2,odd)/2;
  cout << ans;
}

Measured memory_bytes: 256
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if m*f<-1 or s<30:print('F')
 elif s<50 and r<50:print('D')
 elif s<65:print('C')
 elif s<80:print('B')
 else:print('A')

Measured memory_bytes: 5592