akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll N;
  string S;
  cin>>N>>S;
  ll num=0;
  for(int i=0;i<1000;++i){
    ll f=0;
    FOR(j,S.size()){
      if(f==0){
        if(S[j]-'0'==i/100){
          f=1;
        }
      }else if(f==1){
        if(S[j]-'0'==(i/10)%10){
          f=2;
        }
      }else{
        if(S[j]-'0'==i%10){
          num++;
          break;
        }
      }
    }
    
  }
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,a[10000];
	long long max=-1000000,min=1000000,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if (a[i]>max){
			max=a[i];
		}
		if (a[i]<min){
			min=a[i];
		}
		sum+=a[i];
	}
	cout<<min<<' '<<max<<' '<<sum<<endl;
}


Measured memory_bytes: 3108
// C - Connect Cities
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;

int main(){
	int n, m; cin>>n>>m;
	dsu d(n);
	int ans = n - 1;
	while(m--){
		int a, b; cin>>a>>b; --a,--b;
		if(!d.same(a, b)){
			d.merge(a, b);
			ans--;
		}
	}
	cout<< ans <<endl;
}


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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    //　一番大きいものに合わせる
    int m = max(A, B);
    m = max(m, C);

    int cost = 0;
    while ((A + 2) <= m) {
        cost++;
        A += 2;

    }

    while ((B + 2) <= m) {
        cost++;
        B += 2;
    }

    while ((C + 2) <= m) {
        cost++;
        C += 2;
    }


    int bg = 0;
    if (A == m) bg++;
    if (B == m) bg++;
    if (C == m) bg++;
    if (m%2!=1) {
        if (bg == 1) bg = 2;
    }



    cout << cost + (bg % 3) << endl;

    // cout << A << " " << B << " " << C << endl;


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#include<vector>
typedef long long LL;
using namespace std;
const int N=100010;
int n,k,na,nb,a[N],b[N];
int Write[20];
int read() {int d=0,f=1; char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();} while (c>='0'&&c<='9') d=(d<<3)+(d<<1)+c-48,c=getchar(); return d*f;}
void write(int x){int t=0; for (;x;x/=10) Write[++t]=x%10; if (!t) putchar('0'); for (int i=t;i>=1;i--) putchar((char)(Write[i]+48));}
void judge(){freopen(".in","r",stdin); freopen(".out","w",stdout);}
int main()
{
	//judge();
	n=read(); k=read();
	for (int i=1;i<=n;i++)
	{
		int x=read();
		if (x<0) a[++na]=x; else b[++nb]=x;
	}
	reverse(a+1,a+1+na);
	int ans=1E9;
	for (int i=1;i<=k&&i<=na;i++) if (nb>=k-i)
	{
		ans=min(ans,2*(-a[i])+b[k-i]);
		ans=min(ans,2*b[k-i]-a[i]);
	}
	for (int i=1;i<=nb&&i<=k;i++) if (na>=k-i)
	{
		ans=min(ans,2*b[i]-a[k-i]);
		ans=min(ans,2*(-a[k-i])+b[i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
dic_alp= {alp:0 for alp in 'abcdefghijklmnopqrstuvwxyz'}
while True:
    try:
        txt = input()
        
        for s in txt:
            s = s.lower()
            if s in dic_alp.keys():
                dic_alp[s] += 1
    except:
        break

for k in dic_alp:
    print(f'{k} : {dic_alp[k]}')


Measured memory_bytes: 5580
import sys 

S = input()

n = len(S)

l = 0
r = n
while l < r:
    #print(S[l], S[r-1])
    if S[l] != S[r-1]:
        print('No')
        sys.exit()
    l += 1
    r -= 1

ls = S[:((n-1)//2)]
#print(ls)
l = 0
r = len(ls)
while l < r:
    #print(S[l], S[r-1])
    if ls[l] != ls[r-1]:
        print('No')
        sys.exit()
    l += 1
    r -= 1

rs = S[((n+3)//2)-1:]
#print(rs)
l = 0
r = len(rs)
while l < r:
    #print(rs[l], rs[r-1])
    if rs[l] != rs[r-1]:
        print('No')
        sys.exit()
    l += 1
    r -= 1

print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	if( a*b <= 0 ){
		cout << "Zero" << endl;
	} else if( a > 0 or (b-a+1)%2 == 0 ){
		cout << "Positive" << endl;
	} else {
		cout << "Negative" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n, k, i = 0;
    scanf("%d %d", &n, &k);
    for (;;)
    {
        n = n / k;
        i++;
        if (n < 1)
        {
            break;
        }
    }
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int>a(n), b(n),c(n-1);
	for (auto& e : a)cin >> e;
	for (auto& e : b)cin >> e;
	for (auto& e : c)cin >> e;

	int ans=0;
	int prev = -1;
	for (int i = 0; i < n; ++i) {
		ans += b[a[i]-1];
		if (prev == a[i] - 1) ans += c[a[i]-1-1];
		prev = a[i];
	}
	cout << ans << endl;

	return 0;
}

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

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    int a,b;
    cin >> a >>b;
    if(b % a == 0) cout << a +b << '\n';
    else cout << b - a << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <algorithm>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <bitset>
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1e9 + 7;
//__int128
const int maxn = 3e5;
char s[maxn];
signed main()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> (s + 1);
  int n = strlen(s + 1), res = 0;
  std::vector<int> v(n + 1);
  for(int i = 1; i <= n; ++i) {
  	if(s[i] == 'B') {
  		v[i] = v[i - 1] + 1;
  	} else {
  		v[i] = v[i - 1];
  		res += v[i];
  	}
  }
  cout << res << endl;
	return 0;
}

Measured memory_bytes: 2048
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def dfs(now, vis, dis):
    for to,c in edge[now]:
        if not vis[to]:
            if dis[to] == 0:
                dis[to] = dis[now] + c
            else:
                dis[to] = min(dis[now] + c, dis[to])
            vis[now] = 1
            dfs(to, vis, dis)

N = int(input())

edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    edge[a-1].append([b-1, c])
    edge[b-1].append([a-1, c])

visited = [0]*N
distance = [0]*N

Q, K = map(int, input().split())
dfs(K-1, visited, distance)

#print(distance)

for _ in range(Q):
    x, y = map(lambda x:int(x)-1, input().split())
    print(distance[x]+distance[y])

Measured memory_bytes: 139928
//file_name:ABC88_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a[3][3];
    rep(i,3){
        scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    }
    
    int flag = 0;
    rep(i,2){
        rep(j,2){
            if(a[i][j+1]-a[i][j] != a[i+1][j+1]-a[i+1][j])flag++;
        }
    }
    rep(i,2){
        rep(j,2){
            if(a[i+1][j]-a[i][j] != a[i+1][j+1]-a[i][j+1])flag++;
        }
    }
    if(flag==0)yn;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define Yes(a) if(a)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
int aaa(int a, int b) {
	for (int i = 1;; i++) {
		if (i * a > b)return i-1;
	}
}

int main(){
	int a;
	cin >> a;
	int ans = a;
	vector<char> s(a);
	rep(i, 0, a)cin >> s[i];
	rep(i, 0, a - 1) {
		if (s[i] == s[i + 1])ans--;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[10],vis[10],ans=2147483647;
void dfs(int x,int t)
{
	if(x==5)
	{
		for(register int i=1;i<=5;i++)
			if(!vis[i])
				if(t+a[i]<ans)
					ans=t+a[i];
		return;
	}
	for(register int i=1;i<=5;i++)
		if(!vis[i])
		{
			vis[i]=1;
			int s=t+a[i];
			if(s%10)
				s=s/10*10+10;
			dfs(x+1,s);
			vis[i]=0;
		}
}
int main()
{
	for(register int i=1;i<=5;i++)
		scanf("%d",&a[i]);
	dfs(1,0);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(),s.end()
#define fp(x) fixed<<setprecision(x)<<
#define split(x) while ((cout<<s[i],i+=1) && (i<n-1) && (cout<<x));
int digit(ll a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
int main(){
    quickie;
    //txt;
    int a,b; cin>>a;
    char c; cin>>c>>b;
    if(c == '+')
        cout<<a+b;
    else
    {
        cout<<a-b;
    }
    
    
    return 0;
}

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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n) \
  ld n;       \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes              \
  cout << "Yes" << endl; \
  return 0;
#define no              \
  cout << "No" << endl; \
  return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(n) LLI(x) LLIV(a, n) SORT(a) DEFO(flag) lli i;
  for(i = 0;i < n - 1;i++) {
    if(x - a[i] >= 0) {
      flag++;
      x -= a[i];
    }
    else { OUT(flag) return 0; }
  }
  if(x - a[i] == 0) {
    flag++;
  }
  OUT(flag)
}


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

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  
  vector<ll> v;
  ll x;
  ll a = 0;
  for ( ll i = 1; i <= n; i++ ){
    cin >> x;
    if (i == x ) ++a;
    if ( (i != x || i == n) && a > 0 ){
      v.push_back(a);
      a = 0;
    }
  }
  
  ll ans = 0;
  
  for ( auto x: v ) 
    ans += x % 2 ? x / 2 + 1: x / 2;
  
  cout << ans << endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string s; cin >> s;
    int n = s.size();

    vector<lint> a(n); lint fac = 1;
    repr(i, n){
        a[i] = (s[i]-'0')*fac%2019;
        fac = (fac*10)%2019;
    }
    repr(i, n-1){
        a[i] += a[i+1];
        a[i] %= 2019;
    }

    vector<lint> c(2019);
    rep(i, n){
        c[a[i]] += 1;
    }

    lint ans = 0;
    rep(i, 2019){
        if(i==0) c[i]+=1;
        ans += (c[i])*(c[i]-1)/2;
    }
    out(ans);
}

Measured memory_bytes: 5184
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    mat = [list(map(int, readline().split())) for _ in range(n)]
    ct, cx, cy = 0, 0, 0

    for nt, nx, ny in mat:
        dist = abs(nx - cx) + abs(ny - cy)
        interval = nt - ct

        if dist > (nt - ct) or (dist - interval) % 2 == 1:
            print('No')
            sys.exit()
        ct, cx, cy = nt, nx, ny

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 27312
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=n;i>=c;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

long long i, j, q;

ll gcd(ll a, ll b) {
	return (b == 0) ? a : gcd(b, a%b);
}

int main() {
	IO;
	//ifstream cin("In.txt");
	ll n,a, ans = 0;
	cin >> n;
	VEC vc(n),vcr(n);
	f0(i, n) {
		cin >> a;
		vc[i] = a;
		vcr[i] = a;
	}
	f1(i, n - 1) {
		vc[i] = gcd(vc[i], vc[i - 1]);
		vcr[n - i - 1] = gcd(vcr[n - i], vcr[n - i - 1]);
	}
	ans = max(vcr[1], vc[n - 2]);
	f1(i, n-2) {
		ans = max(ans, gcd(vc[i - 1], vcr[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/*input
200000 1
123 456 7
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const int maxn=3e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll pref[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n,q;
    cin>>n>>q;
    set<pair<pii,int>> s;
    pref[0]=0;
    REP1(i,n) pref[i]=(pref[i-1]+mypow(10,i-1))%MOD;
    ll ans=pref[n];
    s.insert({{1,n},1});
    while(q--){
        int l,r,d;
        cin>>l>>r>>d;
        int tl=l;
        l=n-r+1;
        r=n-tl+1;
        //if(q==2) break;
        auto li=*prev(s.upper_bound({{l,INF},0}));
        auto ri=*prev(s.upper_bound({{r,INF},0}));
        auto il=prev(s.upper_bound({{l,INF},0}));
        auto ir=prev(s.upper_bound({{r,INF},0}));
        vector<pair<pii,int>> v;
        while(il!=ir){
            auto x=*il;
            ans-=mult((pref[x.f.s]-pref[x.f.f-1]+MOD)%MOD,x.s);
            ans+=MOD;
            ans%=MOD;
            v.pb(*il);
            il=next(il);
        }
            auto x=*il;
            ans-=mult((pref[x.f.s]-pref[x.f.f-1]+MOD)%MOD,x.s);
            ans+=MOD;
            ans%=MOD;
            v.pb(*il);
            for(auto x:v) s.erase(s.find(x));
        if(li.f.f!=l){
            ans+=mult(((pref[l-1]-pref[li.f.f-1]+MOD)%MOD),li.s);
            ans%=MOD;
            s.insert({{li.f.f,l-1},li.s});
        }
        if(ri.f.s!=r){
            ans+=mult(((pref[ri.f.s]-pref[r]+MOD)%MOD),ri.s);
            ans%=MOD;
            s.insert({{r+1,ri.f.s},ri.s});
        }

        ans+=mult(((pref[r]-pref[l-1]+MOD)%MOD),d);
        ans%=MOD;
        s.insert({{l,r},d});
        //for(auto x:s) cout<<x.f.f<<' '<<x.f.s<<'\n';
        cout<<ans<<'\n';
    }
}


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

using int64 = long long;

template <typename T>
struct FenwickTree {
    int n;
    vector<T> dat;

    FenwickTree(vector<T>& d) {
        n = d.size();
        dat.resize(n + 1, 0);
        for (int i = 0; i < n; i++) dat[i + 1] = d[i];
    }

    FenwickTree(int size) {
        n = size;
        dat = vector<T>(n + 1, 0);
    }

    // 0-indexed
    T sum(int i) {
        if (i < 0) return 0;

        i++;
        T res = 0;
        while (i > 0) {
            res += dat[i];
            i -= i & -i;
        }
        return res;
    }

    // [i, j]
    T sum(int i, int j) {
        return sum(j) - sum(i - 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};

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

    map<int64, int> b2id;
    b2id[0] = 0;

    vector<int64> b(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
        b[i] -= K;

        if (i > 0) b[i] += b[i - 1];

        b2id[b[i]] = 0;
    }

    int id = 0;
    for (auto& mp : b2id) mp.second = id++;

    FenwickTree<int64> ft(id);
    ft.add(b2id[0], 1);

    int64 ans = 0;
    for (int i = 0; i < N; i++) {
        ans += ft.sum(b2id[b[i]]);
        ft.add(b2id[b[i]], 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int a, b, c, d, n = 0, ans = 0, ans2 = 0;
	string s;
	cin >>a>>s;
    n=a/2;
    string ss=s.substr(n);
    ss+=ss;
    if(s==ss)cout<<"Yes"<<endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*input
8 1000 800 100
300
333
400
444
500
555
600
666
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int n,a,b,c;
int x[maxn];
int type[maxn];
int ans=INF;

void dfs(int u){
	if(u==n){
		int A,B,C;
		A=B=C=0;
		int cur=-30;
		REP(i,n){
			cur+=10;
			if(type[i]==1) A+=x[i];
			else if(type[i]==2) B+=x[i];
			else if(type[i]==3) C+=x[i];
			else cur-=10;
		}
		if(A==0||B==0||C==0) return;

		cur+=abs(A-a)+abs(B-b)+abs(C-c);
		ans=min(ans,cur);
		return;
	}
	REP(i,4) type[u]=i,dfs(u+1);
}

int main()
{
	cin>>n>>a>>b>>c;
	REP(i,n) cin>>x[i];
	dfs(0);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
// ITP1_7_B How many ways?
import java.io.*;

public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         while (true) {
            String strAry[] = br.readLine().split(" ");
            int n = Integer.parseInt(strAry[0]);
            int x = Integer.parseInt(strAry[1]);

            if ((n == 0 && x == 0) || (n < 3 || n > 100))
               break;

            System.out.println(combination(n, x));
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }

   private static int combination(int n, int x) {
      int count = 0;
      int a, b, c;
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j < i; j++) {
            for (int k = 1; k < j; k++) {
               if (i + j + k == x)
                  count++;
            }
         }
      }

      return count;
   }
}

Measured memory_bytes: 18592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		sc.close();
		long k = (long)Math.ceil((Math.sqrt(1 + 8 * X) - 1) / 2);
		System.out.println(k);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1e18;
signed main(){
	int h,n;cin >>h >> n;
	vector<int> dp(h+1,INF);
	dp[0] = 0;
	rep(i,n){
		int a,b;cin >> a >> b;
		rep(j,h+1){
			int nj = min(j+a,h);
			dp[nj] = min(dp[nj],dp[j]+b);
		}
	}
	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 3708
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int comp(const void * a, const void * b)
{
  return *(int*)a - *(int*)b;
}
int comp_inv(const void * a, const void * b)
{
  return *(int*)b - *(int*)a;
}

int main(void) 
{
  int s, n, a[100];
  scanf("%d", &n);
  for (int i = 0; i<n; ++i) {
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), comp_inv);
  for (int i=s=0; i < n; ++i) {
    s = i%2?s-a[i]:s+a[i];
  }
  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=105;
int n,L[maxn*2],ans;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
int main()
{
	n=read();
	for(int i=1;i<=2*n;i++) L[i]=read();
	sort(L+1,L+1+2*n);
	for(int i=1;i<=2*n;i+=2) ans+=L[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		// Scannerクラスのインスタンスを作成
 	    // 引数で標準入力System.inを指定する
 	    Scanner scanner = new Scanner(System.in);
 	    String S = scanner.next();
 	    int answer = 0;
 	    
 	    for(int i=0; i<4; i++) {
 	    	if(S.substring(i,i+1).equals("+")) {
 	    		answer++;
 	    	}else {
 	    		answer--;
 	    	}
 	    }
 	    System.out.println(answer);
 	    
 	    
	}

}

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

namespace AOJHelloWorld1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
            x = int.Parse(Console.ReadLine());
            Console.WriteLine(x * x * x);
        }
    }
}


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

signed main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> v(N);
    for (size_t i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    int DP[10000] = {};
    for (size_t i = 0; i < N; i++) {
        int A = v[i].first;
        int B = v[i].second;
        for (int i = T - 1; i >= 0; i--) {
            DP[i + A] = max(DP[i + A], DP[i] + B);
        }
    }
    cout << *max_element(DP, DP + 10000) << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    
    void run(){
	while(sc.hasNext()){
	    String[] s = sc.nextLine().split(",");
	    double w = Double.parseDouble(s[1]);
	    double h = Double.parseDouble(s[2]);
	    double bmi = w/h/h;
	    if(bmi>=25)
		System.out.println(s[0]);
	}
    }
}

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

#define all(a) a.begin(),a.end()
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef std::vector<int>vi;
typedef std::vector<string>vs;
typedef std::vector<double>vd;
typedef std::vector<ll>vll;
typedef vector<vi>vvi;
typedef vector<vvi>vvvi;
typedef vector<vll>vvll;
typedef std::pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vpi>vvpi;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,t,a;
	cin>>n>>t>>a;
	double b[n];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n;i++){
		b[i]=t-b[i]*0.006;
	} 
	int re=-1;
	double k=1000000;
	for(int i=0;i<n;i++){
		if(k>abs(b[i]-a)){
			re=i;
			k=abs(b[i]-a);
		}
	}
	cout<<re+1;
	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  int A,B;
  cin >> A >> B;
  vector<int> P(n);
  int a=0,b=0,c=0;
  rep(i,n) {
    cin >> P[i];
    if( P[i] <= A ) ++a;
    else if( A+1 <= P[i] && P[i] <= B ) ++b;
    else ++c;
  }
  cout << min(a,min(b,c)) << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
void swap(int *,int *);

int main(){
  int flag,i,j,n,count=0;
  int A[N];
  
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  
  flag = 1;
  i=0;
  
  while(flag){
    flag = 0;
    
    for (j=n-1;j>=i+1;j--){
      if( A[j] < A[j-1]){
	swap(&A[j], &A[j-1]);
	count++;
      flag = 1;
      }
    }
    i++;
    
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

void swap(int *a,int *b){
  int temp;
  
  temp = *a;
  *a=*b;
  *b=temp;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
int a[N];
int k, n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> k >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    a[0] = a[n] - k;
    a[n + 1] = a[1] + k;
    int ans = 1e9;
    rep(i, 1, n) {
        int maxi = max(a[i] - a[i - 1], a[i + 1] - a[i]);
        ans = min(ans, k - maxi);
    }
    cout << ans << endl;
    return 0;
}


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

#define io(F) string t_="";ifstream fin(t_+F+".in");ofstreamfout(t_+F+".out")
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define graph unordered_map<int, unordered_set<int>>
typedef long long ll;

int main() {
	qio; int n; cin >> n;
	ll sm = 0;
	forl(i, 1, n+1) {
		if(!(i%3) or !(i%5)) continue;
		sm += i;
	}
	println(sm);
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

struct pax
{
    int a,b,c;
};

bool cmp(pax a, pax b)
{
    return a.a-a.b>b.a-b.b;
}

pax P[100005];
priority_queue<int> Q;
long long Dp[2][100005];

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

    int x,y,z;
    cin>>x>>y>>z;
    int n=x+y+z;

    for(int i=1; i<=n; i++)
        cin>>P[i].a>>P[i].b>>P[i].c;

    sort(P+1,P+n+1,cmp);  //pt cazul cu 2 monede primele x dupa sortare erau a, iar ultimele y b
                              //in cazul asta niciun a nu o sa apara dupa b, iar c-urile o sa fie intercalate

    //Dp[0][i]=am x de a pe prefix si restul c
    for(int i=1; i<=x; i++)
    {
        Dp[0][x]=Dp[0][x]+P[i].a;
        Q.push(P[i].c-P[i].a);
    }

    for(int i=x+1; i<=n; i++)
    {
        Dp[0][i]=Dp[0][i-1]+P[i].a;
        Q.push(P[i].c-P[i].a);

        Dp[0][i]+=Q.top();
        Q.pop();
    }

    while(!Q.empty())
        Q.pop();

    //Dp[0][i]=am y de b pe sufix si restul c
    for(int i=n; i>=n-y+1; i--)
    {
        Dp[1][n-y+1]=Dp[1][n-y+1]+P[i].b;
        Q.push(P[i].c-P[i].b);
    }

    for(int i=n-y; i>=1; i--)
    {
        Dp[1][i]=Dp[1][i+1]+P[i].b;
        Q.push(P[i].c-P[i].b);

        Dp[1][i]+=Q.top();
        Q.pop();
    }

    long long rez=0;
    for(int i=x; i<=n-y; i++)
        rez=max(rez,Dp[0][i]+Dp[1][i+1]);
    cout<<rez<<"\n";
    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
int main(){
    int a,b,A;
    char op;
    
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        if(op == '+'){
            A = a+b;
        }
        else if(op == '-'){
            A = a-b;
        }
        else if(op == '*'){
            A = a*b;
        }
        else if(op == '/'){
            A = a/b;
        }
        printf("%d\n",A);
    }
    return 0;
}


Measured memory_bytes: 2696
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M],B[M],n;
char str[M];
int main(){  
	int n;
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1;i<=n;i++){
		if(str[i]=='R'){
			int j=i;
			while(j<=n&&str[j]=='R')j++;
			j--;
			//[i,j]->R
			for(int k=i;k<=j;k++){
				int step=j-k;
				if(step&1)A[j+1]++;
				else A[j]++;
			}
			i=j;
		}else{
			int j=i;
			while(j<=n&&str[j]=='L')j++;
			j--;
			//[i,j]-->L
			for(int k=i;k<=j;k++){
				int step=k-i;
				if(step&1)A[i-1]++;
				else A[i]++;
			}
			i=j;
		} 
	}
	for(int i=1;i<=n;i++)printf("%d ",A[i]);puts("");
	return 0;
}

Measured memory_bytes: 2560
import numpy as np

N, K = map(int, input().split())
lst = np.array([int(x) for x in input().split()])
dp = np.zeros(N, dtype=int)

for i in range(1, N):
    start = max(i - K, 0)
    dp[i] = np.min(dp[start:i] + np.abs(lst[start:i] - lst[i]))
print(dp[-1])


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

const int Maxn = 22;

int n;
int A[Maxn];
int B[Maxn];
int C[Maxn];
int res;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> A[i];
    for (int i = 1; i <= n; i++)
        cin >> B[i];
    for (int i = 1; i < n; i++)
        cin >> C[i];
    for (int i = 1; i <= n; i++) {
        res += B[A[i]];
        if (i + 1 <= n && A[i] + 1 == A[i + 1])
            res += C[A[i]];
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define tp tuple<int,int,int>
#define mtp make_tuple
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    vector<bool> ok(n+1);
    for(int i=1;i<=k;i++)
    {
        int cnt;
        cin>>cnt;
        while(cnt--)
        {
            int x;
            cin>>x;
            ok[x]=true;
        }
    }
    int res=0;
    for(int i=1;i<=n;i++) if(!ok[i]) res++;
    cout<<res;
}


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

using namespace std;

#define N 100000

long long a[N + 1];

int main(){
	long long l, r, m1, m2;
	int k, i;

	scanf("%d", &k);

	for (i = 1; i <= k; i++){
		scanf("%lld", a + i);
	}

	l = r = 2;

	for (i = k; i >= 1; i--){
		m1 = ((l + a[i] - 1) / a[i]) * a[i];
		m2 = (r / a[i]) * a[i];

		if (m1 < l or m1 > r){
			break;
		}

		l = m1;
		r = m2 + a[i] - 1;

		// printf("[%lld, %lld]\n", l, r);
	}

	if (i >= 1){
		printf("-1\n");
	}
	else{
		printf("%lld %lld\n", l, r);
	}

	return 0;
}

Measured memory_bytes: 1024
from collections import deque
S=input()
N=len(S)+1
X=[-1 for i in range(N)]
'''
 < > >
0 2 1 0
'''
q=deque([])
for i in range(N-2):
    if S[i]==">" and S[i+1]=="<":
        X[i+1]=0
        q.append(i+1)
if S[0]=="<":
    q.append(0)
    X[0]=0
if S[N-2]==">":
    q.append(N-1)
    X[N-1]=0

while(len(q)>0):
    r=q.popleft()
    for p in [r-1,r+1]:
        if not(0<=p<N):
            continue
        if (p<r and S[p]==">") or (p>r and S[r]=="<"):
            if X[p]<=X[r]:
                X[p]=X[r]+1
                q.append(p)
#print(X)
print(sum(X))


Measured memory_bytes: 111524
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,x,y;
ll d[2010]={};
int main(){
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            d[min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)))]++;
        }
    }
    for(int i=1;i<n;i++)cout<<d[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
int f[200050],a[200050],n;
bool inq[200050];
inline int lst(int x){return x-1==0?n:x-1;}
inline int nxt(int x){return x+1>n?1:x+1;}
struct node{
	int p;
	node(){}
	node(int p):p(p){}
	inline bool operator <(const node &b)const{return a[lst(p)]+a[nxt(p)]>a[lst(b.p)]+a[nxt(b.p)];}
};
priority_queue<node> Q;
inline bool check(int i){return a[i]>f[i]&&a[i]-f[i]>=a[lst(i)]+a[nxt(i)];}
int main(){
	int i,t1,t2;
	long long ans=0ll;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",f+i);
	for(i=1;i<=n;++i){
		scanf("%d",a+i);
		if(a[i]<f[i]){
			puts("-1");
			return 0;
		}
	}
	for(i=1;i<=n;++i)if(check(i))Q.push(node(i)),inq[i]=1;
	while(!Q.empty()){
		i=Q.top().p;Q.pop();inq[i]=0;
		t1=a[i]-f[i];
		t2=a[lst(i)]+a[nxt(i)];
		ans+=t1/t2;
		a[i]=f[i]+t1%t2;
		if(!inq[lst(i)]&&check(lst(i)))Q.push(lst(i)),inq[lst(i)]=1;
		if(!inq[nxt(i)]&&check(nxt(i)))Q.push(nxt(i)),inq[nxt(i)]=1;
	}
	for(i=1;i<=n;++i)if(f[i]!=a[i]){
		puts("-1");
		return 0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2684
import java.util.*;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			Scanner sc=new Scanner(System.in);
			int A=sc.nextInt();
			int B=sc.nextInt();
			int C=sc.nextInt();
			int D=sc.nextInt();
			int m1=A*B;
			int m2=C*D;
			if(m1>=m2){
				System.out.println(m1);
			}else{
				System.out.println(m2);
			}
	}

}

Measured memory_bytes: 9796
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if((A < C && C < B) || (B < C && C < A)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21588
ans=Array.new(10){ Array.new(1001){0}}
ans[0][0]=1

0.upto(100) do |i|
    1000.downto(0) do |j|
        9.downto(1) do |k|
            break if j-i<0
            ans[k][j]+=ans[k-1][j-i]
        end
    end
end

while gets do
    n,s=$_.split(nil).map(&:to_i)
    break if n==0 && s==0
    puts ans[n][s]
end

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

using namespace std;
const int mod=1e9+7;

int N;
vector<int>som[100007];
bool vis[100007];
long long tak[100007];
long long nie[100007];

void DFS(int a)
{
    vis[a]=true;
    tak[a]=1;
    nie[a]=1;
    for(int i=0; i<som[a].size(); i++)
    {
        if(!vis[som[a][i]])
        {
            DFS(som[a][i]);
            tak[a]=(nie[som[a][i]]*tak[a])%mod;
            nie[a]=(nie[a]*(nie[som[a][i]]+tak[som[a][i]]))%mod; 
        }
    }
}

int main()
{
    cin >> N;
    for(int i=1; i<N; i++)
    {
        int x,y;
        cin >> x >> y;
        som[x].push_back(y);
        som[y].push_back(x);
    }
    DFS(1);
    cout << (tak[1]+nie[1])%mod;
}

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

int main(){
    int K;
    cin >> K;
    int no, ne;
    ne = K/2;
    if(K%2==0){
        no = K/2;
    }else{
        no = K/2 + 1;
    }

    cout << no*ne << endl;
}


Measured memory_bytes: 764
c = int(input())
def solve(n,k,x):
    diff = []
    for i in range(n-1):
        diff.append(x[i+1]-x[i])
    diff.sort()
    ans  = x[-1] - x[0]
    for i in range(min(k-1,len(diff))):
        ans -= diff.pop()
    return print(ans)
for j in range(c):
    n, k = map(int,input().split())
    x = list(map(int,input().split()))
    solve(n,k,x)



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

long long int cost1(int N,int h[])
{
	int cost[N]={0};
	cost[0]=0;
	cost[1]=abs(h[1]-h[0]);
	for(int i=2;i<N;i++)
	{
		cost[i]=min(abs(h[i]-h[i-1])+cost[i-1],abs(h[i]-h[i-2])+cost[i-2]);
	}
	//for(int i=0;i<N;i++)
	//	printf("%d ",cost[i]);
	return cost[N-1];
}

int main()
{
	int N;
	cin>>N;
	int h[N]={0};
	for(int i=0;i<N;i++)
		cin>>h[i];
	printf("%lld\n",cost1(N,h));

	return 0;
}

Measured memory_bytes: 1024
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string ans = "";
        int[] a=inta();
        if(a[0] == a[1]){
            if(a[0] != a[2]){
                ans="Yes";
            }else{
                ans="No";
            }
        }else{
            if(a[0] == a[2] || a[1] == a[2]){
                ans="Yes";
            }else{
                ans="No";
            }
        }
        WriteLine(ans);
    }
    
    
    
    
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
}

Measured memory_bytes: 13140