akhauriyash/Code-Regression huggingface dataset:
//Inserting 'x'

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s;cin>>s;
    int n(s.size());
    int ans{},i{},j=n-1;
    for(;i<n&&i<=j;i++){
        for(;j>=0&&i<=j;j--){
            if(s[i]==s[j]){
                j--;
                break;
            }else if(s[i]=='x'){
                ans++;
                break;
            }else if(s[j]=='x'){
                ans++;
                continue;
            }else{
                cout<<-1<<nnn;
                return 0;
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
 
int main()
{
    int a[100][100],i,j,n,m,a1[100],sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&a1[i]);
    }
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum+=a[i][j]*a1[j];
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2148
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll N;
    cin >> N;
    ll a=N;
    ll a2=N*N;
    ll a3=N*N*N;
    ll ans=a+a2+a3;
    cout << ans << endl;
    return 0;
}

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

long long GetGreatestCommonDivisor(long long a, long long b) {
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main() {

	ll n, y; cin >> n >> y;
	
	vector<ll> x(n + 1);
	for (int i = 0; i < n; i++) cin >> x[i];
	x[n] = y;
	
	sort(x.begin(), x.end());

	vector<ll>diff_x(n);
	for (int i = 0; i < n; i++) diff_x[i] = x[i + 1] - x[i];
	
	long long tmp = diff_x[0];
	for (int i = 1; i < n; i++) {
		tmp = GetGreatestCommonDivisor(tmp, diff_x[i]);
	}

	cout << tmp << endl;
	return 0;
}

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

using namespace std;

int n;
char x[5];

int main() {
	scanf("%s", x);
	int ans = 0, cur = 0;
	for (int i = 0; x[i]; i++)
		if (x[i] == 'R')
			ans = max(ans, ++cur);
		else
			cur = 0;
	printf("%d\n", ans);
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int gcd(int x, int y){
	if(x < y) swap(x, y);
	if(y == 0) return x;
	else return gcd(x % y, y);
}

int gcdary(int *a, int n){
	int ans;
  ans = gcd(a[0], a[1]);
  for(int i = 2; i < n; i++){
		ans = gcd(ans, a[i]);
	}
	return ans;
}

int main(void){
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	if(n == 1) cout << abs(a[0] - x) << endl;
	else{
	a.push_back(x);
	SORT(a);
	int b[n];
	rep(i, n) b[i] = a[i + 1] - a[i];
	cout << gcdary(b, n) << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll inf=1e18;
const ll mod=1e9+7;
const ll maxn=2e3+10,lg=20;

ll dp[maxn],s;

int main(){
	FAST_IO;
	dp[1]=0;
	dp[2]=0;
	dp[3]=1;
	dp[4]=1;
	dp[5]=1;
	for(int i=6;i<maxn;i++){
		dp[i]=1;
		for(int j=3;j<=i-3;j++){
			dp[i]+=dp[j];
			dp[i]%=mod;
		}
	}
	cin>>s;
	cout<<dp[s]<<endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;
int mp[('z'-'a')+1][1000001];
     signed main(){
int  n;

cin>>n;
string s[n],ss;
pair<string,char> p[n];
for(int i=0;i<n;i++){
    cin>>s[i];
   reverse(s[i].begin(),s[i].end());
   char c=s[i][s[i].size()-1];
   s[i].pop_back();
   p[i]={s[i],c};
}
sort(p,p+n);
int ans=0;
for(int y=0;y<=('z'-'a');y++)mp[y][0]=0;
for(int i=0;i<n;i++){
    int k=0;
    s[i]=p[i].first;
    s[i].push_back(p[i].second);
    bool t[('z'-'a')+1]={};
    while(i!=0&&k<s[i-1].size()-1&&k<s[i].size()-1&&s[i-1][k]==s[i][k])k++;
    for(int j=k+1;j<s[i].size();j++)for(int y=0;y<=('z'-'a');y++)mp[y][j]=0;
    for(int j=s[i].size()-1;j>=0;j--){
        t[(s[i][j]-'a')]=true;
       for(int jj=0;jj<=('z'-'a');jj++)if(t[jj]) ans+=mp[jj][j];
    }
    mp[(s[i][s[i].size()-1]-'a')][s[i].size()-1]++;
}
cout<<ans<<endl;
//for(int i=0;i<n;i++)cerr<<s[i]<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 203964
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
	string s; cin >> s;
	map<char,bool>l;
	for (char c = 'a'; c <= 'z'; c++)l[c] = false;
	for (int i = 0; i < s.size(); i++)
		l[s[i]] = !l[s[i]];
	int num = 0;
	for (char c = 'a'; c <= 'z'; c++)if (l[c])num++;
	if (num % 2 == 1)num--;
	cout << num/2 << endl;
}

Measured memory_bytes: 3188
using System;

class main
{
    public static int Main()
    {
        string x = Console.ReadLine();
        string[] str = x.Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);

        if (a < b)
        {
            Console.WriteLine("a < b");
        }

        if (a > b)
        {
            Console.WriteLine("a > b");
        }

        if (a == b)
        {
            Console.WriteLine("a == b");
        }


        return 0;
    }
}

Measured memory_bytes: 8908
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double

#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}

typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

const ll mod =1e9+7;
const ll maxn=1e5+10;

int main()
{ 
  
   IOS
   
  ll r;
  cin>>r;
  cout<<r*r;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,R,i,max_v,v;
    scanf("%d",&n);
    scanf("%d",&v);
    scanf("%d",&R);
    max_v=R-v;
    if(R<v)v=R;
    for(i=2;i<n;i++){
        scanf("%d",&R);
        if(R-v>max_v)max_v=R-v;
        if(R<v)v=R;
    }
    printf("%d\n",max_v);
    return 0;
}


Measured memory_bytes: 1992
n, k = map(int, input().split())
a = list(map(int, input().split()))
doubling_list = [[-1] * n for i in range(60)]

for i in range(n):
    tmp = a[i] - 1
    doubling_list[0][i] = tmp

for i in range(1, 60):
    for j in range(n):
        doubling_list[i][j] = doubling_list[i - 1][doubling_list[i - 1][j]]

now = 0
for i in range(60)[::-1]:
    if k >> i & 1:
        now = doubling_list[i][now]

ans = now + 1        
print(ans)

Measured memory_bytes: 174824
#include<iostream>
#include<queue>
using namespace std;
#define int long long
signed main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	priority_queue<pair<int,int> > h;
	while(a--){
		int w;
		cin>>w;
		h.push(make_pair(w,1));
	}
	while(b--){
		int w;
		cin>>w;
		h.push(make_pair(w,2));
	}
	while(c--){
		int w;
		cin>>w;
		h.push(make_pair(w,3));
	}
	int z=x+y;
	int ans=0;
	while(z){
		pair<int,int> f=h.top();
		h.pop();
		if(f.second==3){
			ans+=f.first;
			--z;
		}
		else if(f.second==1 && x){
			ans+=f.first;
			--x;
			--z;
		}
		else if(f.second==2 && y){
			ans+=f.first;
			--y;
			--z;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int p[3][3];
    int a, b, c, d;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> p[i][j];
        }
    }
    a = p[0][1] - p[0][0];
    b = p[0][2] - p[0][1];
    c = p[1][0] - p[0][0];
    d = p[2][0] - p[1][0];
    for (int i = 0; i < 3; i++) {
        if (a != p[i][1] - p[i][0] || b != p[i][2] - p[i][1] || c != p[1][i] - p[0][i] || d != p[2][i] - p[1][i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<int,int> P;

int n,a;
int child[100000],rank[100000];
vector<int> tree[100000];

int dfs(int num){
	int ma = 0;
	vector<int> vec;
	for(int i = 0;i < tree[num].size();i++){
		vec.push_back(dfs(tree[num][i]));
	}
	if(vec.empty()) return 1;
	sort(vec.begin(),vec.end(),greater<int>());
	for(int i = 0;i < vec.size();i++){
		ma = max(ma,vec[i] + i + 1);
	}
	//cout << num << " " << ma << endl;
	return ma;
}

int main(){
	cin >> n;
	for(int i = 1;i < n;i++){
		cin >> a;
		tree[a - 1].push_back(i);
	}
	cout << dfs(0) - 1 << endl;
	return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i < s.size() - 1; i++)
		if (s.substr(i, 2) == "AC")
			ok = true;
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<ii> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].second, &a[i].first);
  }
  sort(a.begin(), a.end(), greater<ii>());
  vector<bool> visit(n);
  int64 cur = 0, ret = 0, cnt = 0;
  stack<int> S;
  for (int i = 0; i < m; ++i) {
    if (visit[a[i].second]) {
      S.push(a[i].first);
    } else {
      visit[a[i].second] = true;
      ++cnt;
    }
    cur += a[i].first;
    ret = cur + cnt * cnt;
  }
  for (int i = m; i < n && !S.empty(); ++i) {
    if (visit[a[i].second]) continue;
    visit[a[i].second] = true;
    cur -= S.top();
    S.pop();
    cur += a[i].first;
    ++cnt;
    ret = max(ret, cur + cnt * cnt);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1152
import java.awt.*;
import java.io.*;
import java.net.StandardSocketOptions;
import java.util.*;

public class Main {
    Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        new Main();
    }
    public Main(){
        new TestB().doIt();
    }
    class TestB{
        void doIt() {
            int N = sc.nextInt();
            int L[] = new int[N];
            for(int i = 0;i < N;i++){
                L[i] = sc.nextInt();
            }
            int cnt = 0;
            for(int i = 0;i < N;i++){
                for(int j = i+1;j < N;j++){
                    if(L[i] == L[j])continue;
                    for(int k = j+1;k < N;k++){
                        if(L[j] == L[k])continue;
                        if(L[i] == L[k])continue;
                        if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j])cnt++;
                    }
                }
            }
            System.out.println(cnt);
        }
    }
}

Measured memory_bytes: 36620
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,D;
    cin >>N>>D;
    int a=N%(2*D+1);
    if(a==0){
        cout << N/(2*D+1)<<endl;
    }
    else if(a!=0){
        cout<<N/(2*D+1)+1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    int N,K;
    cin >> N >> K;
    vector<pll> sushi(N);
    for (int i=0; i<N; i++) {
        ll t,d;
        cin >> t >> d;
        sushi[i] = {d,t};
    }
    sort(sushi.begin(),sushi.end());
    reverse(sushi.begin(),sushi.end());
    map<ll,ll> sushi_type;

    //resolve
    ll ans=0;
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    for (int i=0; i<K; i++) {
        pll st = sushi[i];
        ans += st.first;
        if (sushi_type[st.second]>0) pq.push(st);
        sushi_type[st.second]++;
    }
    ans += pow(sushi_type.size(),2);

    ll tmp = ans;
    for (int i=K; i<N; i++) {
        if (pq.size() == 0) break;
        if (sushi_type[sushi[i].second]>0) continue;
        auto st = pq.top(); pq.pop();
        tmp -= st.first;
        tmp += sushi[i].first;
        sushi_type[sushi[i].second]++;
        tmp -= pow(sushi_type.size()-1,2);
        tmp += pow(sushi_type.size(),2);
        ans = max(ans,tmp);
        //cout << tmp << endl;
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  auto R = P;
  sort(R.begin(), R.end());
  int a, b;
  int i = 1;
  do {
    if (R == P) {
      a = i;
    } 
    if (R == Q) {
      b = i;
    }
    i++;
  } while (next_permutation(R.begin(), R.end()));
  cout<< abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
#define INF (1<<29)
using namespace std;
int C[2][100][100];
int main()
{
	while (true) {
		int n, m; scanf("%d %d", &n, &m);
		if (n == 0 && m == 0) break;
		rep(k, 2) rep(i, 100) {
			rep(j, 100) { C[k][i][j] = INF; }
			C[k][i][i] = 0;
		}
		rep(i, n) {
			int a, b, c, t; scanf("%d%d%d%d", &a, &b, &c, &t);
			a--, b--;
			C[0][a][b] = C[0][b][a] = c;
			C[1][a][b] = C[1][b][a] = t;
		}
		rep(k, m) rep(i, m) rep(j, m) rep(l, 2) {
			C[l][i][j] = min(C[l][i][k] + C[l][k][j], C[l][i][j]);
		}
		int k; scanf("%d", &k);
		rep(i, k) {
			int p, q, r; scanf("%d%d%d", &p, &q, &r);
			printf("%d\n", C[r][p-1][q-1]);
		}
	}
	return 0;
}

Measured memory_bytes: 840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int C[n],S[n],F[n];
  for(int i=0; i<n-1; i++){
    cin>>C[i]>>S[i]>>F[i];
  }
  for(int i=0; i<n; i++){
    int ans=0;
    for(int j=i; j<n-1; j++){
      if(ans<S[j])ans=S[j];
      else{
        if(ans%F[j])ans+=(F[j]- ans%F[j]);
      }
      ans+=C[j];
    }
    cout<<ans<<endl;
  }
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int length=0,i=0,k=0,good=1,doublelen=0;
    char s[201];
    scanf("%s",s);
    while(i<201){
        if(s[i]=='\0'){
            length=i;
            break;
        };
        i++;
    };
    //printf("length=%d\n",length);
    i=(length-1)/2;
    while(i>0){
        //half[i]=s[i];
        good=1;
        for(k=0;k<i;k++){
            if(s[k]!=s[i+k]){
                good=0;
                break;
            };
            //printf("i=%d,k=%d,s[k]=%c,s[k+i]=%c\n",i,k,s[k],s[i+k]);
        };
        if(good==1){
            doublelen=i;
            //printf("doublelen=%d\n",doublelen);
            s[doublelen]='\0';
            //printf("answer: %s %s\n",s,s);
            break;
        };
        i--;
    };
    printf("%d",2*doublelen);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N;
ll v[200000], u[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        ans += i*(N-i+1);
    }
    for(int i = 0; i < N-1; i++){
        cin >> u[i] >> v[i];
        if(u[i] > v[i]) swap(u[i], v[i]);
        ll cnt = u[i]*(N-v[i]+1);
        ans -= cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6784
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S[3];
	cin >> S[0] >> S[1] >> S[2];
	int turn = 0;
	int d[3];
	d[0] = 0, d[1] = 0, d[2] = 0;
	while (true) {
		if (d[turn] == S[turn].size()) {
			cout << (char)(turn + 'A') << endl;
			return 0;
		}
		d[turn]++;
		turn = S[turn][d[turn] - 1] - 'a';
	}
}


Measured memory_bytes: 256
d = int(input())
c = list(map(int,input().split()))
like=0
but=0
s=[]
last=[]
for i in range(26):
    last.append(0)
for i in range(d):
    keys=list(map(int,input().split()))
    s.append(keys)
t=[]
for i in range(d):
    t.append(int(input())-1)
for i in range (d):
    like+=s[i][t[i]]
    #print(like)
    last[t[i]]=i+1
    for j in range(26):
        like-=c[j]*(i+1-last[j])
    print(like)

Measured memory_bytes: 9288
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int n,m,i,j,k,l,a[1005];
    memset(a,0,sizeof(a));
    cin>>n>>m;
    a[0]=0;
    for(i=1;i<=999;i++)
        a[i]=i+a[i-1];
    k=m-n;
    l=a[k]-m;
    cout<<l;
    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 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 fi first
#define se second
#define setpre(x) 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(){ cout << 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 = 100005;

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

int main(){
    int n, m; cin >> n >> m;
    vector<P> v(m);
    rep(i, m){
        int s, c; cin >> s >> c; v[i] = P(s, c);
    }

    for(int k = 0; k <= 999; k++){
        if(n == 1 && k < 10){
            bool ok = true;
            rep(i, m){
                if(k != v[i].se){
                    ok = false;
                }
            }
            if(ok){
                out(k); return 0;
            }
        }
        if(n == 2 && 10 <= k && k < 100){
            bool ok = true;
            rep(i, m){
                int d = k / (int)pow(10, 2 - v[i].fi) % 10;
                if(d != v[i].se){
                    ok = false;
                }
            }
            if(ok){
                out(k); return 0;
            }
        }
        if(n == 3 && 100 <= k){
            bool ok = true;
            rep(i, m){
                int d = (k / (int)pow(10, 3 - v[i].fi)) % 10;
                if(d != v[i].se){
                    ok = false;
                }
            }
            if(ok){
                out(k); return 0;
            }
        }
    }
    out(-1);
}


Measured memory_bytes: 256
//*in the name of GOD*\\

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main(){
  int n;
  cin >> n;
  int a[n];
  ld sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += ld(1.0 / a[i]);
  }
  cout << fixed << setprecision(5);
  cout << 1.0 / sum;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
)
func main() {
  var n,x,m,y int64
  fmt.Scan(&n,&x)
  if n%2 == 0 && x == n/2 {
    m = n + x
  } else if x <= n/2 {
    m = n + 2*x
    y = n - 2*x
    for {
      if x%y == 0 {
        m += 2*x - y
        break
      }
      m += 2*(x/y)*y
      x,y = y,x%y
    }
  } else {
    y = n - x
    m = n
    for {
      if x%y == 0 {
        m += 2*x - y
        break
      }
      m += 2*(x/y)*y
      x,y = y,x%y
    }
  }
  fmt.Println(m)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

bool solve(){
  ll a = in();
  ll b = in();
  ll c = in();
  ll d = in();
  if(d < b){
    return false;
  }
  if(a < b){
    return false;
  }
  if(c >= b){
    return true;
  }
  ll g = __gcd(b, d);
  ll cn = (c+1) / g;
  ll bn = b / g;
  if(a % g < (c+1) % g){
    if(bn >= cn + 2 || (bn == cn + 1 && a % g < b % g)){
      return false;
    } else {
      return true;
    }
  } else {
    if(bn >= cn + 1 || (bn == cn && a % g < b % g)){
      return false;
    } else {
      return true;
    }
  }
}

int main(){

  ll t = in();
  REP(i, t){
    bool res = solve();
    if(res){
      puts("Yes");
    } else {
      puts("No");
    }
  }
  
  return 0;
}

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		int h[n];
		for(auto &it : h) cin >> it;
		int dp[n+1];
		dp[0] = dp[1] = 0;
		dp[2] = abs(h[1]-h[0]);
		for(int i=3;i<=n;i++){
			dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
		}
		cout << dp[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int r, c;
    cin >> r >> c;
    int list[r+1][c+1];
    for(int i = 0; i < r; i++){
        int sum = 0;
        for(int j = 0; j < c; j++){    
            int a; cin >> a;
            list[i][j] = a;
            sum += a;
        }
        list[i][c] = sum;
    }
    for(int i = 0; i < c; i++){ 
        int sum = 0;
            for(int j = 0; j < r; j++){
                sum += list[j][i];
            }
        list[r][i] = sum;
    }
    int sumX = 0;
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                sumX += list[i][j];
            }
        }
    list[r][c] = sumX;
    
    for(int i = 0; i <= r ; i++){
        for(int j = 0; j <= c ; j++){
            cout<<list[i][j];
            if(j!=c)    cout<<" ";
        }
        cout<<endl;
    }
return 0;
}

Measured memory_bytes: 3080
C = int(1e9) + 7
H, W, A, B = map(int, input().split())

fact = [1]
for x in range(1, H + W - 2):
	fact.append( (x * fact[x-1]) % C )

factinv = [1] * (H + W -2)
factinv[H + W - 3] = pow(fact[H + W -3], C-2, C)

for x in reversed(range(2, H + W -3)):
	factinv[x] = ( factinv[x+1] * (x+1) ) % C

def nCr(n,r):
	return ( fact[n] * factinv[r] * factinv[n-r] ) % C

ans = 0
for i in range(B,W):
	ans = (ans + nCr(i+H-A-1, H-A-1) * nCr(A-1+W-i-1, A-1)) % C
	
print(ans)

Measured memory_bytes: 18964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<bool> b(n,true);
    int ans=0;
    for(int i = 0; i < n; i++) {
        if(a[a[i]]==i && b[i] && b[a[i]]){
            ans++;
            b[i]=false;
            b[a[i]]=false;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3756
N,M=[int(x) for x in input().split()]

def loc(ab):
  d=10**9
  t=''
  for m in range(M):
    td=abs(ab[0]-cd[m][0])+abs(ab[1]-cd[m][1])
    if td<d:
      d=td
      t=m
  return t

ab=['']*N
cd=['']*M
for i in range(N):
  ab[i]=[int(x) for x in input().split()]

for i in range(M):
  cd[i]=[int(x) for x in input().split()]

for n in range(N):
  print(loc(ab[n])+1)

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

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

int main() {
  ll h;
  cin >> h;
  ll height = log2(h);
  ll ans=0;
  rep(i, height+1){
    ans+=pow(2, i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int isprime(int n){
	int i;
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			return 0;
			break;
		}
	}
	return 1;
}

int main(){
	int i,n,p1,q1;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		if(isprime(n)==0){
			while(1){
				n--;
				if(isprime(n)==1) break;
			}
		}
		//printf("deback %d\n",n);
		if(isprime(n)==1){
			p1=n;
			q1=n;
			for(i=n-1;i>0;i--){
				if(isprime(i)==1) q1=i;
				if(p1-q1==2){
					printf("%d %d\n",q1,p1);
					break;
				}else{
				p1=q1;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
def main():
    N = int(input())  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト

    a0 = 0
    a1 = 0
    a2 = 0

    for e in a:
        if e % 4 == 0:
            a2 += 1
        elif e % 2 == 0:
            a1 += 1
        else:
            a0 += 1

    if a1 == 0 and a2 >= a0-1:
        print("Yes")
        return

    if a0 <= a2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 15020
N,M = map(int,(input().split()))
d = [[] for _ in range(N)]
P = [[] for _ in range(M)]
Y = [[] for _ in range(M)]

for i in range(M):
    P[i],Y[i] = map(int,(input().split()))
    d[P[i]-1].append(Y[i])
for i in range(N):
    d[i].sort()

result = {}
for i in range(N):
    tmp = 1
    for j in d[i]:
        result[j] = tmp
        tmp += 1

def sixlize(n):
    k = len(str(n))
    return "0"*(6-k) + str(n)

for i in range(M):
    print( sixlize(P[i]) + sixlize(result[Y[i]]) )

Measured memory_bytes: 78620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef long long ll;
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"         here"
#define out(value) cout<<value<<en



#define MAX 1005
ll cakes[MAX][3];

int main(){
  int n,m;
  cin>>n>>m;
  
  for(int i=1; i<=n; i++){
    for(int j=0; j<3; j++) cin>>cakes[i][j];
  }
  
  ll ans=0;
  for(int i=0; i<8; i++){
    bitset<3> bit(i);
    vector<ll> ve;
    for(int j=1; j<=n; j++){
      ll cnt=0;
      for(int k=0; k<3; k++){
        if(bit[k]) cnt+=cakes[j][k];
        else cnt-=cakes[j][k];
      }
      ve.push_back(cnt);
    }
    
    sort(ve.rbegin(), ve.rend());
    ll l=accumulate(ve.begin(), ve.begin()+m, 0LL);
    ans=max(ans,l);
  }
  
  cout<<ans<<en
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a , b , c  ;
    cin >> a >> b >> c ;
    if (a==b ){
        cout << c <<endl ;
    }else if (a==c){
        cout << b <<endl ;
    }else{
    cout << a << endl ;
    }

return 0 ;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())))

T = 0
i = 0
while T == 0:
  if H[i] >= K:
    T = 1
  else:
    i += 1
    if i >= N:
      print(0)
      quit()
      
print(N - i)



Measured memory_bytes: 11916
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
string s;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy";
    else if(s == "Cloudy")
        cout << "Rainy";
    else
        cout << "Sunny";
    return 0;
}



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

int main(){
        while(1){
        int a , b;
        char op;
        int k = 0;
        cin >> a >> op >> b;

        if(op =='+'){
                k = a+b;
        }else if(op =='-'){
                k = a-b;
        }else if(op =='*'){
                k = a*b;
        }else if(op =='/'){
                k = a/b;
        }else if(op =='?'){
                break;
        }else{
        break;
        }
        cout << k<< endl;
        }
        return 0;
}


Measured memory_bytes: 3072
def main():
    bingo = []
    for i in range(3):
        tmp = list(map(int, input().strip().split()))
        for j in range(3):
            bingo.append(tmp[j])

    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(bingo)):
            if(bingo[j]==b):
                bingo[j] = 0

    flag = False

    for i in range(3):
        if (bingo[0+3*i]+bingo[1+3*i]+bingo[2+3*i])==0:
            flag = True

    for i in range(3):
        if (bingo[0+i]+bingo[3+i]+bingo[6+i])==0:
            flag = True

    if (bingo[0]+bingo[4]+bingo[8])==0:
        flag = True
    if (bingo[2]+bingo[4]+bingo[6])==0:
        flag = True

    if flag==True:
        print('Yes')
    else:
        print('No')

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ld n, m;
    cin >> n >> m;
    if (n * 500 >= m) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll> mp;
	int n;
	cin >> n;
	vl v(n);
	ll sum = 0;
	REP(i, n)cin >> v[i];
	REP(i, n) {
		sum += v[i];
		mp[sum] = i+1;
	}
	sum = 0;
	int ans = 0;
	REP(i, n) {
		ans = max(ans, mp[sum] - i);
		sum += v[i];
		
	
	}

	cout << ans << endl;
}

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


int main(void){
    int x;
    cin >> x;
    int h;
    h = x/2;
    if(x%2 == 1){
        cout << (h+1)*h << endl;
    }else{
        cout << h*h << endl;
    }
    return 0;
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    double A, B, X, rad;
    cin >> A >> B >> X;
    if (X < A * A * B / 2)
    {
        rad = atan((A * B * B) / (X * 2));
    }
    else
    {
        X = A * A * B - X;
        rad = atan((X * 2) / (A * A * A));
    }

    cout << fixed << setprecision(10) << rad * (180 / PI);
}

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

int main(){
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1}; 
  int x, y; 
cin >> x >> y;
if (a[x] == a[y])cout << "Yes" <<endl;
else cout<<"No"<< endl;
}

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

struct edge{int from, to; i64 wei;};
using GraphType = vector<edge>;
template<typename Int>
bool Bellman_Ford(GraphType& Graph, vector<Int>& dist, int V, int start){
    dist[start] = 0;
    for(int v = 0;v < V; ++v){
        for(auto& e : Graph){
            if(dist[e.from] == 1e18) continue;
            if(dist[e.to] > dist[e.from] + e.wei){
                dist[e.to] = dist[e.from] + e.wei;
                if(v == V-1) return true;
            }
        }
    }
    return false;
}

int main(){
    i64 N, M, P;
    cin >> N >> M >> P;
    vector<int> A(M), B(M);
    vector<i64> C(M);
    rep(i, M) cin >> A[i] >> B[i] >> C[i], A[i]--, B[i]--;

    vector<i64> C_inv(M);
    rep(i, M) C_inv[i] = -(C[i] - P);
    
    vector<bool> visited_start(N, false);
    vector<bool> visited_end(N, false);
    {       
        vector<vector<int>> Graph_start(N);
        vector<vector<int>> Graph_end(N);
        rep(i, M) {
            Graph_start[A[i]].emplace_back(B[i]);
            Graph_end[B[i]].emplace_back(A[i]);
        }
            
        function<void(vector<vector<int>>&, vector<bool>&, int)> dfs = [&](vector<vector<int>>& Graph, vector<bool>& visited, int v){
            visited[v] = 1;
            for(int nxt : Graph[v]){
                if(visited[nxt]) continue;
                dfs(Graph, visited, nxt);
            }
        };
        dfs(Graph_start, visited_start, 0);
        dfs(Graph_end, visited_end, N-1);
    }

    vector<edge> Graph(N);
    vector<i64> dist(N, 1e18);

    rep(i, M){
        if(visited_start[A[i]] && visited_end[A[i]] && visited_start[B[i]] && visited_end[B[i]])
            Graph.push_back({A[i], B[i], C_inv[i]});
    }
    bool circle = Bellman_Ford(Graph, dist, N, 0);

    if(circle) cout << -1 << endl;
    else cout << max(-dist[N-1], (i64)0) << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100009];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    if(n%2)
    {
        printf("0");
        return 0;
    }
    sort(a+1,a+n+1);
    printf("%d",a[n/2+1]-a[n/2]);
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int i,e;
  static int n[26];
  char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  do{
    e = scanf("%c", &st);

    for(i=0;i<52;i++)
      if(al[i] == st){
        n[ i%26 ]++;
      }

  }while(e != EOF);

  for(i=0;i<26;i++)
    printf("%c : %d\n", al[i] , n[i]);

  return 0;
}

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

/*
レート 1-399：灰色
レート 400-799：茶色
レート 800-1199：緑色
レート 1200-1599：水色
レート 1600-1999：青色
レート 2000-2399：黄色
レート 2400-2799：橙色
レート 2800-3199：赤色
*/
int main() {
  int N;
  cin >> N;
  vector<int>iro(8);
  int kami = 0;
  vector<int>vec(N,0);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    if(vec[i] >= 3200){
      kami++;
    }
    else{
      iro[vec[i]/400]++;
    }
  }
  int syou = 0;
  for(int i=0; i<8; i++){
    if(iro[i] != 0){
      syou++;
    }
  }
  cout << max(syou,1) << " " << syou+kami << endl;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n,a,b,c,d;
cin >> n>>a>>b>>c>>d;
a--;b--;c--;d--;
string s;
cin >> s;
for(ll i=a;i<max(c,d);i++){
    if(s[i]=='#'&&s[i+1]=='#'){
        cout << "No" << endl;
        return 0;
    }
}
if(c<d){
    cout << "Yes" << endl;
    return 0;
}
for(ll i=b;i<=d;i++){
    if(s[i]=='.'&&s[i-1]=='.'&&s[i+1]=='.'){
        cout << "Yes" << endl;
        return 0;
    }
    
}

cout << "No" << endl;
return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int FLG[10001][761];
main(){
  int N,M,t,n,m,s,r,i,j,k,cnt,pc[1001];
  while(1){
    for(i=0;i<=1000;i++)pc[i]=0;
    scanf("%d %d",&N,&M);
    if(N==0&&M==0)break;
    for(i=0;i<=M;i++){
      for(j=0;j<761;j++){
    FLG[i][j]=0;
      }
    }
    scanf("%d",&r);
    for(i=0;i<r;i++){
      scanf("%d %d %d %d",&t,&n,&m,&s);
      if(s==1){
    pc[n]=t;
      }else{
    for(j=pc[n];j<t;j++){
      FLG[m][j-500]=1;
    }
      }
    }
    scanf("%d",&N);
    for(i=0,cnt=0;i<N;i++,cnt=0){
      scanf("%d %d %d",&t,&n,&m);
      for(j=t;j<n;j++){
    if(FLG[m][j-500]==1){
      cnt++;
    }
      }
      printf("%d\n",cnt);
    }
  }
  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


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

    int N, K;
    cin >> N >> K;

    vector<int> V(N);

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

    int ans = 0;

    for(int d = 0; d <= K; d++){
        for(int l = 0; l + d <= K; l++){
            if(d + l > N) continue;
            int tmp_sum = 0;
            vector<int> tmp_elm;
            for(int i = 0; i < d; i++){
                tmp_sum += V[i];
                tmp_elm.push_back(V[i]);
            }
            for(int i = 0; i < l; i++){
                tmp_sum += V[N-1-i];
                tmp_elm.push_back(V[N-1-i]);
            }

            sort(tmp_elm.begin(), tmp_elm.end());

            int N_add = K - d - l;
            for(int i = 0; i < N_add; i++){
                if(i >= tmp_elm.size()) break;
                if(tmp_elm[i] >= 0) break;
                tmp_sum -= tmp_elm[i];
            }

            chmax(ans, tmp_sum);

        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll min(ll x,ll y){
    if(x>=y) return y;
    else return x;
}
int main(){
    int test,count=0;
    //cin>>test;
    for(int g=0;g<1;g++){
        int x;
        cin>>(x);
        if(x>=30) cout<<"Yes";
        else cout<<"No";
        
    }
    return 0;
}
    

Measured memory_bytes: 3592
import java.util.Scanner;
public class Main{
    static tree[] wd;
    static int root =-1;
	public static void main(String[] args) {
	    int i=0,j,n;
	    String x;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     wd=new tree[n];
    for(j=0;j<n;j++){
       x=sca.next();
    	if(x.equals("insert")){
	    wd[i]=new tree(sca.nextInt());
	    insert(i);
	    i++;
	 }
    	if(x.equals("print")){
    	    inorder(root);
    	    System.out.println("");
    	    preorder(root);
    	    System.out.println("");  		
    	}
	if(x.equals("find")){
	    if(find(sca.nextInt(),root)==true){
		System.out.println("yes");
	    }else{
		System.out.println("no");
	    }
	}
    }
   }
    public static void preorder(int nd){
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getleft()!=-1)preorder(wd[nd].getleft());
	if(wd[nd].getright()!=-1)preorder(wd[nd].getright());
    }
    public static void inorder(int nd){
	if(wd[nd].getleft()!=-1)inorder(wd[nd].getleft());
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getright()!=-1)inorder(wd[nd].getright());
    }
    public static void insert(int data){//NIL->-1
     int y=-1,x=root;//parent of x
     while(x!=-1){
    	y=x;
    	if(wd[data].getnode()<wd[x].getnode()){
    		x=wd[x].getleft();
    	}else{
    		x=wd[x].getright();
    	}
    }
     if (y==-1){//it is root
    	 root=data;
     }else if(wd[data].getnode()<wd[y].getnode()){
    	 wd[y].setleft(data);
     }else{
    	 wd[y].setright(data);
     }
    }
    public static boolean find(int key,int opo){
	if(opo==-1)return false;
	if(key==wd[opo].getnode())return true;
	if(key<wd[opo].getnode()){
	return find(key,wd[opo].getleft());
	}else{
	return find(key,wd[opo].getright());
	}
    }
}
class tree{
    int node,par,n,i,degree=0;
    int left=-1,right=-1;
    tree(int node){
	this.node=node;
    }
    public int getnode(){
	return node;
    }
    public void setleft(int c){
	left=c;
	if(left!=-1) degree++;
    }
    public int getleft(){
	return left;
    }
    public void setright(int c){
	right=c;
	if(right!=-1) degree++;
    }
    public int getright(){
	return right;
    }
}



Measured memory_bytes: 220632
#include <iostream>
#include <string>
#define LEN 100005

typedef struct pp{
	std::string name;
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail+1)%LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head+1)%LEN;
	return x;
}

int min(int a, int b){return a < b ? a : b;}

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	std::cin >> n;
	std::cin >> q;
	for(int i = 1; i <= n; i++){
		std::cin >> Q[i].name;
		std::cin >> Q[i].t;
	}
	head = 1;
	tail = n+1;
	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else std::cout << u.name << " " << elaps << std::endl;
	}
}

