akhauriyash/Code-Regression huggingface dataset:
def is_kaibun(word):
    for i in range(len(word)):
        if 2*i < len(word):
            if word[i] == word[len(word)-i-1]:
                continue
            else:
                return False
                break
        elif 2*i == len(word):
            return True
            break
    else:
        return True
    
s = []
while True:
    try:
        s.append(raw_input())
    except EOFError:
        break

tot = 0
for word in s: 
    if is_kaibun(word):
        tot += 1
print tot

Measured memory_bytes: 4220
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll D, T, S; cin >> D >> T >> S;
	if (D > T* S)cout << "No" << endl;
	else cout << "Yes" << endl;




}


Measured memory_bytes: 3632
from string import ascii_lowercase
S = input()
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()
if len(S) < 26:
    for a in ascii_lowercase:
        if a not in S:
            print(S + a)
            exit()
can = []
for i in range(25, 0, -1):
    can.append(S[i])
    if S[i - 1] < S[i]:
        for c in sorted(can):
            if S[i - 1] < c:
                print(S[:i - 1] + c)
                exit()


Measured memory_bytes: 9928
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  string s;
  while (cin >> s) {
    int n = s.size();
    ll res = 0;
    for (int bit : range(1 << (n-1))) {
      string t;
      for (int i : range(n)) {
        t += s[i];
        if (i < n - 1 && (bit & (1 << i))) {
          t += " ";
        }
      }
      stringstream ss;
      ss << t;
      ll x;
      while (ss >> x) {
        res += x;
      }
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if(b1 > a1) {
        swap(a1, b1);
        swap(a2, b2);
    }
    ll f = (a1 - b1) * t1;
    ll s = f + (a2 - b2) * t2;
    if(s == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    s = -s;
    if(s < 0) {
        cout << 0 << endl;
    } else {
        cout << (f / s) + (f + s - 1) / s << endl;
    }
}

Measured memory_bytes: 384
n = int(input())
b = list(map(int, input().split()))

ans = 0
for i in range(n - 2):
    if b[i] <= b[i + 1]:
        ans += b[i]
    else:
        ans += b[i + 1]

ans += b[0]
ans += b[n - 2]
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char tmp = s.charAt(0);
        boolean isGood = true;
        for (int i = 1; i < s.length(); i++) {
            if (tmp == s.charAt(i)) {
                isGood = false;
            }
            tmp = s.charAt(i);
        }
        System.out.println(isGood ? "Good" : "Bad");
    }
}

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

#define N 1000009
int su[N],cnt;
int n,arr[N];
bool isprime[N];
void prime(){
    cnt=1;
    memset(isprime,1,sizeof(isprime));//初始化认为所有数都为素数
    isprime[0]=isprime[1]=0;//0和1不是素数
    for(int i=2;i<=N;i++){
        if(isprime[i])
            su[cnt++]=i;//保存素数i
        for(int  j=1;j<cnt&&su[j]*i<N;j++){
            isprime[su[j]*i]=0;//筛掉小于等于i的素数和i的积构成的合数
        }
    }
}
map<int,int> mp;
signed main(){
	prime();
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
	int tmp=arr[1];
	for(int i=1;i<=n;i++) tmp=__gcd(tmp,arr[i]);
	int F=1;//是否互质 
	for(int i=1;i<=n;i++){
		if(isprime[arr[i]]){
			if(mp[arr[i]]){
				F=0;
				break;
			}
			mp[arr[i]]=1;
		}else{
			int temp=arr[i];
			for(int j=1;j<cnt;j++){	
				if(temp%su[j]==0){
					if(mp[su[j]]){
						F=0;
						break;
					}mp[su[j]]=1;
					
				}
				if(su[j]>temp) break;
			}
			
		}
		if(!F) break;
	}
	if(F) cout<<"pairwise coprime";
	else if(tmp==1) cout<<"setwise coprime";
	else cout<<"not coprime";
	return 0;
}


Measured memory_bytes: 9004
<?php
$n = intval(fgets(STDIN));
$aArray = array_map("intval", explode(" ", fgets(STDIN)));

$mode = 0;
$count = 1;
for($i = 0; $i < $n - 1; $i++){
  $d = $aArray[$i+1]-$aArray[$i];
  if($mode == 0){
    if($d > 0){
      $mode = 1;
    }elseif($d < 0){
      $mode = -1;
    }
  }elseif($mode == 1){
    if($d < 0){
      $mode = 0;
      $count++;
    }
  }elseif($mode == -1){
    if($d > 0){
      $mode = 0;
      $count++;
    }
  }
}
echo $count;



