akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>

using namespace std;



int main(){

	long long int ans=0;
	long long int n;
	cin>>n;

	int count=0;
	while(n>0){
		count+=1;
		n/=2;
	}

	ans=1;
	for(int i=0;i<count;i++){
		ans*=2;
	}

	cout<<ans-1;


	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
main(){
  double a,b,c,d,e,f,a2,b2,c2,d2,e2,f2,x,y,t,u;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=-1)
    {
      d2=a2=a*d;
      e2=e*a;
      b2=d*b;
      c2=c*d;
      f2=f*a;
      t=b2-e2;
      u=c2-f2;
      y=u/t;
      b2=e2=b*e;
      a2=e*a;
      c2=c*e;
      d2=d*b;
      f2=f*b;
      t=a2-d2;
      u=c2-f2;
      x=u/t;
      if(x==-0.000)
	x=0;
      if(y==-0.000)
	y=0;
      printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 0
import re
import copy
import numpy as np
import queue

def accept_input():
    H,W = map(int,input().split())
    S = []
    for _ in range(H):
        S.append(input())
    return H,W,S


def widthsearch(q):
    movelist = [(0,1),(0,-1),(1,0),(-1,0)] 
    while not q.empty():
        pack = q.get()
        y = pack[0][0]
        x = pack[0][1]
        num = pack[1]
        if S[y][x] == "g":
            return num
        for move in movelist:
            if y+move[0] == -1 or y + move[0] == H or x+move[1] == -1 or x + move[1] == W:
                continue
            elif visitedlist[y+move[0]][x+move[1]] == 1:
                continue
            elif S[y+move[0]][x+move[1]] == "#":
                continue
            else:
                visitedlist[y+move[0]][x+move[1]] = 1
                q.put(((y+move[0],x+move[1]),num+1))
    return -1

H,W,S = accept_input()
for i in range(len(S)):
    if i == 0:
        S[i] = "s"+S[i][1:]
    if i == H-1:
        S[i] = S[i][:W-1]+"g"
siro = H*W
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            siro -= 1
q = queue.Queue()
q.put(((0,0),0))
#幅優先探索
visitedlist = np.zeros((H,W))
visitedlist[0][0] = 1
result = widthsearch(q)
if result == -1:
    print(-1)
else:
    print(siro-result-1)


Measured memory_bytes: 27156
#include<stdio.h>
#define A 1 B 2 C 3 D 4 E 5 F 6
int main(){
   char arr1[100], arr2[100] ;
   int count=0,count2=0,count3=0 , i , j ;
    scanf("%s",&arr1 ) ;
    scanf("%s",&arr2) ;
   for(i = 0 ;arr1[i] != '\0' ; i++){
        count++;
   }

   for(i = 0 ;arr2[i] != '\0' ; i++){
        count2++;
   }
      if(count==count2){
   for(i = 0 , j= count2-1 ; i < count && j>=0 ; i++,j--){
        if(arr1[i] == arr2[j]){
            count3++;
        }
    }

    if(count3 == count){
        printf("YES");
    }else{
        printf("NO");
    }

    }


}


Measured memory_bytes: 128
def c_one_stroke_path(N, M, E):
    import itertools
    edge = [[] for j in range(N + 1)]
    for a, b in E:
        edge[a].append(b)
        edge[b].append(a)

    ans = 0
    # 頂点1を除いて、この順番に頂点を回れるか試す
    route = itertools.permutations(range(2, N + 1), N - 1)
    for r in route:
        if not r[0] in edge[1]:
            # 頂点1からrが示す次の行き先に行くことができない
            continue
        count = 0
        for i in range(len(r) - 1):
            if not r[i + 1] in edge[r[i]]:
                # 次の行き先に行くことができなかった
                break
        else:  # すべての頂点を訪れることができた
            ans += 1
    return ans

N,M = [int(i) for i in input().split()]
E = [[int(i) for i in input().split()] for j in range(M)]
print(c_one_stroke_path(N, M, E))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N; cin >> N;
  for (int n = 0; 4 * n <= N; n++) {
    for (int m = 0; 7 * m <= N; m++) {
      if (4 * n + 7 * m == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
  	if(a>=13) cout << b << endl;
  	else if(a>=6) cout << b/2 << endl;
  	else cout << 0 << endl;
}


Measured memory_bytes: 3612
fn main() {
    let l = read::<f64>();
    let a = l / 3.0;
    println!("{}", a*a*a);
}

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

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int k = vs[0];
            int x = vs[1];

            StringBuilder sb = new StringBuilder();
            for (int i = x - (k - 1); i <= x + (k - 1); i++) {
                sb.Append($"{i} ");
            }
            Console.WriteLine(sb.ToString().Trim());
        }
    }
}


Measured memory_bytes: 13396
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

class graph{
public:
    vector<ll>* adjList;
    vector<ll> dp;
    ll n;
    graph(ll x){
        n = x;
        adjList = new vector<ll>[x];
        dp.resize(x);
    }
    void addEdge(ll u, ll v){
        adjList[u].push_back(v);
    }
    ll solve(ll node){
        if(dp[node]!=-1) return dp[node];
        bool isLeaf = true;
        ll best = 0;
        for(auto ch: adjList[node]){
            isLeaf = false;
            best = max(best, solve(ch));
        }
        return dp[node] = (isLeaf)?0:best+1;
    }
};

int main(){
    cpp();
    ll n, m;
    cin>>n>>m;
    graph g(n);
    for(auto& ele: g.dp) ele=-1;
    for(ll i=0; i<m; i++){
        ll u, v;
        cin>>u>>v;
        g.addEdge(--u, --v);
    }
    for(ll i=0; i<n; i++){
        g.solve(i);
    }
    cout<<(*max_element(g.dp.begin(), g.dp.end()))<<endl;
    return 0;
}






Measured memory_bytes: 11548
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%i",&n);
	vector<string> t(n);
	vector<int> d(n);
	for(int i=0;i<n;i++) cin>>t[i]>>d[i];
	string taj;
	cin>>taj;
	for(int i=0;i<n;i++)
	{
		if(taj.size()==t[i].size())
		{
			bool ok=1;
			for(int j=0;j<taj.size();j++) if(taj[j]!=t[i][j]) ok=0;
			if(ok)
			{
				int sum=0;
				for(int k=i+1;k<n;k++) sum+=d[k];
				printf("%i\n",sum);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	x := readInt()
	if x < 1200 {
		println("ABC")
	} else {
		println("ARC")
	}
}


Measured memory_bytes: 640
from collections import Counter
import math
mod = 10**9+7
N,M = map(int,input().split())
factors = []
f = 2
while M%f==0:
    M//=2
    factors.append(f)
f = 3
while f*f<=M:
    if M%f==0:
        M//=f
        factors.append(f)
    else:
        f+=2
if M!=1:
    factors.append(M)
count = Counter(factors)

def choose(n,k):
    import math
    return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
ans = 1
for v in count.values():
    ans *= choose(N+v-1,N-1)
    ans %= mod
print(ans)


Measured memory_bytes: 114396
def resolve():
	D = int(input())
	# 各コンテストタイプの満足度の下がりやすさ
	c = list(map(int, input().split()))
	# 各日程に各コンテストを開催した時の満足度増加量
	s = []
	for i in range(D):
		s.append(list(map(int, input().split())))
	# 最後に各コンテストを開催した日
	l = [-1] * 26
	# 満足度
	v = 0
	for d in range(D):
		# この日に開催されるコンテストタイプ
		t = int(input())-1
		l[t] = d
		# 増加分加算
		v += s[d][t]
		# 不満足分減算
		for i in range(26):
			v -= c[i] * (d - l[i])
		print(v)
resolve()

Measured memory_bytes: 9024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

	    Scanner sc = new Scanner(System.in);
	    int A = sc.nextInt();
	    int B = sc.nextInt();
	    int C = sc.nextInt();

	    if ((A == B) && (A == C)) {
	    	System.out.print("No");
	    } else if ((A == B) || (A == C) || (B == C)){
	    	System.out.print("Yes");
	    } else {
	    	System.out.print("No");
	    }

	  }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
   
   boolean seven = false;
   if(s1==7||s2==7||s3==7) seven =true;
   
   boolean five = false;
   if(s1==5&&s2==5||s2==5&&s3==5||s3==5&&s1==5) five = true;
 
   if(seven&&five) System.out.println("YES");
   else System.out.println("NO");
 }
}

