akhauriyash/Code-Regression huggingface dataset:
def main():
    n, m, c = map(int, input().split())
    bb = list(map(int, input().split()))
    res = 0
    for _ in range(n):
        aa = list(map(int, input().split()))
        if sum(a * b for (a, b) in zip(aa, bb)) + c > 0:
            res += 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>

void print_array(int* array, int n) {
  for (int i = 0; i < n; ++i) {
    if (i) {
      std::cout << " ";
    }
    std::cout << array[i];
  }
  std::cout << std::endl;
}

int main(int argc, char *argv[])
{
  int n;
  std::cin >> n;
  int* a = new int[n];
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  print_array(a, n);

  int v, j;
  for (int i = 1; i < n; ++i) {
    v = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    print_array(a, n);
  }
  return 0;
}



Measured memory_bytes: 3136
// -*- coding:utf-8 -*-
#include<iostream>
#include<stack>

int main(){
  std::stack<int> stk;
  int ans;
  std::string str;
  while(std::cin >> str){
    if(str == "+" || str == "-" || str == "*"){
      int b = stk.top(); stk.pop();
      int a = stk.top(); stk.pop();
      if(str == "+"){
	stk.push(a + b);
      }else if(str == "-"){
	stk.push(a - b);
      }else{
	stk.push(a * b);
      }
    }else{
      int a = 0;
      const char* c = str.c_str();
      for(unsigned long i = 0; i < str.length(); i++){
      	a = a * 10 + (c[i] - '0');
      }
      stk.push(a);
    }
  }
  
  std::cout << stk.top() << std::endl;
 
  return 0;
}



Measured memory_bytes: 3152
// AOJ 0615 Cake 2
// 2018.2.27 bal4u

#include <stdio.h>

int a[2002];
long long dp[2002][2002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, f, i, l, r, nl, nr;
	long long k, ans;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();

	f = n & 1;
	for (i = 0; i < n; i++) {
		nl = 0, r = i-1;
		if (i == 0) nr = n-2; else nr = i-2;
		for (l = 0; l < n; l++) {
			if (++ r == n)  r = 0;
			if (++nl == n) nl = 0;
			if (++nr == n) nr = 0;

			if (f) {
				dp[l][r] = dp[nl][r] + a[l];
				       k = dp[l][nr] + a[r];
				if (k > dp[l][r]) dp[l][r] = k;
			} else {
				if (a[l] > a[r]) dp[l][r] = dp[nl][r];
				else             dp[l][r] = dp[l][nr];
	        }
		}
		f = !f;
	}

	ans = 0;
	r = n-2; for (l = 0; l < n; l++) {
		if (++r == n) r = 0;
		if (dp[l][r] > ans) ans = dp[l][r];
	}
	printf("%lld\n", ans);
	return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, r; std::cin >> n >> r;
  if (n >= 10)
    std::cout << r << "\n";
  else
    std::cout << r + 100 * (10 - n) << "\n";
}


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

const int N = 1e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

bool OK[N][2];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a > b) swap(a, b);
		if (a == 1) OK[b][0] = 1;
		if (b == n) OK[a][1] = 1;
	}
	bool ok = false;
	for (int i = 1; i <= n; i ++) {
		
		if (OK[i][0] && OK[i][1]) {
			ok = true;
		}
	}
	printf("%sPOSSIBLE\n", not ok ? "IM" : ""); 
}


Measured memory_bytes: 640
#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++)
typedef long long ll;

