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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

namespace std{
  bool operator<(const P& a,const P& b){
    return a.X==b.X?a.Y<b.Y:a.X<b.X;
  }
}
bool cmp_x(const P& a,const P& b){ return abs(a.X-b.X)<eps?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return abs(a.Y-b.Y)<eps?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(P a,P b){
    push_back(a);
    push_back(b);
  }
};

struct C{
  P p; D r;
  C(P p,D r):p(p),r(r){}
};

enum RELATION{SAME=1,CONTAINED=2,OVER=4,NO_CROSS=8,ONE_CROSS=16,ONE_CONTAINED_CROSS=32,ONE_OVER_CROSS=64,TWO_CROSS=128};
int cRel(C c1, C c2) {
  D d=abs(c1.p-c2.p);
  D dr1=c1.r-c2.r,dr2=c2.r-c1.r;
  D ar=c1.r+c2.r;
  if(d<eps&&c1.r==c2.r)return SAME;
  if(d<dr1)return OVER;
  if(d<dr2)return CONTAINED;
  if(d==dr1)return ONE_OVER_CROSS;
  if(d==dr2)return ONE_CONTAINED_CROSS;
  if(d==ar)return ONE_CROSS;
  if(d>ar)return NO_CROSS;
  return TWO_CROSS;
}

// 2????????±?????\???
L tanC(C c,D t){
  P p=c.p+polar(c.r,t);
  P d=polar(c.r,t)*P(0,1);
  return L(p-d,p+d);
}
vector<L> tanCC(C c1,C c2){
  vector<L> res;
  D d=arg(c2.p-c1.p),d2=arg(c1.p-c2.p);
  D i=acos((c1.r+c2.r)/abs(c2.p-c1.p));
  D o=acos((c1.r-c2.r)/abs(c2.p-c1.p));
  int r=cRel(c1,c2);
  if(r==NO_CROSS){
    res.push_back(tanC(c1,d+i));
    res.push_back(tanC(c1,d-i));
  }
  if(!(r&(SAME|CONTAINED|OVER|ONE_CONTAINED_CROSS|ONE_OVER_CROSS))){
    res.push_back(tanC(c1,d+o));
    res.push_back(tanC(c1,d-o));
  }
  if(r&(ONE_CROSS|ONE_CONTAINED_CROSS|ONE_OVER_CROSS)){
    if(r&ONE_CONTAINED_CROSS) res.push_back(tanC(c2,d2));
    else res.push_back(tanC(c1,d));
  }
  return res;
}

P projection(L l,P p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*(c/b).X;
}


int main(){
	cin.sync_with_stdio(false);
  D x,y;
  D cx,cy,cr;
  cin>>x>>y>>cx>>cy>>cr;

  C cc=C(P(cx,cy),cr);
  vector<L> ls=tanCC(cc,C(P(x,y),0));
  vector<P> res;
  rep(i,ls.size()){
    P ans=projection(ls[i],cc.p);
    res.push_back(ans);
  }
  sort(all(res),cmp_x);
  uni(res);
  rep(i,res.size()){
    printf("%.10Lf %.10Lf\n", res[i].X,res[i].Y);
  }
  return 0;
}

Measured memory_bytes: 3612
s = gets.chop.split('')

white_count = s.select{ |str| str == "W" }.count

white_dis_sum = 0
s.each_with_index do |v, i|
    white_dis_sum += i if v == "W"
end

diff = white_count * (white_count - 1) / 2

puts white_dis_sum - diff


Measured memory_bytes: 18300
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 1000005;

int dp[MAX_N][2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    const int n = (int)s.size();
    for(int i = 0; i <= n; ++i) dp[i][0] = dp[i][1] = INF;
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i){
        dp[i+1][0] = min(dp[i+1][0], dp[i][0] + (int)(s[i] - '0'));
        dp[i+1][0] = min(dp[i+1][0], dp[i][1] + (int)(s[i] - '0'));
        dp[i+1][1] = min(dp[i+1][1], dp[i][0] + (int)('9' - s[i]) + 2);
        dp[i+1][1] = min(dp[i+1][1], dp[i][1] + (int)('9' - s[i]));
    }
    cout << min(dp[n][0], dp[n][1]) << "\n";
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int dp[100000000];

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

    vector<int> A(N, 0);
    vector<int> B(N, 0);
    rep(i, N) { cin >> A[i] >> B[i]; }

    fill(dp, dp + 100000000, INF);

    dp[0] = 0;

    for (int h = 0; h <= H; h++) {
        for (int i = 0; i < N; i++) {
            int nh = h + A[i];
            dp[nh] = min(dp[nh], dp[h] + B[i]);
        }
    }

    for (int i = 100000000 - 1; 0 < i; i--) {
        dp[i - 1] = min(dp[i - 1], dp[i]);
    }

    // for (int i = 0; i < 20; i++) {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 391292