Measured memory_bytes: 20944
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define INF 2e9
using namespace std;
const int N=1e6+1;
const int mod=1e9+7;
ll fastexp(ll base,ll exp){
	base%=mod;
	ll ans=1;
	while(exp>0){
		if(exp&1){
			ans*=base;
			ans%=mod;
		}
		base*=base;
		base%=mod;
		exp/=2;
	}
	return ans;
}
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int arr[N];
int main() {
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(a==0){
		cout << "1";
	}
	else if(b == 0){
		cout << "2";
	}
	else if(c == 0){
		cout << "3";
	}
	else if(d == 0){
		cout << "4";
	}
	else 
		cout << "5";
	return 0;
}
   







Measured memory_bytes: 3580
#include<stdio.h>
#include<stdlib.h>
int arr[200000]={0};

int cmp(const void *a,const void *b)
{
	return (*(int *)a-*(int *)b);//升序
} 
int hasDup(int arr[], int n)
{
    int i;
    for(i=0; i<n-1; i++)
            if(arr[i] == arr[i+1])
                return 1; 
    return 0;
}
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&arr[i]);
	qsort(arr,n,sizeof(int),cmp);
	if(hasDup(arr, n) == 1)
		printf("NO");
	else 
		printf("YES");
}

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

int main(){
  string s;
  cin >> s;
  int a_count = 0;
  int b_count = 0;
  int c_count = 0;
  rep(i, s.size()){
    if (s[i] == 'a') a_count++;
    if (s[i] == 'b') b_count++;
    if (s[i] == 'c') c_count++;
  }
  int max_count = max(a_count, max(b_count, c_count));
  int min_count = min(a_count, min(b_count, c_count));
  if (max_count - min_count <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;
                      
}


Measured memory_bytes: 512
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < pair < ll, ll >, ll >&a,const pair < pair <ll, ll>, ll >&b){
    return (a.ff.ff > b.ff.ff ||(a.ff.ff == b.ff.ff && a.ss > b.ss));
}

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }
    ll f = 0;
    ren(i, n-1){
        if(a[i] <= a[i+1]);
        else{
            ll x = a[i] - a[i+1];
            if(x != 1){
                f = 1;
                break;
            }
            else{
                a[i] = a[i+1];
            }
        }
    }
    if(f){
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
    }
    return 0;
} 

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

