akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>

int selectionSort(int *,int);

int main()
{
  int i,A[100],cnt,N;
  
  scanf("%d",&N);
  if(N<1 || N>100) exit(1);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  cnt = selectionSort(A,N);

  for(i=0;i<N;i++){
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

int selectionSort(int A[],int N)
{
  int i,j,tmp,cnt=0,minj;

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj])
	minj = j;	 
    }
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
    if(i != minj)
      cnt++;
  }
  return cnt;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int x;

int main(){
  cin >> x;
  if (x==0) cout << "1" << endl;
  else cout << "0" << endl;
}


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

using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    for(int i =0; i<N-1; i++){
        cin >> B.at(i);
    }
    vector<int> A(N);
    A.at(0) = B.at(0);
    for(int i = 1; i<N-1; i++){
        A.at(i) = min(B.at(i-1), B.at(i));
    }
    A.at(N-1) = B.at(N-2);
    ll ans = 0;
    for(int x : A){
        ans +=x;
    }

    cout << ans <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       string s;
       cin>>s;
       int n = sz(s);
       rep(i,0,n)
       cout<<'x';

    }
   return 0;
}


Measured memory_bytes: 256
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  const checkFlag = (f: any) => {
    return f['A'] && f['B'] && f['C'];
  };

  async function slove() {
    const sc = new Scanner();
    const input = [];
    let ans = 'Yay!';
    for (let i = 0; i < 6; i += 1) {
      input.push(+(await sc.getLine()));
    }
    for (let i = 0; i < 5; i += 1) {
      for (let j = i + 1; j < 5; j += 1) {
        const d = Math.abs(input[i] - input[j]);
        if (d > input[5]) {
          ans = ':(';
          break;
        }
      }
    }
    console.log(ans);
    sc.close();
  }

  slove();
}


Measured memory_bytes: 11596
#include <iostream>

using namespace std;

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