Measured memory_bytes: 16884
MOD = 10**9 + 7

L, R = [int(item) for item in input().split()]
L_blen = L.bit_length()
R_blen = R.bit_length()

# dp[y loose/tight][x loose/tight][index]
dp = [[[0] * (R_blen+1) for _ in range(2)] for _ in range(2)]

for i in range(R_blen + 1):
    L_bit = L & (1 << R_blen - i)
    R_bit = R & (1 << R_blen - i)

    # Form R's MSB to L's LSB can be the initial bit  
    curbit_idx = R_blen - i + 1
    if curbit_idx <= R_blen and curbit_idx >= L_blen:
        dp[R_blen == curbit_idx][L_blen == curbit_idx][i] += 1

    # R=0, L=0
    if not R_bit and not L_bit:
        # y=1, x=1
        dp[0][0][i] += dp[0][0][i-1] 
        dp[0][0][i] += dp[0][1][i-1] 
        # y=0, x=0
        dp[1][1][i] += dp[1][1][i-1] 
        dp[1][0][i] += dp[1][0][i-1] 
        dp[0][0][i] += dp[0][0][i-1] 
        dp[0][1][i] += dp[0][1][i-1] 
        # y=1, x=0
        dp[0][1][i] += dp[0][1][i-1] 
        dp[0][0][i] += dp[0][0][i-1] 

    # R=1, L=0
    if R_bit and not L_bit:
        # y=1, x=1
        dp[0][0][i] += dp[0][0][i-1] 
        dp[1][0][i] += dp[1][0][i-1] 
        dp[0][0][i] += dp[0][1][i-1] 
        dp[1][0][i] += dp[1][1][i-1] 
        # y=0, x=0
        dp[0][0][i] += dp[0][0][i-1] 
        dp[0][0][i] += dp[1][0][i-1] 
        dp[0][1][i] += dp[0][1][i-1] 
        dp[0][1][i] += dp[1][1][i-1] 
        # y=1, x=0
        dp[0][0][i] += dp[0][0][i-1] 
        dp[1][0][i] += dp[1][0][i-1] 
        dp[0][1][i] += dp[0][1][i-1] 
        dp[1][1][i] += dp[1][1][i-1] 

    # R=0, L=1
    if not R_bit and L_bit:
        # y=1, x=1
        dp[0][0][i] += dp[0][0][i-1] 
        dp[0][1][i] += dp[0][1][i-1] 
        # y=0, x=0
        dp[0][0][i] += dp[0][0][i-1] 
        dp[1][0][i] += dp[1][0][i-1] 
        # y=1, x=0
        dp[0][0][i] += dp[0][0][i-1]

    # R=1, L=1
    if R_bit and L_bit:
        # y=1, x=1
        dp[0][0][i] += dp[0][0][i-1] 
        dp[1][0][i] += dp[1][0][i-1] 
        dp[0][1][i] += dp[0][1][i-1] 
        dp[1][1][i] += dp[1][1][i-1] 
        # y=0, x=0
        dp[0][0][i] += dp[1][0][i-1] 
        dp[0][0][i] += dp[0][0][i-1] 
        # y=1, x=0
        dp[1][0][i] += dp[1][0][i-1] 
        dp[0][0][i] += dp[0][0][i-1] 

    # Take MOD
    for i in range(2):
        for j in range(2):
            dp[i][j][i] %= MOD

ans = 0
for i in range(2):
    for j in range(2):
        ans += dp[i][j][-1]
        ans %= MOD