int main(){
  int h,w;
  while(1){
    cin >> h >> w;
    if(w==0 && h==0)break;
    rep1(i,h){
      rep1(j,w){
        if(i==1 || i==h || j==1 || j==w)cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3116
#include <iostream>

using namespace std;

int main() {
	int k = 0, s = 0;
	cin >> k >> s;
	int ans = 0;
	int z = 0;
	for (int x = 0; x <= k; ++x) {
		for (int y = 0; y <= k; ++y) {
			z = s - x - y;
			if (z >= 0 && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

    vector<int> a(N + 1);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }

    std::sort(a.begin(), a.end(), greater<int>());

    int Alice = 0;
    for (int i = 0; i < N; i = i + 2){
        Alice = Alice + a[i] - a[i + 1];
    }

    cout << Alice << endl;

    return 0;
}

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

int main()
{
	int n;
	int *arry = NULL;
	int d = 0;
	int i = 0;
	int max = 0;
	int sec = 0;
	int maxIndex = 0;

	if (scanf("%d", &n) != 0)
		;

	for (; i < n; i++)
	{
		if (scanf("%d", &d) != 0);
		if (d > max)
		{
			max = d;
			maxIndex = i;
		}
		else if(d > sec)
		{
			sec = d;
		}
	}

	for (i = 0; i < n; i++)
	{
		if (maxIndex == i)
			printf("%d\n", sec);
		else
			printf("%d\n", max);
	}

	return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
main()
{
	char S[3];
	int i,a=0,b=0;
	for(i=0;i<3;i++)
	{
		scanf("%c",&S[i]);
	}
	for(i=0;i<3;i++)
	{
		if(S[i]=='A')
		a++;
		else
		b++;
	}
	if(a>=1&&b>=1)
	printf("Yes");
	else
	printf("No");
}

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

namespace ConsoleApplication59
{
    class Program
    {
        static void Main(string[] args)
        {
            int a=int.Parse(Console.ReadLine());
            if (a < 1200)
                Console.WriteLine("ABC");
            else Console.WriteLine("ARC");
        }
    }
}


Measured memory_bytes: 2648
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
count=0
def battle(a,ai,b):
  if a+ai <= b:
    count=a+ai
    ai=0
  elif a<=b:
    ai=ai-(b-a)
    count=b
  else:
    ai=ai
    count=b
  return ai,count
  
for i in range(n):
  c=0
  a[i+1],c=battle(a[i],a[i+1],b[i])
  count += c
 
print(count)


Measured memory_bytes: 18624
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int ch(char c) {
	switch (c) {
	case 'A':
		return 1;
	case 'C':
		return 2;
	case 'G':
		return 3;
	default:
		return 4;
	}
}

long long gethash(string s) {
	long long sum = 0;int p = 1;
	REP(i, s.size()) {
		sum += ch(s[i])*p;
		p *= 4;
	}
	return sum;
}

int main() {
	vector<int> h(1 << 24, 0);
	int n;

	cin >> n;
	REP(i, n) {

		string s, t;
		cin >> s >> t;
		if (s[0] == 'i') {
			h[gethash(t)-1] = 1;
		}
		else if (s[0] == 'f') {
			if (h[gethash(t)-1]) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 68140
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
check=[False]*n
now=0
order=[]
while True:
    now=a[now]-1
    order.append(now)
    if check[now]:
        break
    else:
        check[now]=True
order2=[]
now=order[-1]
while True:
    now=a[now]-1
    order2.append(now)
    if now==order[-1]:
        break
if k<=len(order):
    print(order[k-1]+1)
else:
    k-=len(order)
    x=k%len(order2)
    print(order2[x-1]+1)



Measured memory_bytes: 112048
#include <iostream>
#include <cstdio>
#include <cctype>
#include <map>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<char, int> alpha_cnt;
    char moji;
    while ((moji = getchar()) != EOF){
        //if(moji == '.') break;
        if(isupper(moji) != 0){
            alpha_cnt[tolower(moji)] += 1;
        }else{
            alpha_cnt[moji] += 1;
        }
    }
    
    //output
    for(int i = 97; i <= 122; i++){
        char alphabet = char(i);
        printf("%c : %d\n", alphabet, alpha_cnt[alphabet]);
    }
}



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

int n;
map<int,int> s;
int kaisuu(int n){
    if(n==0) return 0;
    if(n<6) return n;
    if(s.count(n)) return s[n];
    int min=n;
    for(int i=6;i<=n;i*=6){
        int x=kaisuu(n-i)+1;
        if(min>x) min=x;
    }
    for(int i=9;i<=n;i*=9){
        int x=kaisuu(n-i)+1;
        if(min>x) min=x;
    }
    s[n]=min;
    return min;
}
int main(){
    cin>>n;
    cout<<kaisuu(n);
}

Measured memory_bytes: 3072
n,m = input().split()
N = int(n)
M = int(m)
k = []
for i in range(N):
    s = input().split()
    s = [int(i) for i in s]
    s.pop(0)
    k += s
likesum = 0
for i in range(1,M+1):
    if k.count(i) == N:
        likesum += 1
print(likesum)

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

#define PI 3.141592653589793

int main() {
    int a, b, x;
    cin >> a >> b >> x;

    double theta = 0.0;
    if(pow(a, 2)*b / 2 < x) theta = atan(2*(pow(a, 2)*b - x) / pow(a, 3))*180.0 / PI;
    else                    theta = atan(a*pow(b, 2) / (2*x))*180.0 / PI;
    
    cout << setprecision(10) << theta << endl;
    

    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
$ret = array_pad([], $n, 0);
for($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    $ret[$a - 1]++;
    $ret[$b - 1]++;
}
foreach($ret as $key => $v) echo $v. "\n";

Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    vector<ll> a(n,0);
    ll prev=INF;
    int count=0;
    int maxcount=0;
    rep(i,n)
    {
        cin>>a[i];
        
        
    }
    rep(i,n-1)
    {
        if(a[i+1]<=a[i])
        {
            count++;
        }
        else
        {
           maxcount=max(maxcount,count);
           count=0; 
        }
        prev=a[i+1];

    }
    maxcount=max(maxcount,count);
    cout<<maxcount;

}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    int a,b,plus,minus,multi,res;
    
    scanf("%d %d",&a,&b);
    
    plus = a + b;
    minus = a - b;
    multi = a * b;

    
    if(plus > minus)
    {
        if(plus > multi)
        {
            res = plus;
        }
        else
        {
            res = multi;
        }
    }
    else if(multi > minus)
    {
        res = multi;
    }
    else
    {
        res = minus;
    }
    printf("%d\n",res);
    
    return 0;
}



Measured memory_bytes: 128
#include<stdio.h>
  
#define MAX 100000
  
int parent(int);
int left(int);
int right(int);
  
int main(){
  int i,n,A[MAX+1];
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);
  
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= n)printf("left key = %d, ",A[left(i)]);
    if(right(i) <= n)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  
  return 0;
}
  
int parent(int i){
  
  return i/2;
}
  
int left(int i){
  
  return 2 * i;
}
  
int right(int i){
  
  return 2 * i + 1;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <math.h>

#define pai 3.14159265358979323846264338327950288

typedef struct {
  double x;
  double y;
}XY;

void kock(int,XY,XY);

int main(){
  int n;
  XY p1={0.0,0.0};
  XY p2={100.0,0.0};

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);
  
  kock(n,p1,p2);
  
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}

void kock(int n,XY p1,XY p2){
  XY s,t,u;
  
    if(n==0)return;

    s.x = (double)((double)2*p1.x + (double)1*p2.x)/(double)3;
    s.y = (double)((double)2*p1.y + (double)1*p2.y)/(double)3;
    t.x = (double)((double)1*p1.x + (double)2*p2.x)/(double)3;
    t.y = (double)((double)1*p1.y + (double)2*p2.y)/(double)3;
    u.x = (double)(t.x - s.x)*cos(pai/(double)3) - (double)(t.y - s.y)*sin(pai/(double)3) + s.x;
    u.y = (double)(t.x - s.x)*sin(pai/(double)3) + (double)(t.y - s.y)*cos(pai/(double)3) + s.y;

    kock(n-1,p1,s);

    printf("%.8f %.8f\n",s.x,s.y);

    kock(n-1,s,u);

    printf("%.8f %.8f\n",u.x,u.y);

    kock(n-1,u,t);

    printf("%.8f %.8f\n",t.x,t.y);

    kock(n-1,t,p2);
}



Measured memory_bytes: 2108
use proconio::{input, marker::Usize1};

const M: u64 = 1000_000_007;

fn main() {
    input! {
        n: usize,
        xy: [(Usize1, Usize1); n - 1],
    }

    println!("{}", DP::new(n, &xy).calc(0, 0));
}

struct DP {
    dp: Vec<Option<(u64,u64)>>,
    t: Vec<Vec<usize>>,
}

impl DP {
    fn new(n: usize, xy: &Vec<(usize, usize)>) -> DP {
        let mut t = vec![vec![]; n];
        for &(x, y) in xy {
            t[x].push(y);
            t[y].push(x);
        }

        DP {
            dp: vec![None; n],
            t: t,
        }
    }

    fn calc(&mut self, i: usize, p: usize) -> u64 {
        let v = if let Some(v) = self.dp[i] {
            v
        } else {
            let mut v = (1, 1);
            for j in self.t[i].clone() {
                if j != p {
                    v.0 = v.0 * self.calc(j, i) % M;
                    v.1 = v.1 * self.dp[j].unwrap().0 % M;
                }
            }
            self.dp[i] = Some(v);
            v
        };
        (v.0 + v.1) % M
    }
}



Measured memory_bytes: 26300
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
    // Your code here!
    int a, b; cin >> a >> b;
    int ans;
    if (a > b) ans = (a+b)/2;
    else ans = (b+a)/2;
    if (abs(a - ans) == abs(b - ans)) cout << ans << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
//---------------------------

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


  string s;cin >> s;
  int data[26] = {};
  int n = s.size();
  REP(i,n){
    int num = s[i] - 97;
    data[num]++;
  
  }
  REP(i,26){
    if (data[i] == 0) {
      P((char)(i+97));
      break;
    }
    if (i == 25 && data[i] != 0) {
      P("None");
      break;
    }
  }


  return 0;
}


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

typedef long long ll;
const ll N = 2e5 + 100, inF = 2e16;

ll n, a[N], l[N], l_back[N], r[N], r_back[N], help[N], help_back[N];

ll go(ll l) {
	return !(l & 1);
}

ll come(ll l) {
	return (l == 0? 2: l & 1);
}

void build() {
	fill(help, help + N, inF);
	fill(help_back, help_back + N, inF);
	help[n - 1] = help_back[n - 1] = 0;
	ll sum = 0;
	for (int i = n - 2; i >= 0; i--) {
		ll len = a[i];
		sum += len;
		help[i] = go(len) + help[i + 1];
		help_back[i] = come(len) + help_back[i + 1];
		help_back[i] = min(help_back[i], sum);
		help[i] = min(help[i], help_back[i]);
	}
}

int main() {// 1 base
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	n++;
	for (int i = 0; i < n - 1; i++)
		cin >> a[i];
	build();
	for (int i = 0; i < n; i++)
		r[i] = help[i], r_back[i] = help_back[i];
	reverse(a, a + n - 1);
	build();
	for (int i = 0; i < n; i++)
		l[i] = help[n - i - 1], l_back[i] = help_back[n - i - 1];
	ll ans = inF;
	for (int i = 0; i < n; i++)
		ans = min(ans, min(l_back[i] + r[i], r_back[i] + l[i]));
	cout << ans;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	sort(p.begin(), p.end());
	int out = p[n - 1] / 2;
	rep(i, n - 1) out += p[i];
	cout << out << endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %.5lf\n",d,r,f);
    return 0;
}



Measured memory_bytes: 2100
N = int(input())
A = list(map(int, input().split()))
from collections import defaultdict
D = [0]*2001

#N =7
#A =[218, 786, 704, 233, 645, 728, 389]

A = sorted(A)
#print(A)
ans = 0

for i in range(N):
    tmp = 0
    for j in range(A[i]+1,2001):
        tmp += D[j]
        ans += D[j]
    #print(tmp)
    for j in range(i):
        D[A[i]+A[j]] += 1
print(ans)

Measured memory_bytes: 41708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
typedef vector<string> vs;
typedef pair<l_l,ll> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    ll n;cin>>n;
    ll r=(n+999)/1000;
    ll ans=r*1000-n;
    cout<<ans<<endl;
    return 0;
}

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


int main(void){
 int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(A >= B && A >= C){
    cout << B + C + A * pow(2,K);
  }
  else if(B >= A && B >= C){
    cout << A + C + B * pow(2,K);
  }
  else
    cout << A + B + C * pow(2,K);
  
  
  return 0;
}

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

const int N=1005,M=40005,oo=1e9;
struct edge{
	int di,nextt,ed;
}e[M];
int son[N],nedge,cur[N],deep[N],n,m;
inline void aedge(int a,int b,int c){
	e[++nedge].nextt=son[a];
	son[a]=nedge;
	e[nedge].ed=b;
	e[nedge].di=c;
}
inline void insert(int a,int b,int c){
	aedge(a,b,c); aedge(b,a,0); //cout<<a<<" "<<b<<endl;
}
inline bool bfs(int s,int t){
	for(int i=1;i<N;i++)deep[i]=oo;
    for(int i=1;i<N;i++)cur[i]=son[i];
    deep[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int now=q.front();q.pop();
        for(int tmp=son[now];tmp;tmp=e[tmp].nextt)
            if(deep[e[tmp].ed]>=oo&&e[tmp].di){deep[e[tmp].ed]=deep[now]+1,q.push(e[tmp].ed);}
    }
    return deep[t]<oo;
}
int dfs(int now,int t,int limit){
    if(!limit||now==t) return limit;
    int flow=0,f;
    for(int tmp=cur[now];tmp;tmp=e[tmp].nextt){
        cur[now]=tmp;
        if(deep[e[tmp].ed]==deep[now]+1&&(f=dfs(e[tmp].ed,t,min(limit,e[tmp].di)))){
            flow+=f; limit-=f; e[tmp].di-=f; e[((tmp-1)^1)+1].di+=f; if(!limit)break;
        }
    }
    return flow;
}
inline int dinic(int s,int t){
    int ans=0;
    while(bfs(s,t))ans+=dfs(s,t,oo);
    return ans;
}
inline int read(){
	int x=0;char ch=getchar();bool positive=1;
	for(;!isdigit(ch);ch=getchar())	if(ch == '-')	positive=0;
	for(;isdigit(ch);ch=getchar())	x=x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a;putchar('-');
	}
	write(a);puts("");
}
const int P=10000005;
int tot,q[P/10];
bool heshu[P],a[P];
int b[205];
int main(){
    n=read();
	for(int i=2;i<P;i++){
		if(!heshu[i])q[++tot]=i;
		for(int j=1;j<=tot&&i*q[j]<P;j++){
			heshu[i*q[j]]=1; if(i%q[j]==0)break;
		}
	}
	tot=0;
	for(int i=1;i<=n;i++){
		int t=read(); a[t]^=1; a[t+1]^=1;
	}
	heshu[1]=1;
	int jb=0;
	for(int i=1;i<P;i++)if(a[i])b[++jb]=i;
	for(int i=1;i<=jb;i++)if(b[i]&1){
		for(int j=1;j<=jb;j++)if(b[j]%2==0){
			if(!heshu[abs(b[i]-b[j])]){insert(i,j,1);}
		}
	}
	int s=jb+1,t=jb+2;
	for(int i=1;i<=jb;i++)if(b[i]&1){insert(s,i,1); tot++; }else insert(i,t,1);
	int jj=dinic(s,t); 
	cout<<jj+(jb-jj*2)+((tot-jj)&1)<<endl;
}


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

typedef pair<int,int> P;
typedef pair<int,P> P2;

int main(){
  int t,p,r;
  int tid,pid,time;
  string mes;
  int wa[100][20];
  P2 team[100];

  while(cin >> t >> p >> r,(t||p||r)){
    for(int i=1;i<=t;i++)team[i] = P2(0,P(0,i));
    for(int i=1;i<=t;i++)
      for(int j=1;j<=p;j++)wa[i][j] = 0;

    for(int i=0;i<r;i++){
      cin >> tid >> pid >> time >> mes;
      if(mes == "CORRECT"){
	team[tid].first--;
	team[tid].second.first += wa[tid][pid]*1200 + time;
      }else{
	wa[tid][pid]++;
      }
    }
    
    sort(team+1,team+t+1);
    for(int i=1;i<=t;i++)
      cout << team[i].second.second << " " << -1*team[i].first <<
	" " << team[i].second.first << endl;
  }
}

Measured memory_bytes: 936
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<b)return 0; a=b; return 1;}

ll mod = 998244353;
ll dp[3002][3002];

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


    int n,s;
    cin>>n>>s;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll ans = 0;
    for(int i=0;i<n;i++){
        dp[i+1][0] = 1;
        dp[i+1][a[i]] = 1;
        for(int j=0;j<=s;j++){
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
            if(j + a[i] <= s){
                dp[i+1][j+a[i]] += dp[i][j];
                dp[i+1][j+a[i]] %= mod;
            }
        }
        ans = (ans + dp[i+1][s]) % mod;
        //cerr << i << " " << dp[i+1][s] << " " << ans << endl;
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

bool solve(vector<string> &data, int x, int y)
{
    rep(i, data.size()/2) {
        rep(j, data.size()/2) {
            /*
            cout << i+x << " " << j+y << " " << 
                data[i+x][j+y] << " " <<
                data[j+x][i+y] << endl;
                */
            if (data[i+x][j+y] != data[j+x][i+y])
                return false;
        }
    }
    return true;
}

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

    Int(n);
    vector<string> board(n * 2);
    rep(i, n) {
        cin >> board[i];
        board[i] += board[i];
        board[i + n] = board[i];
    }

    rep(i, board.size()) {
    //    cout << board[i] << endl;
    }

    int ans = 0;
   // cout << "call " << 0 << " " << 0 << endl;
    if (solve(board, 0, 0)) ans += n;
    Rep(i, n) {
    //    cout << "call " << i << " " << 0 << endl;
        if (solve(board, i, 0)) ans += n;
    }

    cout << ans << endl;

    return 0;
}






Measured memory_bytes: 640
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(a:isize);
    println!("{}", a+a*a+a*a*a);
}


