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

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

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

typedef long long ll;



int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    REP(i,N) cin >> H[i];
    reverse(ALL(H));
    REP(i,N-1){
        if (H[i] < H[i+1]) {
            if (H[i+1]-1==H[i]) {
                H[i+1]--;
            }
            else {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
    exit(0);
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  vector<ll> L(N);
  REP(i, N) L[i] = nextLong();
  sort(ALL(L));

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        if (L[i] == L[j] || L[j] == L[k]) continue;
        if (L[i] + L[j] <= L[k]) continue;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <utility>
#include <map>

using namespace std;

typedef pair <int, int> ii;

#define MOD 1000000007

int x, y;
//n + 2m = x
//2n+ m = y
int n, m;

long long fact[1000005];

long long fastExp(int base, int power)
{
    if (power == 1) return base % MOD;
    long long ans = fastExp(base, power / 2);
    ans *= ans;
    ans %= MOD;
    if (power % 2 == 1)
    {
        ans *= base % MOD;
    }
    return ans % MOD;
}

long long choose(int n, int r)
{
    if (n == r || r == 0) return 1;
    return fact[n] * ((fastExp(fact[r], MOD - 2) * fastExp(fact[n - r], MOD - 2)) % MOD) % MOD;
}

int main()
{
	scanf("%d%d", &x, &y);
	if ((x + y) % 3 != 0)
	{
		printf("0\n");
	}
	else
	{
		m = (2 * x - y) / 3;
		n = x - 2 * m;
		if (n < 0 || m < 0) printf("0\n");
		else
		{
		    fact[1] = 1;
		    for (int i = 2; i <= n + m; i++) fact[i] = (fact[i - 1] * i) % MOD;
			printf("%lld\n", choose(n + m, n));
		}
	}
	return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl

ll reqd(vb &taken,vv &a,ll k)
{
    ll n=a.size();
    ll m=a[0].size();
    vi arr;
    arr.pb(-1);
    for(ll i=0;i<n-1;i++)
    {
        if(taken[i])
        {
            arr.pb(i);
        }
    }
    arr.pb(n-1);
    vii p;
    for(ll i=0;i<(ll)arr.size()-1;i++)
    {
        p.pb(mp(arr[i],arr[i+1]));
    }
    vv b;
    for(ll o=0;o<p.size();o++)
    {
        vi ar;
        ll l=p[o].F;
        ll r=p[o].S;
        for(ll j=0;j<m;j++)
        {
            ll count=0;
            for(ll i=l+1;i<=r;i++)
            {
                count+=a[i][j];
            }
            ar.pb(count);
        }
        b.pb(ar);
    }
/*    trv(taken);
    cout<<"b:\n";
    for(ll i=0;i<b.size();i++)
    {
        for(ll j=0;j<b[0].size();j++)
        {
            cout<<b[i][j]<<" ";
        }
        cout<<nl;
    }
    return 0;*/
    for(ll i=0;i<b.size();i++)
    {
        for(ll j=0;j<b[0].size();j++)
        {
            if(b[i][j]>k)
                return inf;
        }
    }
    ll num_seg=1;
    vi count(b.size(),0);
    for(ll i=0;i<m;i++)
    {
        bool possible=true;
        for(ll j=0;j<b.size();j++)
        {
            count[j]+=b[j][i];
            if(count[j]>k)
                possible=false;
        }
        if(possible==false)
        {
            num_seg++;
            for(ll j=0;j<b.size();j++)
            {
                count[j]=b[j][i];
            }
        }
    }
    return num_seg-1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    vs y(n);
    for(ll i=0;i<n;i++)
        cin>>y[i];
    vv a(n,vi(m,0));
    for(ll i=0;i<n;i++)
        for(ll j=0;j<m;j++)
            a[i][j]=y[i][j]-'0';
    ll ans=inf;
    for(ll i=0;i<((1ll)<<(n-1));i++)
    {
        vb taken(n-1,false);
        ll num=0;
        for(ll j=0;j<n-1;j++)
        {
            if(((1ll<<j)&i))
            {
                taken[j]=true;
                num++;
            }
        }
        num+=reqd(taken,a,k);
        ans=min(ans,num);
    }
    cout<<ans<<"\n";
}


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

int dp[100000] = {} ;
vector<vector<int>> adj(100000) ;

int longest(int v) {

  if(dp[v]!=-1) return dp[v] ;
  
  if(adj[v].size()==0) {
  	dp[v] = 0 ;
  }
  
  else {

    for(int i : adj[v]) {    	
      dp[v] = max(dp[v],1 + longest(i)) ;
    }
  }
  
  return dp[v] ;
} 


int main() {

  int n,m; cin>>n>>m;
  
  for(int i=0; i<m; i++) {
    int x,y; cin>>x>>y ;
    adj[x-1].push_back(y-1) ;
  }
  
  for(int i=0; i<n; i++) dp[i] = -1 ;
  
  int ans = 0 ;
  
  for(int i=0; i<n; i++){
    ans = max(ans, longest(i)) ;
  }
  
  cout<<ans ;
  
  return 0 ;
} 



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

int main() {
    int n, t; cin >> n >> t;
    vector<int> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    int maxd = 0;
    int maxc = 0;
    for (int i = n-1; i >= 0; i--) {
        maxd = max(maxd, maxc - a[i]);
        maxc = max(maxc, a[i]);
    }
    assert(maxd >= 1);
    int ans = 0;
    maxc = 0;
    for (int i = n-1; i >= 0; i--) {
        if (a[i] + maxd == maxc) {
            ans++;
        }
        maxc = max(maxc, a[i]);
    }
    cout << ans << '\n';
}






























Measured memory_bytes: 640
#include <bits/stdc++.h>
#define inf (long long)1e16
using namespace std;

long long n, m;
vector<long long> a, b, h;
vector<vector<long long>> dp;

long long solve();

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    a.resize(n);
    b.resize(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i) cin >> b[i];
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  long long ans = inf;
  h.assign(n + 1, 0);
  for(int i = 0; i < n; ++i) {
    h[i + 1] = b[i] - a[i];
    if(h[i + 1] < 0) h[i + 1] += m;
  }
  dp.assign(n + 1, vector<long long>(2 * n, inf));
  for(int i = 0; i < 2 * n; ++i) dp[0][i] = i * m;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 2 * n; ++j)
      for(int k = -1; k <= 1; ++k)
        if(j + k >= 0 && j + k < 2 * n) {
          dp[i + 1][j] =
              min(dp[i + 1][j],
                  dp[i][j + k] +
                      max(0LL, h[i + 1] - h[i] - k * m));
          if(i == n - 1) ans = min(ans, dp[i + 1][j]);
        }
  return ans;
}


Measured memory_bytes: 25244
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
		int n = s.Length;
    long answer = 0;
    int skipA = 0;

    if(n != 1)
    {
      for(int i = 0; i < n-1; i++)
      {
        if(s[i] == 'A') skipA++;
        else if(s[i] == 'B' && s[i+1] == 'C')
        {
          answer += skipA;
          i++;
        }
        else skipA = 0;
      }
    }

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0

for i in range(n) :
    a = list(map(int,input().split()))
    d = 0
    for j in range(m) :
        d += a[j]*b[j]
    d += c
    if d > 0 :
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using Int = long long int;
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return -1;
}

Int getKey(string str){
  Int sum = 0, p = 1, i;
  for ( i = 0; i < str.size(); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int main(){
    set<Int> str;
    Int n;cin >> n;
    for(Int i=0;i<n;i++){
        string meirei;cin >> meirei;
        string s;cin >> s;
        Int data =getKey(s);
        if(meirei[0]=='f'){
            if(str.find(data)!=str.end()) cout << "yes" << endl;
            else cout << "no" << endl; 
        }else{
            str.insert(data);
        }
    }
}


Measured memory_bytes: 16080
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			int[]p = new int[N];
			for(int i = 0;i<N;i++)p[i] = scan.nextInt();



			int count = 0;
			for(int i = 0;i<N;i++) {
				if(i!=N-1) {
					if(p[i]-1==i) {
						if(p[i+1]-1==i+1) {
							count++;
							i++;
						}else {
							count++;
						}
						}
				}else {
					if(p[i]-1==i) {
						count++;
					}


				}


			}


			System.out.println(count);

		}


	}


}