print(ans)

Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
bool ok(string S)
{
    map<char, int> cnt;
    rep(i, S.size())
    {
        cnt[S[i]]++;
    }
    rep(i, S.size())
    {
        if (cnt[S[i]] > 1)
            return false;
    }
    return true;
}
int main()
{
    string S;
    cin >> S;
    if (S == "zyxwvutsrqponmlkjihgfedcba")
    {
        cout << -1;
        return 0;
    }
    int n = S.size();
    map<char, int> cnt;
    rep(i, n)
    {
        cnt[S[i]]++;
    }
    string ans;
    for (char c = 'a'; c <= 'z'; c++)
    {
        if (cnt[c] == 0)
        {
            cout << S + c;
            return 0;
        }
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (char c = S[i] + 1; c <= 'z'; c++)
        {
            if (find(S.begin(), S.begin() + i, c) >= S.begin() + i)
            {
                for (int k = 0; k < i; k++)
                {
                    ans.push_back(S[k]);
                }
                ans.push_back(c);
                cout << ans;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = list(map(int, input().split()))
grid = [input() for _ in range(h)]

ans = [[10000]*w for _ in range(h)]
ans[0][0] = 0 if grid[0][0] == "." else 1

queue = deque([(0, 0)])

while len(queue) > 0:
    x, y = queue.popleft()

    for xo, yo in [(0, 1), (1, 0)]:
        xnext, ynext = x+xo, y+yo

        if xnext >= w or ynext >= h:
            continue

        if grid[y][x] == "." and grid[ynext][xnext] == "#":
            if ans[y][x] + 1 < ans[ynext][xnext]:
                ans[ynext][xnext] = ans[y][x] + 1
                queue.append((xnext, ynext))
        else:
            if ans[y][x] < ans[ynext][xnext]:
                ans[ynext][xnext] = ans[y][x]
                queue.append((xnext, ynext))

print(ans[h-1][w-1])

Measured memory_bytes: 9552
import java.util.Scanner;

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

        while(true){
            int n = scanner.nextInt();
            if(n == 0){
                break;
        }

        int[] scores = new int[n];

        for(int i=0; i<scores.length; i++){
          scores[i] = scanner.nextInt();  
        }

        int sum1 = 0, sum2 = 0;
        double average = 0, variance = 0;
        for(int j=0; j<scores.length; j++){
            sum1 += scores[j];
            sum2 += scores[j] * scores[j];
        } 
        average = (double)sum1 / n;
        variance = (double)sum2 / n - average * average;
        
        System.out.println(Math.sqrt(variance));
       }
    }
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

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

	int a,b;
	cin>>a>>b;

	int ans = max(a,b);

	if(ans > 9)
	{
		cout<<-1<<endl;
	}

	else
	{
		cout<<a*b<<endl;
	}

}

Measured memory_bytes: 3520
#include <stdio.h>

int main(void)
{
	int n, i;
	int a[100];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = (n - 1); i >= 0; i--) {
		printf("%d", a[i]);
		if (i != 0) {
			printf(" ");
		}
		else {
			printf("\n");
		}
	}

	
	return 0;
}


Measured memory_bytes: 2052
#include<stdio.h>
int main(void)
{
	int i;
	
	while(1)
	{
		char x[1000];
		int sum=0;
		
		
		scanf("%s",x);
		
		for(i=0;i<1000;i++)
		{
			if(x[i]=='\0')
		{
			break;
		}
			sum+=x[i]-48;
		}
		if(sum==0)
		{
			break;
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
const int nax = 1e4+500;
const ll inf = 1e18+5;
int main() {
	int h,w,k;
	cin >> h >> w >> k;
	vector<vector<char>> grid(h,vector<char> (w));
	vector<int> rowb(nax,0),colb(nax,0);
	int tot = 0;
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			cin >> grid[i][j];
			if(grid[i][j] == '#') {
				rowb[i]++;
				colb[j]++;
				tot++;
			}
		}
	}
	ll ways = 0;
	ll base1 = pow(2,h)-1;
	ll base2 = pow(2,w)-1;
	for(int row = 0; row<=base1;row++) {
		for(int col =0; col<=base2;col++) {
			ll del = 0;
			for(int rep = 0;rep<32;rep++) {
				if(1 & (row >> rep)) {
					del += rowb[rep];
					for(int repc =0; repc<32;repc++) {
						if(1 & (col >> repc)) {
							if(grid[rep][repc] == '#') {
								del--;
							}
						}
					}
				}
			}
			for(int rep = 0; rep<32;rep++) {
				if(1 & (col >> rep)) {
					del+=colb[rep];
				}
			}
			if(tot-del == k) ways++;
		}
	}
	cout<<ways;
 }


Measured memory_bytes: 4164
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

ll g[101][101],a[101][2],ct;

void dfs(ll ci) {
  //cout<<ci<<endl;
  if (a[ci][0]) return;
  ll ni;
  ct++;
  a[ci][0]=ct;

  for (ll i = 1; i <= g[ci][0]; i++)
  {
    ni=g[ci][i];
    if (ni>0) {
      g[ci][i] = 0;
        dfs(ni);
    }
  }

  ct++;
  a[ci][1] = ct;
}

int main()
{
  ll n,ci;
  cin>>n;
  fill_n(a[0],101*2,0);
  a[0][0]=1;
  ct=0;

  for (ll i = 0; i < n; i++)
  {
    cin>>ci;
    cin>>g[ci][0];
    for (ll j = 1; j <= g[ci][0]; j++)
    {
      cin>>g[ci][j];
    }
  }

  for (ll i = 1; i <= n; i++)
  {
    dfs(i);
  }
  

  for (ll i = 1; i <= n; i++)
  {
    cout<< (i) <<" "<<a[i][0]<<" "<<a[i][1]<<endl;
  }
  

  return 0;
}



Measured memory_bytes: 3172
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

using namespace std;
typedef long long ll;

int main()
{
  int n, m;
  cin >> n >> m;
  int x[100100];
  for (int i = 0; i < m; i++)
  {
    cin >> x[i];
  }
  sort(x, x + m);
  int sub[100100];
  for (int i = 0; i < m - 1; i++)
  {
    sub[i] = x[i + 1] - x[i];
  }
  sort(sub, sub + m - 1);
  reverse(sub, sub + m - 1);

  int ans = x[m - 1] - x[0];
  for (int i = 0; i < n - 1; i++)
  {
    ans -= sub[i];
  }

  if (n >= m)
  {
    ans = 0;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NX = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, X) = (NX[0], NX[1]);
            var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var answer = 0L;
            for (var i = 1; i < A.Length; i++)
            {
                var tmp = Math.Max(0, A[i] + A[i - 1] - X);
                answer += tmp;
                A[i] = Math.Max(0, A[i] - tmp);
            }

            Console.WriteLine(answer);
        }
    }
}


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