Measured memory_bytes: 5112
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a>0&&b>0)printf("Positive");
	else if(a<=0&&b>=0)printf("Zero");
	else if((b-a)&1)printf("Positive");
	else printf("Negative");
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int n, k;
vector<ll> a;

int main() {
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    ll sum = accumulate(a.begin(), a.end(), 0LL);
    vector<ll> divisor;
    for(ll i = 1; i * i <= sum; i++) {
        if(sum % i != 0)  continue;
        divisor.push_back(i);
        divisor.push_back(sum / i);
    }
    sort(divisor.begin(), divisor.end());
    divisor.erase(unique(divisor.begin(), divisor.end()), divisor.end());
    reverse(divisor.begin(), divisor.end());

    for(auto d : divisor) {
        vector<ll> a_mod;
        auto mod = [&](ll x){ return x % d; };
        transform(a.begin(), a.end(), back_inserter(a_mod), mod);
        sort(a_mod.begin(), a_mod.end());
        reverse(a_mod.begin(), a_mod.end());
        ll sum_mod = accumulate(a_mod.begin(), a_mod.end(), 0LL);
        ll ope = accumulate(a_mod.begin() + (sum_mod / d), a_mod.end(), 0LL);
        if(ope > k)  continue;
        cout << d << endl;
        return 0;
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int sum1[222222],sum2[222222];
int N;
int X[222222],S[222222];
int sum[222222];

signed main(){
    cin>>N;
    rep(i,N){
        cin>>X[i]>>S[i];
    }

    rep(i,N)sum[i+1]=sum[i]+S[i];

    for(int i=1;i<=N;i++){
        sum1[i]=sum[i]-X[i-1];
        sum2[i]=sum[i-1]-X[i-1];
    }

    int mi=LLONG_MAX;

    int ans=0;
    for(int i=1;i<=N;i++){
        chmin(mi,sum2[i]);
        chmax(ans,sum1[i]-mi);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8576