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

int main(){

    int N;

    cin>>N;

    int a[200001];

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

    long long ans=0;

    for(int i=0;i<N-1;i++){
        if(a[i]>a[i+1]){
            ans+=(a[i]-a[i+1]);
            a[i+1]=a[i];
        }
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 4364
N,K = map(int,input().split())
S = list(input())
if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
print(''.join(S))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int l[600000];
int cnt=0,ans=0;
signed main(){
    cin>>s;
    int le=s.size();
    l[0]=0;
    rep(i,le){
        if(s[i]=='>')cnt=0;
        else cnt++;
        l[i+1]=cnt;
    }
    cnt=0;
    for(int i=le-1;i>=0;i--){
        if(s[i]=='<')cnt=0;
        else cnt++;
        l[i]=max(l[i],cnt);
    }
    rep(i,le+1){
        ans+=l[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    int a,b,t;
    sfff(a,b,t);
    cout<<(t/a)*b;
}


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

using namespace std;

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

  if (K > Q) {
    for (size_t i = 0; i < N; i++) {
      cout << "Yes" << endl;
    }
    return 0;
  }

  vector<size_t> A(N, 0);
  for (size_t i = 0; i < Q; i++) {
    size_t a;
    cin >> a;
    A[a - 1]++;
  }

  for (size_t i = 0; i < N; i++) {
    if (Q - K < A[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int bfs[30][30];
int dat[100][100];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<2*b-1;i++){
			for(int j=0;j<a+i%2-1;j++){
				scanf("%d",&dat[i][j]);
			}
		}
		for(int i=0;i<30;i++)
			for(int j=0;j<30;j++)
				bfs[i][j]=0;
		bfs[0][0]=1;
		queue<pair<int,int> >Q;
		Q.push(make_pair(0,0));
		while(Q.size()){
			int row=Q.front().first;
			int col=Q.front().second;
			Q.pop();
			if(row){
				if(!dat[row*2-1][col]&&!bfs[row-1][col]){
					bfs[row-1][col]=bfs[row][col]+1;
					Q.push(make_pair(row-1,col));
				}
			}
			if(row<b-1){
				if(!dat[row*2+1][col]&&!bfs[row+1][col]){
					bfs[row+1][col]=bfs[row][col]+1;
					Q.push(make_pair(row+1,col));
				}
			}
			if(col){
				if(!dat[row*2][col-1]&&!bfs[row][col-1]){
					bfs[row][col-1]=bfs[row][col]+1;
					Q.push(make_pair(row,col-1));
				}
			}
			if(col<a-1){
				if(!dat[row*2][col]&&!bfs[row][col+1]){
					bfs[row][col+1]=bfs[row][col]+1;
					Q.push(make_pair(row,col+1));
				}
			}
		}
		printf("%d\n",bfs[b-1][a-1]);
	}
}

Measured memory_bytes: 1080
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    map<P,int> mp;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        if(range(x,2,h)&&range(y,2,w)){
                mp[P(x,y)]++;
        }
        rep(j,8){
            int nx=x+dx[j];
            int ny=y+dy[j];
            if(range(nx,2,h)&&range(ny,2,w)){
                mp[P(nx,ny)]++;
            }
        }
    }
    cout<<(h-2)*(w-2)-(int)mp.size()<<endl;
    vec b(10);
    for(auto &x:mp){
        b[x.sc]++;
    }
    for(int i=1;i<=9;i++) cout<<b[i]<<endl;
    
}

Measured memory_bytes: 61184
import sys
r=sys.stdin.readline
I=float('inf')
for e in iter(r,'0 0\n'):
 n,k=map(int,e.split())
 F=[[I]*-~n for _ in[0]*-~n]
 for i in range(1,n+1):F[i][i]=0
 for _ in[0]*k:
  f=r();g=map(int,f[2:].split())
  if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
  else:
   c,d,e=g
   if e<F[c][d]:
    for i in range(2,n+1):
     for j in range(1,i):
      F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])


Measured memory_bytes: 6232
import sys
import numpy as np
import itertools

N = int(sys.stdin.readline().strip())
dct = {}
dct["M"] = 0
dct["A"] = 0
dct["R"] = 0
dct["C"] = 0
dct["H"] = 0
char_list = ["M", "A", "R", "C", "H"]

for _ in range(N):
    name = sys.stdin.readline().strip()
    first = name[0]
    if first not in dct:
        continue
    dct[first] += 1

count = 0
for a, b, c in list(itertools.combinations(char_list, 3)):
    count += dct[a] * dct[b] * dct[c]
print(count)


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

int main() {

  int N, K, x, l, M;
  cin >> N >> K;
  l = 0;
  M = K / 2;

  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < M) l += x;
    else if (x > M) l += K - x;
    else if (x = M) l += x;
  }

  cout << l * 2 << endl;

}


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