int x, arr[100], i=1;
char s[100];

void push(char *s) {
  arr[i++]=atoi(s);
}

void pop() {
  i--;
}

int main() {

  while (scanf("%s", s)!=EOF) {
    if (s[0]=='+') {
      pop();
      arr[i-1]+=arr[i];
    } else if (s[0]=='-') {
      pop();
      arr[i-1]-=arr[i];
    } else if (s[0]=='*') {
      pop();
      arr[i-1]*=arr[i];
    } else {
      push(s);
    }

    if (i==102) {
      printf("overflow\n");
      return 0;
    } else if (i==1) {
      printf("underflow\n");
      return 0;
    }
  }

  printf("%d\n", arr[i-1]);
  return 0;
}


Measured memory_bytes: 2132
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int m = 1, d = 1; (m < a) || (m == a && d <= b); m++, d++, ans++);
	cout << ans << endl;
	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int A, B; cin >> A >> B;
	int C, D; cin >> C >> D;
	cout << max(A*B, C*D) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int MAXN = 2e3 + 5;
const ll mod = 1e9 + 7;

inline ll pow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans = ans*a %mod;
		a = a*a %mod;
		b>>=1;
	}
	return ans;
}

int a[MAXN];
int b[MAXN];

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; ++i)
		scanf("%d",&a[i]);
	
	ll ans=0;
	ll t=((ll)m-1)*(ll)m/2 %mod;
	
	for(int i=1; i<=n; ++i)
	{
		for(int j=1; j<=n; ++j)
			if(a[j]<a[i]) ++b[i];
		ans = (ans + (ll)t*b[i])%mod;
	}
	
	for(int i=1; i<=n; ++i)
	{
		int cnt=0;
		for(int j=i+1; j<=n; ++j)
			if(a[j]<a[i]) ++cnt;
		ans = (ans + (ll)m*cnt) %mod;
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
n,*v=map(int,open(0).read().split())
a,b={},{}
for i,j in zip(v[::2],v[1::2]):	
  a[i]=a.get(i,0)+1
  b[j]=b.get(j,0)+1
A=list(a.items())
B=list(b.items())
A.sort(key=lambda x: x[1])
B.sort(key=lambda x: x[1])
c,d=A[-1][1],B[-1][1]
if len(set(v))==1:
    print(n//2)
    exit()
if A[-1][0]==B[-1][0]:
    if c==d:
        c=max(A[-2][1],B[-2][1])
    elif c>d:
        d=B[-2][1]
    else:c=A[-2][1]    
print(n-c-d)

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

#define NAME "rewind"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2e5;
int n;
double dp[301][301][301];
double cal(int c1,int c2,int c3){
    //cout<<c1<<" "<<c2<<" "<<c3<<endl;
    if (c1==0&&c2==0&&c3==0) return 0.0;
    if (dp[c1][c2][c3]!=0) return dp[c1][c2][c3];
    double ret = 1.0*n/(c1+c2+c3);

    if (c3>0) ret+= cal(c1,c2+1,c3-1)*c3/(c1+c2+c3);
    if (c2>0) ret+= cal(c1+1,c2-1,c3)*c2/(c1+c2+c3);
    if (c1>0) ret+= cal(c1-1,c2,c3)*c1/(c1+c2+c3);

    return dp[c1][c2][c3] = ret;

}
int cnt[4];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    cin>>n;
    int tmp;

    for(int i=0;i<=300;i++)for(int j=0;j<=300;j++)for(int k=0;k<=300;k++) dp[i][j][k]=0;

    for(int i=0;i<n;i++) cin>>tmp,cnt[tmp]++;
    cout<<setprecision(12)<<fixed<<cal(cnt[1],cnt[2],cnt[3]);

}


Measured memory_bytes: 216836
# coding: utf-8
# Your code here!
for i in range(4):
    ti,ni=map(int,input().split())
    
    if ti==1:
        print(ni*6000)
    elif ti==2:
        print(ni*4000)
    elif ti==3:
        print(ni*3000)
    else:
        print(ni*2000)


Measured memory_bytes: 5600
#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)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll b=0,c=0,cnt=0;
	rep(i,n-1){
		if(a.at(i)==a.at(i+1)){
			if(cnt) c=a.at(i);
			else b=a.at(i);
			cnt++;
			i++;
		}
		if(cnt==2) break;
	}
	cout << b*c << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define MP make_pair
#define PII pair<int, int>
typedef long long LL;
const LL MOD = 998244353;
const int INF = 0x3fffffff;
const int N = 100010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

LL s;

int main(){
	//freopen("test.in","r",stdin);
	scanf("%lld",&s);
	if(s==1e18){
		printf("0 0 1000000000 0 0 1000000000\n");
		return 0;
	}
	LL x = sqrt(1.0*s);
	if(x*(x+1)>=s){
		printf("0 0 %lld 1 %lld %lld\n",x,x*(x+1)-s,x+1);
	}else{
		printf("0 0 %lld 1 %lld %lld\n",x+1,(x+1)*(x+1)-s,x+1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char a[3], b[3];
	int n, i, point;
	
	while (1) {
		point = 0;
		scanf("%d", &n);
		if (n == 0) break;
		
		while (n > 0) {
			if (n != 1) {
				scanf("%s", a);
				scanf("%s", b);
					if (a[0] != b[0])
						point++;
			}
			else
				scanf("%s", a);
			n -= 2;
		}
		printf("%d\n", point);
	}
	
	return 0;
}

Measured memory_bytes: 604
import math
def main():
    x, y = map(int, input().split())
    a = (4*x-y)
    b = (y-2*x)

    am = 50
    bm = 25

    out = 'No'

    for a in range(0, am+1):
        for b in range(0, bm+1):
            Y = 2*a + 4*b
            X = a + b
            if X==x and Y==y:
                out = 'Yes'
    
    print(out)

main()

Measured memory_bytes: 9192
s = input()
ans = 0
length = int(len(s)/2)
s_f = s[:length]
s_b = list(reversed(list(s[length:])))
s_b = ''.join(s_b)
for i in range(length):
  if s_f[i] != s_b[i]:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
#define MOD 1000000007
using namespace std;
ll FastM(ll a, ll p, ll m){
	if(p == 0) return 1;
	ll r = a % m;
	ll k = 1;
	while(p > 1){
		if((p & 1) != 0){
			k = (k * r) % m;
		}
		r = (r * r) % m;
		p >>= 1;
	}
	return (r * k) % m;
}
int main()
{
    int n;
    cin>>n;
    int a[100005];
    int cnt[100005]={0};
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i = n-1; i > 0; i--){
        if(cnt[i] > 2){
            printf("0");
            return 0;
        }
    }
    if(n % 2 == 0){
        if(cnt[0] > 2){
            printf("0");
            return 0;
        }
        ans = FastM(2, n/2, MOD);
    }
    else {
        if(cnt[0] > 1){
            printf("0");
            return 0;
        }
        ans = FastM(2, (n-1)/2, MOD);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
// ABC175-B
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int ans=0,n;
    cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]<l[j]+l[k] && l[j]<l[i]+l[k] && l[k]<l[i]+l[j]){
                    if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]) ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>

int main(){
	int a[4],b[4];
	while(std::cin>>a[0]){
		int hit=0,blow=0;
		for(int i=1;i<4;i++)std::cin>>a[i];
		for(int i=0;i<4;i++)std::cin>>b[i];
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j)hit++;
					else blow++;
				}
			}
		}
		std::cout<<hit<<" "<<blow<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int n,d;
	cin>>n>>d;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	
	int ans = 0;
	rep(i,n){
		if(v[i]>d)ans+=v[i]-d;
	}

	if(ans<=0)cout<<"kusoge"<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod  998244353
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
#define NEG_INF -2e18
			 