flag = 1
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      flag = 0

if flag == 1:
  print('APPROVED')
else:
  print('DENIED')
    

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextLong();
		int ret = 0;
		for(int i = 0 ; i < N ; ++i){
			long x = sc.nextLong();
			long y = sc.nextLong();
			long dist = x * x + y * y;
			if(dist <= D * D){
				++ret;
			}
		}
		System.out.println(ret);
	}
}


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

int main()
{
    int i, N, A, num = 0, min = 0;

    cin >> N;

    for (i = 0; i < N; i++)
    {
        cin >> A;
        while (1)
        {
            if (A % 2 == 0)
            {
                num++;
                A = A / 2;
            }else{
                break;
            }
        }
    if (i == 0 || num < min){
        min = num;
    }
        num = 0;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
function main(lines) {
    const input = lines.split('\n')

        let result = ''
    for(let i=0; i<input.length; i++){
        const arrayNum = input[i].split(' ').map(Number)
        const H = arrayNum[0]
        const W = arrayNum[1]
        const edgeLine = Array(W+1).join('#').slice(0,W) + '\n'
        const innerLine = '#' + Array(W).join('.').slice(1,W+3) + '#' + '\n'

        for(let i=1; i<H+1; i++){
            result += (i===1 || i===H) ? edgeLine : innerLine
        }

        if(H === 0 && W === 0) break;
        result += '\n'
    }
    console.log(result.trim() + '\n')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 16076
#include <bits/stdc++.h>
    #define ll long long
    #define sz(a) int((a).size())
    #define fr(i,n) for(int i=0;i<n;i++) 
    #define rf(i,n) for(int i=1;i<=n;i++)
    #define jdb(i,v) for(__typeof(v.begin())i=v.begin(); i!=v.end();i++)
    #define present(c,a) (find(all(c),a) != c.end())
    #define spresent(c,a) (c.find(a)!=c.end())
    #define no(s,c) s.count(c)  
    #define pb push_back 
    #define eb emplace_back
    #define mp make_pair
    #define all(c) (c).begin(),(c).end()
    #define MAX INT_MAX 
    using namespace std;
    #define f first
    #define s second
    int M = 1000000007;
    bool x[1000001],y[1000001];
    int main() 
    { 
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int a,b,c;
        cin>>a>>b>>c;
        int h = min(a,b);
        int br = min(max(a,b),c);
        int area = 0.5*br*h;
        cout<<area<<endl;
        return 0; 
    }

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

#define long long ll;

bool checkStr(const string &str, const char c) {
  for (int i=0; i<(int)str.length(); i++) {
    if (c != str[i]) return false;
  }
  return true;
}

void replaceChar(string &str, const char c) {
  string t="";
  for (int i=0; i<(int)str.length()-1; i++) {
    if (str[i] == c || str[i+1] == c) {
      t += c;
    } else {
      t += str[i];
    }
  }
  str = t;
}

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

  int min=100;
  for (int i=0; i<(int)s.length(); i++) {
    int ans=0;
    string tmp = s;
    while(!checkStr(tmp, s[i])) {
      //cout << tmp << endl;
      replaceChar(tmp, s[i]);
      ans++;
    }
    min = (min>ans)?ans:min;
  }

  cout << min << endl;
  return 0;
}


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

int main(){
  int n,m,a[100],b,pt[100] = {};
  cin >> n >> m;
  for(int i = 0;i < m;i++) cin >> a[i];
  for(int i = 0;i < m;i++){
    int cnt = 0;
    for(int j = 0;j < n;j++){
      cin >> b;
      if(b == a[i]) pt[j]++;
      else cnt++;
    }
    pt[a[i] - 1] += cnt;
  }
  for(int i = 0;i < n;i++) cout << pt[i] << endl;
  return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
	int h[300];
	int w[300];
	int i = 0;
	int j = 0;
	int k,l;
	
	while(1){
		scanf("%d %d",&h[i],&w[i]);
		if(h[i] == 0 && w[i] == 0){
			break;
		}
		for(k = 0;k < h[i];k++){
			for(l = 0;l < w[i];l++){
				printf("#");
			}
			printf("\n");
		}
		++i;
		printf("\n");
	}

	
	return(0);
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) ll t;cin>>t; while(t--)
ll mod=1000000007;
int main()
{
  ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//w(t){
ll i,n,s=0;cin>>n;
   ll a[n],suffix[n+1]={0};
   for(i=0;i<n;i++)
  {
  cin>>a[i];
  }
  for(i=n-1;i>=0;i--)
  suffix[i]=suffix[i+1]+a[i];//cout<<suffix[i];
    for(i=0;i<n;i++)
{//s+=a[i]*suffix[i+1];
    
        s+=((a[i]%mod)*(suffix[i+1]%mod))%mod;
       /// s+=s;
    }
 
cout<<s%mod<<endl;
}

Measured memory_bytes: 6804
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

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

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

int main(){
	int n, k;
	cin >> n >> k;
	cout << n-k+1 << endl;
	return 0;
}


Measured memory_bytes: 256
def lcm(a, b):
    return a // gcd(a, b) * b
 
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
 
while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break


Measured memory_bytes: 5600
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	char str[105];
	scanf("%s",str);
	int pc=-1,pf=-1;
	for(int i=0;i<strlen(str);i++){
		if(str[i]=='C'){
			pc=i;
			break;
		}
	}
	for(int i=strlen(str)-1;i>=0;i--){
		if(str[i]=='F'){
			pf=i;
			break;
		}
	}
	if(pc<pf&&pc!=-1){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp
import itertools
import functools
import math

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N,K = ria()
if N<=K:
  print(1)
else:
  print(math.ceil((N-K)/(K-1))+1)

Measured memory_bytes: 4204
N = int(raw_input().replace("\n", ""))

w_list = []

flag = True
for i in xrange(N):
    w_i = raw_input().replace("\n", "")
    if i >= 1:
        w_last = w_list[i-1]
        if w_last[-1] != w_i[0] and flag == True:
            flag = False
        if w_i in w_list and flag == True:
            flag = False
    w_list.append(w_i)

if flag:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 2568
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define s(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int a, b, c, x, y, abc = 0, agc = 0; 
	ll ans = 0,arc=0;
	cin >> a >> b >> c >> x >> y;
	if (a + b <= c * 2)ans = a * x + b * y;
	else {
		abc = min(x, y);
		agc = max(x, y);
		ans += c * 2 * abc;
		if (x > y)ans += a * (agc - abc);
		else ans += b * (agc - abc);
	arc = c*2 * agc;
	ans = min(arc, ans);
    }
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#%%
n = int(input())
d = list(map(int, input().split()))

count = [0] * (10**5)
for i in range(n):
    count[d[i]] += 1

#print(count[:10])

ans = 1
inf = 998244353

for i in range(len(count)):
    if i == 0:
        pass
    else:
        tmp = pow(count[i-1], count[i], inf)
        ans *= tmp
        ans %= inf

if d[0] != 0:
    ans = 0
if count[0] != 1:
    ans = 0

print(ans)

Measured memory_bytes: 14396
// C - Subarray Sum
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, k, s, w, ans = 0, count = 0;
  string t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> k >> s;
  vlli d;
  a = 1000000000;
  while (d.size() < n)
  {
    if (d.size() < k)
    {
      d.push_back(s);
    }
    else if (s >= a)
    {
      d.push_back(1);
    }
    else
    {
      d.push_back(s + 1);
    }
  }
  rep(i, 0, n)
  {
    cout << d[i] << " ";
  }
  cout << endl;
}

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


string solve(const string& s){
    if(s.size() == 0)
        return "";

    char head = s[0];
    string tail = s.substr(1);

    int p = 0;
    int c = 0;
    //cout << "head" << head << endl;
    if(head == '['){
            int b = 1;
            int i = 1;
            while(b > 0){ // XXX
                if(s[i] == '[')
                    b++;
                else if(s[i] == ']')
                    b--;
                i++;
            }
            string res1 = solve(s.substr(1, i - 2));
            reverse(begin(res1), end(res1));
            return res1 + solve(s.substr(i));
    }else if(head == '+'){
            string res2 = solve(tail);
            if(res2[0] == '?')
                return "?" + res2.substr(1); //XXX
            else{
                if(res2[0] == 'Z'){
                    return "A" +  res2.substr(1);
                }else{
                    return string({(char)(res2[0] + 1)}) +  res2.substr(1);
                }                
            }
    }else if(head == '-'){
        //cout << "-" << endl;
            string res3 = solve(tail);
            if(res3[0] == '?')
                return "?" + res3.substr(1); //XXX
            else{
                //cout << res3[0] << endl;
                if(res3[0] == 'A'){
                    //cout << "hoeg" << endl;
                    return "Z" +  res3.substr(1);
                }else{
                    return string({(char)(res3[0] - 1)}) +  res3.substr(1);
                }
            }
    }else if(head == '?'){            
            return "?" + solve(tail);
    }else{
            return head + solve(tail);
    }
}

int main(){
    string s;
    while(cin >> s, s != "."){
        string res = solve(s);
        for(int i = 0; i < s.size(); i++){
            if(res[i] == '?')
                res[i] = 'A';
        }
        cout << res << '\n';
    }
    return 0;
}

Measured memory_bytes: 3020
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble()*(Math.PI/180);
        
        double s =(a*b*Math.sin(c))/2;
        double l = Math.sqrt(a*a + b*b -2*a*b*Math.cos(c))+a+b;
        double h = (2*s)/a;
        
        System.out.printf("%f\n%f\n%f\n",s,l,h);
    }
}


Measured memory_bytes: 28172
n,m=map(int,input().split())
a=[]
for i in range(0,n):
    b,c=map(int,input().split())
    a.append([b,c])
a.sort()
number=0
for i in range(0,len(a)):
    if number<m:
        number=number+a[i][1]
        l=i
answer=0
kosu=0
for k in range(0,l):
    answer=answer+a[k][0]*a[k][1]
    kosu=kosu+a[k][1]
answer=answer+a[l][0]*(m-kosu)
print(answer)

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class Combi {
private:
  v(ll) fac, inv, finv;
  void init(int N) {
    fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }
public:
  Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
  ll Cmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }
  ll Pmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }
};