Measured memory_bytes: 59528
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string a;
	cin >> a;
	if (a[0] != a[1] && a[1] != a[2] && a[2] != a[0])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if(a*b >= c*d) {
			System.out.println(a*b);
		}else {
			System.out.println(c*d);
		}
}
}

Measured memory_bytes: 22996
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


def main():
    N = int(readline())
    L = list(map(int, readline().split()))

    if sum(L)-max(L)>max(L):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
s = input()
ans = "AC"
cnt = 0

for i in range(len(s)):
    if i == 0:
        if s[i] != "A":
            ans = "WA"
            break
    elif 2 <= i <= len(s)-2 and s[i] == "C":
        cnt += 1
    elif s[i] != s[i].lower():
        ans = "WA"
        break
else:
    if cnt != 1: ans = "WA"

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
//#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
   Fast;
   ll mod=998244353;
   
    string s;I s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   
   XXX;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int count = 0;
		while(sc.hasNext()){
			if(count!=0) System.out.println();
			int p = sc.nextInt();
			int[][] map = new int[8][5];
			int q = 10000;
			int r = 0;
			for(int i=0;i<5;i++){
				r = p/q;
				p = p%q;
				map[r/5][i] = 1;
				map[2][i] = 2;
				for(int j=0;j<5;j++){
					if(r%5!=j) map[j+3][i] = 1;
				}
				q /= 10;
			}
			for(int i=0;i<8;i++){
				for(int j=0;j<5;j++){
					if(map[i][j]==0) System.out.print(" ");
					else if(map[i][j]==1) System.out.print("*");
					else if(map[i][j]==2) System.out.print("=");
				}
				System.out.println();
			}
			
			count++;
		}
	}	
}