const ll INF=1e15;	
const int N=2e5+50;
		 
 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
		
	string s;
	cin>>s;
	int n=s.length();
	
	if(s[n-1]=='s')
	{
		s+="es";
	}
	else
		s+="s";
	cout<<s;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
struct point
{
	ll x;
	ll y;
}p[N];
bool cmp(point a,point b)
{
	return atan2(a.x,a.y)>atan2(b.x,b.y);
}
int main()
{
	int n;	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&p[i].x,&p[i].y);
	int nx[N];
	for(int i=1;i<=n;i++)
		nx[i]=i+1; nx[n]=1;
	sort(p+1,p+1+n,cmp);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x=p[i].x;
		ll y=p[i].y;
		ans=max(ans,x*x+y*y);
		for(int j=nx[i];j!=i;j=nx[j])
		{
			x=x+p[j].x;
			y=y+p[j].y;
			ans=max(ans,x*x+y*y);
		} 
	}
	printf("%.10lf\n",sqrt(ans));
	return 0;
} 

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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000000] = {};
ll X[1000000] = {};
ll rui[100002] = {},ruin[100002] = {};
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, ma = INF,mi=-1;
str S;
bool an = false,bn = false;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                X[i] = n%10;
                n /= 10;
                i++;
        }
        return i;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
