akhauriyash/Code-Regression huggingface dataset:
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))
    return n, alist

def get_sign(x):
    if x > 0:
        return 1
    elif x < 0:
        return -1
    return 0

def submit():
    n, alist = read_input()

    # pattern 1
    s = 0
    sign = 1
    edit = 0

    for a in alist:
        temp = s + a
        temp_sign = get_sign(temp)

        if sign == temp_sign:
            edit += temp_sign * temp
            temp -= temp

        if temp == 0:
            edit += 1
            temp -= sign

        s = temp
        sign = get_sign(s)

    edit1 = edit

    # pattern 2
    s = 0
    sign = -1
    edit = 0

    for a in alist:
        temp = s + a
        temp_sign = get_sign(temp)

        if sign == temp_sign:
            edit += temp_sign * temp
            temp -= temp

        if temp == 0:
            edit += 1
            temp -= sign

        s = temp
        sign = get_sign(s)

    edit2 = edit

    print(min(edit1, edit2))


if __name__ == '__main__':
    submit()
    

Measured memory_bytes: 63216
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

string to_four(int x, int n)
{
    string s;
    while (1)
    {
        if (x == 0)
            break;
        s += to_string(x % 4);
        x /= 4;
    }
    int l = s.size();
    rep(i, 0, n - l) s += '0';
    //cout << s << endl;
    reverse(s.begin(), s.end());
    return s;
}

