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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[101010],B[101010];
ll SA,SB;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		SA+=A[i];
	}
	FOR(i,N) {
		cin>>B[i];
		SB+=B[i];
	}
	if(SA>SB) return _P("No\n");
	ll R=SB-SA;
	
	ll RA=R,RB=R;
	FOR(i,N) {
		if(A[i]<B[i]) {
			ll a=(B[i]-A[i]+1)/2;
			A[i]+=a*2;
			RA-=a;
		}
		if(A[i]>B[i]) {
			RB-=A[i]-B[i];
			B[i]=A[i];
		}
	}
	
	
	if(RA<0 || RB<0) return _P("No\n");
	_P("Yes\n");
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    int M = 0, ans = 0;
    REP(i, N){
        if(M >= A[i]){
            ans += M - A[i];
        }else{
            M = A[i];
        }
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 2010;
const ll bits = 30;
const ll mod = 998244353;



int main(){
    FASTIO;
    ll n;
    cin>>n;

    vector<ll>dp(n+1,inf),arr(n+1,0);

    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    dp[1] = 0;

    for(int i=1;i<=n;i++){
        if(i+1<=n){
            dp[i+1] = min(dp[i]+abs(arr[i]-arr[i+1]),dp[i+1]);
        }

        if(i+2<=n){
            dp[i+2] = min(dp[i]+abs(arr[i]-arr[i+2]),dp[i+2]);
        }
    }

    cout<<dp[n]<<"\n";




    
}

Measured memory_bytes: 1792
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

int times(double k, double start) {
  int cnt = 0;
  while(k > start) {
    cnt++;
    start *= 2;
  }
  return cnt;
}

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

  double n,k;
  cin >> n >> k;
  double ans = 0;
  REP(i, n) {
    ans += pow(0.5, times(k, i+1)) / n;
  }
  printf("%.16f", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  cin >>A>>B;
  bool answer=true;
  if(A%2==0) {
answer=false;
  }
if (B%2==0) {
answer=false;
}
if(answer) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}
  

Measured memory_bytes: 256
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    P = [II() for _ in range(n)]

    # dp[i]: 末尾がiになる正しい順序に並んでいる部分列の長さ
    dp = [0] * (n + 1)
    for p in P:
        dp[p] += dp[p - 1] + 1

    return n - max(dp)


print(main())


Measured memory_bytes: 18860
import math
n = int(input())
a = list(map(int, input().rstrip().split()))
s = sum(a)
t1 = 0
t2 = 0
mean1 = s // n
mean2 = mean1 + 1
for x in a:
    t1 += math.pow(abs(x - mean1), 2)
    t2 += math.pow(abs(x - mean2), 2)
print(int(min(t1, t2)))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void){
    int x=0;
    int a=0;
    int b=0;

    cin >> x >> a >> b;

    if(abs(x-a)>=abs(x-b))cout << "B" << endl;
    else cout << "A" << endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    long long sum[n] = {};
    for(int i=0; i<n; i++){
        long long t;
        cin >> t;
        if(i==0){
            sum[i] = t;
        }else{
            sum[i] = sum[i-1] + t;
        }
    }
    long long ans = 1e12;
    for(int i=0; i<n-1; i++){
        ans = min(ans, abs(sum[n-1] - sum[i]*2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
  ll a,b,c,d,i,k=0;
cin>>s>>t;
    if(s[1]==t[1])k++;
    if(s[2]==t[2])k++;
    if(s[0]==t[0])k++;
cout<<k<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int k, x; cin >> k >> x;
  int mn = max(x - k + 1, -1000000), mx = min(x + k - 1, 1000000);
  FOR(i, mn, mx + 1) cout << i << (i == mx ? '\n' : ' ');
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  char str[1001] = {};
  /* char a[] = {"apple"};
  char a_[] = {"apple."};
  char p[] = {"peach"};
   char p_[] = {"peach."};
  */  int i = 0;
  
  /*   while(scanf("%s", str[i]) != EOF){
       if(strcmp(str[i],a) == 0)
       strcpy(str[i],a);
    
       if(strcmp(str[i],p) == 0)
       strcpy(str[i],p);

       if(strcmp(str[i-1],a_) == 0)
       strcpy(str[i-1], a_);
  
       if(strcmp(str[i],p_) == 0)
       strcpy(str[i], p_);

       i++;
       }
       printf("%s",str);

       return 0;

       }*/


  gets(str);
  while(str[i]){
    if(str[i] == 'a')
      if(str[i+1] == 'p')
	if(str[i+2] == 'p')
	  if(str[i+3] == 'l')
	    if(str[i+4] == 'e'){
	      str[i++] = 'p';
	      str[i++] = 'e';
	      str[i++] = 'a';
	      str[i++] = 'c';
	      str[i] = 'h';
	    }
    
    if(str[i] == 'p')
      if(str[i+1] == 'e')
	if(str[i+2] == 'a')
	  if(str[i+3] == 'c')
	    if(str[i+4] == 'h'){
	      str[i++] = 'a';
	      str[i++] = 'p';
	      str[i++] = 'p';
	      str[i++] = 'l';
	      str[i] = 'e';
	    }
    i++;
  }

  printf("%s\n", str);

  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


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

	vector<int> a(n);
	int sum = 0,minus=0;
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
		sum += a.at(i);
		minus += a.at(i) * a.at(i);
	}
	cout << (sum * sum - minus) / 2 << endl;
}


Measured memory_bytes: 256
import copy

n = int(input())
x = list(map(int, input().split()))
num = 0

y = copy.copy(x)
x.sort()
num1 = x[n//2-1]
num2 = x[n//2]

for i in y:
  if i <= num1:
    print(num2)
  else:
    print(num1)

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(a>0 && c>0){
    c -= b;
    if(c<=0){
        printf("Yes");
        return 0;
    }
    a -= d;
    if(a<=0){
        printf("No");
        return 0;
    }
  }
  
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  bool judge = true;
  ll sum = 0;
  while(N >= 10) {
    if (N % 10 != 9) {
      judge = false;
    }
    sum += 9;
    N /= 10;
  }

  sum += judge ? N : N - 1;

  std::cout << sum << std::endl;

  return 0;
}


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

using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;
	while (H!=0&&W!=0)
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cout << "#" ;
			}
			cout << "" << endl;
			
		}
		cout << "" << endl;
		cin >> H >> W;
	}
	return 0;
}