cin >> a >> n;
for(int i = 0;i < n;i++){
  cin >> A[i] >> X[i];
  if(A[i] > mi)mi = A[i];
  if(X[i] < ma)ma = X[i];
  if(A[i] < mi)A[i] = min(mi , X[i]);
    if(X[i] > ma)A[i] = max(ma , A[i]);
}

if(ma - mi +1 > 0)cout << ma - mi +1 << endl;
else cout << 0 << endl;
  //Code Line
        return 0;
}



Measured memory_bytes: 4864
N=int(input())
A=[int(i) for i in input().split()]
I,J,K=0,0,0
for a in A:
    if a==1:
        I+=1
    if a==2:
        J+=1
    if a==3:
        K+=1
L=I+J+K
M=J+K
dp=[[[0.0]*(K+1) for i in range(M+1)] for i in range(L+1)]
for n in range(1,L+1):#n=i+j+k
    for m in range(min(n,M)+1):#m=j+k
        for k in range(min(m,K)+1):
            j=m-k
            i=n-m
            #print(i,j,k)
            ret=N/(i+j+k)
            if i>0:
                ret+=dp[i-1][j][k]*(i/(i+j+k))
            if j>0:
                ret+=dp[i+1][j-1][k]*(j/(i+j+k))
            if k>0:
                ret+=dp[i][j+1][k-1]*(k/(i+j+k))
            dp[i][j][k]=ret
print(dp[I][J][K])


Measured memory_bytes: 254344
abcd = input()

def dfs(i, s, sum):
    if i == 3:
        if sum == 7:
            print(s + "=7")
            exit()

    else:
        dfs(i+1, s + "+" + abcd[i+1], sum + int(abcd[i+1]))
        dfs(i+1, s + "-" + abcd[i+1], sum - int(abcd[i+1]))

dfs(0, abcd[0], int(abcd[0]))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    int mx = 0, cnt = 0, flag = 0;
    rep(i,n) {
        int a, b; cin >> a >> b;
        if (flag && a == b) {
            cnt++;
        } else if (!flag && a == b) {
            flag = 1;
            cnt = 1;
        } else if (a != b) {
            cnt = 0;
        }
        chmax(mx, cnt);
    }

    if (mx >= 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  vector<int> a(3);
  rep(i,3){cin >> a[i];}
  sort(a.begin(),a.end());
  cout << a[2] - a[1] + a[1] - a[0] << endl;


  return 0;
}