int main()
{
    int n, a, b, c;
    int l[8];
    cin >> n >> a >> b >> c;
    rep(i, 0, n) cin >> l[i];

    int ans = INF;
    for (int i = 0; i < pow(4, n); i++)
    {
        string s = to_four(i, n);
        //cout << s << endl;
        int al = 0, bl = 0, cl = 0;
        int mp = 0;
        for (int j = 0; j < n; j++)
        {
            if (s[j] == '1')
            {
                if (al != 0)
                    mp += 10;
                al += l[j];
            }
            else if (s[j] == '2')
            {
                if (bl != 0)
                    mp += 10;
                bl += l[j];
            }
            else if (s[j] == '3')
            {
                if (cl != 0)
                    mp += 10;
                cl += l[j];
            }
        }
        if (al != 0 && bl != 0 && cl != 0)
        {
            mp += abs(a - al) + abs(b - bl) + abs(c - cl);
            ans = min(ans, mp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#define HS 251

int main(void){
  int hs,i;
  int a[HS];
  
  scanf("%d",&hs);
  for(i=1; i<=hs; i++){
    scanf("%d",&a[i]);
  }
  
  for(i=1; i<=hs; i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i!=1){
      printf("parent key = %d, ",a[i/2]);
    }
    if(i*2<=hs){
      printf("left key = %d, ",a[i*2]);
    }
    if(i*2+1<=hs){
      printf("right key = %d, ",a[i*2+1]);
    }
    printf("\n");
  } 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n, x, y, d[N], f[N]; 
vector<int>g[N];
bool vs[N];

void go(int u){
    queue<int> q; 
    vs[u] = 1;
    q.push(u);
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(auto i: g[u]){
            if(!vs[i]){
                 q.push(i);
                 vs[i] = 1;
                 d[i] = d[u]+1;
            }
        }
    }
}

int main(){
    scanf("%d%d%d", &n, &x, &y);
    for(int i = 1; i<n; ++i)g[i].push_back(i+1), g[i+1].push_back(i);
    g[x].push_back(y), g[y].push_back(x);
    for(int i = 1; i<=n; ++i){
        memset(vs, 0, sizeof vs);
        memset(d, 0, sizeof d);
        d[i] = 0;
        go(i);
        for(int j = i+1; j<=n; ++j){
            ++f[d[j]];
        }
    }
    for(int i = 1; i<n; ++i)printf("%d\n", f[i]);
} 

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

int main() {
  int n,d;
  cin>>n>>d;
  vector<vector<int>> x(n, vector<int>(d));
  
  int cou=0;
  for (int l=0;l<n;++l) {
    for (int m=0;m<d;++m) {
      cin>>x[l][m];
    }
  }
    
  for(int l=0;l<n;++l) {
    for(int m=0;m<l;++m) {  
      int sdis=0;
      for (int i=0;i<d;++i) {
        sdis+=(x[l][i]-x[m][i])*(x[l][i]-x[m][i]);
      }

      for (int p=1;p<150;++p) {
        if (sdis==p*p) {
          cou+=1;
        }
      }
    }
  }
  cout<<cou<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int x, y, ans=0;
    cin >> x >> y;
    if(x<4){
        ans+=(4-x)*100000;
    }
    if(y<4){
        ans+=(4-y)*100000;
    }
    if(x<2&&y<2){
        ans+=400000;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
solve :: String -> String -> Int -> Bool
solve s1 s2 c
  | s1 == s2 = True
  | c <= 0 = False
  | otherwise = solve ((last s1) : init s1) s2 (c - 1)

main = do
  s <- getLine
  n <- getLine
  if(solve s n (length s))
  then putStrLn "Yes"
  else putStrLn "No"

Measured memory_bytes: 892
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector<pair<char,int> >vepa;
typedef set<char>se;
typedef map<char ,int> mpp;
const ll N=1e6+5 ,OO=1e18;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
ll TC,n,m,a,sum,arr[N];
bool f,vis[N];

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
        cin>>n>>m;
        rep(i,n&&cin>>arr[i]);
        sort(arr,arr+n);
        rep(i,m)
         sum+=arr[i];
        cout<<sum;
go;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod = MOD) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod = MOD) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {
	fact_inv(2123456);
	
	int X, Y;
	cin >> X >> Y;
	
	if (X > Y) swap(X, Y);
	
	ll ans = 0;
	REP(i, X + 1) {
		int cx = X - i;
		int cy = Y - i;
		if (cx + cy != i) continue;
		(ans += ncr(cx + cy, cx)) % MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 33408
open Printf open Scanf
open Array

let rec gcd m n = match m,n with | m,0 -> m | m,n -> gcd n (m mod n)

module SegTree_tmp = struct
  module type S = sig
    type t
    val  op: t -> t -> t
    val ide: t
    val upd: t -> t -> t
  end
  let par i = (i-1)/2
  let chl i = 2*i+1
  let chr i = 2*i+2
  module Make (X:S) = struct
    type t = SegTree of (X.t array * int)
    let raw (SegTree (a,_)) = a
    let make raw = (* O(n) *)
      let ln = Array.length raw in
      let n =
        let n = ref 1 in
        while !n<ln do n := !n*2 done; !n in
      let a = Array.make (2*n-1) X.ide in
      for i=0 to ln-1 do
        a.(i+n-1) <- raw.(i) done;
      for i=n-2 downto 0 do
        a.(i) <- X.op a.(chl i) a.(chr i) done;
      SegTree (a,n)
    let update_destructive (SegTree(a,n)) i v =
      let i = ref @@ i+(n-1) in
      a.(!i) <- X.upd a.(!i) v;
      while !i>0 do
        i := par !i;
        a.(!i) <- X.op a.(chl !i) a.(chr !i) done
    let get_half_open (SegTree(a,n)) l r = (* O(logn), [l,r) *)
      let rec f0 i p q =
        if q<=l || r<=p then X.ide
        else if l<=p && q<=r then a.(i)
        else
          let vl = f0 (2*i+1) p ((p+q)/2) in
          let vr = f0 (2*i+2) ((p+q)/2) q in
          X.op vl vr
      in f0 0 0 n
    let get_closed seg l r = get_half_open seg l (r+1) (* [l,r] *)
  end
end

module ST = SegTree_tmp.Make(struct
  type t = int
  let op = gcd
  let ide = 0
  let upd _prev nw = nw
end)

let () = scanf " %d" @@ fun n ->
  let a = init n (fun _ -> scanf " %d" @@ fun v -> v) in
  let t = ST.make a in
  mapi (fun i _ ->
    let l = if i=0 then 0 else ST.get_closed t 0 (i-1) in
    let r = if i=n-1 then 0 else ST.get_closed t (i+1) (n-1)
    in gcd l r
  ) a
  |> fold_left max 0
  |> print_int





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

 using namespace std;

 int main() {
   string s, t, smin, tmax;
   int i;

   cin >> s >> t;

   vector<char> S(s.length());
   vector<char> T(t.length());

   for (i = 0; i < s.length(); i++) S.at(i) = s.at(i);
   for (i = 0; i < t.length(); i++) T.at(i) = t.at(i);

   sort(S.begin(), S.end());
   sort(T.begin(), T.end());

   for (i = 0; i < s.length(); i++) {
     smin = smin + S.at(i);
   }

   for (i = 0; i < t.length(); i++) {
     tmax = tmax + T.at(t.length() - 1 - i);
   }

   if (smin < tmax) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


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


def main():
    from itertools import combinations
    import sys
    input = sys.stdin.readline

    n = int(input())
    l = list(map(int, input().split()))
    comb = list(combinations(range(n), 3))
    ans = 0

    for i, j, k in comb:
        a = l[i]
        b = l[j]
        c = l[k]

        total = a + b + c
        max_value = max(a, b, c)
        diff = total - max_value

        if a == b:
            continue
        if b == c:
            continue
        if c == a:
            continue

        if diff <= max_value:
            continue

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20316
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx_4[]={1,0,-1,0}, dy_4[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, X, x[100010];
	cin >> n >> X;
	REP(i, n) cin >> x[i];

	sort(x, x+n);

	int k = x[n-1] - x[0];
	REP(i, n-1){
		int a = x[i+1] - x[i];
		k = GCD(k, a);
	}
	int min = 2000000000;
	REP(i, n){
		int a = abs(X - x[i]);
		if(a < min) min = a;
	}
	k = GCD(k, min);

	cout << k << endl;
	rtn 0;
}

Measured memory_bytes: 640
/*   You have lost, my dear   */

#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define mod 1000000007
using namespace std;
int a,b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b;
    if(a<=8 && b<=8)
        cout<<"Yay!";
    else
        cout<<":(";
    return 0;
}


Measured memory_bytes: 256
/*
                                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include <bits/stdc++.h>
 
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
 
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}
signed main()
{   jaldi
    int n,m,ac=0,wc=0;
    string ar="AC";
    cin>>n>>m;
 	bool p[n];
 	int a[n]={0};
 	for(int i=0;i<n;i++)
    p[i]=true;
    if(m==0)
    cout<<0<<" "<<0;
    else
    {   for(int i=1;i<=m;i++)
        {   int x;
            string str;
            cin>>x;
            cin>>str;
         	x--;
            if(str==ar && p[x]==true)
            {	wc+=a[x]; 
                p[x]=false;
             	ac++;
            }
             else
            a[x]++;
        }
        cout<<ac<<" "<<wc;
    }
    
}

Measured memory_bytes: 1152
s = input().split()
for i in range(len(s)):
    if "peach" in s[i]:n = s[i].index("peach");s[i] = s[i][:n] + "apple" + s[i][n + 5:]
    elif "apple" in s[i]:n = s[i].index("apple");s[i] = s[i][:n] + "peach" + s[i][n + 5:]
print(*s)


Measured memory_bytes: 5564
import java.util.Scanner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main{
    public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
      		double[] height = new double[n];
      		int[] rate = new int[6];
      		for(int i=0; i<n; i++){
			 	height[i] = sc.nextDouble();
              	if(height[i]<165){
                  rate[0] = rate[0]+1;
                }else if(height[i]<170){
                  rate[1] = rate[1]+1;
                }else if(height[i]<175){
                  rate[2] = rate[2]+1;
                }else if(height[i]<180){
                  rate[3] = rate[3]+1;
                }else if(height[i]<185){
                  rate[4] = rate[4]+1;
                }else{
                  rate[5] = rate[5]+1;
				}
            }
      		for(int i=0; i<6; i++){
              System.out.print(i+1+":");
              for(int j=0; j<rate[i]; j++){
			 		System.out.print("*");
              }
              System.out.println();
            }
    }
}



Measured memory_bytes: 27440
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
A = [1]*n
for i in range(k):
    d = int(input())
    x = [int(h) for h in input().split()]
    for k in x:
        if A[k - 1] == 1:
            A[k - 1] = 0

sum = 0
for m in A:
    sum += m
print(sum)

Measured memory_bytes: 9192
N,K = [int(i) for i in input().split()]
hate_numbers = [i for i in input().split()]


while True:
	is_okay = True
	for n in hate_numbers :
		if (str(N).find(n) == -1) :
			continue
		is_okay = False
		break
	
	if (is_okay == True) :
		print(N)
		break
	else :
		N += 1



Measured memory_bytes: 2940
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nzw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nzw[0];
			int z = nzw[1];
			int w = nzw[2];
			var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			if (n == 1) {
				Console.WriteLine(Math.Abs(a[0] - w));
			} else {
				int dif0 = Math.Abs(a[n - 1] - w);
				int dif1 = Math.Abs(a[n - 1] - a[n - 2]);
				if (dif0 > dif1) {
					Console.WriteLine(dif0);
				} else {
					Console.WriteLine(dif1);
				}
			}
		}
	}
}

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

int main()
{
    int A[3];
    cin >> A[0] >> A[1] >> A[2];

    int ans = 0;
    if( A[1] < A[0] && A[2] < A[0] ){
        if( A[1] < A[2] )
            ans = abs(A[0]-A[2]) + abs(A[2]-A[1]);
        else
            ans = abs(A[0]-A[1]) + abs(A[1]-A[2]);
    } else if( A[0] < A[1] && A[2] < A[1] ){
        if( A[0] < A[2] )
            ans = abs(A[1]-A[2]) + abs(A[2]-A[0]);
        else
            ans = abs(A[1]-A[0]) + abs(A[0]-A[2]);
    } else {
        if( A[0] < A[1] )
            ans = abs(A[2]-A[1]) + abs(A[1]-A[0]);
        else
            ans = abs(A[2]-A[0]) + abs(A[0]-A[1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]

P_dict = itertools.permutations(sorted(P), N)
P_dict = [i for i in list(P_dict)]
Q_dict = itertools.permutations(sorted(Q), N)
Q_dict = [i for i in list(Q_dict)]

ans = 0
for i in range(len(P_dict)):
  if list(P_dict[i]) == P:
    ans += (i+1)
  if list(Q_dict[i]) == Q:
    ans -= (i+1)

print(ans if ans >= 0 else -ans)

Measured memory_bytes: 13368
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<Long, Long> map = new HashMap<>();
      map.put(0L, 1L);
      long sum = 0;
      long cnt = 0;
      for(int i = 0; i < n; i++) {
        sum += sc.nextInt();
        if(map.containsKey(sum)) {
          cnt += map.get(sum);
        }
        map.put(sum, map.getOrDefault(sum, 0L) + 1);
      }
      System.out.println(cnt);
  }
}

Measured memory_bytes: 99852
import Control.Arrow
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.List

fact n = product [1..n]

solve :: Int -> VU.Vector (Int, Int) -> Double
solve n vs = (/ fromIntegral (fact n)) $ sum $ map dist $ permutations [0 .. n - 1]
  where
    dist (i:j:ks) =
      let (x1,y1) = vs VU.! i
          (x2,y2) = vs VU.! j
      in sqrt (fromIntegral $ (x1-x2)^2 + (y1-y2)^2) + dist (j:ks)
    dist _ = 0.0

main = do
  let readInt = fmap (second B.tail) . B.readInt

  n   <- (VU.! 0) . VU.unfoldrN 1 readInt <$> B.getLine
  xys <-
    VU.replicateM n
    $   (\vec -> (vec VU.! 0, vec VU.! 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine

  print $ solve n xys


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){
 
	int a, b, c;
	cin >> a >> b >> c;
	
	bool f = false;
	f |= (a == 7 && b == 5 && c == 5);
	f |= (a == 5 && b == 7 && c == 5);
	f |= (a == 5 && b == 5 && c == 7);
	
	cout << (f ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    string s;
    while(cin>>s){
        if(s[2]==s[3] && s[4]==s[5])
            cout<<"Yes"<<endl;
        else 
            cout<<"No"<<endl;
    } 
    return 0;
}

Measured memory_bytes: 256
/*input
10000 3 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	ll n,a,b;
	cin>>n>>a>>b;
	if(b%2==a%2){
		cout<<(b-a)/2<<'\n';
		return 0;
	}
	cout<<min(1+abs(a-1)+abs(b-1),1+abs(a-n)+abs(b-n))/2<<'\n';
	return 0;
}


Measured memory_bytes: 256
n = int(input())
c = input()
a = 0
b = 0
for i in range(n):
    if c[i] == 'R':
        a+=1
ans = max(a, b)
for i in range(n):
    if c[i] == 'R':
        a-=1
    else:
        b+=1
    now = max(a, b)
    ans = min(ans, now)
print(ans)

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

struct b {
	long long x, y;

	b(long long x, long long y) : x(x), y(y) {}

	long long mn() {
		return min(x, y);
	}

	bool operator< (b t) const {
		return min(x, y) < min(t.x, t.y);
	}
};

long long n;
long long cnt;
vector<long long> a(200005);
priority_queue<b, vector<b>> pq;

main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.begin() + n);
	pq.emplace(a[n - 1], a[n - 1]);
	for (long long i = n - 2; i >= 0; i--) {
		b temp = pq.top();
		cnt += temp.mn();
		pq.pop();
// cout << temp.x << ' ' << temp.y << endl;
		pq.emplace(temp.x, a[i]);
		pq.emplace(temp.y, a[i]);
	}
	cout << cnt << endl;
	return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = 998244353;
const int N = 100005;

int mpower(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1){
            res = (res*x) % p;
        }
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int inv2 = mpower(2,M-2,M);
        int n,s;
        cin>>n>>s;
        int a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        int dp[n][s+1] = {};
        dp[0][0] = mpower(2,n,M);
        if(a[0] <= s)dp[0][a[0]] = mpower(2,n-1,M);
        for(int i=1;i<n;i++)
        {
            for(int j=0;j<=s;j++)dp[i][j] = dp[i-1][j];
            for(int j=s;j>=0;j--)
            {
                if(j-a[i] >= 0)
                {
                    int add = (dp[i-1][j-a[i]]*inv2)%M;
                    dp[i][j] += add;
                    dp[i][j] %= M;
                }
            }
        }
        cout<<dp[n-1][s]<<endl;
    }
    return 0;
}


Measured memory_bytes: 74016
// std::set を用いた解
#include <iostream>
#include <set>
using namespace std;

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    set<int> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < N; ++i) {
        values.insert(d[i]); // 挿入します
    }

    // set のサイズを出力します
    cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	TLong a,b;
	scanf("%lld%lld",&a,&b);
	if(a * b < 0)	puts("Zero");
	else if(a < 0 && b < 0 && (b - a + 1) % 2)	puts("Negative");
	else puts("Positive");
	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  ll n,m;cin>>n>>m;
  vector<ll>rui(n,0);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    if(i==0)rui[i]=a;
    else 
    rui[i]+=rui[i-1]+a;
  }
  for(int i=0;i<n;i++){
    rui[i]%=m;
  }
  sort(ALL(rui));
  for(int i=0;i<n-1;i++){
    ll cnt=1;
    while((i<n-1)&&rui[i]==rui[i+1]){cnt++;i++;}
    if(rui[i]==0)
      ans+=cnt*(cnt+1)/2;
    else ans+=(cnt-1)*cnt/2;
  }
  if(n==1){
    if(rui[0]==0)cout<<1<<endl;
    else cout<<0<<endl;
  }else
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  int sum=1;
  
  for(int i=0;i<N;i++){
    if(sum<K)
      sum=sum*2;
    else
      sum+=K;
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import sys

 
H,W,K = list(map(int, input().split()))

c = []
for i in range(H):
    c.append(list(map(str, input().split()))[0])

o = 0
p = 0

for i in range(2**H):
    for j in range(2**W):
        o = 0
        for b,n in enumerate(bin(i)[2:].zfill(H)):
            for a,l in enumerate(bin(j)[2:].zfill(W)):
                if n == '0' and l == '0' and c[b][a]=='#':
                    o += 1
        if o == K:
            p += 1
print(p)


Measured memory_bytes: 74564
from itertools import permutations as p

from scipy.sparse.csgraph import floyd_warshall

n, m, r = map(int, input().split())
R = list(map(int, input().split()))
l = [[0]*n for _ in range(n)]
for _ in range(m):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1
  l[a][b] = c
  l[b][a] = c
F = floyd_warshall(l)

ans = float("inf")
for v in p(R):
  temp = 0
  for i in range(r-1):
    temp += F[v[i]-1][v[i+1]-1]
  ans = min(ans, temp)
  
print(int(ans))

Measured memory_bytes: 15300
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        Stack<int> stack = new Stack<int>();
        foreach (var item in Console.ReadLine().Split())
        {
            if (item.All(char.IsDigit))
            {
                stack.Push(int.Parse(item));
                continue;
            }
            switch (item)
            {
                case "+":
                    stack.Push(stack.Pop() + stack.Pop());
                    break;
                case "-":
                    stack.Push(-stack.Pop() + stack.Pop());
                    break;
                case "*":
                    stack.Push(stack.Pop() * stack.Pop());
                    break;
            }
        }
        Console.WriteLine(stack.Pop());
    }
}


Measured memory_bytes: 18656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, m, x;
vi c;
vvi a;
int ans = INF;
vi buy = {};

void dfs() {

	if (buy.size() < n)rep(i, 2) {
		buy.push_back(i);
		dfs();
		buy.pop_back();
	}
	else {
		int cost = 0;
		vi learn(m, 0);
		rep(i, n)if (buy[i]) {
			cost += c[i];
			rep(j, m)learn[j] += a[i][j];
		}
		bool ok = true;
		rep(i, m)if (learn[i] < x)ok = false;
		if (ok)ans = min(ans, cost);
	}
	return;

}

int main() {

	cin >> n >> m >> x;
	c.resize(n);
	a.resize(n, vi(m));
	rep(i, n) {
		cin >> c[i];
		rep(j, m)cin >> a[i][j];
	}

	dfs();
	
	if (ans == INF)ans = -1;
	cout << ans << endl;

}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		string s;
		cin >> n >> s;
		vector<vector<int>> start(26);
		int ret = 0;
		queue<pair<int, int>> q[2];
		for(int i=0; i < n; i++){
			start[s[i]-'a'].emplace_back(i);
			unordered_set<int> si;
			while(!q[i%2].empty()){
				auto tmp = q[i%2].front();
				q[i%2].pop();
				int pos = tmp.first;
				int len = tmp.second;
				if((s[pos+1] == s[i]) && (pos + len + 1 < i)){
					q[(i+1)%2].push(make_pair(pos+1, len+1));
					si.insert(pos+1);
					updmax(ret, len+1);
				}
			}
			for(int j = 0; j < start[s[i]- 'a'].size()-1; j++){
				if(si.end() != si.find(start[s[i]-'a'][j]))continue;
				q[(i+1)%2].push(make_pair(start[s[i]-'a'][j], 1));
				ret = max(ret, 1);
			}			
		}
		cout << ret << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 696
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, readline().split())
H = list(map(int, readline().split()))

maps = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int1, readline().split())
    maps[A].append(B)
    maps[B].append(A)

cnt = 0
for i, ma in enumerate(maps):
    acc = 0
    for m in ma:
        acc = max(acc, H[m])
    if H[i] > acc:
        cnt += 1
print(cnt)


Measured memory_bytes: 29576
#include <bits/stdc++.h>
using namespace std;
 
int bubblesort(vector<int> &a){
    int cnt=0,n=a.size(),flag=1;
    while(flag){
        flag=0;
        for(int j=n-1;j>0;j--){
            if(a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                flag=1;
                cnt++;
            }
        }
    }
    return cnt;
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans=bubblesort(a);
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i<n-1) cout << " ";
    }
    cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3096
// Aizu Vol0 0056: Goldbach's Conjecture
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  50000
#define SQRT 223     // sqrt(MAX)
#define HALF 25000

int table[MAX + 5];
int combi[MAX+MAX];

int main()
{
	int i, j, n;
	char buf[100];

	for (i = 2; i <= SQRT; i++) {
		if (!table[i]) {
			for (j = i + i; j <= MAX; j = j + i) table[j] = 1;
		}
	}
	combi[4] = 1;
	for (i = 3; i < MAX; i+=2) {
		if (!table[i]) combi[i + 2] = 1;
	}
	for (i = 3; i < HALF; i+=2) {
		if (!table[i]) {
			for (j = i; j < MAX; j++) {
				if (!table[j]) combi[i + j]++;
			}
		}
	}
#if 0
	for (i = 2; i < 200; i++) printf("[%d]=%d\n", i, combi[i]);
#endif

	while (1) {
		gets(buf);
		n = atoi(buf);
		if (n == 0) break;
		printf("%d\n", combi[n]);
	}
	return 0;
}

Measured memory_bytes: 1016
#pragma warning (disable:4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;
void solve() {
	unordered_map<int, int>L, R;
	int N, X, D; cin >> N >> X >> D;
	int absD = abs(D);
	ll ans = 0;
	if (D == 0) {
		map<int, int>mp2;
		REP(k, N + 1) {
			int now = k * X;
			if (!mp2.count(now)) {
				ans++;
				mp2[now] = 1;
			}
		}
		print(ans);
		return;
	}
	REP(k, N + 1) {
		int r = ((X*k) % D);
		//r = (r + D) % D;
		int rem = X * k - r;
		r = (r + absD) % absD;

		int le = k * (k - 1) / 2;
		int ri = N * (N - 1) / 2 - (N - k)*(N - k - 1) / 2;
		if (r < 0) {
			print(0); exit(0);
		}
		le += rem / D; ri += rem / D;
		if (le>ri)swap(le, ri);
		if (!R.count(r) || !L.count(r) || le>R[r] || ri<L[r]) {
			ans += ri - le + 1;
		}
		else {
			if (ri>R[r]) {
				if (le < L[r]) {
					ans += ri - le + 1 - (R[r] - L[r] + 1);
				}
				else ans += ri - le + 1 - (R[r] - le + 1);
			}
			else if (le<L[r]) {
				if (ri > R[r]) {
					ans += ri - le + 1 - (R[r] - L[r] + 1);
				}
				ans += ri - le + 1 - (ri - L[r] + 1);
			}
		}
		if (!R.count(r) || !L.count(r)) {
			R[r] = ri; L[r] = le;
		}
		else {
			R[r] = max(R[r], ri);
			L[r] = min(L[r], le);
		}
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 16784
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i) 
#define per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)

#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define maxn 400020
#define N 8000020
using namespace std;

int n;
int a[maxn];
int sum=0;
int main()
{ cin>>n;
  rep(i,0,n-1) {cin>>a[i];sum+=a[i];}
  int idex=0;
  rep(i,1,n-1)
   {if(abs(a[i]*n-sum)<abs(a[idex]*n-sum))  idex=i;
   }
   cout<<idex<<endl;
return 0;
} 

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val max = sc.nextInt() match {
    case 1 => 1
    case x =>
      (for {
        i <- 2.to(x)
        j <- 2.to(x)
      } yield math.pow(i, j).toInt).filter(_ <= x).max
  }
  println(max)
}


Measured memory_bytes: 76852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	if(k==1)
	{
		cout<<"0";
	}
	else
	{
		cout<<n-k;
	}
}

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

#define pb push_back
#define ll long long
 
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
    ll x, y, z, a, b;
    cin >> x >> y >> z >> a >> b;
    ll m1 = a * x + b * y;
    ll m2 = 2 * a * z + (b - a > 0 ? b - a : 0) * y;
    ll m3 = 2 * b * z + (a - b > 0 ? a - b : 0) * x;
    // cout << m1 << " " << m2 << " " << m3 << '\n';
    ll ans = min({m1, m2, m3});
    cout << ans;
	return 0;
}

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

int main(){
    int s1,h,m,s;
    cin >> s1;
    h = s1 / 3600;
    m = s1 % 3600 / 60;
    s = s1 % 60;
    cout << h <<":"<< m <<":"<< s << endl;
}


Measured memory_bytes: 3084
N = int(input())
P = (input().split())
Q = (input().split())

# 全探索
import itertools
S = [str(i) for i in range(1,N+1)]
All = itertools.permutations(S) # これですべての要素を選択する場合の順列
I = []
for a in All:
    a = list(a) # tupleだから
    a = ''.join(a)
    I.append(a)
I.sort()
ind_p = I.index(''.join(P))
ind_q = I.index(''.join(Q))
print(abs(ind_p-ind_q))




Measured memory_bytes: 6040
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>

int main() {
	long long int x;
	std::cin >> x;
	long long int nSum = 0;
	nSum += x / 11*2;
	if (x % 11 >= 7) {
		nSum += 2;
	}
	else if (x % 11 == 0) {
		nSum += 0;
	}
	else {
		nSum += 1;
	}
	std::cout << nSum << std::endl;
	return 0;
}
	


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

int main(){
	vector<ll> a(3);
	int k;
	cin >> a.at(0) >> a.at(1) >> a.at(2);
	cin >> k;
	sort(a.begin(), a.end());
	rep(i, k) a.at(2) *= 2;
	ll ans = 0;
	rep(i, 3) ans += a.at(i);
	cout << ans << endl;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,d[400111],x;
double p[200111];
double dp[200111];
//sum[200111];
double solve(int n,double D)
{
	if(n==1)return D;
	else
	{
		return D+solve(n-1,D*1.0*(2*n-1)/n/2+3*D*1.0/n/2);
	}
}
int main()
{
	getiii(n,d[1],x);
	int D=2*d[1]+(2*n-1)*x;
	double ans=solve(n,D)/2;
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8576
#include <cstdio>  
#include <iostream>  
using namespace std;  
int pd[110][110];  
int main(){  
    int h,w,n,x=0;  
    cin>>h>>w>>n;  
    int a[n];  
    for(int i=0;i<n;i++)
{  
        cin>>a[i];  
        for(int j=0;j<a[i];j++){  
            if((x/w)%2==0) pd[x/w][x%w]=i+1;  
            else pd[x/w][w-(x%w)-1]=i+1;  
            x++;  
        }  
    }  
    for(int i=0;i<h;i++){  
        for(int j=0;j<w;j++){  
            if(j==w-1) printf("%d\n",pd[i][j]);  
            else printf("%d ",pd[i][j]);  
        }  
    }  
    return 0;
}  

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void){
  int n;
  int d;
  int jud[101]={0};
  int count = 0;
  
  cin >> n;
  
  for(int i = 0 ; i < n ; i++){
    cin >> d;
    jud[d] = 1;
  }
  
  for(int i = 1 ; i <= 100 ; i++){
    if(jud[i] == 1) count++;
  }
  
  cout << count << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


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

    int x; cin >> x;

    int ans = 0;
    if (x == 0) {
        ans = 1;
    } else {
        ans = 0;
    }
    cout << ans << '\n';

    return 0;
}


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

int main(){
    int price = 700;
    int add = 0;
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s[i]=='o') add += 100;
    }
    cout << price + add << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
bool kaibun(string s){
    string r = "";
    for(int i = s.size() -1; i >= 0; i--){
        r.push_back(s[i]);
    }
    return s == r;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    int N = S.size();
    int x = (N+3)/2 - 1;
    //cerr << S << " "  <<  S.substr(0,(N-1)/2) << " " <<S.substr(x, N - x) << endl;
    if(kaibun(S)  && kaibun(S.substr(0,(N-1)/2)) && kaibun(S.substr(x, N - x))){
        cout << Yes << endl;
    }
    else{
        cout << No <<  endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long lmao[4005];
	lmao[0]=100ll;
	for(int i=1; i<4005; i++)
		lmao[i]=(long long)floor((double)lmao[i-1]*101.0/100.0);
	long long x; cin>>x;
	for(int i=1; i<4005; i++){
		if(lmao[i]>=x){
			cout<<i<<endl;
			return 0;
		}
	}
}

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

int main(){
    int a[3], tmp;
    cin >> a[0] >> a[1] >> a[2];

    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 3; j++){
            if(a[j] < a[i]){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}


Measured memory_bytes: 3096