Measured memory_bytes: 3064
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

newtype MyGraph = MyGraph (A.Array Int [Int])

listToGraph :: Int -> [(Int, Int)] -> MyGraph
listToGraph n paths = MyGraph $ STA.runSTArray $ do
    a <- MA.newArray (1, n) []
    forM_ paths $ \(from, to) -> do
        f <- MA.readArray a from
        MA.writeArray a from $ to : f
        t <- MA.readArray a to
        MA.writeArray a to $ from : t
    pure a

getPaths :: Int -> MyGraph -> [Int]
getPaths i (MyGraph lst) = lst A.! i

solve :: Int -> [Int] -> [(Int, Int)] -> Int
solve n heights paths = let 
    hs :: UA.UArray Int Int 
    hs = A.listArray (1, n) heights
    grp = listToGraph n paths
    isGood i = case getPaths i grp of
        [] -> True
        paths -> let
            mine = hs A.! i
            in
            all ((mine>) . (hs A.!)) paths
    in 
    length $ filter isGood [1..n]


main :: IO ()
main = do
    (n, m) <- readTuple2
    heights <- readInts
    paths <- replicateM m readTuple2
    print $ solve n heights paths





Measured memory_bytes: 46652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  int ans = 1e9;
  rep(i, s.size() - t.size() + 1){
    int cnt = 0;
    if(i+t.size() > s.size()) break;
    string sub = s.substr(i, t.size());
    rep(j, t.size()){
      if(sub[j] != t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

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

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

void solve()
{
    li n;
    cin>>n;

    bool ok = false;
    while(n!=0)
    {
      if(n%10==7)
        ok = true;
      n/=10;
    }  
    if(ok)
    {
      cout<<"Yes\n";
    }
    else
      cout<<"No\n";
}
int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    solve();
    
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

void input_vector(int &x);
void show(int x);

//#define DEBUG
using namespace std;

int main(){
    int N;
    string S;
    int K;
    cin >> N;
    cin >> S;
    cin >> K;
    char a = S.at(K-1);
    for(int i = 0; i < S.length(); i++){
        if( S.at(i) != a){
            S.at(i) = '*';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
while True:
	m, f, r = map(int, input().split())
	if m == -1 and f == -1 and r == -1:
		break
	if m == -1 and f != -1:
		print("F")
		continue
	if m != -1 and f == -1:
		print("F")
		continue
	result = m + f
	if result >= 80:
		print("A")
	elif result >= 65 and result < 80:
		print("B")
	elif result >= 50 and result < 65:
		print("C")
	elif result >= 30 and result < 50:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")


Measured memory_bytes: 5592
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (N%i)continue;
		int box = N / i;
		for (int j = i; j < N; j++) {
			if (v[j] != v[j - i])box = 0;
		}
		ans = max(ans, box);
	}
	cout << ans << endl;
}


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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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


int main() {
    int K;
    cin >> K;
    int ans = 0;
    FOR (i, 1, K+1) {
        FOR (j, 1, K+1) {
            FOR (k, 1, K+1) {
                ans += gcd(i, gcd(j, k));
            }
        }
    }

    cout << ans << endl;
    //REP(i, K+1) {
    //    cout << "n : " << i << endl;
    //    REP(j, K+1) {
    //        cout << "divisor : " << divisor[i][j] << endl;
    //    }
    //}
}


Measured memory_bytes: 3600
import java.util.Scanner;

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

            for (int i = 0; i < 3; i++) {
                if (line1.charAt(i) != line2.charAt(2 - i)) {
                    System.out.println("NO");
                    return;
                }
            }
            System.out.println("YES");
        }
    }
}


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

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

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

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

int main() {
  string s;
  ll ans = 1, c;
  int mm[200000] = {};
  map<char, int> m;
  cin >> s;
  dep(i, s.length() - 1, 0) {
    m[s[i]]++;
    mm[i] = m[s[i]];
  }

  dep(i, s.length() - 1, 0) {
    ans += s.length() - i - mm[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String row1 = sc.next();
		String row2 = sc.next();
		StringBuffer sb = new StringBuffer(row2);
		row2 = sb.reverse().toString();
		if(row1.equals(row2)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		sc.close();
	}

}


Measured memory_bytes: 21716
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
    int a[100005],x,y,i,t;
    long long sum,z;
    cin >> t;
    cin >>a[0];
    sum=abs(a[0]);
    for(i=1;i<t;i++)
    {
        cin >> a[i];
        sum=sum+abs(a[i]-a[i-1]);
    }
    sum=sum+abs(a[t-1]);
    for(i=0;i<t;i++)
    {
        if(i==0)
        {
            z=sum+abs(a[1])-abs(a[0])-abs(a[1]-a[0]);
        }
        else if(i==t-1)
        {
            z=sum+abs(a[t-2])-abs(a[t-1])-abs(a[t-1]-a[t-2]);
        }
        else
        {
            z=sum-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]);
        }
        cout << z <<endl;


    }
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<LL> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  reverse(a.begin(), a.end());
  
  vector<LL> dp(n, 1e9);
  dp[0] = a[0];
  LL length = 1;
  for (int i = 1; i < n; i ++) {
    if (dp[length - 1] <= a[i]) dp[length ++] = a[i];
    else *upper_bound(dp.begin(), dp.begin() + length, a[i]) = a[i];
  }

  cout << length << endl;
}

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