Measured memory_bytes: 256
//
// Created by TakahiroYamaji on 2020/08/03.
//
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int N;
string S;
int main(){
    cin >> N >> S;
    int a = 0, b = 0;
    for (int i=0;i<N;i++){
        if (S[i] == 'R') a++;
    }
    int res = max(a,b);
    for (int i=0;i<N;i++){
        if (S[i] == 'R') --a;
        else ++b;
        res = std::min(res, max(a, b));
    }
    cout << res << endl;

}



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

typedef long long ll;

const int Maxn = 305;
const int mod = 998244353;

int pw2[Maxn];
int n, m;
int M[Maxn][Maxn];

void Swap(int r1, int r2)
{
    for (int j = 0; j < m; j++)
        swap(M[r1][j], M[r2][j]);
}

void Add(int r1, int r2)
{
    for (int j = 0; j < m; j++)
        M[r2][j] ^= M[r1][j];
}

int main()
{
    pw2[0] = 1;
    for (int i = 1; i < Maxn; i++)
        pw2[i] = 2ll * pw2[i - 1] % mod;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf("%d", &M[i][j]);
    int r = 0;
    for (int j = 0; j < m; j++) {
        int i = r;
        while (i < n && M[i][j] == 0) i++;
        if (i == n) continue;
        Swap(i, r);
        for (int l = r + 1; l < n; l++) if (M[l][j])
            Add(r, l);
        r++;
    }
    int res = (pw2[n] - pw2[n - r] + mod) % mod;
    res = ll(res) * pw2[m - 1] % mod;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	int ans = 0;
	bool b = true;
	while (b) {
		rep(i, n) {
			if (a[i] % 2 != 0) {
				b = false;
			}
		}
		rep(i, n) {
			a[i] = a[i] / 2;

		}
		if (b)ans++;
	}
	cout << ans;
	return 0;
}










Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        
Scanner sc = new Scanner(System.in);
String get;
get = sc.next();    
             String str = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
         
int index_s = str.indexOf(get);
String str1 = str.substring(index_s + 2, index_s + 3);

          System.out.print(str1);

      }
}

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

using namespace std;
typedef long long int ll;
/*bool compx(vector<ll> a, vector<ll> b)
{
    if(a[0]>=b[0])
        return false;
    else
        return true;
}*/

int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h, a;
    cin>>h>>a;
    cout<<ceil(h*1.0/a);
    return 0;
}

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

int main(){
  int n,m;
  while(cin >> n >> m,n||m){
    vector<int> h;
    vector<int> w;
    vector<int> a(1500000,0);
    vector<int> o(1500000,0);
    int tmp;

    for(int i=0; i<n; ++i){
      cin >> tmp;
      h.push_back(tmp);
      int x=0;
      for(int j=i; j>=0; --j){
	x += h[j];
	++a[x-1];
      }
    }

    for(int i=0; i<m; ++i){
      cin >> tmp;
      w.push_back(tmp);
      int x=0;
      for(int j=i; j>=0; --j){
	x += w[j];
	++o[x-1];
      }
    }

    int mi = min(accumulate(h.begin(),h.end(),0),accumulate(w.begin(),w.end(),0));
    int ans = 0;
    for(int i=0; i<mi; ++i){
      ans += a[i] * o[i];
    }
    cout << ans << endl;
  }
  return 0;
}
      
      

Measured memory_bytes: 14640
import java.util.*;
import java.io.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String s;
		String p;
		String str;
		int j = 0;
		int i = 0;
		int count = 0;
	    char sli[];
	    char pli[];
	    
	    s = as.nextLine();
	    p = as.nextLine();
	    
	    s = s+s;
	    
	    sli = new char[s.length()];
	    pli = new char[p.length()];
	    
	    for(i=0;i<s.length();i++){      //?????????????????????????????????????´???????
            
            sli[i] = s.charAt(i);
             
        }
	    
		for(i=0;i<p.length();i++){      //?????????????????????????????????????´???????
		    
			pli[i] = p.charAt(i);
		     
		}
		
		for(i=0;i<(s.length()/2);i++){      //?????????????????????????????????????´???????
		    
			for(j=0;j<p.length();j++){
			
				if(sli[j+i] == pli[j]){
		        	
					count++;
					
				}
				else{
					
					count = 0;
				
				}
				
				
			}
			
			
			if(count == p.length()){
				
				break;
				
			}
			
			count = 0;
			
			
        }
		
		if(count == p.length()){
			
			str = "Yes";
			System.out.println(str);
			
		}
		else{
			
			str = "No";
			System.out.println(str);
			
		}
	    
	    
	    

	}

}