Measured memory_bytes: 27920
#include <bits/stdc++.h>
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
using namespace std;
typedef long long ll;

ll c_to_i(char c)
{
  return (ll)c - (ll)'0';
}

class mint
{
  const ll mod = 2019;

public:
  ll x;

  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const
  {
    return mint(-x);
  }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint &a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint &a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint &a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint &a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint &a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint &a) const
  {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &m)
  {
    os << m.x;
    return os;
  }
};

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

  ll n = s.length();

  mint *dp = new mint[n + 1];
  mint base = 1;
  map<ll, ll> ms;

  dp[n] *= 0;
  ms[0] += 1;
  FORD(i, n - 1, 0)
  {
    dp[i] *= 0;
    dp[i] += dp[i + 1] + base * c_to_i(s[i]);
    base *= 10;
    ms[dp[i].x] += 1;
  }

  ll ans = 0;
  for (auto m : ms)
  {
    ans += m.second * (m.second - 1) / 2;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
	int m, d, m1,d1;
	while(cin >> m >> d >> m1 >> d1){
//		int a[20] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
		if(d1 != 1) cout << 0 << endl;
		else printf("1\n"); 
		
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	double ax,ay,bx,by,cx,cy,dx,dy;
	while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy)){
		if(ax>dx||by<cy||cx>bx||dy<ay)printf("NO\n");
		else printf("YES\n");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;

int cntRed[4005]{};
int cntGreen[4005]{};
int cntBlue[4005]{};
int main()
{

    int n;
    string s;
    cin >> n >> s;
    ll sum = 0 ;

    for(int i = 0 ; i<n ; i++){
        if(s[i] == 'R'){
            cntRed[i]++;
        }
        if(s[i] == 'G'){
            cntGreen[i]++;
        }
        if(s[i] == 'B'){
            cntBlue[i]++;
        }

        if(i>0){
            cntRed[i] += cntRed[i-1];
            cntBlue[i] +=cntBlue[i-1];
            cntGreen[i] += cntGreen[i-1];
        }
    }

    for(int i = 0 ; i<n ; i++){
        for(int j = i+1 ; j<n ; j++){

            char c1 = s[i];
            char c2 = s[j];
            if(c1 =='R' && c2 == 'G' || c1 == 'G' && c2 == 'R'){

                ll x = cntBlue[n-1] - cntBlue[j-1];
                sum+=x;
                if(j + j-i <n && s[j+j-i]=='B')sum--;

            }
            else if(c1 =='R' && c2 == 'B' || c1 == 'B' && c2 == 'R'){

                ll x = cntGreen[n-1] - cntGreen[j-1];
                sum+=x;
                if(j + j-i <n && s[j+j-i]=='G')sum--;

            }
            else if(c1 =='B' && c2 == 'G' || c1 == 'G' && c2 == 'B'){

                ll x = cntRed[n-1] - cntRed[j-1];
                sum+=x;
                if(j + j-i <n && s[j+j-i]=='R')sum--;
            }
        }
    }

    printf("%lld\n" , sum);
    return 0;
}


Measured memory_bytes: 3724
N = int(input())
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[N-1])

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