int main( void ) {
	int i, e, ee, y, z, min;

	while ( scanf( "%d", &e ), e ) {
		min = e;
		for ( z = 0; z * z * z <= e; z++ ) {
			ee = e - z * z * z;
			y = sqrt( ee );

			if ( ee - y * y + y + z < min )
				min = ee - y * y + y + z;
		}

		printf( "%d\n", min );
	}

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define nmax 200000
#define ll long long
int main(){
int n;
int a[nmax];
ll sum=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
}
ll s=a[0],r=sum-s;
ll ans=abs(r-s);
for(int i=1;i<n-1;i++){
    s+=a[i];r-=a[i];
    ans=min(abs(ans),abs(r-s));
}
cout<<ans<<endl;
return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep2(i,m,n) for(int i=int(m);i<int(n);i++)
#define drep2(i,m,n) for(int i=int(m-1);i>=int(n);i--)
#define rep(i,n) rep2(i,0,n)
#define drep (i,n) drep2(i,n,0)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int MOD = int(1e9)+7;


int main()
{
    string s,t;cin >>s;cin >>t;
    int S=(int)s.size();
    int T=(int)t.size();
    int dp[S+1][T+1];
    rep(i,S+1)rep(j,T+1)dp[i][j]=0;
    rep(a,S)rep(b,T){
        dp[a+1][b+1]=max(dp[a][b+1],dp[a+1][b]);
        if(s[a]==t[b])dp[a+1][b+1]=max(dp[a+1][b+1],dp[a][b]+1);

    }
    string ans="";
    int i=S;int j=T;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j])i--;
        else if(dp[i][j]==dp[i][j-1])j--;
        else if(dp[i][j]==dp[i-1][j-1]+1){
                ans=s[i-1]+ans;
                i--;j--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

  bool ans = false;
  for (int i = 0; i < s.size() - 1; i++) {
    for (int j = i + 1; j < s.size(); j++) {
      if (s[i] == 'C' && s[j] == 'F') {
        ans = true;
      }
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N = int(input())
Task = []
now = 0
is_clear = 0
for i in range(N):
  a, b = map(int, input().split())
  Task.append((b, a))

Task.sort()

for i in range(N):
  now += Task[i][1]
  if now > Task[i][0]:
    is_clear = 1
    break
if is_clear == 1:
  print("No")
else:
  print("Yes")

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n;
struct uzi
{
	int a,b;
	bool operator <(const uzi & t)const{
		if(b==t.b)return a<t.a;
		return b<t.b;
	}
}p[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i].a>>p[i].b;
	sort(p+1,p+1+n);
LL now=0;
	for(int i=1;i<=n;i++){
		now+=p[i].a;
		if(now>p[i].b)return cout<<"No\n",0;
	}
	cout<<"Yes\n";
	return 0;
}

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

typedef long long LL;

LL a, b, x;

int work() {
    scanf("%lld%lld%lld", &a, &b, &x);
    printf("%lld\n", b/x-a/x+(a%x==0));
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 256
c;main(n){while(~scanf("%d",&n)){int m[15][15]={0},x=n/2,y=x+1;for(;c<n*n;m[x++%n][y++%n]=++c)for(;m[x%n][y%n];y++)x--;for(y=-1;++y<n;puts(""))for(c=x=0;x<n;)printf("%4d",m[x++][y]);}}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>

using namespace std;
typedef long long lint;
typedef pair<lint, lint> Pii;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

template <typename _KTy, typename _Ty>
ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) {
	cout << "{" << m.first << ", " << m.second << "}";
	return ostr;
}

template <typename _KTy, typename _Ty>
ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) {
	if (m.empty()) {
		cout << "{ }";
		return ostr;
	}
	cout << "{" << *m.begin();
	for (auto itr = ++m.begin(); itr != m.end(); itr++) {
		cout << ", " << *itr;
	}
	cout << "}";
	return ostr;
}

struct compare {
	bool operator() (Pii a, Pii b) {
		return ((double)a.second / a.first) > ((double)b.second / b.first);
	}
};

int main()
{
	lint V[4], N, ans = 0;
	cin >> V[0] >> V[1] >> V[2] >> V[3];
	cin >> N;

	//val per 2L
	priority_queue<Pii, vector<Pii>, compare > pq;
	pq.push(Pii(1, V[0] * 4));
	pq.push(Pii(2, V[1] * 4));
	pq.push(Pii(4, V[2] * 4));
	pq.push(Pii(8, V[3] * 4));
	N *= 4;

	while (pq.size()) {
		ans += (N / pq.top().first) * pq.top().second;
		N -= pq.top().first * (N / pq.top().first);
		pq.pop();
	}

	cout << ans / 4 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using  P=pair<int,int>;
int main(){
  int N,T,dp[3020][6020],maxvalue=0,a,b;
  cin>>N>>T;
  vector<P> vec(0);
  for(int i=0;i<N;i++){
    cin>>a>>b;
    vec.push_back(make_pair(a,b));//所要時間,価値
  }
  sort(vec.begin(),vec.end());
  //(1+(10^価値)*x^(所要時間))の累積の考えて指数について制限をかけて考える
  for(int h=0;h<N;h++){
    dp[h][0]=1;
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<T;j++){
      if(dp[i-1][j]!=0){
        dp[i][j+vec.at(i-1).first]+=dp[i-1][j]+vec.at(i-1).second;
        if(j==0){dp[i][j+vec.at(i-1).first]--;}
        dp[i][j+vec.at(i-1).first]=max(dp[i][j+vec.at(i-1).first],dp[i-1][j+vec.at(i-1).first]);
        dp[i][j]=max(dp[i][j],dp[i-1][j]);
      }
      maxvalue=max(maxvalue,dp[i][j]);
      maxvalue=max(maxvalue,dp[i][j+vec.at(i-1).first]);
    }
  }
  cout<<maxvalue<<endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 330;
const ll inf = 1e18;

int n;
ll a[maxn];


void relax(ll &x, ll y) {
    x=max(x,y);
}


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


    cin>>n;
    assert(n>=2);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    ll T = 0;
    for (int i=2; i<n; i++) {
	T ^= a[i];
    }
    ll a0=a[0];
    ll a1=a[1];

    ll S = a[0]+a[1];
    
    vector<ll> dp(2, 0);
    dp[0] = -inf;
    dp[1] = 0;
    //dp[0]=max value<a[0] for first i bits
    //dp[1]=max value=a[0] for first i bits

    for (int i=60; i>=0; i--) {
	if (T>>i&1) {
	    //01 or 10
	    if (a0>>i&1) {
		dp[0] += (1ll<<i); //give a0 the 1
		relax(dp[0], dp[1]); //don't give a0 the 1
		dp[1] += (1ll<<i); //give a0 the 1		
	    } else {
		//a0 can't have 1 (to keep matching)
		dp[0] += (1ll<<i);
	    }
	    S -= (1ll<<i);
	} else {
	    // both 0 or both 1
	    

	    //rest = 2*(2^(i-1) + ... 2^0) = 2^(i+1)-2
	    //if both have 1, S >= 2^(i+1)
	    if (S >= (1ll<<(i+1))) {
		//11
		if (!(a0>>i&1)) {
		    dp[1] = -inf;
		}
		dp[0] += (1ll<<i);
		dp[1] += (1ll<<i);
		S -= (1ll<<i);
		S -= (1ll<<i);
	    } else {
		//00
		if (a0>>i&1) {
		    relax(dp[0], dp[1]);
		}
	    }
	}
    }

    // watch(S);
    // watch(dp[0]);
    // watch(dp[1]);

    if (S==0 && (dp[0]>0 || dp[1]>0)) {
	ll x = a0-max(dp[0],dp[1]);
	cout<<x<<endl;
    } else {
	cout<<-1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3652
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#define ll long long
using namespace std;
const int maxn=1e5;
int x,y,z,n;
ll sum,ans;

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

struct Vertex
{
    int v1,v2,v3,cm;
}a[maxn+8];

struct node
{
    int id,v;
    bool operator <(const node &y)const{return v!=y.v?v<y.v:id<y.id;}
};
set<node>st1,st2;

bool cmp(Vertex x,Vertex y){return x.cm>y.cm;}

int main()
{
    x=read(),y=read(),z=read();n=x+y+z;
    for (int i=1;i<=n;i++)
	a[i].v1=read(),a[i].v2=read(),a[i].v3=read(),a[i].cm=a[i].v1-a[i].v2,sum+=a[i].v3;
    sort(a+1,a+n+1,cmp);
    //for (int i=1;i<=n;i++) printf("%d %d %d\n",a[i].v1,a[i].v2,a[i].v3);
    for (int i=1;i<=x;i++) st1.insert((node){i,a[i].v1-a[i].v3}),sum+=a[i].v1-a[i].v3;
    for (int i=x+1;i<=n;i++) st2.insert((node){i,a[i].v2-a[i].v3});
    for (int i=1;i<=y;i++)
	{
	    node x=*(--st2.end());
	    sum+=x.v;
	    st2.erase(x);
	}
    ans=sum;
    //printf("%lld\n",ans);
    for (int i=x+1;i<=n-y;i++)
	{
	    sum+=a[i].v1-a[i].v3;
	    st1.insert((node){i,a[i].v1-a[i].v3});
	    node x=*(st1.begin()++);
	    sum-=x.v;st1.erase(x);
	    x=*(st2.lower_bound((node){i,a[i].v2-a[i].v3}));
	    if (st2.lower_bound((node){i,a[i].v2-a[i].v3})!=st2.end()) st2.erase(x);
	    else
		{   
		    sum-=a[i].v2-a[i].v3;
		    x=*(--st2.end());
		    sum+=x.v;
		    st2.erase(x);
		}
	    ans=max(ans,sum);
	}
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6528
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

typedef	vector<int>	vi;

const int INF=1<<29;

struct Edge{
	int u,v,cost;
	Edge(){}
	Edge(int U,int V,int C):u(U),v(V),cost(C){}
	bool operator<(const Edge &e)const{ return cost<e.cost; }
};

class UnionFind{
	vi a;
	int root(int x){ return ~a[x]?a[x]=root(a[x]):x; }
public:
	UnionFind(int n):a(n,-1){}
	bool find(int x,int y){ return root(x)==root(y); }
	bool unite(int x,int y){ return find(x,y)?0:(a[root(y)]=root(x),1); }
};

int Kruskal(int n,vector<Edge> e){
	int m=e.size(),ans=0,cnt=1;
	UnionFind uf(n);
	sort(e.begin(),e.end());
	rep(i,m){
		if(uf.unite(e[i].u,e[i].v)){
			ans=e[i].cost;
			if(++cnt==n)	return ans;
		}
	}
	return -1;
}

int main(){
	for(int m,n;scanf("%d%d",&n,&m),n;){
		vector<Edge> e(m);
		rep(i,m){
			scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].cost);
			e[i].u--,e[i].v--;
		}
		sort(e.begin(),e.end());

		int ans=INF;
		rep(i,m){
			int res=Kruskal(n,vector<Edge>(e.begin()+i,e.end()));
			if(~res)	ans=min(ans,res-e[i].cost);
		}

		printf("%d\n",ans<INF?ans:-1);
	}

	return 0;
}

Measured memory_bytes: 936
import java.util.*;


public class Main {

	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int x  = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		
		int ary[] = new int[3];
		
		ary[0] = x;
		ary[1] = y;
		ary[2] = z;
		
		ary[0] = ary[1];
		ary[1] = x;
		
		ary[0] = z;
		ary[2] = y;
		
		sc.close();
		log( ary[0] + " " + ary[1] + " " + ary[2]);
	}
}	


Measured memory_bytes: 21972
# coding: utf-8
N, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if t[i+1] - t[i] < T:
        ans += t[i+1] - t[i]
    else:
        ans += T
ans += T
print(ans)

Measured memory_bytes: 25196
import numpy as np
from collections import Counter

# 最頻値
def mode(list):
    c = Counter(list)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]
    modes = []
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