Measured memory_bytes: 2136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	int n;
	cin>>n;
	cout<<24+(24-n)<<endl;
}

Measured memory_bytes: 256
module ABC125

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_C
  private :: calculate_gcd

  ! variables for this <module>
  integer(INT32), private              :: num_integers
  integer(INT32), private              :: gcd_max
  integer(INT32), private, allocatable :: list_integer (:)
  integer(INT32), private, allocatable :: list_gcd_fore(:)
  integer(INT32), private, allocatable :: list_gcd_rear(:)

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the number of given integers
    read(unit=INPUT_UNIT, fmt=*) num_integers

    ! STEP.02
    ! allocate the array to store the given integers
    allocate( list_integer (1:num_integers  ) )
    allocate( list_gcd_fore(0:num_integers+1) )
    allocate( list_gcd_rear(1:num_integers+1) )

    ! STEP.03
    ! read out the given integers
    read(unit=INPUT_UNIT, fmt=*) list_integer(1:num_integers)

    ! STEP.04
    ! calculate the greatesst common divisors
    list_gcd_fore(0               ) = 0_INT32
    list_gcd_rear(num_integers + 1) = 0_INT32

    do itr = 0_INT32, num_integers, 1_INT32
      list_gcd_fore(itr+1) = calculate_gcd( list_gcd_fore(itr), list_integer(itr) )
    end do

    do itr = num_integers, 1_INT32, -1_INT32
      list_gcd_rear(itr) = calculate_gcd( list_gcd_rear(itr+1), list_integer(itr) )
    end do

    gcd_max = 0_INT32

    do itr = 1_INT32, num_integers, 1_INT32
      gcd_max = max(gcd_max, calculate_gcd( list_gcd_fore(itr), list_gcd_rear(itr+1) ))
    end do

    ! STEP.05
    ! output the maximum greatest common divisor
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') gcd_max

    ! STEP.06
    ! deallocate the array to store the given integers
    deallocate( list_integer  )
    deallocate( list_gcd_fore )
    deallocate( list_gcd_rear )

    ! STEP.END
    return

  end subroutine task_C

  recursive function calculate_gcd (x, y) result(gcd)

    ! arguments for this <function>
    integer(INT32), intent(in) :: x, y

    ! return value of this <function>
    integer(INT32) :: gcd

    if (y .eq. 0_INT32) then
      gcd = x
    else
      gcd = calculate_gcd(y, mod(x, y))
    end if

    return

  end function calculate_gcd