int main() {
  int A,B,C;
  cin >> A >> B;
  C = A - 2*B;
  if (C >= 0) {
    cout << C << endl;
  }
  else if (C < 0) {
    cout << 0 << endl;
  }  
}


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

def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)
def lcm(x, y):
    return (x * y) // gcd(x, y)

k = 1
tf = True

for i in l:
    i //= 2
    k = lcm(k, i)
    if (k // i) % 2 == 0 or k > m:
        print(0)
        tf = False
        break

if tf == True:
    print(m // k - m // (k * 2))

Measured memory_bytes: 63856
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] t = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            t[i] = scan.nextInt();
            sum += t[i];
        }
        int m = scan.nextInt();
        int[][] px = new int[m][2];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < 2; j++){
                px[i][j] = scan.nextInt();
            }
        }
        int out = 0;
        for(int i = 0; i < m; i++){
            out = sum - t[px[i][0] - 1] + px[i][1];
            System.out.println(out);
        }
    }
}

Measured memory_bytes: 21716
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/

#include <bits/stdc++.h>
using namespace std;

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*********************************!Template Ends Here!**********************************//

const int nn = 2e5+5;
int a[nn], dp[nn][10];

void robin(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];

    // D   S  T   U    or   D  T   S   U  (editorial)    => 5 states for any point i
    // dp[i][j] : min no. of operation upto point i, if point i is in jth state
    // states : ... ->  D, D -> S,  S -> T (vice versa),  T -> U, U -> ...

    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 5; j++){

            if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j-1]);
            int here = 0;
            if(j == 0 || j == 4) here = a[i+1];
            else if(j == 2){
                here = (a[i+1] % 2 ? 0 : 1);
            }
            else{
                here = (a[i+1] % 2);
                if(! a[i+1]) here = 2;                  // ---->       // as it lies in the even range, so we have to remove 2 that will be generated
                                                       //  <----
            }                                         // any distance(a[i]) can be traversed for an ear by running b/w two consecutive points i-1 to i

            dp[i+1][j] =  dp[i][j] + here;
        }
    }

    int ans = 1e18;
    for(int j = 0; j < 5; j++) ans = min(ans, dp[n][j]);
    cout << ans;
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        robin();
    }
    return 0;
}

Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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 UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2])cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    lint res = 0;

    for (int i = 1; i <= n; i++) {
        lint terms = n/i;
        lint start = i;
        lint end = i * terms;
        res += (start + end) * terms / 2;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  map<ll,ll> ans;
  for(ll x=1;x<101;x++)for(ll y=1;y<101;y++)for(ll z=1;z<101;z++)
  ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
  rep(i,n) print(ans[i+1]); 
  return 0;
}

Measured memory_bytes: 5952
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(n):
    tmp=[a[i][j]*b[j] for j in range(m)]
    if sum(tmp)+c>0:
        count+=1
print(count)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		a = sc.nextInt();
		b = sc.nextInt();

		if (a <= 0 && 0 <= b) {
			System.out.println("Zero");
		} else if (0 < a) {
			System.out.println("Positive");
		} else if (b < 0) {
			if ((Math.abs(b - a) + 1) % 2 == 0)
				System.out.println("Positive");
			else
				System.out.println("Negative");
		}
	}
}

Measured memory_bytes: 9552
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
dp = [0] * (n+1)
dp[0] = 1
for i in range(1,n+1):
  dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
  if i in a:dp[i]=0
print(dp[n])


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

int main() {
	int N;
	cin >> N;
	bool ans = true;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 2 == 1) ans = false;
	}
	cout << (ans ? "second" : "first") << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Bits

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- getIntList
    let gs = map (\g -> (head g, length g)) . group $ sort as
    putStrLn $ if check n gs then "Yes" else "No"

check n gs | l == 1 = fst (head gs) == 0 
           | n `mod` 3 /= 0 = False
           | l == 2 = let (a:b:_) = sort gs in fst a == 0 && snd a == (n `div` 3) && snd b == (2*n `div` 3)
           | l == 3 = let (a:b:c:_) = map fst gs in a `xor` b `xor` c == 0 && all (== n `div` 3) (map snd gs)
           | otherwise = False
           where l = length gs