Combi C = Combi(100000);
int N,K;
vvi ch;
ll dfs(int x,int parent) {
  if(x == 0) {
    ll res = C.Pmod(K-1,sz(ch[x]));
    rep(i,sz(ch[x])){
      if(ch[x][i] != parent) {
        res *= dfs(ch[x][i],x);
        res %= MOD;
      }
    }
    return res;
  }
  if(sz(ch[x]) == 0) {
    return 1;
  }
  ll res = C.Pmod(K-2,sz(ch[x])-1);
  rep(i,sz(ch[x])){
    if(ch[x][i] != parent) {
      res *= dfs(ch[x][i],x);
      res %= MOD;
    }
  }
  return res;
};
  
int main() {
  cin >> N >> K;
  ch = vvi(N);
  rep(i,N-1) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    ch[a].push_back(b);
    ch[b].push_back(a);
  }
  cout << K * dfs(0,-1) % MOD << endl;
  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll H,N;
  cin>>H>>N;
  vector<vector<ll>> vec(N,vector<ll>(2));
  ll dp[20040];
  for(ll i=0;i<N;i++){
    ll a,b;
    cin>>a>>b;
    vec.at(i).at(0)=a;
    vec.at(i).at(1)=b;
  }
  for(ll i=1;i<=20040;i++){
    dp[i]=0;
  }
  for(ll i=1;i<=H;i++){
    for(ll j=0;j<N;j++){
      if(j==0){dp[10020+i]=dp[10020+i-vec.at(j).at(0)]+vec.at(j).at(1);}
      else{
        ll a=dp[10020+i-vec.at(j).at(0)]+vec.at(j).at(1);
        if(a<dp[10020+i]){dp[10020+i]=a;}
      }
    }
  }
  cout<<dp[10020+H]<<endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if((A + B) > (C + D)){
    cout << "Left" << endl;
  }else if((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b,c,d,e;
  cin >> a;
  b = a / 1000;
  c = a / 100 %10;
  d = a /10 %10;
  e = a % 10;
  if(c==b && d==c) cout <<"Yes" << endl; 
  else if(d==c && d==e) cout <<"Yes" << endl; 
  else cout <<"No" << endl;
}

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

int main() {
  string A,B,C;
  cin >> A >> B >> C;
  
  char a = A.at(0);
  char b = B.at(0);
  char c = C.at(0);
  
  cout << a << b << c << endl;
  }


Measured memory_bytes: 256
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int ans = 0;
    for (int i = 0; i< 3; i++) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> l(n);
  int d = 0;
  int count = 0;
  for(int i=0;i<n;i++){
    cin>>l.at(i);
    d+=l.at(i);
    if(d>x){
      break;
    }
    else{
      count++;
    }
  }
  
  cout<<count+1<<endl;
  
  return 0;
}

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