n = int(input())
p_list = list(map(int, input().split()))
ans = 1
min = p_list[0]
for i in range(1, n):
  if min >= p_list[i]:
    ans += 1
    min = p_list[i]
print(ans)

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

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var diff = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] != t[i])
            {
                diff++;
            }
        }

        Console.WriteLine(diff);
    }
}

Measured memory_bytes: 27436
#include <stdio.h>
#include <string.h>

int main(void)
{
    enum { S = 10 + 1 };
    char a[S], b[S], c[S];
    scanf("%s %s %s", a, b, c);
    if (a[strlen(a) - 1] == b[0] && b[strlen(b) - 1] == c[0]) {
        puts("YES");
        return 0;
    }
    puts("NO");
    return 0;
}


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

int main(){

    string S;
    cin >> S;

    vector<int> cnt(2, 0);

    for (int i = 0; i< S.size(); i++){
        cnt[S[i] - '0']++;

    }
    int ans = min(cnt[0], cnt[1]) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<cstdio>

int main(){
	int total;

	while(1){
		scanf("%d",&total);
		if(total == 0)break;

		int sum = 0;
		for(int i=0;i<9;i++){
			int tmp;
			scanf("%d",&tmp);
			sum += tmp;
		}
		printf("%d\n",total-sum);
	}
}

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

const int N = (int) 1e5 + 5;

int n;
int h[N];

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];
	h[1]--;
	for (int i = 2; i <= n; i++) {
		if (h[i] > h[i - 1]) {
			h[i]--;
		}
	}
	bool ok = true;
	for (int i = 1; i < n; i++)
		if (h[i] > h[i + 1]) {
			ok = false;
			break;
		}
	if (ok) cout << "Yes";
	else cout << "No";
	return 0;
}

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

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

    int k; cin >> k;
    vector<int> a(k+1);

    a.at(0) = 7 % k;

    for(int i = 1;i < k+1;i ++){
        a.at(i) = ((a.at(i-1) * 10) + 7) % k;
    }

    int ans = -1;
    for(int i = 0;i < k+1;i ++){
        if(a.at(i) == 0){
            ans = i+1;
            break;
        }
    }

    cout << ans << endl;
}

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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