Measured memory_bytes: 24924
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int index = scanner.nextInt();
        String str = scanner.next();
        index=index-1;
        char c = str.charAt(index);
        String ans = "";
        for (int i = 0; i < n; i++) {
            if (i == index) {
                if (!Character.isUpperCase(c)) {
                    ans = ans + (c+"").toUpperCase();
                } else {
                    ans = ans + (c+"").toLowerCase();

                }
            } else {
                ans = ans + str.charAt(i);
            }
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define deb(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    int A[110];
    rep(i, N) {
        cin >> A[i];
    }

    int ceat[110];
    rep(i, N) {
        ceat[i] = ((D - 1) / A[i]) + 1;
    }
    int sum = accumulate(ceat, ceat + N, 0);
    cout << sum + X << endl;
}

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

//関数


//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> h(N+1);
    h.at(0)=0;
    for(int i=1;i<=N;i++){
        cin>>h.at(i);
    }
    
    //計算
    long ans=0;
    for(int i=0;i<N;i++){
        if(h.at(i+1)>h.at(i)) ans+=h.at(i+1)-h.at(i);
    }
    
 
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-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; }

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a + 1) % 2 == 0) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }
}


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

int main(){
    int n;
    string s;
    int count = 0;
    int ans = 0;
    cin >> n;
    cin >> s;
    for(int i = 0; i < n ;i++){
        if(s.at(i) == 'I'){
            count += 1;
            ans = max(ans,count);
        }else if(s.at(i) == 'D'){
            count -= 1;
            ans = max(ans,count);
        }else{
            
        }
    }
    cout << ans<< endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) {
        swap (a , b);
    }
    if (b > c) {
        swap (b , c);
    }
    if (a > b) {
        swap (a , b);
    }
    cout << a << " ";
    cout << b << " ";
    cout << c << endl ;
    
}



Measured memory_bytes: 3088
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val Array(s, t) = in.readLine().split("\\s+")

    System.out.println(
      s.toCharArray.zip(t.toCharArray).flatMap {
        case (a, b) => "" + a + b
      }
    )
  }
}


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

using namespace std;