#include<stdio.h>
int main()
{
  int a;
  
  scanf("%d",&a);
  
  if(a==1){
    printf("1");
  }else if(a<=3){
    printf("2");
  }else if(a<=7){
    printf("4");
  }else if(a<=15){
    printf("8");
  }else if(a<=31){
    printf("16");
  }else if(a<=63){
    printf("32");
  }else if(a<=100){
    printf("64");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std; //头文件和命名空间
int arrCount[200005] = { 0 }; //定义存放每个数字出现次数的数组并初始化为0
bool cmp(int iNum1, int iNum2){ //降序排序判断函数
    return iNum1 > iNum2;
}
int main(){
    ios::sync_with_stdio(false); //输入输出加速
    int nCount, nDiff, i, iTemp, iSum=0; //nCount-球的个数；nDiff-不同的数的个数；i-循环计数器；iTemp-输入暂存；iSum-累加器
    cin >> nCount >> nDiff; //读入球的个数和不同的数的个数
    for (i = 1; i <= nCount; ++i){ //读入数字并计数
        cin >> iTemp; //读入数字
        ++arrCount[iTemp]; //计数
    }
    sort(arrCount, arrCount + 200005,cmp); //降序排序(使用STL提供的快速排序函数)
    for (i = nDiff; arrCount[i] != 0; ++i){ //对第K+1项到最后一项求和，控制遇到值为0的项结束缩短时间
        iSum += arrCount[i]; //累加
    }
    cout << iSum << endl; //输出
    return 0; //结束
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long

using namespace std;

void test_case()
{
int n,k,temp=0;
cin>>n>>k;
vector<int> p;
for(int i=0;i<n;++i)
{
cin>>temp;
p.push_back(temp);
}
sort(p.begin(),p.end());
ll s=0;
for(int i=0;i<k;++i)
{
s+=p[i];
}
cout<<s;
}
int main()
{
test_case();
return 0;
}

Measured memory_bytes: 3628
N,M = map(int,input().split())

par = [-1]*(N+1)


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True


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


def size(x):
    return -par[find(x)]

for i in range(M):
    x,y,z = map(int,input().split())
    unite(x,y)

ans = 0
counted = [False] * (N+1)
for i in range(1,N+1):
    root = find(i)
    if not counted[root]:
        ans += 1
        counted[root] = True
print(ans)


Measured memory_bytes: 72408
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint l[100];
int main()
{
	l[0]=2;l[1]=1;
	rep(i,90) l[i+2]=l[i]+l[i+1];
	int n;cin>>n;cout<<l[n]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 205;
const int mod = 1e9+7;
const int N = 200;

int ehead[maxn],ecnt=1;
struct edge {
	int u,v,next;
}edg[maxn<<1];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;
}
int n,m,K,pw[maxn],fac[maxn],inc[maxn];
LL fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
int gcd(int n,int m) {
	return m?gcd(m,n%m):n;
}
int polya(int n)
{
	int ans=0;
	for (int i=1;i<=n;i++)
		ans=(ans+pw[gcd(n,i)])%mod;
	return ans*fpm(n,mod-2)%mod;
}
LL comb(int n,int m) {
	return (LL)fac[n]*inc[m]%mod*(LL)inc[n-m]%mod;
}
int dfn[maxn],idx,low[maxn],stk[maxn],top;
bool vis[maxn];LL ans=1ll;
void solve(int pos)
{
	memset(vis,0,sizeof vis);
	int cnte=0,cntn=0;
	while (top!=pos) {
		++cnte;int i=stk[top--];
		vis[edg[i].u]=vis[edg[i].v]=true;
	}
	for (int i=1;i<=n;i++) cntn+=vis[i];
	if (!cnte) return ;
	if (cnte<=1) ans=(LL)ans*K%mod;
	else if (cnte!=cntn) ans=(LL)ans*comb(cnte+K-1,K-1)%mod;
	else ans=(LL)ans*polya(cntn)%mod;
}
void tarjan(int u,int faj)
{
	low[u]=dfn[u]=++idx;
	for (int v,j=ehead[u];j;j=edg[j].next)
	if (j/2!=faj) {
		if (!dfn[v=edg[j].v]) {
			int pos=top;stk[++top]=j;
			tarjan(v,j>>1);
			if (low[v]>=dfn[u]) solve(pos);
			low[u]=min(low[u],low[v]);
		}
		else if (dfn[v]<dfn[u]) {
			stk[++top]=j;
			low[u]=min(low[u],dfn[v]);
		}
	}
	if (!faj) solve(0);
}
int main()
{
	#ifdef Amberframe
		freopen("arc062f.in","r",stdin);
		freopen("arc062f.out","w",stdout);
	#endif
	scanf("%d %d %d",&n,&m,&K);fac[0]=inc[0]=pw[0]=1;
	for (int i=1;i<=N;i++) pw[i]=(LL)pw[i-1]*K%mod;
	for (int i=1;i<=N;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[N]=fpm(fac[N],mod-2);
	for (int i=N;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	for (int u,v,i=1;i<=m;i++)
		scanf("%d %d",&u,&v),add(u,v);
	for (int i=1;i<=n;i++)
		if (!dfn[i]) tarjan(i,0);
	printf("%d",ans);
	return 0;
}

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

int main(void){
    int i,j;
    char ch;
    while(1){
        scanf("%c",&ch);
        if(ch == '\n'){
            printf("\n");
            break;
        }
        else if(islower(ch)){
            printf("%c",toupper(ch));
        }
        else if(isupper(ch)){
            printf("%c",tolower(ch));
        }
        else{
            printf("%c",ch);
    }
}
    return(0);
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)

int32_t main() { fastio;
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    rep(i,n-1){
        ans=k*(ans/(k-1))+ans%(k-1)+1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n,a[60],pos,ans;
string s[60],t;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		cin>>s[i];
		read(a[i]);
	}
	cin>>t;
	for (int i=1;i<=n;i++) if (t==s[i]) pos=i;
	for (int i=pos+1;i<=n;i++) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

x2 = x.copy()
x2.sort()
c1 = x2[n // 2 - 1]
c2 = x2[n // 2]
for i in x:
    if(c1 >= i):
        print(c2)
    else:
        print(c1)


Measured memory_bytes: 26180
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

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

  map<string, int> m;
  m["MON"] = 1;
  m["TUE"] = 2;
  m["WED"] = 3;
  m["THU"] = 4;
  m["FRI"] = 5;
  m["SAT"] = 6;

  int ans = 7 - m[S];
  cout << ans << endl;
}

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

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	bool a_flag = true, b_flag = false, c_flag = false;
	int a_index = 0, b_index = 0, c_index = 0;
	while(1){
		if(a_flag){
			if(a_index == (int)a.size()){
			cout << "A" << endl;
			return 0;
			}
			if(a.at(a_index) == 'b'){
				a_flag = false;
				b_flag = true;
			}
			else if(a.at(a_index) == 'c'){
				a_flag = false;
				c_flag = true;
			}
			a_index++;
		}
		else if(b_flag){
			if(b_index == (int)b.size()){
				cout << "B" << endl;
			return 0;
			}
			if(b.at(b_index) == 'a'){
				b_flag = false;
				a_flag = true;
			}
			else if(b.at(b_index) == 'c'){
				b_flag = false;
				c_flag = true;
			}
			b_index++;
		}
		else{
			if(c_index == (int)c.size()){
				cout << "C" << endl;
				return 0;
			}
			if(c.at(c_index) == 'a'){
				c_flag = false;
				a_flag = true;
			}
			else if(c.at(c_index) == 'b'){
				c_flag = false;
				b_flag = true;
			}
			c_index++;
		}
	}
}

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

const int N = 1e2 + 5, INF = 1e9;
int n,m, d[N][N], edge[N][N];



void Floyd(){
    cin>>n>>m;
    fill_n(&d[0][0], N*N, INF);
    for (int i = 0; i < n; i++)d[i][i] = 0;
    
    for(int i = 1; i <= m; i++){
        int u,v,dist;
        cin>>u>>v>>dist;
        u--,v--;
        d[u][v] = edge[u][v] = dist;
        d[v][u] = edge[v][u] = dist;
    }
    
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                if(d[i][k] < INF && d[k][j] < INF)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    

    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if(edge[i][j] == 0)continue;
            int used = 0;
            for (int k = 0; k < n; k++){
                if(d[k][j] == d[k][i] + edge[i][j]) used = 1;
            }
            if(!used)ans++;
        }
    }
    cout<<ans<<endl;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    Floyd();
    
    return 0;
}


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

const int MOD = 1e9 + 7;

int main(){
	string L;
	cin >> L;
	vector<vector<ll>> dp(L.size(), vector<ll>(2));
	dp[0][1] = 1;
	dp[0][0] = 2;

	rep(i,L.size()-1){
		if(L[i+1] == '0'){
			dp[i+1][1] = 3*dp[i][1] % MOD;
			dp[i+1][0] = dp[i][0];
		}
		else{
			dp[i+1][1] = (3*dp[i][1] % MOD + dp[i][0]) % MOD;
			dp[i+1][0] = 2*dp[i][0] % MOD;
		}
	}
	
	cout << (dp[L.size()-1][0] + dp[L.size()-1][1]) % MOD << endl;
	return 0;
}

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

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;

int main(){
   // freopen("in.txt", "r", stdin);
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> cnt[2];
    for(int i = 0; i < n; ++i){
        cin >> v[i];
        cnt[i&1][v[i]]++;
    }
    vector<pair<int, int> > p[2];
    for(int i = 0; i < 2; ++i){
        for(auto it : cnt[i]){
            p[i].push_back(make_pair(it.second, it.first));
        }
        sort(p[i].rbegin(), p[i].rend());
    }
    int ans = n;
    for(int i = 0; i < min((int)p[0].size(), 2); ++i){
        for(int j = 0; j < min((int)p[1].size(), 2); ++j){
            pair<int, int> a = p[0][i], b = p[1][j];
            if(a.second != b.second){
                ans = min(ans, n - a.first - b.first);
            } else {
                ans = min(ans, n - a.first);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6520
#include <algorithm>
#include <string.h>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string x;
    cin >> x;
    char last = '#';
    int ans = 0;
    for (int i = 0; i < x.size(); i++)
    {
        if (x[i] != last)
        {
            ans++;
            last = x[i];
        }
    }
    cout << ans;
    return 0;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;

int32_t main()
{
	fio;
	int n;
	cin>>n;
	unordered_map<string,bool> mp;
	while(n--)
	{
		string str;
		cin>>str;
		mp[str]=true;
	}

	cout<<mp.size()<<endl;
	return 0;
}

Measured memory_bytes: 17760
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    map<string, int> M;
    int q; cin >> q;
    REP(i, q){
        string key;
        int op, x; cin >> op >> key;
        switch(op){
            case 0:
                cin >> x;
                M[key] = x;
                break;
            case 1:
                cout << M[key] << "\n";
                break;
            case 2:
                M[key] = 0;
                break;
        }
    }
    return 0;
}



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

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

  vector<string> s_list;
  s_list.reserve(n);
  for (int i = 0; i < n; ++i) {
    string tmp;
    cin >> tmp;
    s_list.emplace_back(move(tmp));
  }

  vector<int> min_count_array(26, 50);
  for (int i = 0; i < n; ++i) {
    const string &s = s_list[i];
    vector<int> count(26, 0);
    for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
      ++(count[*it - 'a']);
    }

    for (int j = 0; j < 26; ++j) {
      min_count_array[j] = min(min_count_array[j], count[j]);
    }
  }

  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < min_count_array[i]; ++j) {
      cout << static_cast<char>(i + 'a');
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
//given n integers and an integer m such that n>m then there exits a pair
//(a-b) such that (a-b)%m==0


#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll M=1000000007;
void solve(){
 int n,x,t;
 cin>>n>>x>>t;
 int ans=(n/x)*t;
 if(n%x)ans+=t;
 cout<<ans;
}

int main(){
 int t=1;
 //cin>>t;
 while(t--){
        solve();
        cout<<endl;
 }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>


int main()
{
    int n,d;
    cin>>n>>d;
   int m[n][d];

   for(int i=0;i<n;i++)
   {
       for(int j=0;j<d;j++)
           cin>>m[i][j];
   }
    int i,j,k,c=0;

   for(i=0;i<n-1;i++)
   {
       for(j=i+1;j<n;j++)
       {  int r=0;
           for(k=0;k<d;k++)
           {
               int s=abs(m[i][k]-m[j][k]);
               r+=(s*s);
           }
           double t=sqrt(r);
           ll o=t;
           if(o==t)
            c++;
       }
   }

   cout<<c<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	int n, m, P[100000], M[100000], Count[100001] = { 0 }, Index[100000];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++)
		scanf("%d %d", P + i, M + i);
	for (int i = 0; i < m; i++)
		Index[i] = i;
	sort(Index, Index + m, [&](int a, int b){
		return M[a] < M[b];
	});
	for (int i = 0; i < m; i++)
		M[Index[i]] = ++Count[P[Index[i]]];
	for (int i = 0; i < m; i++)
		printf("%06d%06d\n", P[i], M[i]);
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin >> n >> k;
    long long int ans=0;
    long long int m=1000000007;
    for(long long int i=k;i<=n;i++)
    {
        ans+= (((n*(n+1))/2) -(((n-i)*(n-i+1))/2)-((i*(i-1))/2)+1);
        ans %=m;

    }
    ans+=1;
    cout << ans<<"\n";
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


bool solve(int in){
	const int n = 4;
	int aa[] = {10, 50, 100, 500};
	vector<pair<int, int> > a(n);
	for(int i=0;i<n;i++){
		a[i].first = aa[i];
		cin>> a[i].second;
	}
	
	vector<pair<int, int> > b = a;
	for(int i=n-1;i>=0;i--){
		while(b[i].second && in>0){
			in -= b[i].first;
			b[i].second--;
		}
	}
	b[0].second += -in/10;
	for(int i=0;i<n-1;i++){
		while(b[i].second * b[i].first >= b[i+1].first){
			b[i].second -= b[i+1].first/b[i].first;
			b[i+1].second++;
		}
	}
	
	for(int i=0;i<n;i++){
		int num = a[i].second - b[i].second;
		if(num > 0){
			cout<< b[i].first<<" "<< num<< endl;
		}
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int k;
	bool f = false;
	while(cin>> k, k){
		if(f) cout<< endl;
		else f = true;
		solve(k);
	}

	return 0;
}

 

Measured memory_bytes: 1192
def min(i,j); i < j ? i : j ; end
class Row
  def initialize(pat); @pat = pat; end
  def bit?(i); (@pat & (1 << i)) > 0; end
  def valid?; (1 .. W).each_cons(3).none?{|i,j,k| bit?(i - 1) && bit?(j - 1) }; end
  def to(from)
    if from == 1
      bit?(from - 1) ? from + 1 : from
    elsif from == W
      bit?(from - 2) ? from - 1 : from
    else
      bit?(from - 1) ? from + 1 
      : bit?(from - 2) ? from - 1
      : from
    end
  end
end

H, W, K = gets.split.map(&:to_i)
P = (1 << (W - 1)).times.map{|pat| Row.new(pat) }.select(&:valid?)

dp = Array.new(H + 1){ Array.new(W + 1, 0) }
dp[0][1] = 1

(1 .. H).each do |n|
  P.each do |pat|
    (1 .. W).each do |from|
      to = pat.to(from)
      dp[n][to] += dp[n - 1][from]
      dp[n][to] %= 1_000_000_007
    end
  end
end
puts dp[H][K]




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

ll l,r;
int tg[2020];

int main(){
	cin>>l>>r;
	if (r-l+1>=2019) cout<<0<<endl;
	else{
		for (int i=l;i<=r;++i){
			tg[i%2019]=1;
		}
		int ans=1e9;
		for (int i=1;i<=2019;++i){
			for (int j=i+1;j<=2019;++j){
				if (tg[i]&&tg[j]) ans=min(ans,i*j%2019);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int rectnum = 0;
	int lozenum = 0;
	while(true)
	{
	int a,b,c;
	cin >> a;
	if(cin.eof())break;
	fgetc(stdin);
	cin >> b;
	fgetc(stdin);
	cin >> c;
	if((a*a+b*b)==c*c)rectnum++;
	if(a==b)lozenum++;
	}
	cout << rectnum << endl;
	cout << lozenum << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;

    int v = n;
    for (int i = 0; i <= n; i++) {
        int c = 0;
        int t = i;
        while (t > 0) {
            c += t % 6;
            t /= 6;
        }
        t = n - i;
        while (t > 0) {
            c += t % 9;
            t /= 9;
        }
        v = min(v, c);
    }

    put(v);

    return 0;
}

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

int main()
{
  int h, a, count=0;
  cin >> h >> a;

  for(;;){
    if(h<=0){
      break;
    }
    h = h - a;
    count++;

  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

struct Dice {
    V v;
    Dice() {}
    Dice(V _v) : v(_v) {}
    void rot(char c) {
        int t = v[0];
        switch(c) {
            case 'N':
                v[0] = v[1];
                v[1] = v[5];
                v[5] = v[4];
                v[4] = t;
                break;
            case 'S':
                v[0] = v[4];
                v[4] = v[5];
                v[5] = v[1];
                v[1] = t;
                break;
            case 'W':
                v[0] = v[2];
                v[2] = v[5];
                v[5] = v[3];
                v[3] = t;
                break;
            case 'E':
                v[0] = v[3];
                v[3] = v[5];
                v[5] = v[2];
                v[2] = t;
                break;
        }
    }
};

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

    V v(6);
    rep(i, 6) cin >> v[i];
    Dice d(v);

    string s;
    cin >> s;
    for (const auto& c : s) {
        d.rot(c);
    }

    cout << d.v[0] << endl;
}

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

int main() {
    int n;
    string c;
    cin >> n >> c;
    int num_w = 0;
    rep(i,n){
        if(c.substr(i,1)=="W"){
            num_w++;
        }
    }
    int num_r = c.size()-num_w;
    int left_w=0,right_r=0;
    for(int i=0;i<num_r;i++){
        if(c.substr(i,1)=="W") left_w++;
    }
    for(int i=num_r;i<n;i++){
        if(c.substr(i,1)=="R") right_r++;
    }
    int ans = max(left_w,right_r);
    cout << ans << endl;
}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>

using namespace std;

typedef long long ll;


const int INF = 1e9;

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

struct point
{
	int x, y;
	point() {}
	point(int x, int y) :x(x), y(y) {}
};

int H, W;
vector< vector<int> > m;
vector<point> p;
int dp[1005][1005] = {};
int main() {
	cin >> H >> W;
	m = vector<vector<int>>(H+2, vector<int>(W+2, INF));
	p = vector<point>(H*W+1);
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> m[i][j];
			p[m[i][j]] = point(i, j);
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			bool ok = true;
			for (int k = 0; k < 4; k++) {
				int nx = i + dx[k], ny = j + dy[k];
				if (m[i][j] > m[nx][ny]) {
					ok = false;
				}
			}
			if (ok) dp[i][j] = m[i][j];
		}
	}

	int ans = 0;
	for (int i = 1; i <= H*W; i++) {
		int x = p[i].x, y = p[i].y;
		for (int j = 0; j < 4; j++) {
			int nx = x + dx[j], ny = y + dy[j];
			if (m[x][y] > m[nx][ny]) {
				if(dp[x][y] == 0) dp[x][y] = dp[nx][ny];
				else if (dp[x][y] != dp[nx][ny]) dp[x][y] = -1;
			}
		}
		if (dp[x][y] == -1) ans++;
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 18552
#include <iostream>
#include <algorithm>

int N;
long long a[200005];
int main(){
  std::cin>>N;
  long long sum = 0;
  for(int i=0;i<N;++i){
    std::cin>>a[i];
    sum+=a[i];
  }
  
  long long ans=200000000000005;
  long long now=0;
  for(int i=0;i<N-1;++i){
    now+=a[i];
    ans=std::min(ans,std::abs(sum-2*now));
  }
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    static tree[] wd;
	public static void main(String[] args) {
	    int x,i,j,n,pn,swi=0,root = 0,hz;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     wd=new tree[n];
    for(j=0;j<n;j++){
    	x=sca.nextInt();
	if(j==0)root=x;
    	pn=sca.nextInt();
	wd[x]=new tree(x,pn);
    	for(i=0;i<pn;i++) {
	    hz=sca.nextInt();
	    if(hz==root) root=x;
	    wd[x].setchil(hz,i);
    	}
    	if(swi==0&&pn!=0){
    		swi=-1;
    		root=x;
    	}
    }
    chain(root,-1);
     for(i=0;i<n;i++){
    	 System.out.print("node "+i+": parent = "+ wd[i].getpar()+", depth = "+serdepth(i,0)+", ");
	 if(wd[i].getpar()==-1){
    	System.out.print("root, [");
	 }else if(wd[i].getn()==0){
    	 System.out.print("leaf, [");
    	}else{
    		System.out.print("internal node, [");
    	}
	 for(j=0;j<wd[i].getn();j++){
	     System.out.print(wd[i].getchil(j));
	     if(j+1<wd[i].getn()){
    			System.out.print(", ");
    		}
    	}
	   System.out.println("]");	   
   
     }
	}
    public static void chain(int chi,int p){
	int i;
	wd[chi].setpar(p);
	if(wd[chi].getn()==0)return;
	for(i=0;i<wd[chi].getn();i++){
	    chain(wd[chi].getchil(i),chi);
	}
	}
	public static int serdepth(int x,int cnt){
	    if(wd[x].getpar()==-1)return cnt;
		cnt++;
		return serdepth(wd[x].getpar(),cnt);
	}
    
}
class tree{
    int node,par,n,i;
    int[]children;
    tree(int node,int n){
	this.n=n;
	this.node=node;
	children= new int[n];
    }
    public void setchil(int c,int p){
	children[p]=c;
    }
    public int getchil(int c){
	return children[c];
    }
    public void setpar(int p){
	par=p;
    }
    public int getpar(){
	return par;
    }
    public boolean existch(int p){
	for(i=0;i<n;i++){
	    if(p==children[i])return true;
	}
	return false;
    }
    public int getn(){
	return n;
    }
    
}



Measured memory_bytes: 134660
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> W(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	
	int sum = accumulate(W.begin(), W.end(), 0);

	int S1 = 0;
	int S2 = 0;
	int d = 0;
	int ans = sum;
	for (int i = 0; i < N; i++) {
		S1 += W[i];
		S2 = sum - S1;
		d = abs(S1 - S2);
		if (d < ans) {
			ans = d;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
extern crate core;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        list: [usize; m],
    }
    let mut dp = Vec::new();
    let mut ptr = 0;
    let modi = 1000000007;
    for i in 0..n + 1 {
        match i {
            0 => dp.push(0),
            _ => {
                if let Some(p) = list.get(ptr) {
                    if i == *p {
                        dp.push(0);
                        ptr += 1;
                    } else {
                        if i == 1 {
                            dp.push(1);
                        } else if i == 2 {
                            if dp[i - 1] == 1 {
                                dp.push(2);
                            } else {
                                dp.push(1);
                            }
                        } else {
                            let v1 = dp[i - 1];
                            let v2 = dp[i - 2];
                            dp.push((v1 + v2) % modi);
                        }      
                    }
                } else {
                    if i == 1 {
                        dp.push(1);
                    } else if i == 2 {
                        if dp[i - 1] == 1 {
                            dp.push(2);
                        } else {
                            dp.push(1);
                        }
                    } else {
                        let v1 = dp[i - 1];
                        let v2 = dp[i - 2];
                        dp.push((v1 + v2) % modi);
                    }
                }
            }
        }
    }
    if let Some(n) = dp.get(n) {
        println!("{}", n);
    }
}


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

int main(){
	int n,x;
	cin >> n >> x;
	int kona = 0;
	int mini = 2000000;

	rep(i, n){
		int a;
		cin >> a;
		x -=a;
		mini = min(mini, a);
	}

	int ans = 0;
	while(mini <= x){
		ans++;
		x -= mini;
	}

	cout << n+ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
using ui = unsigned int;
using ul = unsigned long;
#pragma GCC optimize("Ofast")
#define loop(i, n) for (ui i = 0; i < n; i++)
ul bit[550010];ui N;inline ul sum(ui x){ul ret = 0;while (x > 0){ret += bit[x];x -= x & -x;}return ret;}inline void add(ui i, ul x){i++;while (i <= N){bit[i] += x;i += i & -i;}}int main(){cin.tie(0);ios::sync_with_stdio(false);ui Q;cin >> N >> Q;loop(i, N){ul A;cin >> A;bit[i + 1] = A;}for (ui i = 1; i < N; i++)bit[i + (i & -i)] += bit[i];loop(i, Q){ui a, b, c;cin >> a >> b >> c;if (a == 0)add(b, c);else cout << sum(c) - sum(b) << "\n";}return 0;}


Measured memory_bytes: 8268
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
h = na()

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
count = 1
for i in range(2,n):
  dp[i] = min(abs(h[i-1]-h[i])+dp[i-1], abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])

Measured memory_bytes: 13716
#include<stdio.h>
int main ()
{   int a[5];
    int maxx=0,sum=0;
    for (int i=1;i<=3;i++)
    {
        scanf("%d",&a[i]);
        if (a[i]>maxx)
            maxx=a[i];
        sum=sum+a[i];
    }
    printf("%d\n",sum-maxx);




    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i, j;
	int a = (int)'a';
	int freq[30];
	char w[128];

	for(i = 0; i < 30; i += 1) {
		freq[i] = 0;
	}

	fgets(w, sizeof(w), stdin);

	i = 0;
	while(w[i] != '\0') {
		j = (int)w[i] - a;
		freq[j] += 1;
		i += 1;
	}

	for(i = 0; i < 30; i += 1) {
		if(freq[i] % 2 != 0) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 1900
N,u,v = map(int,input().split())
u,v = u-1, v-1
E = [[] for i in range(N)]
for i in range(N-1):
	a,b = map(int,input().split())
	E[a-1].append(b-1)
	E[b-1].append(a-1)

# T[node] = [parent, depth, [children]]
T = [[] for i in range(N)]
search = [(v, -1, 0)]
searched = [False for i in range(N)]
while len(search) > 0:
	s = search.pop()
	node = s[0]
	parent = s[1]
	depth = s[2]
	searched[node] = True
	children = []
	for n in E[node]:
		if not searched[n]:
			search.append((n, node, depth+1))
			children.append(n)
	T[node] = [parent, depth, children]

root2 = u
d_u = T[u][1]
for i in range((d_u - 1) // 2):
	root2 = T[root2][0]
max_depth = -1
leaf = -1
search = [(root2, 0)]
while len(search) > 0:
	s = search.pop()
	node = s[0]
	depth = s[1]
	children = T[node][2]
	for c in children:
		search.append((c, depth+1))
	if len(children) == 0 and max_depth < depth:
		max_depth = depth
		leaf = node
if d_u == 1:
	print(0)
else:
	print(T[leaf][1] - 1)


Measured memory_bytes: 46512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;

template<typename T,bool directed>
struct Fordfulkerson{
  struct edge{
    ll to,cap,rev;
    edge(){}
    edge(ll to,ll cap,ll rev):to(to),cap(cap),rev(rev){}
  };

  vector<vector<edge> > G;
  vector<ll> used;

  Fordfulkerson(){}
  Fordfulkerson(ll n):G(n),used(n){}

  void add_edge(ll from,ll to,T cap){
    G[from].emplace_back(to,cap,G[to].size());
    G[to].emplace_back(from,directed?0:cap,G[from].size()-1);
  }

  T dfs(ll v,ll t,T f){
    if(v==t) return f;
    used[v]=true;
    for(ll i=0;i<(ll)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to]&&e.cap>0){
        T d=dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          G[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }

  ll flow(ll s,ll t,T lim){
    T fl=0;
    while(1){
      fill(used.begin(),used.end(),0);
      T f=dfs(s,t,lim);
      if(f==0) break;
      fl+=f;
      lim-=f;
    }
    return fl;
  }

  ll flow(ll s,ll t){
    return flow(s,t,numeric_limits<T>::max()/2);
  }

};

int main() {
  ll n;
  cin >> n;
  vec x(2*n),y(2*n);
  Fordfulkerson<ll,true> G(2*n+2);
  for(ll i=0;i<n;i++) {
    cin >> x[i] >> y[i];
    G.add_edge(2*n,i,1);
  }
  for(ll i=0;i<n;i++) {
    cin >> x[n+i] >> y[n+i];
    G.add_edge(n+i,2*n+1,1);
  }
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<n;j++) {
      if(x[i]<x[n+j]&&y[i]<y[n+j]) {
        G.add_edge(i,n+j,1);
      }
    }
  }
  cout << G.flow(2*n,2*n+1) << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    long long int A,B,K;
    cin >> A >> B >> K;
    if(A>K){
        A = A -K;
        cout << A << " " << B;
    }
    else if(A<K && K>=A+B){
        cout << 0 << " " << 0;
    }
    else{
        cout << 0  << " " << B-K+A;
    }
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_SIZE_MAX		85										// 最大サイズ
#define D_RNG_MAX		26000									// 最大範囲
#define D_RNG_AVG		D_RNG_MAX / 2							// 範囲中間値

// 内部変数
static FILE *szpFpI;											// 入力
static int siW, siH;											// 幅・高さ
static int si2DF[D_SIZE_MAX][D_SIZE_MAX];						// 数字差
static char sc3Exist[D_SIZE_MAX][D_SIZE_MAX][D_RNG_MAX];		// 存在フラグ

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j, k;
	char lc1Buf[1024];

	// データ - 初期化
	memset(sc3Exist, D_OFF, sizeof(sc3Exist));

	// 幅・高さ - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siH, &siW);

	// 数字差 - 取得
	for (i = 0; i < siH; i++) {
		for (j = 0; j < siW; j++) {
			fscanf(szpFpI, "%d", &si2DF[i][j]);
		}
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	}
	for (i = 0; i < siH; i++) {
		for (j = 0; j < siW; j++) {
			int liVal;
			fscanf(szpFpI, "%d", &liVal);
			si2DF[i][j] -= liVal;
		}
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	}

	// 存在フラグ - 初期値
	sc3Exist[0][0][D_RNG_AVG + si2DF[0][0]] = D_ON;
	sc3Exist[0][0][D_RNG_AVG - si2DF[0][0]] = D_ON;

	// 存在フラグ - セット
	for (i = 0; i < siH; i++) {
		for (j = 0; j < siW; j++) {
			for (k = 0; k < D_RNG_MAX; k++) {
				if (sc3Exist[i][j][k] != D_ON) {
					continue;
				}

				// 右へ
				sc3Exist[i][j + 1][k + si2DF[i][j + 1]] = D_ON;
				sc3Exist[i][j + 1][k - si2DF[i][j + 1]] = D_ON;

				// 下へ
				sc3Exist[i + 1][j][k + si2DF[i + 1][j]] = D_ON;
				sc3Exist[i + 1][j][k - si2DF[i + 1][j]] = D_ON;
			}
		}
	}

	// 最小値 - 取得
	int liMin = INT_MAX;
	for (i = 0; i < D_RNG_MAX; i++) {
		if (sc3Exist[siH - 1][siW - 1][i] != D_ON) {
			continue;
		}

		// 最小値 - 更新
		int liVal = abs(D_RNG_AVG - i);
		if (liMin > liVal) {
			liMin = liVal;
		}
	}

	return liMin;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 183680
import sys
n = int(input())
lis = [input()]
for i in range(1,n):
    w = input()
    if lis[i-1][-1] != w[0]:
        print("No")
        sys.exit()
    if w in lis:
        print("No")
        sys.exit()
    lis.append(w)
print("Yes")

Measured memory_bytes: 3060