end module ABC125


program main

  ! <module>s to import
  use, non_intrinsic :: ABC125

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        StringBuilder s = new StringBuilder(scan.next());
        StringBuilder t = new StringBuilder(scan.next());
        for (int i = 0; i < N; i++) {
            if (s.substring(i).equals(t.substring(0, N-i))) {
                System.out.println(2 * N - (N - i));
                return;
            }
        }
        System.out.println(2 * N);
    }
}


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

int main() {
	int n;
	cin >> n;
	pair<int, int>* coord = new pair<int, int>[n];
	int* keiro = new int[n];
	double av=0;
	double kaijo=1;
	for (int i = 0;i < n;i++) {
		cin >> coord[i].first >> coord[i].second;
		kaijo *= (i + 1);
		keiro[i] = i;
	}
	while (1) {
		for (int i = 0;i < n - 1;i++) {
			av += sqrt((pow(coord[keiro[i + 1]].first - coord[keiro[i]].first, 2) + pow(coord[keiro[i + 1]].second - coord[keiro[i]].second, 2)));
		}
		if (!next_permutation(keiro, keiro + n)) {
			break;
		}
	}
	cout.precision(8);
	cout << av / kaijo << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  cout << n*n*n << endl;



  return 0;
}


Measured memory_bytes: 764
from math import factorial
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x % 2, A))
counter = {'0': 0, '1': 0}
for a in A:
    c_a = str(a)
    counter[c_a] += 1