struct T {
  int i, s;

  bool operator<(const T& right) const {
    return s == right.s ? i < right.s : s < right.s;
  }
};

int MAX_N = 1 << 17;
int n = 1;
vector<T> dat(MAX_N * 2 - 1);
T minT;

void update(int k, int a) {
  k = k + n - 1;
  dat[k].s += a;
  while(k > 0) {
    k = (k - 1) / 2;
    dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

int main() {
  int t, r, l, z = 0, zi = 0, sc[100001] = {};
  cin >> t >> r >> l;
  while(t > n) n *= 2;
  minT.i = 10000000;
  minT.s = -9999999;
  rep(i, 0, n * 2 - 1) dat[i] = minT;
  rep(i, n - 1, n * 2 - 1) dat[i].i = i - (n - 1);



  rep(i, 0, r) {
    int a, b, c;
    cin >> a >> b >> c;
    sc[zi] += b - z;
    update(a - 1, c);
    zi = dat[0].i;
    z = b;
  }

  sc[zi] += l - z;
  int ms = 0, ans;
  rep(i, 0, t) if(ms < sc[i]) ans = i + 1, ms = sc[i];

  cout << ans << endl;
}

Measured memory_bytes: 5192
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    println(k * Math.pow(k - 1.0, n - 1.0).toInt())
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int main(){
  int N;
  cin >> N;
  
  bool ans=false;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(N==4*i+7*j){
        ans=true;
      }
    }
  }
  
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
n,k = map(int,input().split())
h = list(int(input()) for i in range(n))
h.sort()
ans = max(h)
i = 0
for i in range(n-k+1):
    if ans > h[i+k-1]-h[i]:
        ans = h[i+k-1]-h[i]
print(ans)

Measured memory_bytes: 7396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, b; cin >> a >> b;
  cout << a*b/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<char> a(3);
  cin>>a.at(0)>>a.at(1)>>a.at(2);
  sort(a.begin(),a.end());
  if(a.at(0)=='a' && a.at(1)=='b' && a.at(2)=='c')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    int n, a, b;
    int deg[5]={0,0,0,0,0};
    ll ans=0,sum;
    cin >> n >> a >> b;
    for(int i=1; i<=n; i++){
        deg[0]++;
        for(int j=0; j<4; j++){
            if(deg[j]==10){
                deg[j]=0;
                deg[j+1]++;
            }
        }
        sum=0;
        for(int j=0; j<5; j++){
            sum+=deg[j];
        }
        if(a<=sum && sum<=b){
            ans+=(ll)i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    string s;
    int n;
    cin >> n >> s;
    int r = 0, w = 0;
    int op = 0;
    for(char x : s)
        if(x == 'R')
            r++;
    for(int i = 0; i < r; i++)
        if(s[i] == 'W')
            w++;
    cout << w;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3708
#include <stdio.h>
#include <algorithm>
using namespace std;
int val, size_, heap[2097168]; char c[9];
inline void insert(int x) {
	int ptr = size_++; heap[ptr] = x;
	while (ptr > 1) {
		if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
		ptr >>= 1;
	}
}
inline int extract() {
	int ret = heap[1], ptr = 1;
	while ((ptr << 1) + 1 < size_) {
		ptr <<= 1;
		if (heap[ptr] > heap[ptr + 1]) swap(heap[ptr >> 1], heap[ptr]);
		else swap(heap[ptr + 1], heap[ptr >> 1]), ptr++;
	}
	heap[ptr] = heap[--size_], heap[size_] = 0;
	while (ptr > 1) {
		if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
		ptr >>= 1;
	}
	return ret;
}
int main() {
	size_ = 1;
	while (scanf("%s", c), c[2] != 'd') {
		if (c[0] == 'i') scanf("%d", &val), insert(val);
		else printf("%d\n", extract());
	}
	return 0;
}

Measured memory_bytes: 6468
#include<stdio.h>
#define N 100
#define INF 99999999
#define WHITE 0
#define BLACK 2
#define GRAY 1
void prim(int n,int A[N][N]){
  
  int i,p[N],mincost,cost[N],color[N],k,ver;

  for(i=0;i<n;i++){
    cost[i] = INF;
    color[i] = WHITE;
  } //初期化
  cost[0] = 0;
 
 p[0] = -1;
  while(1){
   
    mincost = INF;
    for(i=0;i<n;i++){
        if(color[i] != BLACK && cost[i] < mincost){
      
      mincost = cost[i];
   
      ver = i; 
      }
    }

  
    
  
    if(mincost == INF)break; 
  
  
  color[ver] = BLACK;

  for(k=0;k<n;k++){
    if(color[k] != BLACK && A[ver][k]!=INF){
      if(cost[ver]+A[ver][k] < cost[k]){
          cost[k] = A[ver][k] + cost[ver];
          p[k] = ver;
          color[k] = GRAY;
      }
        
    }
      
  }
  }
    
   for(i=0;i<n;i++) printf("%d %d\n",i,(cost[i]==INF ? -1: cost[i]));
}




int main(){

  int i,j,n,A[N][N],v,u,k;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
         A[i][j] = INF; //ここで全て辺無しにしておく
    }
  }
  
  for(i=0;i<n;i++){
      scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
        scanf("%d",&v);
      scanf("%d",&A[u][v]);//ここで編の番号を入力。ないなら－１を入力
    
    }
  }

  prim(n,A);

  return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
string s;
bool check(int x){
    string tmp="";
    int i;
    for(i=0;i<x;++i)
        tmp+=s[i];
//    cout<<x<<" "<<tmp<<endl;
    if(s.find(tmp,i)!=string::npos)return true;
    for(i;s[i];++i){
        tmp+=s[i];
        tmp=tmp.substr(1,x);
//        cout<<tmp<<endl;
        if(s.find(tmp,i+1)!=string::npos)return true;
    }
    return false;
}
int main(){
    int n;
    cin>>n>>s;
    int l=0,r=s.length();
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)){
            l=mid+1;
        }
        else r=mid-1;
    }
    cout<<r<<endl;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

				var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			var aArray = retreiveLongArray();

			var rightGcds = new long[N];
			rightGcds[0] = aArray[0];
			for (int i = 1; i < N; i++) {
				rightGcds[i] = getGcd(rightGcds[i - 1], aArray[i]); 
			}
			var leftGcds = new long[N];
			leftGcds[N-1] = aArray[N-1];
			for (var i = N-2; i >= 0; i--) {
				leftGcds[i] = getGcd(leftGcds[i + 1], aArray[i]);
			}

			var mArray = new long[N];
			mArray[0] = leftGcds[1];
			mArray[N - 1] = rightGcds[N - 2];
			for (int i = 1; i < N-1; i++) {
				mArray[i] = getGcd(rightGcds[i - 1], leftGcds[i + 1]);
			}

			//答えの出力
			var ans = mArray.Max();
			Console.WriteLine(ans);

		}

		private static long getGcd0(long a, long b) {
			if (a==0) {
				return b;
			}

			if (b==0) {
				return a;
			}

			return getGcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		static long getGcd(long a, long b) {
			if (a < b) {
				return getGcd(b, a);
			}
			if (b > 0) {
				return getGcd(b, a % b);
			}
			else {
				return a;
			}
		}


		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 32092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void){

    int n;
    cin >> n;
    
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    string r;

    int i=0;
    string l, a[n];
    while(cin>>l){
        a[i] = l;
        i++;
    }
    
    rep (i, n) {
        if (a[i] == "AC") ac ++;
        if (a[i] == "WA") wa ++;
        if (a[i] == "TLE") tle ++;
        if (a[i] == "RE") re ++;
    }
    
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    
}