int main(){
  char a[8][8][4];

  rep(i,8){
    rep(j,8){
      cin >> a[i][j][0];
    }
  }

  rep(k,3){
    cout << (k+1)*90 << endl;
    rep(i,8){
      rep(j,8){
	cout << a[7-j][i][k];
	a[i][j][k+1] = a[7-j][i][k];
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1136
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 400;
int A[N][N], rem[N], vvv[N], cnt[N];
int check(int l)
{
    for (int i = 1; i <= m; ++ i) rem[i] = cnt[i] = 0;
    for (int i = 1; i <= n; ++ i)
    {
        vvv[i] = 1;
        cnt[A[i][1]] ++;
    }
    while (1)
    {
        int ok = 0;
        for (int i = 1; i <= m; ++ i) if (cnt[i] > l) {ok = i; break;}
        if (ok == 0) return 1;
        rem[ok] = 1;
        for (int i = 1; i <= n; ++ i)
            if (A[i][vvv[i]] == ok)
            {
                cnt[A[i][vvv[i]]] --;
                while (rem[A[i][vvv[i]]]) vvv[i] ++;
                if (vvv[i] > m) return 0;
                cnt[A[i][vvv[i]]] ++;
            }
    }
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++ i)
        for (int j = 1; j <= m; ++ j)
            scanf("%d", &A[i][j]);
    int l = 1, r = n;
    while (l < r)
    {
        int m = (l + r) / 2;
        if (check(m)) r = m; else l = m + 1;
    }
    printf("%d\n", l);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> v(n);
	rep(i,n) cin >> v.at(i);
	ll ans=-1000000000;
	rep(i,n+1){
		if(i>k) break;
		rep(j,n+1){
			int t=k;
			t-=i+j;
			if(t<0) break;
			if(i+j>n) break;
			ll sum=0;
			vector<int> a;
			rep(l,i) a.pb(v.at(l));
			rep(l,j) a.pb(v.at(n-1-l));
			sort(a.begin(),a.end());
			vector<bool> c(a.size(),true);
			rep(l,a.size()){
				if(t==0) break;
				if(a.at(l)<0){
					c.at(l)=false;
					t--;
				}
			}
			rep(l,a.size()) if(c.at(l)) sum+=a.at(l);
			ans=max(ans,sum);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var S = input.split(' ')[0];
    var W = input.split(' ')[1];
    if (S-W<=0) {
        console.log("unsafe");
    } else {
        console.log("safe");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int digit_sum(long n)
{
    if (n < 10)
        return n;
    return digit_sum(n / 10) + n % 10;
}

int main()
{
    long N, digit;
    cin >> N;

    digit = digit_sum(N);

    if (N % digit == 0)
    {
        cout << "Yes";
    }

    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
	int a, b, c;
	std::cin >> a >> b >>c ;

	if (a == b) {
		std::cout << c << std::endl;
	}
	else if (a == c) {
		std::cout << b << std::endl;
	}
	else if (b == c) {
		std::cout << a << std::endl;
	}
    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {

    input = input.split(/\n/)
    const n = ~~input[0]

    //スペース区切りで配列化、数値化、重複削除、並べ替え
    let houses = input[1].split(' ').map(v => ~~v).filter((v, i, self) => {
        return self.indexOf(v) === i
    }) //.sort((a, b) => a - b)

    // const ans = houses[houses.length-1] - houses[0]
    const ans = Math.max(...houses) - Math.min(...houses)

    console.log(ans)


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
char a[1000][1000]; 
int m[1000][1000];
int main()
{
	int h,w;
	memset(a,'.',sizeof(a));
	memset(m,48,sizeof(m));
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin>>a[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			if(a[i-1][j-1]=='#') m[i][j]++;
			if(a[i-1][j]=='#') m[i][j]++;
			if(a[i-1][j+1]=='#') m[i][j]++;
			if(a[i][j-1]=='#') m[i][j]++;	
			if(a[i][j+1]=='#') m[i][j]++;	
			if(a[i+1][j-1]=='#') m[i][j]++;			
			if(a[i+1][j]=='#') m[i][j]++;		
			if(a[i+1][j+1]=='#') m[i][j]++;						
		}
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			if(a[i][j]=='#') continue;
			a[i][j]=char(m[i][j]);
		}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
			cout<<a[i][j];
		cout<<endl;		
	}
	return 0;
} 

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const lb pi=acos(-1);
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

const ll K=1000000000000000000;
int main(){

  ll n;cin>>n;
  ll a[n];rep(i,0,n)cin>>a[i];
  sort(a,a+n);

  if(a[0]==0){
    out(0);
    return 0;
  }

  ll k=1;
  rep(i,0,n){
    ll r=K/a[i];
    if(k>r){
      out(-1);
      return 0;
    }
    k*=a[i];
  }

  out(k);
  // bool e=false;
  // rep(i,0,n){
  //   if(a[i]==0)e=true;
  // }
  // ll k=1;
  // rep(i,0,n){
  //   k*=a[i];
  //   if(k>K){
  //     if(e){
  //       out(0);
  //       return 0;
  //     }else {
  //       out(-1);
  //       return 0;
  //     }
  //     // break;
  //   }
  // }
  // out(k);

  return 0;
}


Measured memory_bytes: 4420
#include<stdio.h>
int main (){

 long long int berapaKali; 
 scanf("%lld", &berapaKali);
 long long int a1[berapaKali];
 long long int a2 = 1;
 long long int max = 1000000000000000000;
 long long int hasil ;
 
 for(int j=0;j<berapaKali;j++){
  scanf("%lld", &a1[j]);
 }
 
 for(int h=0;h<berapaKali;h++){
 
  if(a1[h]==0){
   printf("0\n");
   return 0;
  }
 }
 for(int i=0;i<berapaKali;i++){
  if(a1[i]<=max/a2){ 
  a2*= a1[i]; 
  }else{
  printf("-1\n");
  return 0;
  }
 }
 
 printf("%lld\n", a2);

 return 0;
}

Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,W;
    cin>>N>>W;
    long long w[N+1];
    long long v[N+1];
    long long dp[N+1][W+1]={0};

    w[0]=0, v[0]=0;
    for(int i=1;i<=N;++i){
        cin>>w[i]>>v[i];
    }

    for(int j=1;j<=W;++j){
      if(w[1]<=j){
        dp[1][j]=v[1];
      }
    }

    for(int i=2;i<=N;++i){
        for(int j=2;j<=W;++j){
         if(j<w[i]){
            dp[i][j]=dp[i-1][j];
         }else{
           if(j-w[i]<1) dp[i][j]=max(dp[i-1][j],v[i]);
           else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
         }
        }

    }


    long long ans=0;
    for(int j=1;j<=W;++j){
      ans=max(ans,dp[N][j]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 81564
def graph_apd(idx,jdx):
    
    li = ([1,0],[-1,0],[0,-1],[0,1],[1,1],[-1,-1],[1,-1],[-1,1])
    
    for i in li:
        if ((idx+i[0])==-1):continue
        if ((jdx+i[1])==-1):continue
        try:
            if graph2[idx+i[0]][jdx+i[1]]:
                
                if graph2[idx+i[0]][jdx+i[1]] != "#":
                    graph2[idx+i[0]][jdx+i[1]] += 1
            else:
                graph2[idx+i[0]][jdx+i[1]] = 1
        except IndexError:
            pass
        

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

graph1 = [[]for i in range(h)]

for i in range(h):
    x = input().replace("\r","")
    graph1[i].append(x)
          


graph2 = [ [None for i in range(w)] for j in range(h)]

for idx,i in enumerate(graph1):
    for jdx in range(len(graph1[idx][0])):
        if graph1[idx][0][jdx] == "#":
            graph2[idx][jdx] = "#"
            graph_apd(idx,jdx)
    
ret = [[] for i in range(h)]
        
for idx,i in enumerate(graph2):
    for jdx,j in enumerate(graph2[idx]):
        if graph2[idx][jdx]:
            graph2[idx][jdx] = str(graph2[idx][jdx])
        else:
            graph2[idx][jdx] = "0"
    ret[idx] = "".join(graph2[idx])
    print(ret[idx])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
vector<ll>q;

ll getAns(ll m){
	ll x=0;
	auto it=upper_bound(all(q),m)-q.begin()-1;
	return it;
}

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<=60;i++){
		q.pb(((i+1)*i)/2);
	}
	for(ll i=2;i*i<=n;i++){
		ll cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		ans+=getAns(cnt);
	}
	if(n>1)ans++;
	cout<<ans;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3636
a=int(input())
b=int(input())
c=int(input())

li1=[a,b,3*c-a-b]
li2=[4*c-2*a-b,c,2*a+b-2*c]
li3=[a+b-c,2*c-b,2*c-a]
print(*li1)
print(*li2)
print(*li3)

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

int main()
{
	int a, b, c, d;
	scanf( "%d%d%d%d", &a, &b, &c, &d );
	int st = max(a, c), ed = min(b, d);
	if(st <= ed) printf( "%d\n", ed - st );
	else printf( "0\n" );
	return 0;
}

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

using namespace std;

bool is_prime(int n) {
  if (n <= 1) {
    return false;
  }
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int X;
  cin >> X;

  while (!is_prime(X)) {
    X++;
  }
  cout << X << endl;

  return 0;
}


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

using namespace std;
#define N 3

int main(void){
    vector<vector<int> > c(3,vector<int>(3,0));

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int tmp;
            cin >> tmp;
            c[i][j] = tmp;
        }
    }
    int total = 0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            total += c[i][j];
        }
    }

    if((total%3 == 0) && (total == 3*(c[0][0]+c[1][1]+c[2][2]) )){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M; cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

using namespace std;

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

	map<int, int> m;
	for (int i = 0; i < n; i++) {
		cin >> a;
		m[a]++;
	}

	long long ans = 0;
	if (m.size() > k) {
		vector<int> v;
		for (auto p: m) {
			v.emplace_back(p.second);
		}
		sort(v.begin(), v.end(), greater<int>());
		for (int i = k; i < v.size(); i++) {
			ans += v[i];
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10748
# -*- coding: utf-8 -*-

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_m = 0
max_ai = 0
for i in range(1, N + 1):
    if sum_m + A[i - 1] <= K:
        sum_m += A[i - 1]
        max_ai = i
    else:
        break

max_bi = 0
max_count = 0
for j in reversed(range(0, max_ai + 1)):
    for k in range(max_bi + 1, M + 1):
        if sum_m + B[k - 1] <= K:
            sum_m += B[k - 1]
            max_bi = k
        else:
            break
    if j + max_bi > max_count:
        max_count = j + max_bi
    
    sum_m -= A[j - 1] if j >= 0 else 0

print(max_count)


Measured memory_bytes: 40424
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int	n,m,s;
	int x[2000],y[2000],d[2000];
	int leng[2000];
	int flg;
	int i,j;
	cin>>n>>m>>s;
	for(i=0;i<m;i++)	cin>>x[i]>>y[i]>>d[i];
	for(i=0;i<n;i++)	leng[i]=INT_MAX;
	leng[s]=0;
	for(i=0;i<=n;i++){
		flg=0;
		for(j=0;j<m;j++){
			if(leng[x[j]]!=INT_MAX&&leng[y[j]]>leng[x[j]]+d[j]){
				leng[y[j]]=leng[x[j]]+d[j];
				flg=1;
			}
		}
		if(flg==0)	break;
	}
	if(i>n&&flg==1)	cout<<"NEGATIVE CYCLE"<<endl;
	else{
		for(i=0;i<n;i++){
			if(leng[i]==INT_MAX)	cout<<"INF"<<endl;
			else					cout<<leng[i]<<endl;
		}
	
	}
	return 0;
}


Measured memory_bytes: 3152
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<map>
#include<string>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }


const int MOD = 1000000007;
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<char, int> cnt;
    string s;
    int n;
    cin >> n >> s;
    for (char c : s) {
        cnt[c] += 1;
    }
    vector<int> cntv;
    for (auto e : cnt) {
        cntv.push_back(e.second);
    }
    // DV(cntv);
    vector<long long> dp(cntv.size(), -1);
    dp[0] = cntv[0] + 1;
    for (int i = 1; i < cntv.size(); ++i) {
        dp[i] = ((cntv[i] * dp[i - 1]) % MOD + dp[i - 1]) % MOD;
    }
    // DV(dp);
    cout << dp[cntv.size() - 1] - 1<< endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    string s,t;cin >> s >> t;
    sort(all(s));
    resort(t);
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

#define N 10000

int main()
{
  int i, j, n;
  int *A, *B;
  int C[N+1];
  
  scanf("%d",&n);

  A = (int *)malloc(sizeof(int)*n+1);
  B = (int *)malloc(sizeof(int)*n+1);
  
  for( i=1 ; i<=n ; i++ )
    scanf("%d",&A[i]);

  for( i=1 ; i<N ; i++ )
    C[i] = 0;

  for( j=1 ; j<=n ; j++ )
    C[A[j]]++;

  for( i=1 ; i<=N ; i++ )
    C[i] = C[i]+C[i-1];

  for( j=n ; j>=1 ; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for( i=1 ; i<=n-1 ; i++ )
    printf("%d ",B[i]);
  printf("%d\n",B[i]);

  free(A);
  free(B);
    
  return 0;
}

Measured memory_bytes: 16056
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  int ans=0;
  cin >> n;
  cout<<(n*(n-1LL)/2LL)<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll L=0;
    ll R=N-1;
    prt(L);fl
    string LL;
    cin >> LL;if(LL=="Vacant")return 0;
    prt(R);fl 
    string RR;
    cin >> RR;if(RR=="Vacant")return 0;
    for(ll i=0;i<18;++i){
        ll M=(L+R)/2;
        prt(M);fl
        string S;
        cin >> S;
        if(S=="Vacant")return 0;
        if(R%2!=M%2&&S==RR){
            L=M;LL=S;continue;
        }
        else if(R%2==M%2&&S!=RR){
            L=M;LL=S;continue;
        }
        else {
            R=M;RR=S;continue;
        }
    }

    return 0;
}



Measured memory_bytes: 3812
#include <iostream>
using namespace std;
 
int disx,disy,x1,y1,x2,y2;
 
int main() {
	cin >> x1 >> y1 >> x2 >> y2;
 
	disx = x2-x1;
	disy = y2-y1;
 
	for(int i=0;i<disx;i++) cout << "R";
	for(int i=0;i<disy;i++) cout << "U";
	for(int i=0;i<disx;i++) cout << "L";
	for(int i=0;i<disy;i++) cout << "D";
 
	cout << "D";
	for(int i=0;i<disx+1;i++) cout << "R";
	for(int i=0;i<disy+1;i++) cout << "U";
	cout << "L" << "U";
	for(int i=0;i<disx+1;i++) cout << "L";
	for(int i=0;i<disy+1;i++) cout << "D";
	cout << "R";
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 1000000000;
using namespace std;

class Edge{
    public:
        int to, cost;
        Edge(int to, int cost) : to(to) ,cost(cost) {}
};

class Node{
    public:
        int dis;
        bool isUsed;
        Node(){
            this->dis = INF;
            this->isUsed = 0;
        }
};

typedef vector<vector<Edge>> AdjList;

int dijkstra(AdjList g, int start, int n){
    vector<Node> node(n);
    priority_queue<int, vector<pair<int, int>>, greater<pair<int, int>>> q;

    q.push(make_pair(0, start));
    node[start].dis = 0;

    pair<int, int> u;
    while(not q.empty()){
        u = q.top(); q.pop();
        int current = u.second;
        node[current].isUsed = 1;

        rep(i,g[current].size()){
            int next = g[current][i].to;
            if(node[next].isUsed == 0){
                if(node[next].dis > node[current].dis + g[current][i].cost){
                    node[next].dis = node[current].dis + g[current][i].cost;
                    q.push(make_pair(node[next].dis, next));

                }
            }
        }
    }
    for(auto it:node){
        if(it.dis == INF) cout << "INF" << endl;
        else cout << it.dis << endl;
    }
    return 0;
}

int main(){
    int v, e, r;
    cin >> v >> e >> r;

    AdjList g(v);
    rep(i,e){
        int a, b, c;
        cin >> a >> b >> c;
        g[a].emplace_back(b,c);
    }
    dijkstra(g, r, v);

}

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

int main(){
	int H,W;cin >> H >> W;
	int dist[10][10];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;++j){
			cin >> dist[i][j];
		}
	}
	for(int k=0;k<10;++k){
		for(int i=0;i<10;++i){
			for(int j=0;j<10;++j){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int a[H*W];
	int ans=0;
	for(int i=0;i<H*W;++i){
		int a;
		cin >> a;
		if(a>=0) ans+=dist[a][1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    long long n, k, s;
    cin >> n >> k >> s;
    for (int i = 1; i <= k; ++i) {
        cout << s << ' ';
    }
    if (s == 1e9) {
        for (int i = 1; i <= n - k; ++i)
            cout << 1 << ' ';
    } else {
        for (int i = 1; i <= n - k; ++i)
            cout << s + 1 << ' ';
    }
    return 0;
}

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

using namespace std;


void _accepcted_by_one_hit_()
{
    #ifdef NTMA
        freopen("abc.inp", "r", stdin);
        freopen("abc.out", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

int main()
{	
	_accepcted_by_one_hit_();
    long long a, b, n;
    cin >> n >> a >> b;
    long long x = n % (a + b);
    x = min(x, a);
    cout << (n/(a+b)*a) + x;
    
}

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

using namespace std;

uint8_t toggle(uint8_t c) {
    if (islower(c)) {
        return toupper(c);
    } else {
        return tolower(c);
    }
}

int main() {
    string str;

    getline(cin, str);

    transform(str.cbegin(), str.cend(), str.begin(), toggle);

    cout << str << endl;

    return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double EPS=1e-7;
const int N=1e6+10;
const ll mod=998244353;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
int n,x,t;
void solve()
{  string s;
   cin>>s;
   ll sum=0;
   for(int i=0;i<s.size();i++)sum+=s[i]-'0';
   if(sum%9==0)printf("Yes\n");
   else printf("No\n");
}
int main()
{  int t=1;
   while(t--)  
   {  
      solve();
   }
}

Measured memory_bytes: 3716
read N Y
(( Y /= 1000 ))
for (( z = Y % 5; z <= N; z += 5 )); do
    Y0=$(( Y - z - (N - z) * 5 ))
    x=$(( Y0 / 5 )) y=$(( N - x - z ))
    (( x >= 0 && y >= 0 )) && echo $x $y $z && exit
done
echo -1 -1 -1


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 200005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

i64 dp[maxn] , a[maxn] ;

int main()
{
    i64 i , j , k , l , m ,n ;

    scanf("%lld",&n) ;

    for(i=1 ; i<=n ; i++) scanf("%lld",&a[i]) ;

    memset(dp,0,sizeof(dp)) ;

    i64 ret = 0LL ;
    for(i=1 ; i<=n ; i++)
    {
        dp[ a[i]  ] = dp[ a[i]-1 ]+ 1 ;
        ret = max(ret, dp[ a[i] ] ) ;
    }

    printf("%lld\n",n-ret) ;

    return 0 ;
}


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

int main(){
	int n;
	cin>>n;
	int ans = 0;
	for(int i = 0; i<n; i++){
		int x;
		cin>>x;
		if ((i%2 ==0)&(x%2==1))
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, m;

    cin >> n;
    vector <string> s(n);
    REP(i, n) cin >> s[i];

    cin >> m;
    vector <string> t(m);
    REP(i, m) cin >> t[i];

    int ans = 0;

    for(int i = 0; i < n; ++i){
        string w = s[i];
        int cnt = 0;
        for(int j = 0; j < n; ++j){
            if(s[j] == w) ++cnt;
        }
        for(int j = 0; j < m; ++j){
            if(t[j] == w) --cnt;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class AffineCipher {
	String s,c;
	String alph = "abcdefghijklmnopqrstuvwxyz";
	int a[] = {1,3,5,7,9,11,15,17,19,21,23,25};

	AffineCipher(String s) {
		this.s = s;
		this.c = s;
	}

	boolean Found(String t) {
		if (t.indexOf("that")!=-1||
			t.indexOf("this")!=-1) return true;
		else return false;
	}

	String FindString() {
		for (int i=0;i<12;i++) {
			for (int j=0;j<=25;j++) {
				String t = "";
				for (int k=0;k<this.s.length();k++) {
					if (alph.indexOf(this.s.charAt(k))!=-1)
						t = t+alph.charAt((a[i]*alph.indexOf(this.s.charAt(k))+j)%26);
					else t = t+this.s.charAt(k);
				}
				this.s = this.c;
				if (Found(t)) return t;
			}	
			this.s = this.c;
		}
		return "NotFound";
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int n = Integer.parseInt(br.readLine());
			for (int i=0;i<n;i++) {
				AffineCipher ac = new AffineCipher(br.readLine());
				System.out.println(ac.FindString());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 60360
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans=0;
    char pre='#';
    rep(i,N) {
        char now = S[i];
        if(pre!=now) ++ans;
        pre = now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>



auto z_algo(std::string const& s) {
  std::size_t n = s.size();
  std::vector<std::size_t> res(n);
  res[0] = n;
  std::size_t i = 1, j = 0;
  while(i < n) {
    while(i+j < n && s[j] == s[i+j]) ++j;
    res[i] = j;
    if(j == 0) { ++i; continue; }
    std::size_t k = 1;
    while(i+k < n && k+res[k] < j) res[i+k] = res[k], ++k;
    i += k, j -= k;
  }
  return res;
}



#include <iostream>

void abc141_e() {
  using namespace std;
  size_t N; string S;
  cin >> N >> S;
  size_t ans = 0;
  for(size_t i=0;i<N;++i) {
    string T = S.substr(i);
    auto lcp = z_algo(T);
    for(size_t j=0;j<T.size();++j) {
      size_t l = lcp[j];
      if(l > j) l = j;
      if(ans < l) ans = l;
    }
  }
  cout << ans << '\n';
}

signed main() {

  abc141_e();

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main()
{
    int h,w,n;
    int m,s=0,i=0;
    scanf("%d%d%d",&h,&w,&n);
    m=h>w?h:w;
    while(s<n)
    {
        s+=m;
        i++;
    }
    printf("%d",i);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int ans1=0;
int ans2=0;
int ans3=0;
inline ll read()
{
	ans1=ans2=ans3=0;
	ll x=0,w=1;ans1=ans2=ans3=0;
	char c=getchar();ans1=ans2=ans3=0;
	while(c<'0'||c>'9')
	{ans1=ans2=ans3=0;
		if(c=='-') w=-1;ans1=ans2=ans3=0;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{ans1=ans2=ans3=0;
		x=(x<<1)+(x<<3)+c-'0';ans1=ans2=ans3=0;
		c=getchar();ans1=ans2=ans3=0;
	}
	return w==1?x:-x;
}

ll a[maxn],n,x[maxn],suf[maxn];

int main()
{ans1=ans2=ans3=0;
	n=read();ans1=ans2=ans3=0;
	rep(i,0,n) a[i]=read();
	x[n]=a[n];
	ans1=ans2=ans3=0;
	if(n==0)
	{ans1=ans2=ans3=0;
		if(a[0]==1) puts("1");
		else puts("-1");
		ans1=ans2=ans3=0;
		return 0;
	}
	ans1=ans2=ans3=0;
	for(int i=n-1; i>=1; i--) suf[i]=suf[i+1]+a[i];
	ans1=ans2=ans3=0;
	if(a[0]!=0) return puts("-1"),0;
	ans1=ans2=ans3=0;
	ll nw=1,ans=1;ans1=ans2=ans3=0;
	for(int i=1; i<n; i++)
	{ans1=ans2=ans3=0;
		nw=nw*2;ans1=ans2=ans3=0;
		if(nw<a[i])
		{
			ans1=ans2=ans3=0;
			return puts("-1"),0;
		}
		ans1=ans2=ans3=0;
		if(nw-suf[i]>a[n]) nw=a[n]+suf[i];
		ans+=nw;
		ans1=ans2=ans3=0;
		nw-=a[i];
	}
	ans1=ans2=ans3=0;
	if(nw<=a[n]&&2*nw>=a[n]) cout<<ans+a[n]+ans2+ans1+ans3<<endl;
	else puts("-1");
	ans1=ans2=ans3=0;
	return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool  int a, b;
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vector<int> x(n);
  bool jud[n + 1] = {false};
  arep(i, x) cin >> i;
  int cnt = 0;
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if (x[a] < x[b])
      jud[a] = true;
    else if (x[a] > x[b])
      jud[b] = true;
    else
      jud[a] = jud[b] = true;
  }

  rep(i, 0, n) if (!jud[i])++ cnt;
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3952
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    s = [str(input().rstrip('\n')) for _ in range(n)]
    d = collections.defaultdict(int)
    d[s[0]]
    b = True
    for i in range(1, n):
        if s[i] not in d:
            d[s[i]]
            if s[i][0] != s[i-1][-1]:
                b = False
                break
        else:
            b = False
            break
    print("Yes" if b else "No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
    int N = inputValue();

    bool ok = false;
    FOR(i, 1, 10){
        FOR(j, 1, 10){
            int val = i * j;
            if(N == val){
                ok = true;
                break;
            }
        }
        if(ok){
            break;
        }
    }    
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  static int n,x;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      int n= sc.nextInt();
      int x = sc.nextInt();
      int total = 0;
      int ans = 0;
      if (n == 0 && x == 0) {
        break;
        }
      for (int i =1; i<=n; i++) {
        for (int j =i+1; j> i && j<= n; j++) {
          for (int k = j+1; k>j && k<=n; k++) {
            if (i + j + k == x) {
            total ++;
            }
          }
        }
      }
          System.out.println(total);
    }
  }
}


Measured memory_bytes: 26692
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, l;
int a[200005];
LL ps[200005];

LL getsum(int l, int r)
{
	return ps[r + 1] - ps[l];
}

int main()
{
	scanf("%d%d", &l, &n);
	rep(i, n) scanf("%d", &a[i]);
	if(n == 1) {
		printf("%d\n", max(l - a[0], a[0]));
		return 0;
	}
	rep(i, n) ps[i + 1] = ps[i] + a[i];
	
	LL ans = 0;
	for(int i = 1; i < n; i ++) {
		int len = min(i, n - i); 
		ans = max(ans, 2 * (getsum(i - len, i - 1) + 1LL * l * len - getsum(i, i + len - 1)) - min(a[i - 1], l - a[i]));
		len = min(i - 1, n - i);
		ans = max(ans, 2 * (getsum(i - len - 1, i - 1) + 1LL * l * len - getsum(i, i + len - 1)) - a[i - 1]);
		len = min(i, n - i - 1);
		ans = max(ans, 2 * (getsum(i - len, i - 1) + 1LL * l * (len + 1) - getsum(i, i + len)) - l + a[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

signed main() {
  int N, K; cin >> N >> K;
  vector<int> p(N); cin >> p;
  sort(p.begin(),p.end());
  int sum = 0;
  for (int i = 0; i < K; ++i) sum += p[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int top;
int S[1000];
// stack!!

 void init(){
   top = 0;
 }
 void push(int x){
   top++;
   S[top]=x;
 }
int pop(){
  top--;
  return S[top+1];
}


 int main(){
 char s[100];
 int a,b;
 while(scanf("%s",s)!=EOF){
   if(s[0]=='+'){
     a=pop();
     b=pop();
     push(a+b);
   }
   else if(s[0]=='-'){
     a=pop();
     b=pop();
     push(b-a);
   }
   else if(s[0]=='*'){
     a=pop();
     b=pop();
     push(a*b);
   }else{
     push(atoi(s));
   }
 }

 printf("%d\n",pop() );
 return 0;
 }



Measured memory_bytes: 2092
#include <stdio.h>

int main(void)
{
  char A[2][3];
  int i,j;
  int flag=0;
  
  scanf("%s",A[0]);
  scanf("%s",A[1]);

  for(i=0;i<3;i++){
    if(A[0][i]==A[1][2-i]){
      flag++;
    }	 
  }

  if(flag==3)
    printf("YES\n");
  else
    printf("NO\n");

  return 0;
}
    


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long long a;
  cin >> a;
  long long ans = 0;
  long double val = 100;
  while(true){
    if(a <= val){
      break;
    }
    val =floor(val*1.01); 
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl h,w;
    cin >> h >> w;
    char c[h][w];
    ccin(i,j,c);
    bool f1[h];
    bool f2[w];
    rep(i,h){
        bool f = true;
        char a = '.';
        rep(j,w){
            if(a != c[i][j])f = false;
        }
        f1[i] = f;
    }
    rep(i,w){
        bool f = true;
        char a = '.';
        rep(j,h){
            if(a != c[j][i])f = false;
        }
        f2[i] = f;
    }
    rep(i,h){
        if(f1[i])continue;
        rep(j,w){
            if(f2[j])continue;
            cout << c[i][j];
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 256