#print(counter)
ans = 2 ** counter['0']
tmp = factorial(counter['1'])
tmp_ans = 0
for i in range(0 + P,counter['1'] + 1,2):
    tmp_ans += tmp / factorial(i) / factorial(counter['1'] - i)
print(int(tmp_ans * ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

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

	vector <int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	
	rep(i,n){
		if((a[i]%2==0)&&((a[i])%3!=0)&&(a[i]%5!=0)) {
			cout<<"DENIED";
			return 0;
		}
	}
	cout<<"APPROVED";
}


Measured memory_bytes: 256
package main

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

func main() {
	var a, i int
	var list []int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		if i == 0 {
			a = num
			i++
			continue
		}
		list = append(list, num)
		if i == a {
			break
		}
		i++
	}
	list, d := bubbleSort(list, a)
	PrintArray(list)
	fmt.Println(d)
}

func bubbleSort(arr []int, n int) ([]int, int) {
	count := 0
	flag := true
	for i := 0; flag; i++ {
		flag = false
		for j := n - 1; j >= i+1; j-- {
			if arr[j-1] > arr[j] {
				arr[j-1], arr[j] = arr[j], arr[j-1]
				count++
				flag = true
			}
		}
	}
	return arr, count
}

// PrintArray is
func PrintArray(ar []int) {
	str := ""
	for i, a := range ar {
		str += fmt.Sprintf("%d", a)
		if i < len(ar)-1 {
			str += " "
		}
	}
	fmt.Println(str)
}