Measured memory_bytes: 6816
N = int(input())
A_list = list(map(int, input().split()))
A_list_len = len(A_list)

A_set = set(A_list)
A_set_len = len(A_set)

if int(A_list_len) == int(A_set_len):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 26800
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	cout << (b - a - 1) * (b - a) * 0.5 - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define MOD 1000000007

vector<ll> v[300005] ;
ll marked[300005];
ll dist[300005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ;
    ll n,k;
    cin >> n >> k ;
    if(n== 1)
    {

        cout << 1 << endl;
        return 0;
    }
    ll rtn ;
    for(rtn = 1;rtn*rtn <=n ;rtn++);
    rtn--;

    //cout << rtn << endl;

    ll dp[2*rtn+5][k+5];
    //cout << "lol" << endl;

    ll i;
    ll sum = 0;
    stack<ll> st;
    ll numb[2*rtn + 5];
    ll val;

    for(i=1;i<= 2*rtn ;i++)
    {

        if(i<=rtn)
        {

            st.push(i);
            numb[i] = 1;
            val = i;
        }
        else
        {

            ll temp = st.top();
            st.pop();
            ll cur = n /temp;
            numb[i] = cur - val;
            val = cur;


        }
        //cout << numb[i] << endl;

    }
    ll j;
    ll pre[2*rtn+5][k+5];
    for(i=1;i<=k;i++)
    {


        for(j=1;j<=2*rtn;j++)
        {

            if(i==1)
            {

                dp[j][i] = 1;

            }
            else
            {
                dp[j][i] = pre[2*rtn +1- j][i-1] ;


            }

            if(j==1)
            {

                pre[j][i] = dp[j][i] * numb[j];
                pre[j][i] %= MOD ;

            }
            else
            {

                pre[j][i] = pre[j-1][i] + ((dp[j][i] * numb[j]) %MOD);
                pre[j][i] %= MOD;

            }
        }
    }
    cout << pre[2*rtn][k] << endl;

    return 0;
}


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

