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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL
// {{{ define basic macro
// #define rep(i, x) for(int i = 0; i < (int)(x); i++)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii, vii, greater<pii> > spq;  //pop, topで最小値
int dx[]={1, -1, 0, 0, 0};
int dy[]={0, 0, 1, -1, 0};
//}}}


int solve(){
  string s;cin>>s;
  s += "A";

  rep(i, sz(s)-1){
    if (s[i]==s[i+1]) {
      i++;
      cout << i << " " << i+1 << endl;
      return 0;
    }
    if (s[i]==s[i+2]) {
      i++;
      cout << i << " " << i+2 << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << endl;


  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 512
/**
 * B - Exponential
 */

#include <iostream>

using namespace std;

int main() {

    bool p[1001];

    fill(p, p + 1001, false);
    p[1] = true;

    for (int i = 2; i <= 31; i++) {
        int i_ = i * i;
        while (i_ <= 1000) {
            p[i_] = true;
            i_ *= i;
        }
    }

    int X;
    cin >> X;

    for (int j = X; j >= 1; j--) {
        if (p[j]) {
            cout << j << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
vector<int> tre[100010];

int T[100010];//1-indexed
int A[100010];//1-indexed
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int N,u,v;cin>>N>>u>>v;
  for(int i = 0; N-1 > i; i++){
    //uからvの直線距離を求める
    int a,b;cin>>a>>b;
    tre[a].push_back(b);
    tre[b].push_back(a);
  }
  queue<P> t;
  t.push({u,1});
  while(!t.empty()){
    P k = t.front();
    t.pop();
    if(T[k.first]){
      continue;
    }
    T[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      t.push({tre[k.first][i],k.second});
    }
  }


  queue<P> a;
  a.push({v,1});
  while(!a.empty()){
    P k = a.front();
    a.pop();
    if(A[k.first]){
      continue;
    }
    A[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      a.push({tre[k.first][i],k.second});
    }
  }
  int ans = 0;
  int nya = 0;
  for(int i = 1; N >= i; i++){
    if(T[i] < A[i]){
      if(A[i]%2 == T[i]%2){
        ans = max(ans,A[i]-2);
        //cout << A[i]-2 << endl;
      }else{
        ans = max(ans,A[i]-1);
        //cout << A[i]-1 << endl;
      }
      ans = max(ans,T[i]);
      
    }
    if(T[i]%2 == A[i]%2 && nya < T[i]){
      nya = A[i];
      
    }
    //cout << i << ":" << T[i] << " " << A[i] << endl; 
  }
  //距離が偶数の場合
  if((T[v]%2)){
    ans++;
  }
  {
    cout << ans-1 << endl;
  }
}

Measured memory_bytes: 6912
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main() {

   int n;
   scanf("%d",&n);
   int a = pow(n,2);
   printf("%d",a);

  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e3;
const int LOG = 61;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 1e9 + 7;
const ll LLINF = 1e16;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi a(n + 1), b(n);
    forn(i, n + 1) cin >> a[i];
    forn(i, n) cin >> b[i];
    vi dp1(n), dp2(n);
    dp1[0] = min(a[0], b[0]);
    ll ans = 0;
    forn(i, n) {
        if (i) dp1[i] = min(a[i] - dp2[i - 1], b[i]);
        dp2[i] = min(a[i + 1], b[i] - dp1[i]);
        ans += dp1[i], ans += dp2[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
	int N, A, B, i, ans=0;
	scanf("%d %d %d", &N, &A, &B);
	
	for(i=1; i<=N; i++){
		int j=i, S=j, sum=0;
		do{
			j/=10;
			sum += S-j*10;
			S=j;
		}while(j>=10);
		sum += j;
		
		if(A<=sum && sum<=B){
			ans+=i;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
    long long N;
    cin >> N;
    long long m_sum = 0,i;
    for(i=1;i<=sqrt(N);i++){
        if((N-i)%i==0){
          if(N/i-1 > i){
            m_sum += N/i-1;}
        }
    }
    cout << m_sum <<endl;
    return 0;
}

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

int main() {
    int x[5];
    scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
    for(int i=0;i<5;i++)
    {
        if(x[i]==0)
        {
            printf("%d\n",i+1);
        }
    }
    return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

double dp[2][210];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t(n), v(n);
    rep(i,n) cin >> t[i];
    rep(i,n) cin >> v[i];
    rep(i,207){
        dp[0][i] = -1;
        dp[1][i] = -1;
    }
    dp[0][0] = 0;
    rep(i,n){
        rep(j,t[i]*2){
            rep(k,v[i]*2+1){
                if(k < v[i]*2 && dp[0][k+1] != -1){
                    chmax(dp[1][k], dp[0][k+1] + (k+0.5)*0.25);
                }
                if(dp[0][k] != -1){
                    chmax(dp[1][k], dp[0][k] + k*0.25);
                }
                if(k > 0 && dp[0][k-1] != -1){
                    chmax(dp[1][k], dp[0][k-1] + (k-0.5)*0.25);
                }
            }
            rep(k,207){
                dp[0][k] = dp[1][k];
                dp[1][k] = -1;
            }
        }
    }
    cout << fixed << setprecision(12) << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int n =101;
  int sum =0;
  rep(i,n){
    if(a<=i && i<b && c<=i && i<d) sum++;
  }
	cout<<sum;
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

int N;
int S[128];
int dp[128][20000];


int main()
{
  cin >> N;
  rep(i, N) cin >> S[i];
  for(int i=0;i<=N;i++) dp[i][0] = 1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=10000;j++){
      if(dp[i][j]){
	dp[i+1][j+S[i]] = 1;
	dp[i+1][j] = 1;
      }
    }
  }

  int res = 0;
  for(int i=1;i<=N;i++){
    for(int j=0;j<=10000;j++){
      if(j % 10 && dp[i][j])
	res = max(res, j);
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    bool OK = true;
    char last_letter;
    set<string> word;
    string S_first;
    cin >> S_first;
    last_letter = S_first.at(S_first.size() - 1);
    word.insert(S_first);
    for (int i = 1; i < N; i++){
        string S;
        cin >> S;
        if (last_letter != S.at(0)){
            OK = false;
            break;
        }
        if (word.count(S)){
            OK = false;
            break;
        }
        last_letter = S.at(S.size() - 1);
        word.insert(S);
    } 
    if (OK){
        cout << "Yes" << endl;
    } 
    else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int bfr[4][3][10]={};
	int n,b,f,r,v,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		bfr[b-1][f-1][r-1] += v;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",bfr[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3) printf("####################\n");
	}
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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 long long INF = 9223372036854775000;
const int VMAX = 3000;
const int EMAX = 6000;

struct Edge{
	int from;
	int to;
	ll cost;
};

int main() { // 1 --> N minimum cost
	ll N,M,P; cin >> N >> M >> P;
	struct Edge e[EMAX];
	long long d[VMAX];
	bool negcycle[VMAX] = {};

	REP(i,M){
		ll a,b,c;
		cin >> a >> b >> c;
		e[i].from = b;
		e[i].to = a; //reverse
		e[i].cost = -c+P; // -1
	}

	REP(i,VMAX){
		d[i] = INF;
	}

	d[N] = 0;

	REP(i,N-1){ // loop V times --> NEGCYCLE

		bool update = false;
		REP(j,M){
			int u = e[j].from;
			int v = e[j].to;
			ll c = e[j].cost;

			if ((d[u] + c < d[v]) and (d[u] != INF)) { //s-->uへ現状行けないときを弾く
				d[v] = d[u] + c;
				update = true;
			}
		}
	}

	ll ans = d[1];

	REP(i,N){
		REP(j,M){
			int u = e[j].from;
			int v = e[j].to;
			ll c = e[j].cost;

			if (d[u] == INF) continue;

			if (d[v] > d[u] + c){
				d[v] = d[u] + c;
				negcycle[v] = true;
			}

			if (negcycle[u] == true){
				negcycle[v] = true;
			}
		}
	}


	if (negcycle[1]) {
		printf("-1");
		return 0;
	}

	cout << max(0LL,-ans) << endl;


	return 0;
}


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

int n, m;
string grid[1002];

bool vis[1002][1002];
int dp[1002][1002];

const int mod = (1e9 + 7);

int func( int r, int c ) {
  if ( r >= n || c >= m ) return 0;
  if ( r == n - 1 && c == m - 1 ) return 1;
  if ( grid[r][c] == '#' ) return 0;
  if ( vis[r][c] ) return dp[r][c];
  vis[r][c] = 1;

  int x = func( r, c + 1 );
  int y = func( r + 1, c );

  return dp[r][c] = (x + y) % mod;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> grid[i];

  cout << func(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	string s,ans;
	cin >> s;
	for (int i = 0; i < s.length(); i += 2)
	{
		ans += s[i];
	}
	cout << ans << endl;
	return 0;
}

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

char buf[111];
int I;
int N;


int cnt;
bool FLAG;
string Character();
string String();
int Number();

string Character(){
  string ret = "";
  if( 'A' <= buf[cnt]  && buf[cnt] <= 'Z' ) return ret+buf[cnt++];
  else return "";
}

string String(){
  string ret = "";
  while( 'A' <= buf[cnt] && buf[cnt] <= 'Z' ) {
    ret += buf[cnt];
    cnt++;
  }
  return ret;
}

int Number(){
  int it = cnt;
  int ret = 0;
  while( '0' <= buf[cnt] && buf[cnt] <= '9' ) {
    ret *= 10;
    ret += buf[cnt]-'0';
    cnt++;
  }
  if( it == cnt ) return -1;
  return ret;
}

void output( int strnum, string ret ){
  if(FLAG) return;
  int rd = (I-strnum)%(int)ret.size();
  cout << ret[rd] << endl;
  FLAG = true;
}

string Genom(int strnum){
  string rets="";
  while( !FLAG && cnt < N ){
    int num = Number();

    // cout << num <<" "<< cnt << " "<< strnum << " " << buf[cnt]<< " " << rets <<  endl;
    if( buf[cnt] == ')' ) break;
    string ret;
    if( num == -1 ){
      ret = String();
      if( strnum + (int)ret.size() > I ){
	output( strnum, ret );
	return "-";
      }
      rets+=ret;
      strnum += ret.size();
    } else {
      if( buf[cnt] == '(' ){
	cnt++;
	ret = Genom(strnum);
	if( strnum + (int)ret.size() * num > I ){
	  output( strnum, ret );
	  return "-";
	}
	for(int i=0;i<num;i++) rets+=ret;
	strnum += ret.size()*num;
	cnt++;
      } else {
	ret = Character();
	if( strnum + (int)ret.size() * num > I ){
	  output( strnum, ret );
	  return "-";
	}
	for(int i=0;i<num;i++) rets+=ret;
	strnum += ret.size()*num;
      }
    } 
  }
  return rets;
}

int solve(){
  cnt = 0;
  N = strlen(buf);
  FLAG = false;
  Genom(0);
  if( !FLAG ) cout << 0 << endl;
}

int main(){
  while( 1 ){
    cin >> buf >> I;
    if( buf[0] == '0' && I == 0 ) break;
    solve(); 
  }
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int k; cin >> k;
  ll su = 0;
  for(int i=1;i<=k;++i) {
    for(int j=1;j<=k;++j) {
      for(int l=1;l<=k;++l) {
        int g = gcd(i, j);
        g = gcd(g, l);
        su += g;
//        cout << g << endl;
      }
    }
  }
  cout << su << endl;
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d, g;
    cin >> d >> g;
    g /= 100;
    vector<int> p(d), c(d);
    rep(i, 0, d){
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    int ans = INF;
    for(int mask = 0; mask < (1 << d); mask++){
        int cnt = 0;
        int now = g;
        rep(i, 0, d){
            if(mask & (1 << i)){
                cnt += p[i];
                now -= (i + 1) * p[i] + c[i];
            }
        }
        for(int i = d - 1; i >= 0; i--){
            if(mask & (1 << i)) continue;
            if(now <= 0) continue;
            int tmp = (now + i) / (i + 1);
            if(tmp <= p[i]){
                cnt += tmp;
                now = 0;
            }else{
                cnt += p[i];
                now -= p[i] * (i + 1);
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;
    
public:
    u64 a;
    
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};


#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long int
#define MOD 1000000007
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair

using namespace std;
using mint = modint<1000000007>;

mint dp0[2005][2005];
mint dp1[2005][2005];

int main(){
    int N,M;
    cin >> N >> M;
    vector<ll> S(N+1);
    vector<ll> T(M+1);
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    for(int i=0;i<M;i++){
        cin >> T[i];
    }
    dp0[0][0]=1;
    for(int i=0;i<N+1;i++){
        for(int j=0;j<M+1;j++){
            dp0[i+1][j]+=dp0[i][j];
            dp1[i][j]+=dp0[i][j];
            dp1[i][j+1]+=dp1[i][j];
            if(S[i]==T[j]){
                dp0[i+1][j+1]+=dp1[i][j];
            }
        }
    }
    cout << dp1[N][M].value() << endl;
    return 0;
}

Measured memory_bytes: 62976
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
ll a[200005],b[200005],c[200005];
int main()
{
	ll n,cnt=0;
	scanf("%lld",&n);
	memset(b,0,sizeof(b));
	memset(c,0,sizeof(c));
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(b[a[i]]==0){
			c[cnt++]=a[i];
		}
		b[a[i]]++;
	}
	ll sum=0;
	for(int j=0;j<cnt;j++){
		if(b[c[j]]>=2)
			sum+=(b[c[j]]-1)*b[c[j]]/2;
	}
	//cout<<sum<<endl;
	for(int i=0;i<n;i++){
		if(b[a[i]]-1>=1){
			printf("%lld\n",sum-b[a[i]]+1); 
		}else{
			printf("%lld\n",sum); 
		}
	}
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int n;
  cin >> n;
  vector<string> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  string s="Yes";
  for(i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(vec.at(i)==vec.at(j)){
        s="No";
      }
    }
  }
  for(i=0;i<n-1;i++){
    if(vec.at(i).at(vec.at(i).size()-1)!=vec.at(i+1).at(0)){
      s="No";
    }
  }
  cout << s;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define S second
#define int long long
using namespace std;
int x[1000000];
signed main() {
	int a, b, ans = 0;
	cin >> a >> b;
	f(i, a) {
		cin >> x[i + 1];
		x[i + 1] += x[i];
	}
	for (int i = b; i <= a; i++) {
		ans = max(x[i] - x[i - b], ans);
	}
	printf("%.100lf\n",(ans + b) / 2.0);
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!
N=int(input())

H=list(map(int,input().split()))
count=0

for i in range(1,101):
    judge=False
    for item in H:
        if judge:
            if item>=i:
                continue
            else:
                judge=False
        else:
            if item>=i:
                judge=True
                count+=1
            else:
                continue
print(count)




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

long long a, v, b, w, t;

int main(){
	cin >> a >> v >> b >> w >> t;
	long long dist=abs(a-b);
	if (v>w && dist<=t*(v-w)) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair



int main(){
	int n, w;
	cin >> n>> w;
	ll a[n][2];
	for(int i = 0 ;i < n ;i++)cin>>a[i][0]>>a[i][1];
	long long int dp[n+1][w+1];
	memset(dp,0,sizeof(dp));

	for(int i = 1;i <= n ;i++){
		for(int j = 1; j<= w;  j++){
			if(a[i-1][0] > j)dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],a[i-1][1]+ dp[i-1][j-a[i-1][0]]);
		}
	}
	cout<<dp[n][w]<<"\n";
return 0;
}


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

using namespace std;

using ll = long long;
const int NMAX = 401;
const ll INF = 1e18L + 1;

ll dp[NMAX][NMAX];

int main()
{
    ll N;
    cin>>N;
    vector<ll> v(N);
    for(auto &x: v){
        cin>>x;
    }

    auto sum = [&](ll L, ll R){
        ll s = 0;
        for(ll i = L ; i <= R ; i++){
            s += v[i];
        }
        return s;
    };

    for(ll L = N - 1 ; L >= 0 ; L --){
        for(ll R = L ; R < N ; R++){
            if(L == R){
                dp[L][R] = 0;
            }
            else{
                ll s = sum(L, R);
                dp[L][R] = INF;
                for(int i = L ; i < R ; i++){
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + sum(L, R));
                }
            }
        }
    }

    cout<<dp[0][N - 1];

    return 0;
}


Measured memory_bytes: 1536
import sys
def gcd(x, y):
  while y:
    x, y = y, x % y
  return x
n, m = map(int, input().split())
l = (n * m) // gcd(n, m)
a, b = l // n, l // m
s = input()
t = input()
i, j = 0, 0
while((i < n) & (j < m)):
  if (s[i] != t[j]):
    print(-1)
    sys.exit()
  else:
    i += b
    j += a
print(l)

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n;
  ll t;
  cin >> n >> t;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  map<int, vector<int>> m;
  for (int i = 0; i < n; i++) m[a[i]].eb(i);

  int mx = a[n-1];
  int res = 0;
  for (int i = n-2; i > -1; i--){
    res = max(res, mx - a[i]);
    mx = max(mx, a[i]);
  }

  map<int, int> used;
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (used.count(a[i])) continue;
    vector<pair<int, int>> v;
    for (auto j : m[a[i]]) v.eb(j, 1);
    for (auto j : m[a[i] + res]) v.eb(j, -1);
    int p = 0;
    int s = (int) m[a[i] + res].size();
    int cur = p + s;
    sort(v.begin(), v.end());
    for (auto j : v){
      if (j.ss == 1) p++;
      else s--;
      cur = min(cur, p + s);
    }
  
    ans += cur;
    used[a[i]] = 1;
  }

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 27100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numM = 0;

		try {
			scanner = new Scanner(System.in);
			numM = scanner.nextInt();

			System.out.println(24 + 24 - numM);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;
		String s = "";

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();
			s = scanner.next();
			try {
				String wkA = s.substring(0, numA);
				String wkB = s.substring(numA + 1, s.length());
				Integer.parseInt(wkA);
				Integer.parseInt(wkB);

				if (numA + numB + 1 == s.length()) {
					String wk = s.substring(numA, numA + 1);
					if (wk.equals("-")) {
						System.out.println("Yes");
						return;
					}
				}
			} catch (NumberFormatException e) {
				//				e.printStackTrace();
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
		System.out.println("No");
	}

	private int getTime(int currentI, int currentTime) {

		if (currentI == cNumN - 1) {
			return currentTime;
		}

		int res = currentTime;

		int c = csf[currentI][0];
		int s = csf[currentI][1];
		int f = csf[currentI][2];

		if (currentTime < s) {
			res = s;
		} else if (currentTime % f != 0) {
			res = res + (f - res % f);
		}
		res += c;
		res = getTime(currentI + 1, res);
		return res;
	}

	int cNumN = 0;
	int[][] csf;

	private void solveC() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);
			cNumN = scanner.nextInt();
			csf = new int[cNumN - 1][3];

			for (int i = 0; i < csf.length; i++) {
				csf[i][0] = scanner.nextInt();
				csf[i][1] = scanner.nextInt();
				csf[i][2] = scanner.nextInt();
			}

			for (int i = 0; i < csf.length; i++) {
				System.out.println(getTime(i, 0));
			}

			System.out.println(0);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 28596
import java.util.*;

public class Main {

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		if((a+w<b)||b+w<a){
		int ans1=Math.abs(a+w-b);
		int ans2=Math.abs(b+w-a);
		System.out.println(Math.min(ans1, ans2));
		}
		else System.out.println("0");
	}
}


Measured memory_bytes: 35300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
#define rep2(i, ns, ne) for (int i = ns; i <= ne; ++i)

int main() {
  int x;
  vector<int> v(11, 0);
  rep(i, 0, 3) {
    cin >> x;
    v[x]++;
  }
  cout << ((v[5] == 2 and v[7] == 1) ? "YES" : "NO") << endl;
  getchar();
}

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

int N, K, R, S, P;

int f(char c) {
  if(c == 'r') {
    return P;
  }
  else if(c == 's') {
    return R;
  }
  else {
    return S;
  }
}

char g(char c) {
  if(c == 'r') {
    return 'p';
  }
  else if(c == 's') {
    return 'r';
  }
  else {
    return 's';
  }
}
 
char h(char c) {
  if(c == 'r') {
    return 's';
  }
  else if(c == 's') {
    return 'p';
  }
  else {
    return 'r';
  }
}
  

int main() {
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;
  string log;
  int score = 0;
  for(int i = 0; i < N; i++) {
    if(i < K) {
      score += f(T.at(i));
      log += g(T.at(i));
    }
    else if(i < N - K) {
      if(log.at(i - K) != g(T.at(i))) {
        log += g(T.at(i));
        score += f(T.at(i));
      }
      else if(g(T.at(i + K)) != T.at(i)) {
        log += T.at(i);
      }
      else {
        log += h(T.at(i));
      }
    }
    else {
      if(log.at(i - K) != g(T.at(i))) {
        log += g(T.at(i));
        score += f(T.at(i));
      }
      else {
        log += T.at(i);
      }
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 640
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string S;
	cin >> S;
	cout << S[0] << S[1] << S[2] << '\n';
	
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], c[100005], ans = 0;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        c[a[i]]++;
        c[a[i] + 1]++;
        if(a[i] == 0) {
            c[100005]++; 
        }else {
            c[a[i] - 1]++;
        }
    }
    for(int i = 0; i <= 100005; i++) {
        ans = max(c[i], ans);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(W,H,x,y,r) {
    if(x+r<=W && y+r<=H && y-r>=0 && x-r>=0){
        console.log('Yes');
    }else{
        console.log('No');
    }
    

  }(params[0],params[1],params[2],params[3],params[4])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << max(0, a-b);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char M;
	int n, i, count, plus = 0;
	int S[13] ={0},H[13] = {0}, C[13] = {0}, D[13] = {0};
	scanf("%d", &n);
	while (plus < n) //???????????????n?????\???
	{
		getchar();
		scanf("%c %d", &M, &i);
		switch (M)
		{
			case 'S' :
				S[i - 1] = 1;
				break;
			case 'H' :
				H[i - 1] = 1;
				break;
			case 'C' :
				C[i - 1] = 1;
				break;
			case 'D' :
				D[i - 1] = 1; 
				break;
		}
		plus++;
	}
	//?¶????????????????????????¢???
	for (count = 0; count < 13; count++)
	{
		if(S[count] == 0)
		printf("S %d\n", count + 1);
	}
		for (count = 0; count < 13; count++)
	{
		if(H[count] == 0)
		printf("H %d\n", count + 1);
	}
		for (count = 0; count < 13; count++)
	{
		if(C[count] == 0)
		printf("C %d\n", count + 1);
	}
		for (count = 0; count < 13; count++)
	{
		if(D[count] == 0)
		printf("D %d\n", count + 1);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5 * 1e5 + 10;
typedef pair<long long, long long> P;
bool comp(P &p1, P &p2){
    return p1.second < p2.second;
}
struct BIT{
    vector<long long> num;
    int N;
    BIT(int n){
        N = n;
        num.resize(N + 1, 0);
    }
    long long sum(long long t){
        long long res = 0;
        while(t > 0){
            res += num[t];
            t -= t & -t;
        }
        return res;
    }
    void add(int ind, long long t){
        while(ind <= N){
            num[ind] += t;
            ind += ind & -ind;
        }
    }
};
int main(){
    int N, Q;
    cin >> N >> Q;
    BIT BIT(N);
    vector<long long> c(N);
    vector<long long> ans(Q);
    for(int i = 0; i < N; i++) {
        cin >> c[i];
    }
    vector<long long> l(Q), r(Q);
    vector<int> order(Q);
    for(int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
        order[i] = i;
    }
    sort(order.begin(), order.end(), [&](int x, int y){
        return r[x] < r[y];
    });
    vector<long long> num(500010, -1);
    int ind = 0;
    for(int i = 0; i < N; i++){
        if(ind == Q) break;
        if(num[c[i]] != -1){
            BIT.add(num[c[i]], -1);
            num[c[i]] = i + 1;
            BIT.add(num[c[i]], 1);
        }
        else{
            num[c[i]] = i + 1;
            BIT.add(num[c[i]], 1);
        }
        while(i + 1 == r[order[ind]]){
            long long temp = BIT.sum(i + 1) - BIT.sum(l[order[ind]] - 1);
            ans[order[ind]] = temp;
            ind++;
            if(ind == Q) break;
        }
    }
    for(int i = 0; i < Q; i++){
        cout << ans[i] << endl;
    }
}

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

int main () {
  string S;
  cin >> S;
  int s = S.size();
  vector<int> t(s);
  if (s != 26) {
    vector<bool> u(26, false);
    for (int i = 0; i < s; i++) {
      t.at(i) = S.at(i)-'a';
      int U = t.at(i);
      u.at(U) = true;
    }
    int k;
    for (int i = 0; i < 26; i++) {
      if(u.at(i) == false) {
        k = i;
        break;
      }
    }
   char c  = k + 'a';
   cout << S + c << endl;
  }
  else {
    for (int i = 0; i < s; i++) {
      t.at(i) = S.at(i)-'a';
    }
    int k = -1;
    for (int i = 25; i > 0; i--) {
      if (t.at(i) > t.at(i-1)) {
        k = i;
        break;
      }
    }
    if (k == -1) cout << -1 << endl;
    else {
      int l = 26;
      for (int i = k; i < 26; i++) {
        if (t.at(i) < t.at(k-1)) continue;
        else {
         l = min(t.at(i), l);
        }
      }
      vector<char> T(k);
      for (int i = 0; i < k-1; i++) {
        T.at(i) = S.at(i);
      }
      char a = S.at(k-1);
      T.at(k-1) = l+'a';
      for (int i = 0; i < k; i++) {
        cout << T.at(i);
      }
    }
  }
}
     

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))

minus = 0
for i in range(n):
    if A[i] < 0:
        minus += 1
zplus = n - minus

B = []
C = []
for i in range(n):
    if A[i] < 0:
        C.append(A[i])
    else:
        B.append(A[i])
B.sort(reverse=True)
C.sort()


if k <= minus * zplus:
    ok = 1
    ng = -10**20
    m = (ok+ng) // 2
    while abs(ng-ok) > 1:
        co = 0
        j = len(C)-1
        for i in range(len(B)):
            while j >= 0 and B[i]*C[j] > m:
                j -= 1
            co += j+1
        # print(m, co)
        if co >= k:
            ok = m
            # print("ok")
        else:
            ng = m
            # print("ng")
        m = (ok+ng) // 2
    print(ok)
else:
    k -= minus * zplus
    ok = 10**20
    ng = -1
    m = (ok+ng) // 2
    while abs(ng-ok) > 1:
        co = 0
        j = len(C)-1
        for i in range(len(C)):
            while j > i and C[i]*C[j] <= m:
                j -= 1
            co += len(C)-1-j
            j = max(j, i+1)
        j = len(B)-1
        for i in range(len(B)):
            while j > i and B[i]*B[j] <= m:
                j -= 1
            co += len(B)-1-j
            j = max(j, i+1)

        if co >= k:
            ok = m
            # print("ok")
        else:
            ng = m
            # print("ng")
        m = (ok+ng) // 2
    print(ok)

Measured memory_bytes: 106092
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> L(N); for (auto &l : L) cin >> l;
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                Int a = L[i], b = L[j], c = L[k];
                if (a == b || b == c || c == a) continue;
                Int ma = max(a, max(b, c));
                if (a + b + c - ma > ma) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int r, c;
	cin >> r >> c;
	vector< vector<int>> v(r + 1, vector<int>(c + 1));
	
	for (int i = 0; i < r;i++){
		for (int j = 0; j < c; j++){
			cin >> v[i][j];
		}
	}
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			v[i][c] += v[i][j];
			v[r][j] += v[i][j];
		}
		v[r][c] += v[i][c];
	}
	for (int i = 0; i < r+1; i++){
		for (int j = 0; j < c; j++){
			cout << v[i][j] << " ";
		}
		cout << v[i][c] << endl;
	}
	return 0;
}

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

int main(){
    int N;
    long int ans=0;
    int c=0;
    cin >> N;
    vector<int> A(N,0);
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]<0) c++;
    }
    if(c%2==0){
        for(int i=0;i<N;i++) ans+=abs(A[i]);
    }else{
        for(int i=0;i<N;i++) A[i]=abs(A[i]);
        sort(A.begin(),A.end());
        for(int i=1;i<N;i++) ans+=A[i];
        ans -= A[0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
long long f[10000005];
int vis[10000005];

long long preWork(int n){
    for(int i = 1; i <= n; i++) f[i] = i;
    vis[1] = 1;
    for(int i = 2; i <= n; i++){
        if(!vis[i]){
            f[i] *= 2;
            for(int j = 2*i; j <= n; j+=i){
                vis[j] = 1;
                int cur = j, cnt = 1;
                while(cur%i==0) cur /= i, cnt++;
                f[j] *= (long long)cnt;
            }
        }
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++){ 
        ans += f[i];
    }
    return ans;
}

int main(){
    int n;
    scanf("%d",&n);
    printf("%lld\n",preWork(n));
    return 0;
}


Measured memory_bytes: 118892
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	string s;
	int w;
	cin >> s;
	cin >> w;
	int n = s.length();
	int j = 0;
	rep(i, 0, (int)ceil((double)n/w)) {
		cout << s[j];
		j += w;

	}
	return 0;
}





Measured memory_bytes: 256
using System;

namespace C___Christmas_Eve
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var k = int.Parse (input[1]);
            var a = new int[n];
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse (Console.ReadLine ());
            }
            Array.Sort (a);
            var b = int.MaxValue;
            for (var i = 0; i < a.Length - k + 1; i++)
            {
                b = Math.Min (a[i + k - 1] - a[i], b);
            }
            Console.WriteLine (b);
        }
    }
}

Measured memory_bytes: 17376
def main():
    abcd = input()

    a = int(abcd[0])
    b = int(abcd[1])
    c = int(abcd[2])
    d = int(abcd[3])
    if (a + b + c + d == 7):
        print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    elif (a + b + c - d == 7):
        print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    elif (a + b - c + d == 7):
        print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    elif (a + b - c - d == 7):
        print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    elif (a - b + c + d == 7):
        print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    elif (a - b + c - d == 7):
        print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    elif (a - b - c + d == 7):
        print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    elif (a - b - c - d == 7):
        print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll A = readInt(), B = readInt(), C = readInt();
    ll K = readInt();
    if (K % 2 == 1) {
    	cout << B - A;
    } else {
    	cout << A - B;
    } 
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import math

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    # N = int(input())
    N, M, P = [int(a) for a in input().split()]
    ABC = [
        [int(a) for a in input().split()]
        for _ in range(M)
    ]

    FORWARD = defaultdict(lambda: [])
    BACK = defaultdict(lambda: [])
    for a, b, c in ABC:
        t = FORWARD[a]
        t.append((b, c))
        FORWARD[a] = t

        t = BACK[b]
        t.append((a, c))
        BACK[b] = t

    mem = {N}
    q = [N]
    while len(q) != 0:
        t = q.pop()
        for t2, _ in BACK[t]:
            if t2 in mem:
                continue
            q.append(t2)
            mem.add(t2)

    ABC = [(a, b, P - c) for a, b, c in ABC if a in mem and b in mem]

    table = [MAX] * (N + 1)
    history_table = [set() for _ in range(N + 1)]
    table[1] = 0
    # history_table[1] = {1}
    # table2 = [-1] * N
    for _ in range(len(mem)):
        for a, b, c in ABC:
            if table[a] == MAX:
                continue
            if table[a] + c < table[b]:
                # if b in history_table[a]:
                #     print(-1)
                #     return
                table[b] = table[a] + c
                # h2 = set(history_table[a])
                # h2.add(b)
                # history_table[b] = h2
    for a, b, c in ABC:
        if table[a] == MAX:
            continue
        if table[a] + c < table[b]:
            print(-1)
            return
    print(max(0, -table[N]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 51672