Measured memory_bytes: 1156
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String p = scan.nextLine();
		if(ringJad(s, p)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

	/**
	 * ringJad
	 * ?????????s???????????????p???????????????????????????
	 * @param s
	 * @param p
	 * @return 
	 */
	static boolean ringJad(String s, String p){
		Boolean jad = true;
		while(true){
			if(s.length() <= p.length()) s += s; break;
		}
		s += s;
		if(!(s.indexOf(p) >= 0)){
			jad = false;
		}
		return jad;
	}

}

Measured memory_bytes: 17312
n = int(input())
p = list(map(int, input().split()))

result = 0
for i in range(1,n-1):
    lp = [p[i-1], p[i], p[i+1]]
    lp.sort()
    if p[i] == lp[1]:
        result += 1
        
print(result)

Measured memory_bytes: 3060
#define M 99999
T[M],t[M];main(i,j,m,a,b,p,q){
for(i=2;i<M;i++)if(!T[i])for(j=i*2;j<M;j+=i)T[j]=1;
for(i=2,j=1;i<M;i++)if(!T[i])t[j++]=i;
for(;scanf("%d%d%d",&m,&a,&b),m;printf("%d %d\n",p,q))for(i=1;;i++)if(t[i]*t[i]>m)i=0,m--;else if(p=t[i],q=m/t[i],p*q==m&&!T[q]&&a*q<=b*p)break;
exit(0);}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
vector<string> bd;
VVI v;
const in inf=1e18;
in bst=inf;
in h,w,k;
queue<in> q;
VVI d={{0,1},{1,0},{0,-1},{-1,0}};
in ad(in x, in y){
  in mn=inf;
  mn=min(mn,x);
  mn=min(mn,y);
  mn=min(mn,h-1-x);
  mn=min(mn,w-1-y);
  return (mn+k-1)/k;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>h>>w>>k;
  bd.resize(h);
  in sx=-1;
  in sy=-1;
  forn(i,h){
    cin>>bd[i];
    forn(j,w){
      if(bd[i][j]=='S'){
	bd[i][j]='.';
	sx=i;
	sy=j;
      }
    }
  }
  bst=min(bst,ad(sx,sy));
  v.resize(h,VI(w,inf));
  v[sx][sy]=0;
  q.push(sx);
  q.push(sy);
  in x,y;
  while(!q.empty()){
    sx=q.front();
    q.pop();
    sy=q.front();
    q.pop();
    forn(i,4){
      x=sx+d[i][0];
      y=sy+d[i][1];
      if(x<0 || y<0 || x>=h || y>=w)
	continue;
      if(bd[x][y]=='#')
	continue;
      if(v[x][y]!=inf)
	continue;
      v[x][y]=v[sx][sy]+1;
      bst=min(bst,ad(x,y));
      if(v[x][y]==k)
	continue;
      q.push(x);
      q.push(y);
    }
  }
  cout<<bst+1<<endl;
  return 0;
}


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