int main() {
    int n, k, x;
    cin >> n >> k; 
    x = 1;

    rep(i, n) {
        if (k < x) {
            x += k;
        }
        else {
            x *= 2;
        }
    }

    cout << x << endl;
}

Measured memory_bytes: 256
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
mp a[200000+2];
int cnt=0;
int main(){
	fastio;
	LL res=0;
	int t;
	cin>>t;
	while(t--){
		set<int> s;
		res=cnt=0;
		int n;
		cin>>n;
		rb(i,1,n)
		{
			s.insert(i);
			int k,l,r;
			cin>>k>>l>>r;
//			cerr<<" "<<l<<" "<<r<<endl; 
			res+=r;
			a[i]=II(l-r,k);
		}
		sort(a+1,a+1+n);
		reverse(a+1,a+1+n);
		vector<int> v;
		rb(i,1,n){
			if(a[i].FIR<0){
				break;
			}
			if(*s.begin()<=a[i].SEC){
				res+=a[i].FIR;
				a[i].FIR=-INF;
				set<int> :: IT ite=s.upper_bound(a[i].SEC);
				ite--;
				v.PB(*(ite));
				s.erase(ite);
			}
		}
		sort(ALL(v));
		rb(i,1,v.size()){
			if(*s.begin()<=v[i-1]){
				s.insert(v[i-1]);
				s.erase(s.begin());	
			}
		}
		sort(a+1,a+1+n);
		rb(i,1,n){
			if(a[i].FIR==-INF) continue;
			if(s.upper_bound(a[i].SEC)==s.end()){
				res+=a[i].FIR;
			} 
			else{
				s.erase(s.upper_bound(a[i].SEC));
			}
		}
		cout<<res<<endl;
	}
	return 0;
}
/*
1
3
2 93 78
1 71 59
3 57 96



2 1 3
*/