Measured memory_bytes: 26236
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  string a;cin>>a;
  ll b=0,c=0;
  rep(i,a.size()){
    if(a[i]=='0')b++;
    else c++;
  }
  cout<<min(b,c)*2<<endl;
}

Measured memory_bytes: 23936
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

void printVector(vector<double> vec) {
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << endl;
	}
}


double getMax(vector<int> scores, int K, int N) {
	double max = 0;
	for (int i = 0; i < K; i++) {
		max += scores[i];
	}
	
	double curScore = max;
	for (int i = 0; i < scores.size() - K; i++) {
		curScore = curScore - scores[i] + scores[K + i];
		if (curScore > max) {
			max = curScore;
		}
	}
	return double((max + K)/2);
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> pvec;
	pvec.reserve(N);
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		pvec.push_back(p);
	}
	cout.precision(13);
	cout << fixed << getMax(pvec, K, N) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <regex>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const static ll INF = INT_FAST64_MAX;

int main () {
    vector<ll> b, dp;
    ll N;
    cin >> N;
    dp.resize(10*N, 0);
    ll p = 6;
    while(p <= 100000) {
        b.push_back(p);
        p *= 6;
    }
    p = 9;
    while(p <= 100000) {
        b.push_back(p);
        p *= 9;
    }
    dp[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        dp[i] = dp[i - 1] + 1;
        for(auto y:b) {
            if(y <= i){
                dp[i] = min(dp[i], dp[i - y] + 1);
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;
  long ans = A - B * 2;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input(), q = input();
    string s;
    cin >> s;

    vector< int > rs(n);
    range(i, 1, n) {
        rs[i] = (s[i - 1] == 'A' && s[i] == 'C');
        rs[i] += rs[i - 1];
    }

    while (q--) {
        int l = input(), r = input();
        cout << rs[r - 1] - rs[l - 1] << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1488
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    int n = read();
    auto hs = reads();
    int ans = 1;
    foreach (i ; 1..n) {
        ans += hs[0..i].reduce!(max) <= hs[i];
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
using namespace atcoder;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  scc_graph sg(N);
  REP(i, M){
    int a, b; cin >> a >> b;
    sg.add_edge(a, b);
  }
  vector<vector<int> > ans = sg.scc();
  cout << ans.size() << endl;
  for(auto i : ans){
    int sz = i.size();
    int cnt = 0;
    cout << sz << " ";
    for(auto j : i){
      cout << j;
      cnt++;
      if(cnt == sz){
        cout << endl;
      }else{
        cout << " ";
      }
    }
  }
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  sort(h.begin(), h.end());
  int min=1000000000;
  rep(i,n-k+1){
    int tmp;
    tmp = h.at(i+k-1) - h.at(i);
    if (tmp < min) min = tmp;
  }
  cout << min << endl;
}
  

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	dp := make([][]int, len(S)+1)
	for i := 0; i < len(S)+1; i++ {
		dp[i] = make([]int, 5)
	}
	dp[1][1] = 1
	for i := 1; i < len(S); i++ {
		for j := 1; j <= 4; j++ {
			if i-j < 0 {
				continue
			}
			t := S[i-j : i]
			for k := 1; k <= 4; k++ {
				if i+k > len(S) {
					continue
				}
				u := S[i : i+k]
				if t != u {
					dp[i+k][k] = Max(dp[i+k][k], dp[i][j]+1)
				}
			}
		}
	}
	fmt.Println(Max(dp[len(S)]...))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}


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

int calcSumOfDigit(int num)
{
    int rem = 0;
    int sum = 0;
    while(num > 0)
    {
        rem = num % 10;
        num /= 10;

        sum += rem;
    }

    return sum;
}

int main(void)
{
    int A, B;
    cin >> A >> B;

    int c= 0;    
    for(int i = A; i <= B; i++)
    {
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3])
        {
            c++;
        }
    }
    
    cout << c <<endl;
    

    return 0;

}


Measured memory_bytes: 256