using namespace std;
int can[30];
int main(){
    for(int i =0; i < 30; i++) can[i]=0;
    int n;
    cin >> n;
    for(int i =0;i <n;i++){
        string st;
        cin >> st;
        int arr[30];
        for(int e = 0; e < 30; e++){
            arr[e]=0;
        }
        for(int e = 0; e <st.length(); e++){
            if(i == 0){
                can[st[e]-'a']++;
            }else
            arr[st[e]-'a']++;
        }
        if(i==0)continue;
        for(int e = 0; e <30; e++){
            can[e] = min(can[e],arr[e]);
        }
    }
    string ans="";
    for(int i = 0; i < 30; i++){
        for(int e = 0; e < can[i]; e++){
             //   cout << "ASD";
            ans+=i+'a';
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    public static void Main(string[] args)
    {
        string str = Console.ReadLine();

        int count = 0;
        int currentNo = 1;

        while(currentNo <= int.Parse(str))
        {
            if (currentNo.ToString().Length % 2 != 0)
                count++;
            currentNo++;
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13140
n = int(input())
v = list(map(int,input().split()))
even = []
odd = []
for i in range(n//2):
  even.append(v[2*i]-1)
  odd.append(v[2*i+1]-1)
#print(even,odd)
EVEN = [[i,0] for i in range(100000)]
ODD = [[i,0] for i in range(100000)]
for i in range(n//2):
  EVEN[even[i]][1] += 1
  ODD[odd[i]][1] += 1
maxE = max(EVEN, key=lambda x:x[1])
maxO = max(ODD,  key=lambda x:x[1])
#print(maxE,maxO)
if maxE[0] != maxO[0]:
  print( n - maxE[1] - maxO[1] )
else:
  del EVEN[maxE[0]]
  del ODD[maxO[0]]
  canE = maxE[1] + max(ODD,  key=lambda x:x[1])[1]
  canO = maxO[1] + max(EVEN, key=lambda x:x[1])[1]
  if canE > canO:
    print( n - canE )
  else:
    print( n - canO )

Measured memory_bytes: 37836
#include <iostream> 
#include <map>
using namespace std; 
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long int
#define REPI(a, b, i, inc) for(ll i = a; i < b; i = i + inc)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define F first
#define S second
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define testi ll t; cin>>t; REP(tc,1,t+1)
#define vec vector
#define veci vector<int>
#define pi pair<int,int>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uset unordered_set
#define umap unordered_map

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	map<string,int> m;
       test{
       	string s;
       	cin>>s;
        m[s]++;

       }

       
       	cout<<"AC x "<<m["AC"]<<endl;
       	cout<<"WA x "<<m["WA"]<<endl;
       	cout<<"TLE x "<<m["TLE"]<<endl;
       	cout<<"RE x "<<m["RE"]<<endl;
       






			
 
			
	
	return 0;
}


Measured memory_bytes: 3228
#!/usr/bin/env python3
import sys
import math

def main():
    N = int(input())
    digit = math.floor(math.log10(N))
    c = N // 10**digit
    if N == (1 + c) * 10 ** digit - 1:
        print(9 * digit + c)
    else:
        print(9 * digit + c -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <stdio.h>
int main(void){
    int n;
    scanf("%d", &n);
    int a[100],i,j;
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for
    (j=0; j<n; j++){
        if(!(j==0))printf(" ");
        printf("%d",a[n-1-j]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2112
//JSD
#include<iostream>
#include<cmath>
#include<limits.h>
#define ll long long 
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll a[n+1]={0};
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	ll mi=INT_MAX;
	for(int i=1;i<n;i++){
		ll z=a[i]-a[0];
		ll w=a[n]-a[i];
		mi=min(abs(z-w),mi);
	}
	cout<<mi;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
pii a[100001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	llong sumA = 0, sumB = 0;
	vector<pii> as;
	for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
        sumA += a[i].first;
        sumB += a[i].second;
        as.emplace_back(a[i].first, i);
        as.emplace_back(a[i].second, i);
	}
	llong ans = min(sumA, sumB);
	set<int> mp;
	sort(as.begin(), as.end());
	llong sum = 0;
	for (int i = 0; i < n ; ++i) {
        sum += as[i].first;
        mp.insert(as[i].second);
	}
	if (mp.size() < n) ans = min(ans, sum);
	else {
        llong add;
        if (as[n - 1].second != as[n].second)
            ans = min(ans, sum - as[n - 1].first + as[n].first);
        else {
            ans = min(ans, sum - as[n - 1].first + as[n + 1].first);
            ans = min(ans, sum - as[n - 2].first + as[n].first);
        }
	}
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7280
import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]

n,m,k = map(int, input().split())
vw = []
graph = {}
for i in range(m):
    v,w = map(int,input().split())
    v -= 1
    w -= 1
    vw.append((v,w))
    if v not in graph:
        graph[v] = {}
    if w not in graph:
        graph[w] = {}
    graph[v][w] = graph[w][v] = 1

block = {}
for i in range(k):
    v,w = map(int , input().split())
    v -= 1
    w -= 1
    if v not in block:
        block[v] = {}
    if w not in block:
        block[w] = {}
    block[v][w] = block[w][v] = 1

cnt = [1 for _ in range(n+1)]
par = [i for i in range(n+1)]

for a,b in vw:
    aa = get_par(par, a)
    bb = get_par(par, b)
    if aa == bb:
        continue
    # unite
    if cnt[aa] > cnt[bb]:
        par[bb] = aa
        cnt[aa] += cnt[bb]
    else:
        par[aa] = bb
        cnt[bb] += cnt[aa]

bbb = []
for i in range(n):
    a = get_par(par, i)
    ans = cnt[a] - len(graph.get(i,[])) - 1
    # print(i, ans, cnt[a], graph.get(i,[]))
    if i not in block:
        bbb.append(ans)
        continue
    # print(block[i])
    for v in block[i].keys():
        if get_par(par, v) == a:
            ans -= 1
    bbb.append(ans)
print(*bbb)


Measured memory_bytes: 102104
N = int(input())
a = input().split()
a = [int(i) for i in a]

Bob=0
Alice=0

a.sort(reverse=True)
for i in range(N):
    if i%2 == 1:
        Bob = Bob + a[i]
    else:
        Alice = Alice + a[i]
print(Alice-Bob)


Measured memory_bytes: 8984
# 入力
s = input()

# 処理
leftLen = len(s) // 2 # 文字列の長さの半分
left = s[:leftLen] # sの左半分

# leftの回文チェック
leftLenHalf = leftLen // 2
isPalindromeLeft = True
for i in range(0, leftLenHalf):
	if left[i] != left[leftLen - i - 1]:
		isPalindromeLeft = False

# 全体の回文チェック
right = s[leftLen * -1:] # sの右半分
isPalindrome = isPalindromeLeft and left == right

# 結果
result = "Yes" if isPalindrome else "No"

# 出力
print(result)


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;
int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N, 1);
    vector<bool> check(N, false);
    check[0] = true;

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--, y--;

        if (check[x]) check[y] = true;
        if (cnt[x] == 1) check[x] = false;
        cnt[x]--, cnt[y]++;
    }

    int ans = 0;
    rep(i, N) {
        if (check[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

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


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

	char a;
	cin >> a;
	cout << char(a + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
double ans;
void solve(double n,double d0,double x)
{
	if(n==0) return;
	ans+=d0+(1+2*n)/2*x;
	double D0,X;
	D0=((2*n+2)*d0+3*x)/(2*n);
	X=(2*n+4)*x/(2*n);
	solve(n-1,D0,X);
}
int main()
{
	int n,d,x;scanf("%d%d%d",&n,&d,&x);
	d-=x;
	solve(n,d,x);
	printf("%.20lf\n",ans);
	return 0;
}

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

int main ()
{
int n,i,ct=0;
cin>>n;
int a[n];
for(i=0;i<n;i++)
    cin>>a[i];
for(i=1;i<n;i++)
{
    if(a[i]==a[i-1])
    {
        a[i]=-1;
        ct++;
    }

}
    cout<<ct<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	vector<string> mat;
	for (auto i = 0; i < 100; ++i)
	{
		if (i < 50)
		{
			mat.push_back(string(100, '.'));
		}
		else
		{
			mat.push_back(string(100, '#'));
		}
	}

	for (auto i = 0; i < 50; i += 2)
	{
		if (B - 1 <= 0)
		{
			break;
		}

		for (auto j = 0; j < 100; j += 2)
		{
			mat[i][j] = '#';
			--B;
			if (B - 1 <= 0)
			{
				break;
			}
		}
	}


	for (auto i = 0; i < 50; i += 2)
	{
		if (A - 1 <= 0)
		{
			break;
		}

		for (auto j = 0; j < 100; j += 2)
		{
			mat[99 - i][j] = '.';
			--A;
			if (A - 1 <= 0)
			{
				break;
			}
		}
	}

	cout << 100 << " " << 100 << endl;
	for (auto i = 0; i < 100; ++i)
	{
		cout << mat[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define len length
#define mp make_pair
#define pq priority_queue
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define take(v) for(int i=0;i<(int)v.size();i++){cin>>v[i];}
#define printvec(v) for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define printds(x) while(!x.empty()){cout<<x.top()<<" ";x.pop();}
#define input(n) int n;cin>>n;
#define PI 3.141592653589793238463
#define lnput(n) long long int n;cin>>n;
#define fr(i,s,e) for(int i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
vector<int> v;
int main()
{
  speed;
  input(n);
  v.resize(n);
  fr(i,0,n) {
    cin>>v[i];
  }
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  dp[1] = abs(v[1]-v[0]);
  for(int i = 2;i<n;i++) {
    dp[i] = min((dp[i-1]+abs(v[i-1]-v[i])),(dp[i-2]+abs(v[i]-v[i-2])));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  while(n--){
    int x=0,y=0,mx=-1000,my=0,md=0;
    while(1){
      int dx,dy;
      cin >>dx >>dy;
      if(dx==0 && dy==0) break;
      x+=dx,y+=dy;
      if(x*x+y*y>md) mx=x,my=y,md=x*x+y*y;
      else if(x*x+y*y==md && mx<x) mx=x,my=y,md=x*x+y*y;
    }
    cout << mx <<" "<<my<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160