Measured memory_bytes: 14780
def main() :
    N,K=map(int,input().split())              #N個の整数,K個の積
    A=list(map(int,input().split()))
    mod=10**9+7
    
    minusA=sorted([i for i in A if i < 0], reverse=True) #負で絶対値が小さい数字順
    plusA=sorted([i for i in A if i >= 0])               #正で絶対値が小さい数字順
 
    start=1
    if len(plusA)==0 and K%2==1 :        #負の整数のみ,Kの個数は奇数
        for i in minusA[:K] :
            start=start*i%mod
        print(start)
        exit()

    while K>0 :
        if K== 1 or len(minusA)<=1 :     #Kの個数が1個のとき、または負の整数が1個以下のとき
            if len(plusA)==0 :           #正の整数が存在しない場合
                start*=minusA.pop()
            elif len(plusA)>0 :          #正の整数が存在する場合
                start*=plusA.pop()
            K-=1                         #この場合、Kを1個減らしていってループさせている

        elif len(plusA)<= 1 :            #正の整数が1個以下のとき
            start*=minusA.pop()*minusA.pop()
            K-=2

        elif plusA[-1]*plusA[-2]>minusA[-1]*minusA[-2] :
            start*=plusA.pop()
            K-=1

        elif plusA[-1]*plusA[-2]<=minusA[-1]*minusA[-2] :
            start*=minusA.pop()*minusA.pop()
            K-=2

        start%=mod
    else :
        print(start)



if __name__=="__main__" :
    main()

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

int main(){
	string s; cin >> s;
  	string t; cin >> t;
  	int dem = 0;
  	for(int i = 0;i < s.length();i++){
    	if(s[i] != t[i]){
        	++dem;
        }
    }
  if(dem >= 1){
  	cout << "No";
  }else{
  	cout << "Yes";
  }
}


Measured memory_bytes: 3592
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))




n,m = MI()
a = LI()

r = n-sum(a)
if r>=0:
	print(r)
else:
	print(-1)

Measured memory_bytes: 68472
#include<cstdio>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

// Monoid: operator^
struct Monoid {
  ll d;
  const ll e = 0;
  Monoid() { d = 0; }
  Monoid(ll d) : d(d) {}
  void operator=(const ll& x) { d = x; }
  void operator=(const Monoid& x) { d = x.d; }
  void operator^=(const Monoid& x) { d = x.d + d; }
  Monoid operator^(const Monoid& x) { return Monoid(x.d + d); }
};

struct MinMonoid {
  ll d;
  const ll e = INF;
  MinMonoid() { d = 0; }
  MinMonoid(ll d) : d(d) {}
  void operator=(const ll& x) { d = x; }
  void operator=(const MinMonoid& x) { d = x.d; }
  void operator^=(const MinMonoid& x) { d = min(x.d, d); }
  MinMonoid operator^(const MinMonoid& x) { return MinMonoid(min(x.d, d)); }
};

struct MaxMonoid {
  ll d;
  const ll e = -INF;
  MaxMonoid() { d = 0; }
  MaxMonoid(ll d) : d(d) {}
  void operator=(const ll& x) { d = x; }
  void operator=(const MaxMonoid& x) { d = x.d; }
  void operator^=(const MaxMonoid& x) { d = max(x.d, d); }
  MaxMonoid operator^(const MaxMonoid& x) { return MaxMonoid(max(x.d, d)); }
};

// SegmentTree
template <typename Monoid1, typename Monoid2>
class AbstractSegmentTree {
  using F = function<Monoid2(Monoid1, ll)>;
  ll n;
  vector<Monoid1> data;
  F f;
public:
  AbstractSegmentTree(vector<Monoid1> _data, F f) : f(f) {
    n = 1;
    while ((ll)_data.size() > n) n *= 2;
    data.resize(2*n);
    for (ll i = 0; i < (ll)_data.size(); i++) data[n+i] = _data[i];
    for (ll i = n-1; i > 0; i--) data[i] = data[2*i] ^ data[2*i+1];
  }
  Monoid1 at(ll num) { return data[n+num]; }
  void add(ll num, Monoid1 x) {
    num += n;
    data[num] ^= x;
    num /= 2;
    while (num > 0) data[num] = data[2*num] ^ data[2*num+1], num /= 2;
  }
  void update(ll num, Monoid1 x) {
    num += n;
    data[num] = x;
    num /= 2;
    while (num > 0) data[num] = data[2*num] ^ data[2*num+1], num /= 2;
  }
  // [a, b)
  Monoid2 query(ll a, ll b, ll num = 1, ll s = 0, ll t = -1) {
    if (t == -1) t = n;
    if (a <= s && t <= b) return f(data[num], num);
    ll mid = (s + t) / 2;
    if (b <= mid) return query(a, b, 2*num, s, mid);
    if (mid <= a) return query(a, b, 2*num+1, mid, t);
    return query(a, b, 2*num, s, mid) ^ query(a, b, 2*num+1, mid, t);
  }
};

template <typename T> function<T(T, ll)> _segmentTreeIdentity = [](T t, ll num) { return t; };
//T _segmentTreeIdentity(T t, ll num) { return t; }

template <typename Monoid>
class SegmentTree : public AbstractSegmentTree<Monoid, Monoid> {
public:
  SegmentTree(vector<Monoid> _data) : AbstractSegmentTree<Monoid, Monoid>(_data, _segmentTreeIdentity<Monoid>) {}
};

ll n, q, com, x, y;