int main()
{
	int n, i;
	cin >> n;
	for(i=1; i<10; i++) {
		if(n%i == 0) {
			if(n/i < 10) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int[][] matrix = new int[N][N];
        for (int i = 0; i < N; i++){
            for (int j = i; j < N; j++) {
                matrix[i][j] = j - i;
            }
        }
        for (int i = 0; i < N; i++){
            for (int j = i; j < N; j++) {
                int val = Math.abs(X - (i + 1)) + Math.abs(Y - (j + 1)) + 1;
                if (matrix[i][j] > val){
                    matrix[i][j] = val;
                }
            }
        }
        int[] numVals = new int[N];
        for (int i = 0; i < N; i++){
            for (int j = i; j < N; j++) {
                numVals[matrix[i][j]]++;
            }
        }
        for (int n = 1; n < N; n++){
            System.out.println(numVals[n]);
        }
    }
}


Measured memory_bytes: 53716
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#include<sstream>
#define endl '\n'
#define ll long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll x,n,t;
	cin>>x>>n>>t;
	cout<<((x+n-1)/n)*t<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(){
	int i = 0;
	int a[26] = {0};
	char s[101];
	scanf("%s", s);
	for(i = 0; s[i] != '\0'; i++){
		a[(int)(s[i] - 'a')] += 1;
	}
	for(i = 0; i < 26; i++){
		if(a[i]%2 == 1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<pair<string, int>> vec(n);
  vector<pair<string, int>> vecb(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i).first>>vec.at(i).second;
    vecb.at(i).first=vec.at(i).first;
    vecb.at(i).second=-1*vec.at(i).second;
    vec.at(i).second*=-1;
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(vec.at(i)==vecb.at(j)){
        cout<<j+1<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
open Batteries
let k = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> b)
let s = read_line ()

let t = s.[k-1]
let c = Bytes.of_string s
let () = Bytes.set c (k-1) (String.lowercase_ascii s).[k-1] 
let _ = print_endline (Bytes.to_string c)



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define mp make_pair
#define INF (int)1e9
#define cBits(x) __builtin_popcount(x)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) a/gcd(a,b)*b
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define FORr(i,a,b) for (int i=a;i>=b;i--)
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
#define eachTest int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;

const int MOD=1000000007;

void solve() {
	;
}

int main() {

	fastio;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	// eachTest

	int h, w;
	cin >> h >> w;
	string board[h];
	FOR(i,0,h) {
		cin >> board[i];
	}
	ll table[h][w];
	table[h-1][w-1] = 1;
	FORr(i,h-1,0) {
		FORr(j,w-1,0) {
			if (i==h-1 && j==w-1) {
				continue;
			}
			table[i][j] = 0;
			if (board[i][j] == '#') {
				continue;
			}
				// if (i==0 && j==1) {
				// 	cout << "adding " << table[i][j+1] << " to " << table[i][j] << "\n";
				// }
			if (i!=h-1) {
				// if (board[i+1][j]!='#') {
					table[i][j] += table[i+1][j];
					// continue;
				// }
			}
			if (j!=w-1) {
				// if (board[i][j+1]!='#') {
					table[i][j] += table[i][j+1];
					// continue;
				// }
			}
			table[i][j] %= MOD;
			// if (i==h-1) {
			// 	if (board[i][j+]=='#') {
			// 		continue;
			// 	}
			// 	table[i][j] = table[i][j+1];
			// }
			// else if (j==w-1) {
			// 	if (board[i+1][j]=='#') {
			// 		continue;
			// 	}
			// 	table[i][j] = table[i+1][j];
			// }
			// else {
			// 	table[i][j] = table[i+1][j] + table[i][j+1];
			// }
		}
	}
	// FOR(i,0,h) {
	// 	FOR(j,0,w) {
	// 		cout << table[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	cout << table[0][0] << "\n";

	return 0;
}


Measured memory_bytes: 9088
#include<stdio.h>
int main(void){
    int n;
    int i;
    int m;
    int min=1000000, max=-1000000;
    long int sum=0;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &m);
        if(m<min){
            min=m;
        }
        if(m>max){
            max=m;
        }
        sum+=m;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2104
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
h = [0]*n

for i in range(n):
    h[i] = int(input())

h.sort()

ans = 10**9
for i in range(n-k+1):
    temp = h[i+k-1] - h[i]
    if ans > temp:
        ans = temp
print(ans)

Measured memory_bytes: 7472
from collections import Counter


def prime_factorize(n):
    a=[]
    while n%2==0:
        a +=[2]
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a +=[f]
            n //=f
        else:f +=2
    if n!=1:a +=[n]

    return a


n,p=map(int,input().split())
D=Counter(prime_factorize(p))
ans=1
for i,j in D.items():
    if j//n!=0:
        ans *=pow(i,j//n)
print(ans)

Measured memory_bytes: 38512
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut ans = 1;
    for i in 1..n {
        if s[i - 1] != s[i] {
            ans += 1
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#ifndef ___Class_RollingHash
#define ___Class_RollingHash

#include <string>
#include <vector>

template <int mod, int base = 257>
class RollingHash {
private:
	std::string str;
	std::vector<int> sum;
public:
	RollingHash() : str(""), sum(std::vector<int>(1, 0)) {};
	RollingHash(const std::string &s) : str(s) {
		sum.resize(str.size() + 1);
		for (int i = 0; i < str.size(); i++) sum[i + 1] = (1LL * sum[i] * base + s[i]) % mod;
	}
	static inline int modpow(int a, int b) {
		int ret = 1; a %= mod;
		while (b) {
			if (b & 1) ret = 1LL * ret * a % mod;
			a = 1LL * a * a % mod;
			b >>= 1;
		}
		return ret;
	}
	std::string get() { return str; }
	int gethash(int l, int r) {
		return (sum[r] - 1LL * sum[l] * modpow(base, r - l) % mod + mod) % mod;
	}
};

#endif

#include <string>
#include <iostream>
using namespace std;
string s;
int main() {
	cin >> s;
	int n = s.size();
	RollingHash<998244353> Q(s);
	bool flag = false;
	for (int i = (n + 2) / 3 - 1; i >= 1 && !flag; i--) {
		if ((n - 3 * i) % 2 == 1) continue;
		int r = (n - 3 * i) / 2, p1 = i, p2 = i + r, p3 = 2 * i + r, p4 = 2 * i + 2 * r;
		int z1 = Q.gethash(0, p1);
		int z2 = Q.gethash(p2, p3);
		int z3 = Q.gethash(p4, n);
		int z4 = Q.gethash(p1, p2);
		int z5 = Q.gethash(p3, p4);
		if (z1 == z2 && z1 == z3 && z4 == z5) {
			cout << "Love " << s.substr(0, p2) << "!" << endl;
			flag = true;
		}
	}
	if (!flag) cout << "mitomerarenaiWA" << endl;
	return 0;
}

Measured memory_bytes: 8184
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n,sum = 0;
  cin >> n;
  int p[n - 1];
  for (int i = 0; i < n; i++){
    cin >> p[i];
  }
  sort (p,p+n-1,greater<int>());
  for (int i = 0; i < n; i++){
    if (i == 0){
      sum += p[i] / 2;
    }
    else{
      sum += p[i];
    }
  }
  cout << sum << '\n';
  return 0; 
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())

h = list(map(int, input().split()))

for i in range(n - 2, 0, -1):
  if h[i] > h[i + 1]:
    h[i] -= 1
  if h[i] > h[i + 1]:
    print('No')
    sys.exit()
print('Yes')

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

string n;

int memo[150][5][3];

int solve(int index, int k, int livre) {
	int op1 = 0;
	int op2 = 0;
	int op3 = 0;

	if(index == n.size()){
		if(k == 0) return 1;
		return 0;
	}

	if(memo[index][k][livre] != -1) {
		return memo[index][k][livre];
	}
	
	if(livre) {
		// colocar 0 nessa posicao
		op1 = solve(index+1, k, livre);
		
		if(k > 0) {
			// colocar qualquer numero entre 1 e 9
			op2 = solve(index+1, k-1, livre)*9;
		}
	} else {
		// livre == false
		int digito = n[index] - '0';
		if(digito == 0) {
			// so tenho uma opcao
			op1 = solve(index+1, k, livre);
		} else {
			if(k > 0) {
				// libero colocando qualquer numero menor que eu menos o 0
				op1 = solve(index+1, k-1, 1)*(digito-1);

				// coloco meu proprio numero e nao libero
				op2 = solve(index+1, k-1, livre);
			} 
			// coloca 0 e libera
			op3 = solve(index+1, k, 1);
		}
	}

	return memo[index][k][livre] = op1 + op2 + op3;
}

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

	for(int i = 0; i < 150; i++) {
		for(int j = 0; j < 5; j++) {
			for(int l = 0; l < 3; l++) {
				memo[i][j][l] = -1;
			}
		}
	}

	// index, quantidade de 0 que falta, livre
	printf("%d\n", solve(0, k, 0));

	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 rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
using P = pair <int,int>; //to, cost
using WeightedGraph = vector<vector <P>>; //to cost
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int x; cin>>x;
    if(x == 7 || x == 5 || x == 3){
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
R = set()
G = set()
B = set()
for i, s in enumerate(S):
    if s == 'R':
        R.add(i)
    elif s == 'G':
        G.add(i)
    elif s == 'B':
        B.add(i)

ans = 0
for r in R:
    for g in G:
        ans += len(B)
        d = abs(r-g)
        if (r+g) % 2 == 0 and (r+g)//2 in B:
            ans -= 1
        if r+d in B or g+d in B:
            ans -= 1
        if r-d in B or g-d in B:
            ans -= 1
print(ans)


Measured memory_bytes: 9504
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;


int main() {
    int n, k;
    cin >> n >> k;
    ll ans = k;
    REP(i, n - 1) {
        ans *= k - 1;
    }
    cout << ans;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split(" ")]

sum_index = [0]*(N+1)
index = []
for i in range(N)[::-1]:
    sum_ = 0
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i]
    if sum_index[i+1] == 1:
        index.append(str(i+1))

print(sum(sum_index))
if index:
    print(" ".join(index))

Measured memory_bytes: 17228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  ld N,M;
  cin >> N >> M ;
  ld sum=0;
  ll count=0;
  vector<ll> v(N);
  for(ll i=0 ; i<N ;i++){
    cin >> v[i];
  }
  for(ll i=0 ; i<N ;i++){
    sum+=v[i];
  }
  for(ll i=0 ; i<N ;i++){
    if((sum/(4*M))<=v[i]){
      count+=1;
    }
  }
  if(count>=M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
int main() {
    long double X,Y,x,y;
    cin>>X;
    cin>>Y;
    cin>>x;cin>>y;
    printf("%llf", (X*Y)/2);
    if(x==X/2 && y==Y/2)
    {
        cout<<" 1";
    }
    else 
    cout<<" 0";
    return 0;




}


Measured memory_bytes: 384
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	cnt = defaultdict(lambda: 0)
	for boss in rli():
		cnt[boss] += 1
	for i in range(1, n + 1):
		print(cnt[i])
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 106964