int main(){
    int N, x;
    cin >> N >> x;
    int a[110];

    for(int i = 0; i < N; ++i) cin >> a[i];
    
    sort(a, a + N);

    int stock = x;
    int res = 0;
    for(int i = 0; i < N - 1; ++i){

        if(a[i] <= stock){
            stock -= a[i];
            res++;
        }
    }
    if(stock == a[N - 1]) res++;

    cout << res << endl;
}

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

ans = 0
cnt = True
while cnt:
    temp = [a[i]%2 for i in range(len(a))].count(1)
    if temp == 0:
        ans += 1
        a = [a[i]//2 for i in range(len(a))]
    else:
        cnt = False
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

#define min(a, b) ((a) < (b)?(a):(b))

int ans[55], i, j, k, x;
int main(){
    for(i = 0;i <= 50;i++){
	ans[i] = 1 << 30;
    }
    for(i = 0;i <= 25;i++){
	for(j = 0;j <= 17;j++){
	    for(k = 0;k <= 10;k++){
		int p = i * 2 + j * 3 + k * 5;
		if(p > 50)continue;
		int price;
		price = (i / 5) * 4 * 380 + (i % 5) * 380;
		price += (j / 4) * 550 * 4 * 85 / 100 + (j % 4) * 550;
		price += (k / 3) * 3 * 850 * 88 / 100 + (k % 3) * 850;
		ans[p] = min(price, ans[p]);
	    }
	}
    }
    while(scanf("%d", &x), x){
	printf("%d\n", ans[x / 100]);
    }
    return 0;
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
const int INF=1e+9;
int main(){
	int n;cin>>n;
	int dp[n];dp[0]=0;
	r(i,1,n+1){
		dp[i]=INF;
		int memo=1;
		while(memo<=i){
			dp[i]=min(dp[i],dp[i-memo]+1);
			memo*=6;
		}
		memo=1;
		while(memo<=i){
			dp[i]=min(dp[i],dp[i-memo]+1);
			memo*=9;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    vecin(vec);
    sort(all(vec));
    ll ans = 0;
    for(ll i = 1;i < N;i++){
        ans += vec[N - i / 2 - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();string s;cin>>s;
    ll cnt=0;
    for(ll i=0;i<n-2;++i){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')++cnt;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{

	int N,i,j,ans=0;

	cin >> N;

	int D[N];

	for(i=0;i<N;i++)
	{

		cin >> D[i];

	}

	for(i=0;i<N-1;i++)
	{
		for(j=i+1;j<N;j++)
		{
			
			ans=ans+D[i]*D[j];

		}

	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double x,y,diff;
	x=0.5*(h*60+m);
	y=6*m;
	diff=abs(x-y);
	diff=min(360-diff,diff);
	double res;
	res=a*a+b*b-2*a*b*cos((diff*pie)/180);
	res=pow(res,0.5);
	printf("%0.21f",res);
}

Measured memory_bytes: 4416
/**
n,m=map(int,input().split())
yakusuu=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    yakusuu.append(m//i)
    if m//i==i:continue
    yakusuu.append(i)
ans=0
for y in yakusuu:
  if y<n:continue
  if m%y==0:
    ans=max(ans,m//y)
print(ans)
**/

#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() {
  ll n,m;
  cin >> n >> m;
  vector<ll> yakusuu;
  for (ll i=1;i*i<=(m);i++){
    if (m%i==0) yakusuu.push_back(i);
    if (i!=m/i) yakusuu.push_back((ll)m/i);
  }
  int ans =0;
  for(ll y:yakusuu){
    if(y<n) continue;
    if(m%y==0){
      if(m/y>ans) ans=m/y;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long n, k;
long long a[105] = {0};
// dp[i][j]: person-i, remains-j
long long dp[105][100005] = {0};

long long solve();

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 0; i <= a[0]; ++i)
    dp[0][k - i] = a[0] + 1 - i;
  for(int i = 1; i < n; ++i)
    for(int j = 0; j <= k; ++j) {
      if(j != 0) dp[i][j] = dp[i][j - 1];
      dp[i][j] += dp[i - 1][min(k, j + a[i])];
      dp[i][j] %= N;
      if(j != 0) dp[i][j] -= dp[i - 1][j - 1];
      while(dp[i][j] < 0) dp[i][j] += N;
      dp[i][j] %= N;
    }
  return dp[n - 1][0];
}

Measured memory_bytes: 80128
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    int n;cin>>n;
    vector<int>a,b;
    a.resize(n);
    rep(i,n)cin>>a[i];
    b = a;
    sort(a.begin(),a.end());
    map<int,ll>memo;
    memo[a[0]]=1;
    auto itr=memo.begin();
    rep(i,n-1){
        if(a[i+1] == itr->first)memo[a[i]]++;
        else {
          memo[a[i+1]]=1;
          itr++;
        }
    }
    ll sum = 0;
    for(auto it=memo.begin();it!=memo.end();it++){
        sum += it->second*(it->second-1)/2;
    }
    rep(i,n){
        cout << sum-memo[b[i]]+1 <<endl;
    }
}

Measured memory_bytes: 11008
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
using namespace std;

int main(){
    int n,m;
    while(cin >> n){
        map<string,vector<int> > v;
        stack<vector<int> > s;
        bool ans = true;
        for(int i=0;i<n;i++){
            string str;
            int a,b;
            cin >> str >> a >> b;
            for(int j=a;j<=b;j++) v[str].push_back(j);
        }
        cin >> m;
        for(int i=0;i<m;i++){
            string str;
            cin >> str;
            if(!ans) continue;
            if(str[0] >= '0' && str[0] <= '9'){
                vector<int> v2(1,0);
                for(int j=0;j<str.size();j++){
                    v2[0] *= 10;
                    v2[0] += str[j] - '0';
                }
                s.push(v2);
            }
            else if(str.size() == 1 && (str[0] == '+' || str[0] == '-' || str[0] == '*' || str[0] == '/')){
                vector<int> a,b,c;
                b = s.top();
                s.pop();
                a = s.top();
                s.pop();
                for(int j=0;j<a.size();j++){
                    for(int k=0;k<b.size();k++){
                        int res;
                        if(str[0] == '+') res = (a[j] + b[k]) % 256;
                        else if(str[0] == '-') res = (a[j] - b[k] + 256) % 256;
                        else if(str[0] == '*') res = (a[j] * b[k]) % 256;
                        else if(b[k] != 0) res = (a[j] / b[k]) % 256;
                        else{
                            ans = false;
                            break;
                        }
                        vector<int>::iterator it = lower_bound(c.begin(),c.end(),res);
                        if(c.empty() || *it != res) c.insert(it,res);
                    }
                    if(!ans) break;
                }
                s.push(c);
            } else s.push(v[str]);
        }
        cout << (ans ? "correct" : "error") << endl;
    }
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T1,typename ...T2>
void dbg(const T1& p1, const T2&...pr){ cerr << p1 << ": "; dbg(pr...);}

bool chpal(string s){
	int n=sz(s);
	rep(i,n/2) if(s[i]!=s[n-1-i]) return false;
	return true;
}

int main(){
	
	string s;
	cin >>s;
	
	if(chpal(s)) {puts("0"); return 0;}
	if(sz(s)==2){
		if(s[0]==s[1]) puts("0");
		else if(s[0]=='x' || s[1]=='x') puts("1");
		else puts("-1");
		return 0;
	}
	int cha[30]={};
	for(auto x: s) cha[x-'a'];
	int cto=0;
	rep(i,26) if(i!=23 && cha[i]%2) cto++;
	if(cto >=2)  {puts("-1"); return 0;}
	string s2;
	for(auto z: s) if(z !='x') s2+=z;
	if( !chpal(s2)) {puts("-1"); return 0;}
	
	int l=0,r=sz(s)-1, ans=0;
	while(l<=r){
		if(s[l] == s[r]){
			l++; r--;
		}else if(s[l]=='x'){
			l++; ans++;
		}else{
			r--; ans++;
		}
	}
	
	
	cout<< ans <<"\n";
	
	return 0;
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = [0] * n
    for i in range(n - 1):
        res[A[i] - 1] += 1

    for i in res:
        print(i)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n,p;cin>>n>>p;
	ll even=0,odd=0;
	rep(i,n){
		int a;cin>>a;
		if(a%2==0) even++;
		else odd++;
	}
	if(odd==0){
		ll ans=pow(2,even);
		if(p==0) cout<<ans<<"\n";
		else cout<<0<<"\n";
	}
	else{
		ll ans=pow(2,odd-1)*pow(2,even);
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {


    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();//n?????°????????????
		int cards[][] = new int[4][13];
		for(int cnt1 = 0; cnt1 < 4; cnt1++){//cards???????????????????????????
			for(int cnt2 = 0; cnt2 < 13; cnt2++){
				cards[cnt1][cnt2] = 0;
			}
		}
		for(int cnt_card = 0; cnt_card < n; cnt_card++){//??°????????\?????????
			String mark = scan.next();
			int val = scan.nextInt();
			switch(mark){//cards?????????????????£??????????????????????????§????????????
				case "S":
					cards[0][val - 1] = 1;
					break;
				case "H":
					cards[1][val - 1] = 1;
					break;
				case "C":
					cards[2][val - 1] = 1;
					break;
				case "D":
					cards[3][val - 1] = 1;
			}
		}
		for(int cnt1 = 0; cnt1 < 4; cnt1++){
			for(int cnt2 = 0; cnt2 < 13; cnt2++){
				if(cards[cnt1][cnt2] == 0){//cards??????????????????????????????
					switch(cnt1){//cnt1???????????????????¢??????????????????????
					case 0:
						System.out.println("S " + (cnt2 + 1));
						break;
					case 1:
						System.out.println("H " + (cnt2 + 1));
						break;
					case 2:
						System.out.println("C " + (cnt2 + 1));
						break;
					case 3:
						System.out.println("D " + (cnt2 + 1));
					}
				}
			}
					
		}
    scan.close();
	}
}

Measured memory_bytes: 26216
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
pair<int, int> b[100010];
int main(){
    int n, k;
    while(cin>>n){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
            b[i]=mk(a[i], i+1);
        }
        sort(b, b+n);
        for(int i=0; i<n; ++i){
            cout<<b[i].sc<<" ";
        }
        cout<<endl;
    }
  return 0;
}




Measured memory_bytes: 2048