int main() {
  scanf("%lld%lld", &n, &q);
  vector<Monoid> d(n+1, 0);
  SegmentTree<Monoid> sgt(d);
  for (ll i = 0; i < q; i++) {
    scanf("%lld%lld%lld", &com, &x, &y);
    if (com == 0) sgt.add(x, Monoid(y));
    else printf("%lld\n", sgt.query(x, y+1).d);
  }
}


Measured memory_bytes: 11060
N= int(input())
T= list(map(int, input().split())) 
M= int(input())
T_print=[0]*M
for i in range(M):
    TT=T
    p,x=map(int, input().split()) 
    T_print[i]=sum(TT[0:p-1])+x+sum(TT[p:])
for i in range(M):
    print(T_print[i])

Measured memory_bytes: 3060
import bisect

def main():
	N = int(input())	
	S = input()

	tb_pos = {'BG': None, 'BR': None, 'GR': None}
	for k in tb_pos:
		tb_pos[k] = [0] * (N + 1)
	
	rs = 0
	for i in range(N):
		for j in range(i + 1, N):
			if S[i] == S[j]:
				continue
			d = j - i
			c1, c2 = S[i], S[j]
			if c1 > c2:
				c1, c2 = c2, c1
			word = c1 + c2
			if j + d < N and S[j + d] not in word:
				rs -= 1
			tb_pos[word][j + 1] += 1 

	for i in range(1, N + 1):
		for k in tb_pos:
			tb_pos[k][i] += tb_pos[k][i - 1]
				
	for j in range(2, N):
		word = None
		if S[j] == 'B':
			word = 'GR'
		elif S[j] == 'G':
			word = 'BR'
		else:
			word = 'BG'
		
		rs += tb_pos[word][j + 1]

	print(rs)
	return 0 

main()


Measured memory_bytes: 74236
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, a0; cin >> N;
  map<int, int> s; 
  rep(i,N) {
    cin >> a0;
    s[a0%4]++;
  }
  
  int o = s[1]+s[3], e = s[2], f = s[0];
  if (o<=f) cout << "Yes" << endl;
  else if (o==f+1 && e==0) cout << "Yes" << endl;
  else cout << "No" << endl;

  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[10][10];
int v[10];
char p[10][5];
int solve(int a){
	if(a==9)return 1;
	int ret=0;
	for(int i=0;i<9;i++){
		if(!v[i]){
			v[i]=1;
			for(int j=0;j<4;j++){
				if(a%3){
					if((str[i][(j+3)%4]^32)!=p[a-1][1])continue;
				}
				if(a/3){
					if((str[i][j]^32)!=p[a-3][2])continue;
				}
				for(int k=0;k<4;k++)p[a][k]=str[i][(j+k)%4];
				ret+=solve(a+1);
			}
			v[i]=0;
		}
	}
	return ret;
}
int main(){
	int T;scanf("%d",&T);
	while(T--){
		for(int i=0;i<9;i++)scanf("%s",str[i]);
		for(int i=0;i<9;i++)v[i]=0;
		printf("%d\n",solve(0));
	}
}

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

#define lli long long int
#define ld long double
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

////////////////////////////////////////////////////////    By: Umang Srivastava

// lli extgcd(lli a, lli b, lli *x , lli *y)
// {
//   if(a==0)
//   {
//     *x=0;
//     *y=1;
//     return b;
//   }
//   lli x1 , y1;
//   lli gcd = extgcd(b%a , a , &x1 , &y1);
//   *x=y-(b/a)*x1;
//   *y=x1;
//   return gcd;
// }

// lli modinv(lli a, lli m)
// {
//   lli x,y;
//   lli g = extgcd(a,m,&x,&y);
//   if(g!=1)
//     return -1;
//   return (x%m+m)%m;
// }

// lli moddiv(lli a, lli b, lli m)
// {
//   a=a%m;
//   lli inv = modinv(b,m);
//   if(inv!=-1)
//     return ((a*inv + m)%m);
//   else
//     return -1;
// }

// lli binpow(lli a, lli b, lli m)
// {
//  lli res=1;
//  a=a%m;
//  while(b>0)
//  {
//    if(b & 1)
//    {
//      res = (res * a)%m;
//    }
//    b=b>>1;
//    a=(a*a)%m;
//  }
//  return res;
// }

// lli gcd(lli a, lli b)
// {
//     // if(b<a)
//     // {
//     //     lli t=a;
//     //     a=b;
//     //     b=t;
//     // }
//     if(a==0)
//         return b;
//     return gcd(b%a,a);
// }

/////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  lli t,i,j,f=0,n=0;
  cin>>t;
  while(t--)
  {
  	cin>>i>>j;
  	if(i-j==0)
  	{
  		n++;
  	}
  	else
  	{
  		n=0;
  	}
  	if(n==3)
  		f=1;
  }
  if(f)
  	cout<<"Yes\n";
  else
  	cout<<"No\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    int ans = 0;
    for (int i = 0; i < N - 2; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            ans++;
            i += 2;
        }
    }

    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<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main()
{
int x=0,y=0,z=0,w=0,n=0,d=0;
std::cin >> x;
std::cout << (x-30)/2 << '\n';
}



Measured memory_bytes: 3088