int main(){
  int ticket[] = { 6000, 4000, 3000, 2000};
 
  for(int i = 0; i < 4; i++){
    int t, n;
    cin >> t >> n;
    cout << ticket[t - 1] * n << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

int main() {

  int n, m, l;
  int i,j,k;
  long long a[100][100],b[100][100],p;
  
  scanf("%d %d %d", &n, &m, &l);
  for(i = 0; i < n; i++) {
    for(j = 0; j < m; j++) {
      scanf("%lld", &a[i][j]);
    }
  }
  
  for(i = 0; i < m; i++) {
    for(j = 0; j < l; j++) {
      scanf("%lld",&b[i][j]);
    }
  }
  
  for(i = 0; i < n; i++) {
    for(j = 0; j < l; j++) {
    p = 0;
      for(k = 0; k < m; k++) {
	p +=  a[i][k] * b[k][j];
      }
      if(j < l - 1) {
	printf("%lld ", p);
      } else {
	printf("%lld", p);
      }
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 756
// atcoder/diverta2019-2/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<pair<int, int>> v(n);
    cin >> v;

    vector<pair<int, int>> c;
    each (i, v) {
      each (j, v) {
        if (i != j) {
          int p = i.first - j.first;
          int q = i.second - j.second;
          c.push_back({p, q});
        }
      }
    }

    sort(v.begin(), v.end());
    int mn = n;
    each (i, c) {
      set<pair<int, int>> vis;
      int cnt = 0;
      each (j, v) {
        unless (vis.count(j)) {
          ++cnt;
          for (int k = 0; ; ++k) {
            pair<int, int> x = j;
            x.first += k * i.first;
            x.second += k * i.second;
            unless (binary_search(v.begin(), v.end(), x)) break;
            if (vis.count(x)) break;
            vis.insert(x);
          }
        }
      }
      setmin(mn, cnt);
    }

    cout << mn << endl;
  }

  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,sum=0,ans=0;
    cin >> n;
    vector<int> s(n);
    for(int i = 0;i < n;i ++){
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(),s.end());
    for(int i = 0;i < n;i ++){
        if(sum%10!=0) {ans=sum;break;}
        if((sum-s[i])%10!=0) {ans = sum-s[i];break;}
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1e17;

int main() {
  int N, M, L;
  cin >> N >> M >> L;

  vector<vector<ll> > vec1(N, vector<ll>(N, INF));

  for(int i=0;i<M;i++) {
    int node1;
    int node2;
    int length;

    cin >> node1 >> node2 >> length;

    vec1[node1-1][node2-1] = length;
    vec1[node2-1][node1-1] = length;
  }

  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(i == j) {
        vec1[i][j] = 0;
      }
    }
  }

  for(int k=0;k<N;k++) {
    for(int i=0;i<N;i++) {
      for(int j=0;j<N;j++) {
        if (vec1[i][j] > vec1[i][k] + vec1[k][j]) {
          vec1[i][j] = vec1[i][k] + vec1[k][j];
        }
      }
    }
  }

  vector<vector<ll> > vec2(N, vector<ll>(N, INF));

  for(int i=0;i<N;i++) {
    for(int j=0;j<N;j++) {
      if(i == j) continue;
      if(vec1[i][j] <= L) {
        vec2[i][j] = 1LL;
      }
    }
  }

  for(int k=0;k<N;k++) {
    for(int i=0;i<N;i++) {
      for(int j=0;j<N;j++) {
        if (vec2[i][j] > vec2[i][k] + vec2[k][j]) {
          vec2[i][j] = vec2[i][k] + vec2[k][j];
        }
      }
    }
  }

  int Q;
  cin >> Q;

  for(int k=0;k<Q;k++) {
    int i, j;
    cin >> i >> j;

    if(vec2[i-1][j-1] < INF) {
      cout << vec2[i-1][j-1] - 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1920
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
string s;






//サブ関数
//入力
void input()
{
	cin >> s;
}


//計算
void calc()
{
	int p = s.size() / 2;
	for (auto c : s)if (c == 'p')p--;
	cout << p << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 512
use std::io;

fn main() {
    let ab: Vec<u8> = read_input_vec();
    println!("{}", (ab[0] + ab[1]) % 24);
}

fn read_input<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    return input.parse::<T>().ok().unwrap();
}

fn read_input_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    return input
        .split_whitespace()
        .map(|x| x.parse::<T>().ok().unwrap())
        .collect();
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

signed main()
{
    int N, M, Q; cin >> N >> M >> Q;

    vi nxt(N), prv(N);

    vector<bool> answer(N);

    rep(i, N) {
        nxt[i] = i + 1 >= N ? 0 : i + 1;
        prv[i] = i - 1 < 0 ? N - 1 : i - 1;
    }

    int now_pos = 0;

    rep(i, M) {
        int a; cin >> a;
        if (a % 2 == 0) {
            rep(_, a) {
                now_pos = nxt[now_pos];
            }
            
            prv[nxt[now_pos]] = prv[now_pos];
            nxt[prv[now_pos]] = nxt[now_pos];

            answer[now_pos] = true;

            now_pos = nxt[now_pos];
        } else {
            rep(_, a) {
                now_pos = prv[now_pos];
            }

            prv[nxt[now_pos]] = prv[now_pos];
            nxt[prv[now_pos]] = nxt[now_pos];

            answer[now_pos] = true;

            now_pos = nxt[now_pos];
        }
    }

    rep(i, Q) {
        int q; cin >> q;
        cout << !answer[q] << endl;
    }
}

Measured memory_bytes: 2784
#include<stdio.h>
int main(void){
    char s1[10],s2[10],s3[10],t='A'-'a';
    scanf("%s %s %s",s1,s2,s3);
    printf("%c%c%c\n",s1[0]+t,s2[0]+t,s3[0]+t);
    return 0;
}

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

#define pb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define vi vector
#define forn(i, l, r) for(int i = l; i <= r; i++)
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define f80 double
#define LOCAL 0
#define endl '\n'

typedef long long int ll;
#define int long long int

const int mod = 1e9 + 7;
const int N = 100005;
const int inf = 2e9;

signed main(){
    //IO;
    if(LOCAL){
        freopen("inp.txt", "r", stdin);
    }
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int p = 0; p < n; p++){
        bool yes = 1;
        int pp = p;
        for(int i = 0; i < n; i++){
            if(s[pp] != t[i])
                yes = 0;
            pp = (pp + 1) % n;
        }
        if(yes)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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


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

#define MAXX 100005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 

#define mod  1000000007



int main()
{
	FAST;
	int n;
	cin >> n;
	n %= 10;
	if(n == 2 || n == 4 || n == 7 || n == 9 || n == 5){
		 cout<< "hon"; return 0;
	}
	if(n == 3 ){
		cout << "bon"; return 0;
	}
	cout << "pon";
	return 0;
	
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int d[10]={0};
	for(int i=0;i<k;i++)
	{
		int a;
		cin>>a;
		d[a]=1;
	}
	int t=n;
	while(true)
	{
		int temp=t,flag=0;
		while(temp!=0)
		{
			int di=temp%10;
			for(int i=0;i<10;i++)
			{
				if(d[di]==1)
				{
					flag=1;
					break;
				}
			}
			if(flag==1)
			{
				break;
			}
			temp=temp/10;
		}
		if(flag==0)
		{
			break;
		}
		t++;
	}
	cout<<t;
}

Measured memory_bytes: 3592
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(n) read(m)
    ll ans = 0;
    readarr(h,n);
    ve(ve(ll)) g;
    g.resize(n);
    f(i,0,m)
    {
        read(x) read(y) x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    f(i,0,n)
    {
        bool hmm = 1;
        foto(x,g[i])
        {
            hmm &= (h[i]>h[x]) ;
        }
        if(hmm) ans ++;
    }
    cout<<ans;
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 9824
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;
ll level;
struct edge {
	ll to;
};

vector<edge>G[100010];
ll d[100010];

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b) {
	if (a.second == b.second)return a.first < b.first;
	else return a.second > b.second;
}

void dfs(int root,vector<ll> &c) {
	d[root] = c[level];
	level--;
	for (auto itr = G[root].begin();itr != G[root].end();++itr) {
		//cout << itr->to << endl;
		if (d[itr->to] == 0)dfs(itr->to, c);
	}
	return;
}

int main(void) {
	ll n, m;
	cin >> n >> m;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll dp[100010] = { 0 };
	dp[0] = 0;
	dp[1] = 1;
	dp[2] = 2;
	for (ll i = 3;i <= n;i++)dp[i] = (dp[i - 1] % N + dp[i - 2] % N) % N;
	if (m == 0) {
		cout << dp[n] << endl;
		return 0;
	}
	vector<ll>w(m);
	ll ans = 0;
	for (ll i = 0;i < m;i++)cin >> w[i];
	if (w[0] == 1)ans = 1;
	else ans = (dp[w[0] - 1]) % N;
	for (ll i = 1;i < m;i++) {
		if (w[i] - w[i - 1] - 1 <= 0)ans = ans * 0;
		else {
			if (w[i] - w[i - 1] - 1 == 1)ans = ans * 1;
			else {
				ans = (ans*(dp[w[i] - w[i - 1] - 2]) % N) % N;
			}
		}
	}
	if (n - w[m - 1]>1)ans = (ans*(dp[n - w[m - 1]-1]) % N) % N;
	cout << ans << endl;
	return 0;
}

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

int main() {
	int N;
	string S;
	bool chk=true;
	cin>>N>>S;
	
	if(N%2==1)	cout<<"No";
	else{
		for(int i=0; i< (N/2) ; ++i){
			if(S[i]==S[(N/2)+i])	continue;
			else{
				chk=false;
				break;
			}
		}
		if(chk==true)	cout<<"Yes";
		else{
			cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s, t;
    cin >> s >> t;
    int mn = 2e5;
    for(int i = 0; i + t.size() <= s.size(); i++){
        int c = 0;
        for(int j = 0; j < t.size(); j++){
            if(s[i + j] != t[j]) c++;
        }
        mn = min(mn, c);
    }
    cout << mn;

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100009;
int n,x,w[N],le[N],ho[N];
ll ans;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>x;
		w[x]=i;
	}
	for (int i=1;i<=n;i++)
		le[i]=i-1,ho[i]=i+1;
	for (int i=1;i<=n;i++)
	{
		int x=le[w[i]],y=le[x];
		int z=ho[w[i]],p=ho[z];
		if (x!=0)
			ans+=1ll*(x-y)*(z-w[i])*i;
		if (z!=n+1)
			ans+=1ll*(w[i]-x)*(p-z)*i;
		ho[x]=z;
		le[z]=x;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	int ans = A*B / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    long double a,b;
    cin>>a>>b;
    a=a*b;
    ll ans=floor(a);
    cout<<ans;
    return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];
			List<int>[] to = new List<int>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<int>();
			}
			for (int i = 0; i < m; i++) {
				int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				to[ab[0] - 1].Add(ab[1] - 1);
				to[ab[1] - 1].Add(ab[0] - 1);
			}

			int cross6 = 0;
			List<int> cross = new List<int>();
			for (int i = 0; i < n; i++) {
				if (to[i].Count % 2 == 1) {
					Console.WriteLine("No");
					return;
				}

				if (to[i].Count != 2) {
					cross.Add(i);
					if (to[i].Count >= 6) {
						++cross6;
					}
				}
			}

			if (cross.Count >= 2 || cross6 > 0) {
				if (cross.Count == 2 && cross6 == 0) {
					int same = 0;
					int a = cross[0];
					int b = cross[1];
					foreach (int v in to[a]) {
						int last = a;
						int w = v;
						while (w != a && w != b) {
							if (to[w][0] != last) {
								last = w;
								w = to[w][0];
							} else {
								last = w;
								w = to[w][1];
							}
						}

						if (w == b) {
							same++;
						}
					}

					if (same > 2) {
						Console.WriteLine("No");
					} else {
						Console.WriteLine("Yes");
					}
				} else {
					Console.WriteLine("Yes");
				}
			} else {
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
	using namespace std;
	#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds; 
	#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
	
	#define all(a)      (a).begin(),(a).end()
	#define sz(x)       (int)x.size()
	
	#define ff first
	#define ss second
	#define mp make_pair
		 
	#define pb push_back
	#define endl "\n"
		 
	#define int long long 
	#define double long double
		 
	#define bp __builtin_popcountll
	#define inf 1e16
	
	const int N=1e5+5;
	const int M=1e6+6;
	const int MOD=1e9+7;
	bool is(string s)
	{
		int n=s.size();
		for(int i=0;i<n/2;i++)
		{
			if(s[i]!=s[n-i-1])
			return false;
		}
		return true;
	}
	void solve()
	{	
		string s;
		cin>>s;
		int n=s.size();
		string h=s.substr(0,n/2);
		string g=s.substr(n/2+1,n/2);
		if(is(s) && is(h) && is(g))
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}

	signed main()  
	{
		FAST
		int t=1;
		//cin>>t;
		while(t--)
		{
			solve();
		}
	}
		


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll H1,M1,H2,M2,K; cin>>H1>>M1>>H2>>M2>>K;
  ll n=H1*60+M1;
  ll m=H2*60+M2;
  ll ans=max(0LL,m-n-K);
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int N;
int main(){
 cin>>N;
  vector<int64_t>a(N);bool t=false;
  for(int i=0;i<N;i++){
  int64_t x;cin>>x;
    if(0<=x)t=true;
    a[i]=x;
  }if(!t){
  int64_t ans=-100000000000;int64_t I=0;
    for(int i=0;i<N;i++)
      if(ans<a[i]){ans=a[i];I=i;}
    cout<<ans<<endl;
    cout<<N-1<<endl;
    for(int i=N;I+1<i;i--)
      cout<<i<<endl;
    for(int i=0;i<I;i++)
      cout<<1<<endl;
  
  }else{
  int64_t Even=0;int64_t Odd=0;
    for(int i=0;i<N;i++){
      if(i%2==0 && 0<=a[i])
      Even+=a[i];
      if(i%2==1 && 0<=a[i])
        Odd+=a[i];
     }
    if(Even<=Odd){
      cout<<Odd<<endl;
    vector<int64_t>c;
      int Size=N;
      for(int i=N-1;0<=i;i--)
        if(i%2==1 && a[i]<=0){if(i==0 || i==N-1)Size--;else Size-=2;c.push_back(i);}
      int M=c.size();
      cout<<M+(Size+1)/2<<endl;
      for(int i=0;i<M;i++)
        cout<<c.at(i)+1<<endl;
      for(int i=Size;1<=i;i--)
        if(i%2==1)
          cout<<i<<endl;
      
    }else{
    cout<<Even<<endl;
      vector<int64_t>c;
       int Size=N;bool y=true;
      for(int i=N-1;0<=i;i--)
        if(i%2==0 && a[i]<=0){if(i==0)y=false;if(i==0 || i==N-1)Size--;else Size-=2;c.push_back(i);}
      int M=c.size();
      if(y){
      cout<<M+Size/2<<endl;
        for(int i=0;i<M;i++)
        cout<<c.at(i)+1<<endl;
        for(int i=Size;1<=i;i--)
          if(i%2==0)
            cout<<i<<endl;
      }else{
      cout<<M+(Size+1)/2<<endl;
        for(int i=0;i<M;i++)
        cout<<c.at(i)+1<<endl;
        for(int i=Size;1<=i;i--)
          if(i%2==1)
            cout<<i<<endl;
      
      }
      
    
    }
    
  
           }
  return 0;
}

Measured memory_bytes: 3552
import sys
sys.setrecursionlimit(100000)
h,w = map(int,input().split())
lst = []
for i in range(h):
  lst.append([s for s in input()])
def dfs(x,y):
  if lst[x][y] == '#':
    lst[x][y] = '.'
    if x + 1 <= h - 1:
      dfs(x + 1,y)
    if x - 1 >= 0:
      dfs(x - 1,y)
    if y + 1 <= w - 1:
      dfs(x, y + 1)
    if y - 1 >= 0:
      dfs(x,y - 1)
flag = True
for i in range(h):
  for j in range(w):
    if lst[i][j] == '#':
      if (i - 1 >= 0 and lst[i - 1][j] == "#") or (i + 1 < h and lst[i + 1][j] == "#") or (j - 1 >= 0 and lst[i][j - 1] == "#") or (j + 1 < w and lst[i][j + 1] == "#"):
        dfs(i,j)
      else:
        flag = False
        break
if flag:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 4724
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 2000001;
int ans = 0 ;
int n,m,q;
vector<int> v;
int a[50],b[50],c[50],d[50];
void dfs(int len,int last){
  if(len == n+1){
    int sum = 0;
    for(int i = 0;i<q;i++){
      if(v[b[i]]-v[a[i]] == c[i]){
        sum+=d[i];
      }
    }
    ans = max(sum,ans);
    return ;
  }
  for(int i = last;i<=m;i++){
    v.push_back(i);
    dfs(len+1,i);
    v.pop_back();
  }
}
int32_t main()
{

   IOS
   
   cin>>n>>m>>q;
   for(int  i = 0;i<q;i++){
     cin>>a[i]>>b[i]>>c[i]>>d[i];
     a[i]--;
     b[i]--;
   }
   dfs(1,1);
   cout<<ans<<endl;
  
} 


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

int N;
vector<int> H;
vector<int> Y;

void input_init(void) {
	cin >> N;
	H.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> H[i];
	Y = H;
	Y.push_back(0);
	sort(Y.begin(), Y.end());
	Y.erase(unique(Y.begin(), Y.end()), Y.end());
}

int solve(void) {
	int total = 0;
	for (int j = (int)Y.size() - 2; j >= 0; --j) {
		int cnt = 0;
		int pre = -1;
		for (int i = 0; i < N; ++i) {
			if (H[i] > Y[j]) {
				if (pre <= Y[j])
					++cnt;
			}
			pre = H[i];
		}
		total += (Y[j + 1] - Y[j]) * cnt;
	}
	return total;
}

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

	input_init();
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import math
import copy
def main():
    x,k,d=map(int, input().split())
    res = float('inf')
    x = abs(x)

    if(k*d <= x):
        print(x-k*d)
    else:
        if(k%2 == x//d%2):
            print(x%d)
        else:
            print(d-x%d)




if __name__ == '__main__':
    main()


Measured memory_bytes: 9544