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

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin,(a).end);
#define rSORT(a) sort((a).rbegin,(a).rend);
#define yn(a) cout <<((a)?"Yes":"No")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int H,W,max,min,samin,tmp,tmp2;
    vi me(3),sa(16);
    cin >>H>>W;
    
    FOR(i,0,1){
        tmp=(int)(H/3)+i;
        me[0]=tmp*W;
        FOR(j,0,1){
            tmp2=(int)(W/2)+j;
            me[1]=(H-tmp)*tmp2;
            me[2]=(H-tmp)*(W-tmp2);
            max=me[0];
            min=me[0];
            FOR(k,0,2){
                if(max<me[k]) max=me[k];
                if(min>me[k]) min=me[k];
            }
            sa[i+2*j]=max-min;
        }
    }
    
    FOR(i,0,1){
        tmp=(int)(W/3)+i;
        me[0]=tmp*H;
        FOR(j,0,1){
            tmp2=(int)(H/2)+j;
            me[1]=(W-tmp)*tmp2;
            me[2]=(W-tmp)*(H-tmp2);
            max=me[0];
            min=me[0];
            FOR(k,0,2){
                if(max<me[k]) max=me[k];
                if(min>me[k]) min=me[k];
            }
            sa[4+i+2*j]=max-min;
        }
    }
    
    FOR(i,0,1){
        tmp=(int)(H/3)+i;
        me[0]=tmp*W;
        FOR(j,0,1){
            tmp2=(int)(H/3)+j;
            me[1]=tmp2*W;
            me[2]=(H-tmp-tmp2)*W;
            max=me[0];
            min=me[0];
            FOR(k,0,2){
                if(max<me[k]) max=me[k];
                if(min>me[k]) min=me[k];
            }
            sa[8+i+2*j]=max-min;
        }
    }

    FOR(i,0,1){
        tmp=(int)(W/3)+i;
        me[0]=tmp*H;
        FOR(j,0,1){
            tmp2=(int)(W/3)+j;
            me[1]=tmp2*H;
            me[2]=(W-tmp-tmp2)*H;
            max=me[0];
            min=me[0];
            FOR(k,0,2){
                if(max<me[k]) max=me[k];
                if(min>me[k]) min=me[k];
            }
            sa[12+i+2*j]=max-min;
        }
    }
    
    samin=sa[0];
    FOR(i,0,15) {
        if(samin>sa[i]) samin=sa[i];
    }
    
    cout <<samin<<endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, t = LI()
    print(b * (t // a))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int a, b;
	cin >> a >> b;
	int acount = 0;
	int tap = 1;
	while (tap < b)
	{
		acount++;
		tap--;
		tap += a;
	}
	cout << acount << endl;
}



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

using namespace std;

int main()
{
  uint64_t H, W, N;
  cin >> H >> W >> N;

  uint64_t c = 0, n = 0;
  while (n < N) {
    if (H > W) {
      n += H;
      --W;
    } else {
      n += W;
      --H;
    }
    ++c;
  }
  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
vector<ll> dp[55][2510];
ll n,a;
vector<ll> x;
ll findsum(ll i,ll sum,ll count)
{
    if(sum==a*count&&count)
    {
        if(i==n)
        return 1;
    }
    if(i>=n)
    return 0;
    if(dp[i+1][sum][count]!=-1)
    return dp[i+1][sum][count];
    return dp[i+1][sum][count]=(findsum(i+1,sum+x[i],count+1)+findsum(i+1,sum,count));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        for(ll i=0;i<51;i++)
        for(ll j=0;j<2501;j++)
        for(ll k=0;k<51;k++)
        dp[i][j].push_back(-1);
        cin>>n>>a;
        x.resize(n);
        for(ll i=0;i<n;i++)
        cin>>x[i];
        ll count=findsum(0,0,0);
        cout<<count<<"\n";
    }
    return 0;
}

Measured memory_bytes: 72664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int s[200010];


int main()
{
    int n;
    cin >> n;
    ll s[n+1];
    ll a[n];
    ll ans = 0;
    for(int i = 0; i < n+1; i++){
        s[i] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        s[i+1] = a[i] + s[i];
    }
    sort(s,s+n+1);
    for(int i = 0; i < n+1; i++){
        ll cnt = 1;
        while(s[i] == s[i+1]){
            cnt++;
            i++;
        }
        ans += (cnt * (cnt-1)) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include <list>
using namespace std;

using ll=long long;
list<char> ls;

bool R=false;

void push_front(char c){
    if (R) {
        ls.push_back(c);
    }else{
        ls.push_front(c);
    }
}
void push_back(char c){
    if (R) {
        ls.push_front(c);
    }else{
        ls.push_back(c);
    }
}

int main(){
    string s;
    cin>>s;
    for(auto i:s){
        ls.push_back(i);
    }
    int Q;
    cin>>Q;
    int T,F;
    char c;
    for (int i=0; i<Q; i++) {
        cin>>T;
        if (T==1) {
            R=!R;
        }else{
            cin>>F;
            cin>>c;
            if (F==1) {
                push_front(c);
            }else{
                push_back(c);
            }
            
        }
    }
    if (!R) {
        for (auto i=ls.begin(); i!=ls.end(); i++) {
            cout<<*i;
        }
        cout<<endl;

    }else{
        for (auto i=ls.rbegin(); i!=ls.rend(); i++) {
            cout<<*i;
        }
        cout<<endl;

    }
    
   
    return 0;
}


Measured memory_bytes: 10048
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
 
int main ()
{
	long long m,n,k,i,j,bj=0;
	scanf("%lld %lld %lld",&n,&m,&k);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(k==i*m+j*n-2*i*j)
			{
				cout<<"Yes"<<endl;
				bj++;
				break;
			}
		}
		if(bj)
			break;
	}
	if(bj==0)
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let a: Vec<usize> = read_as_vec();

    let mut ans = 0;
    for i in 0..n {
        if i % 2 == 0 && a[i] % 2 == 1 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2132
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 101;
const int INF = 1000000001;

int n, m;
char a[MAX][MAX];
int dyn[MAX][MAX][2];

bool isOkay(int row, int col, int inv) {
    return inv ? a[row][col] == '#' : a[row][col] == '.';
}

int recurse(int row, int col, int inv) {
    if (row >= n) return INF;
    if (col >= m) return INF;
    if (row == n - 1 && col == m - 1)
        return isOkay(row, col, inv) ? 0 : !inv;
    if (dyn[row][col][inv] != -1)
        return dyn[row][col][inv];
    
    int ans = INF, add = 0;
    int ninv = inv;
    if (!isOkay(row, col, inv))
        ninv = !inv, add = !inv;
    ans = min(ans, recurse(row + 1, col, ninv) + add);
    ans = min(ans, recurse(row, col + 1, ninv) + add);
    
    return dyn[row][col][inv] = ans;
}

int main(void) {
	// in = fopen("A.in", "rt");
	
	fscanf(in, "%d %d", &n, &m);
	for (int row = 0; row < n; row++)
	    fscanf(in, "%s", a[row]);
	
	memset(dyn, -1, sizeof(dyn));
	fprintf(out, "%d\n", recurse(0, 0, 0));
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC094.A
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int a = sc.NextInt ();
            int b = sc.NextInt ();
            int x = sc.NextInt ();
            Console.WriteLine ((a <= x && x <= a + b) ? "YES" : "NO");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int NextInt ()
        {
            return int.Parse (Next ());
        }
        public int[] ArrayInt (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (int N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
A, B, C, D = gets.split(' ').map(&:to_i)
lcm = C.lcm(D)
dC = ((B / C) - (A / C))
dC += 1 if A % C == 0
dD = ((B / D) - (A / D))
dD += 1 if A % D == 0
dCD = ((B / lcm) - (A / lcm))
dCD += 1 if A % lcm == 0
p (B - A + 1) - (dC + dD - dCD)

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a<b){
		System.out.println("a < b");
		}else if(a>b){
		System.out.println("a > b");
		}else if(a==b){
		System.out.println("a == b");
		}
	}
}

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

using namespace std;
int main() {
    long long count[5] = {};
    int n;
    long long ans = 0;
    const string march = "MARCH";

    cin >> n;
    for (int i = 0; i < n; i++) {
        string name;
        cin >> name;

        string::size_type pos = march.find(name[0]);
        if (pos != string::npos) {
            count[pos]++;

        }
    }

    for (int i = 0; i < 3; i++) {
        for (int j = i+1; j < 4; j++) {
            for (int k =j+1; k < 5; k++) {
                ans += count[i]*count[j]*count[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace AtCoder.Contest.D
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();
			string s = cin.next();

			string[] dream = new string[] { "dream", "dreamer", "erase", "eraser" };
			bool ok = true;

			while (s.Length >= 1 && ok)
			{
				bool pass = false;
				int n = s.Length;
				for (int i = 0; i < 4 && !pass; i++)
				{
					if (n - dream[i].Length >= 0 && s.Substring(n - dream[i].Length) == dream[i])
					{
						s = s.Remove(n - dream[i].Length);
						pass = true;
					}
				}
				if (!pass) ok = false;
			}

			if (ok) Console.WriteLine("YES");
			else Console.WriteLine("NO");

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 29688
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static long n = long.Parse(Console.ReadLine());//nCkにおけるnの最大値
static long[] factorials = new long[n+2];//i!(mod p)を先にメモ
static long[] factorialRs = new long[n+2];//i!^-1(mod p), pは素数
static long p = 1000000007;

	static void Main()
	{
    n++;
    factorials[0] = 1;
    factorialRs[n] = DivideModFactorial(n,p);
    for(long i = 1; i <= n; i++)
    {
      factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
      factorialRs[n-i] = (factorialRs[n+1-i]*(n+1-i))%p;//逆元も先にメモ
    }
    n--;
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] numLength = new long[n];//数字の位置
    long lengthMemo = 0;//同じ数間の距離
    long answer = 0;
    for(long i = 0; i < n+1; i++)
    {
      if(numLength[nums[i]-1] == 0) numLength[nums[i]-1] = i+1;
      else
      {
        lengthMemo = (i+1) - numLength[nums[i]-1];
        break;
      }
    }
    for(long i = 0; i < n+1; i++)
    {
      if(i == 0) answer = n;
      else if(i == n) answer = 1;
      else
      {
        answer = Comb(n+1, i+1, p);//nCk(mod p),pは素数
        if(n-lengthMemo >= i)
        {
          answer += p;
          answer -= Comb(n-lengthMemo, i, p);
        }
      }
      answer %= p;
      Console.WriteLine(answer);
    }
		
	}

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//戻り値は組み合わせC(a,b)のmod p
  {
    long answer = 1;
    answer *= factorials[a];
    answer %= p;
    answer *= factorialRs[a-b];//引数a-bは負にならないようにする
    answer %= p;
    answer *= factorialRs[b];
    answer %= p;
    return answer;
  }
  
}

Measured memory_bytes: 27868
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0
ans = 0

N = i()
a = l()

for i in range(N):
    if i % 2 == 0 and a[i] % 2 != 0:
        ans += 1
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#include<cstdio>
int main(){
  int n,k;
  cin>>n>>k;
  long long int m=0;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end(),greater<int> ());
  for(int i=k;i<n;i++){
    m+=vec.at(i);
  }
 cout<<m;
}









Measured memory_bytes: 1024
#include <stdio.h>

int n, m, k[1123];
int now_card[212], tmp_card[212], cou = 0;

int main(void) {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) { scanf("%d", &k[i]); }

	for (int i = 0; i < 2 * n; ++i) { tmp_card[i] = now_card[i] = i + 1; }
	for (int i = 0; i < m; ++i) {
		if (k[i] == 0) {
			for (int j = 0; j < n * 2; j += 2) {
				tmp_card[j] = now_card[cou];
				tmp_card[j + 1] = now_card[n + cou];
				++cou;
			}
		}
		else {
			for (int j = 0; j < 2 * n; ++j) {
				if (2 * n - k[i] >= j + 1) { tmp_card[j] = now_card[k[i] + j]; }
				else { tmp_card[j] = now_card[j - (2 * n - k[i])]; }
			}
		}
		for (int i = 0; i < 2 * n; ++i) { now_card[i] = tmp_card[i]; }
		cou = 0;
	}

	for (int i = 0; i < 2 * n; ++i) { printf("%d\n", now_card[i]); }
	return 0;
}

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

int main(){
  int n,m;cin>>n>>m;
  int sum=0;
  for(int i=0;i<m;i++){
    int a;cin>>a;
    sum+=a;
  }
  
  cout<<max(-1,n-sum)<<endl;
}

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
##################################
# University of Wisconsin-Madison
# Author: Yaqi Zhang
##################################

# standard library
import sys
from functools import lru_cache

sys.setrecursionlimit(10**9)

Input = lambda: sys.stdin.readline().rstrip()
IntRead = lambda: int(Input())
LineRead = lambda: list(map(int, Input().split()))


INF = 10**18

def main():
    N = IntRead()
    s = set()
    for _ in range(N):
        word = Input()
        s.add(word)
    print(len(s))

if __name__ == "__main__":
    main()



Measured memory_bytes: 31444
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	LLONG N, K; cin >> N >> K;
	if (K == 0)
	{
		cout << N * N << endl;
	}
	else 
	{
		LLONG ans = 0;
		for (int b = K + 1; b <= N; ++b)
		{
			ans += (N / b) * (b - K);
			if (N % b != 0 && N % b >= K)
			{
				ans += N % b - K + 1;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3552
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

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

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
ll a[100009],arr[100009];
map<ll,ll> ma;
vector<ll> v[100009];
ll sol(ll n)
{
    return (n*(n+1))/2;
}
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    sff(n,m);
    rep0(i,n)
    {
        sf(x);
        arr[i] = x;
        if(i==0)
            a[i] = x;
        else a[i] = a[i-1]+x;
        a[i] = a[i]%m;
    }
    ll ind = 0;
    for(i=0;i<n;i++)
    {
        if(ma.find(a[i])==ma.end())
        {
            ma[a[i]] = ind++;
        }
        v[ma[a[i]]].push_back(i);
    }
    /*map<ll,ll> :: iterator it;
    for(it=ma.begin();it!=ma.end();it++)
    {
        cout<<it->first<<endl;
        for(i=0;i<v[it->second].size();i++)
        {
            cout<<v[it->second][i]<<" ";
        }
        cout<<endl;
    }*/
    ll ans =0;
    if(ma.find(0)!=ma.end())
    {
        ans+= v[ma[0]].size();
    }
    x = 0;
    ll hi,lo,mid,temp;
    //cout<<"ans = "<<ans<<endl;
    for(i=0;i<n;i++)
    {
        x+= arr[i];
        x = x%m;
        lo = 0;
        hi = v[ma[x]].size()-1;
        temp  = -1;
        while(lo<=hi)
        {
            mid = (lo+hi)/2;
            if(v[ma[x]][mid]>i)
            {
                temp = mid;
                hi = mid-1;
            }
            else lo = mid+1;
        }
        //pff(x,temp);
        //cout<<v[ma[x]].size()<<endl;
        if(temp!=-1)
        {
            ans+= v[ma[x]].size()-temp;
        }
    }
    pf(ans);


    return 0;
}



Measured memory_bytes: 10368
// AOJ 0220
#include<cstdio>
#include<string>

int main()
{
	double f;
	while( scanf( "%lf", &f ), f >= 0 )
	{
		int a = f;
		std::string s, t;
		bool fl = true;

		while( a > 0 )
		{
			if( s.size() >= 8 ) { fl = false; break; }
			s += (a&1)+'0';
			a >>= 1;
		}
		if( fl )
		{
			int cnt = 0;
			f -= int(f);
			while( f )
			{
				if( cnt >= 4 ) { fl = false; break; }
				f *= 2;
				t += int(f) ? '1' : '0';
				f -= int(f);
				++cnt;
			}
		}

		if( fl )
		{
			printf( "%s", std::string( 8-s.size(), '0' ).c_str() );
			for( int i = s.size()-1; i >= 0; --i )
				printf( "%c", s[i] );
			putchar( '.' );
			printf( "%s", t.c_str() );
			printf( "%s\n", std::string( 4-t.size(), '0' ).c_str() );
		}
		else
			puts( "NA" );
	}

	return 0;
}

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

int f(int n){
    int sum = 0;
    while (n>0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i = 1; i <= N; i++)
    {
        int sum = f(i);
        if(sum >= A && sum <= B){
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans=n*(n-1)/2+m*(m-1)/2;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n, A[mn];
// main solution goes here:
void execute(int test_number)
{
    cin>>n;
    for (int i=1; i<=n; i++) cin>>A[i];

    int ans=inf;
    for (int i=1; i<=100; i++)
    {
        int ret=0;
        for (int j=1; j<=n; j++) ret+=(A[j]-i)*(A[j]-i);
        ans=min(ans, ret);
    }
    cout<<ans;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string Ans;
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(3)){
        Ans = "Bad";
    }else{
        Ans = "Good";
    }    
    // 出力
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#N,K = map(str,input().split())
N = int(input())
#K = int(input())
X = list(map(int,input().split()))
Y=X.copy()
A=[]
B=[]
while Y:
    a=max(Y)
    A.append(a)
    Y.remove(a)
    if not Y:
        break
    b=max(Y)
    B.append(b)
    Y.remove(b)
print(sum(A)-sum(B))


Measured memory_bytes: 3060
//39
#include<iostream>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  short (*g)[5001]=(short(*)[5001])malloc(sizeof(short)*5001*5001);
  fill(g[0],g[5000],-1);
  while(m--){
    int a,b,x;
    cin>>a>>b>>x;
    g[a-1][b-1]=x;
  }
  int a=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=i;j++){
      a+=g[i][j]>=0;
      g[i+1][j]=max<short>(g[i+1][j],g[i][j]-1);
      g[i+1][j+1]=max<short>(g[i+1][j+1],g[i][j]-1);
    }
  }
  cout<<a<<endl;
  return 0;
}

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

int main()
{
    string S;
    cin >> S;
    vector<int> d(4);
    for (int i = 0; i < 4; i++)
    {
        d.at(i) = (int)(S.at(i) - '0');
    }
    if (d.at(0) + d.at(1) + d.at(2) + d.at(3) == 7)
        printf("%d+%d+%d+%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) - d.at(1) + d.at(2) + d.at(3) == 7)
        printf("%d-%d+%d+%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) + d.at(1) - d.at(2) + d.at(3) == 7)
        printf("%d+%d-%d+%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) + d.at(1) + d.at(2) - d.at(3) == 7)
        printf("%d+%d+%d-%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) - d.at(1) - d.at(2) + d.at(3) == 7)
        printf("%d-%d-%d+%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) - d.at(1) + d.at(2) - d.at(3) == 7)
        printf("%d-%d+%d-%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) + d.at(1) - d.at(2) - d.at(3) == 7)
        printf("%d+%d-%d-%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
    else if (d.at(0) - d.at(1) - d.at(2) - d.at(3) == 7)
        printf("%d-%d-%d-%d=7\n", d.at(0), d.at(1), d.at(2), d.at(3));
}

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

int main()
{
  std::string s;
  std::cin >> s;
  int i;
  std::string ans = "";
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == '1') ans += s[i];
    if (s[i] == 'B' && ans.size() != 0) ans.pop_back();
  }
  std::cout << ans;
  return 0;
}


Measured memory_bytes: 256
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.root = [-1]*(n+1)
		self.rank = [0]*(n+1)

	def find(self, x):
		if self.root[x] < 0:
			return x
		else:
			self.root[x] = self.find(self.root[x])
			return self.root[x]
			
	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return 0
		elif self.rank[x] > self.rank[y]:
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

	def isSame(self, x, y):
		return self.find(x) == self.find(y)
		
n,m,*l=map(int,open(0).read().split())
p=l[:n];xy=l[n:]
ids=[0]*(n+1)
for i in range(n):
	ids[p[i]]=i+1
uf=UnionFind(n)
for x,y in zip(*[iter(xy)]*2):
	uf.unite(x,y)
print(sum(uf.isSame(i,ids[i])or i==ids[i] for i in range(1,n+1)))

Measured memory_bytes: 35324
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  ll sum = 0;
  while(1){
    if(a%2 == 1 || b%2 == 1 || c%2 == 1){
      break;
    }
    else if(a == b && b == c){
      sum = -1;
      break;
    }
    ll A = a,B = b,C = c;
    a = B/2+C/2;
    b = A/2+C/2;
    c = A/2+B/2;
    sum++;
  }
  cout << sum << endl; 
  return 0;
}


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

int main() {
	int a[101][101], b[101][101], n, m, l, i, j, k;
	long long tmp;
	cin >> n >> m >> l;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++)cin >> a[i][j];
	}
	for (i = 1; i <= m; i++) {
		for (j = 1; j <= l; j++)cin >> b[i][j];
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= l; j++) {
			tmp = 0;
			for (k = 1; k <= m; k++) tmp += a[i][k] * b[k][j];
			cout << tmp;
			if (j != l)cout << " ";
			else cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main(){
	int a[3][6],i,j,in,out;
	for(i=0;i<3;i++){
		for(j=0;j<6;j++)scanf("%d",&a[i][j]);
	}
	for(i=0;i<3;i++){
		in=a[i][0]*3600+a[i][1]*60+a[i][2];
		out=a[i][3]*3600+a[i][4]*60+a[i][5];
		in=out-in;
		out=in%3600;
		printf("%d %d %d\n",in/3600,out/60,out%60);
	}
	return 0;
}


Measured memory_bytes: 2148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] nk = br.readLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);
		int[] h = new int [n];
		nk = br.readLine().split(" ");
		for(int i = 0 ; i < n ;i++) {
			h[i] = Integer.parseInt(nk[i]);
		}
		Arrays.sort(h);
		long sum  = 0;
		for(int i = 0 ; i< n-k ; i++) {
			sum += h[i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 56668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

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

int main(){
  int n, p[2], c[2];
  while(scanf("%d", &n) && n){
    p[0] = p[1] = 0;
    while(n--){
      scanf("%d%d", c, c+1);
      if(c[0] > c[1]) p[0] += c[0]+c[1];
      else if(c[0] < c[1]) p[1] += c[0]+c[1];
      else p[1] += c[1], p[0] += c[1];
    }
    printf("%d %d\n", p[0], p[1]);
  }
  return 0;
}

Measured memory_bytes: 1188
x, y = map(int,input().split())

if x * y == 0:
  if x <= y:
    print(y - x)
  elif x > y:
    print(x - y + 1)
    
elif x * y > 0:
  if x <= y:
    print(y - x)
  elif x > y:
    print(x - y + 2)
    
elif x * y < 0:
  if abs(x) <= abs(y):
    print(abs(y) - abs(x) + 1)
  elif abs(x) > abs(y):
    print(abs(x) - abs(y) + 1)

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if(N<=A)
    cout << "Yes" << endl;
  else{
    if(N % 500 <= A)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#editorial参照

#偶奇
import numpy as np
n=int(input())
a_ = list(map(int, list(input())))
a = np.array(a_)-1###
div2=[0]
cnt=0
ex1 = False

if 1 in a:
    ex1 = True
else:
    a//=2
tst=1
tsts=[1]
for i in range(n-1):
    cnt += bin(n-i-1)[::-1].find('1')
    cnt -= bin(i+1)[::-1].find('1')
    #tst*=n-i-1
    #tst//=i+1
    div2.append(cnt)
    tsts.append(tst)

div2=np.array(div2)###これは2で割れる数のカウント
dv2=1-(div2>0)##これが2で割れるか否か
#print(a)
#print(tsts)
#print(dv2)
tmp= (a*dv2).sum()%2
if tmp:
    if ex1:
        print(1)
    else:
        print(2)

else:
    print(0)


Measured memory_bytes: 64692
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	long long int V, E;
	cin >> V >> E;
	
	long long int cost[V][V];
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			cost[i][j] = INF;
		}
	}
	
	for(int i = 0; i < E; i++){
		int u, v, c;
		cin >> u >> v >> c;
		cost[u][v] = c;
	}
	
	long long int DP[V][(1 << V)];
	
	for(int i = 0; i < V; i++){
		for(int j = 0; j < (1 << V); j++){
			DP[i][j] = INF;
		}
	}
	DP[0][0] = 0;
	
	for(int i = 0; i < (1 << V); i++){
		for(int j = 0; j < V; j++){
			if(i & (1 << j)){
				for(int k = 0; k < V; k++){
					DP[j][i] = min(DP[j][i], DP[k][i - (1 << j)] + cost[k][j]);
				}
			}
		}
	}
	
	long long int ans = DP[0][(1 << V) - 1];
	if(ans == INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	
	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

    int c[n+1];
    fill(c, c+n+1, 0);
    for(int i=1; i<=n; i++){
        if(d[i]>d[i-1]) c[i]=c[i-1]+1;
        else c[i]=1;
    }
    int ans=n;
    for(int i=1; i<=n; i++){
        ans=min(ans, n-c[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		int[][] dp = new int[length + 1][13];
		dp[0][0] = 1;
		for (int i = 1; i <= length; i++) {
		    for (int j = 0; j < 13; j++) {
		        for (int k = 0; k < 10; k++) {
		            if (arr[i - 1] == '?' || arr[i - 1] - '0' == k) {
		                int idx = (j * 10 + k) % 13;
		                dp[i][idx] += dp[i - 1][j];
		                dp[i][idx] %= MOD;
		            }
		        }
		    }
		}
		System.out.println(dp[length][5]);
   }
}


Measured memory_bytes: 46668
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;

        for (int i = 1; i <= n; i++) {
            int sumOfDigit = 0;
            int number = i;

            do {
                int rmd = number % 10;
                sumOfDigit += rmd;
            } while ((number /= 10) != 0);

            if (sumOfDigit >= a && sumOfDigit <= b){
                ans += i;
            }
        }


        System.out.println(ans);
    }

}


Measured memory_bytes: 23124
n, k = map(int,  input().split())
ans = 0
l1 = [i for i in range(1, n+1) if i % k == 0]
n1 = len(l1)
ans += n1 ** 3
if k % 2 == 0:
    l2 = [i for i in range(1, n+1) if i % k == k // 2]
    n2 = len(l2)
    ans += n2 ** 3
print(ans)

Measured memory_bytes: 11016
#include<bits/stdc++.h>
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define int long long
#define ve vector<int>
#define mod 1000000007
#define eb emplace_back
#define inf ((long long) 1e18 )
#define all(x) (x).begin(),(x).end()
#define debug(x) cout << '>' << #x << ':' << x << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug2(x,y) cout << '>' << #x <<" = "<< x <<" & "<< #y <<" = "<< y << '\n';
#define fileIO freopen("input.txt", "r", stdin); freopen("output1.txt", "w", stdout);
using namespace std;
const int N = 2e5 + 7;

int32_t main() {
	IOS
#ifndef ONLINE_JUDGE
	fileIO
#endif
	auto start = std::chrono::high_resolution_clock::now();
	int test;
	test = 1;
	// cin >> test;
	while (test--) {
		int n, x, t;
		cin >> n >> x >> t;
		int val = n / x;
		int flag = (n % x != 0);
		cout << (val + flag) * t << endl;

	}

	auto stop = std::chrono::high_resolution_clock::now();
	auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);

	cerr << "Time taken : " << ((long double)duration.count()) / ((long double) 1e9) << "s " << endl;

	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

  if (n == k) cout << 1;
  else cout << 1 + (n - k - 1) / (k - 1) + 1;

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,a[200000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>a[i];
  for (int i(0);i<N;i++){
    a[i]-=(i+1);
  }
  sort(a,a+N);
  ll sum(0);
  ll cen=(N%2==1? a[N/2]:a[N/2-1]);
  //cout << cen << endl;
  for (int i(0);i<N;i++){
    sum+=abs(a[i]-cen);
  }
  cout << sum << endl;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef pair<double, int> pdi;

int lis[8][3] = {
	{0, 0, 0},
	{0, 0, 0xff},
	{0, 0xff, 0},
	{0, 0xff, 0xff},
	{0xff, 0, 0},
	{0xff, 0, 0xff},
	{0xff, 0xff, 0},
	{0xff, 0xff, 0xff}
};

string color[8] = { "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white" };

int calc(char c) {
	if (isdigit(c)) return c - '0';
	return c - 'a' + 10;
}

int main() {
	string str;
	while (cin >> str, str != "0") {
		int c[3];
		REP(i, 3) { c[i] = 16 * calc(str[1 + i * 2]) + calc(str[1 + i * 2 + 1]); }
		
		vector<pdi> ans;
		REP(i, 8) {
			double d = 0.0;
			REP(j, 3) d += pow(lis[i][j] - c[j], 2.0);
			d = sqrt(d);
			ans.push_back(pdi(d, i));
		}
		sort(ans.begin(), ans.end());
		cout << color[ans[0].second] << endl;
	}
	return 0;
}

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

int main() {
    int n,k;
    cin >> n >> k;
    double ans;
    vector<double> anst(n);

    rep(i,n){
        int sc = i+1;
        double pred = 1.0;
        pred /= n;
        while(sc < k){
            sc *= 2;
            pred /= 2;
        }
        ans += pred;
    }
    cout << fixed << setprecision(12) << ans;
}

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

int main() {
  int k;
  cin >> k;
  int64_t sum = 0;

  for (int i = 1; i < k + 1; i++) {
    for (int j = 1; j < k + 1; j++) {
      for (int n = 1; n < k + 1; n++) {
        sum += __gcd(i, (__gcd(j, n)));
      }
    }
  }

  cout << sum << endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n,m;
    cin >> n >> m;
    priority_queue<ll> data;
    rep(i,0,n){
        ll a;
        cin >> a;
        data.push(a);
    }
    // sort(data.begin(),data.end());
    // reverse(data.begin(),data.end());
    rep(i,0,m){
        ll Max = data.top();
        data.pop();
        data.push(Max/2);
    }
    ll sum = 0;
    while(!data.empty()){
        sum += data.top();
        data.pop();
    }
    cout<<sum<<endl;

    
    return 0;
}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w;

int main(){
	while(1){
		cin>>h>>w;
		if(h==0) break;
		int res=inf,a,b;
		for(int i=1;i*i<h*h+w*w;i++){
			int c=i,d=0;
			while(c*c+d*d<h*h+w*w) d++;
			if(c*c+d*d==h*h+w*w&&c<=h) d++;
			if(c<d&&c*c+d*d<res){
				res=c*c+d*d;
				a=c;
				b=d;
			}
		}
		cout<<a<<' '<<b<<endl;
	}
}


Measured memory_bytes: 3004
#include<cstdio>
#include<algorithm>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

int main(){
	for(int n;~scanf("%d",&n);){
		int t[100];
		rep(i,n)	scanf("%d",t+i);

		sort(t,t+n);

		int pe=0,sum=0;
		rep(i,n)	pe+=(sum+=t[i]);
		printf("%d\n",pe);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
void mixing(int n,int a[]){
	pair<long long int,long long int> slimes[n][n];
	for(int i=0;i<n;i++){
		slimes[i][i].first=a[i];
		slimes[i][i].second=0;
	}
	for(int l=2;l<=n;l++){
		for(int i=0;i<n-l+1;i++){
			int j=i+l-1;
			slimes[i][j].first=1e17;slimes[i][j].second=1e17;
			for(int k=i;k<j;k++){
				long long int x=min(slimes[i][j].second,slimes[i][k].first+slimes[k+1][j].first+slimes[i][k].second+slimes[k+1][j].second);
				if(x<slimes[i][j].second){
					slimes[i][j].first=slimes[i][k].first+slimes[k+1][j].first;slimes[i][j].second=x;
				}
			}
		}
	}
	cout<<slimes[0][n-1].second<<endl;
}
int main(){
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	mixing(n,a);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 200002;
int n,f[26];
char a[N];

int main(){
    scanf("%s",a);
    n = strlen(a);
    lp(i,0,n-1) ++f[a[i]-'a'];

    ll ans = 1ll * n * (n+1) / 2 + 1 - n;
    lp(i,0,25) ans -= 1ll * f[i] * (f[i] - 1) / 2;
    cout <<ans;

}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;


char S[11];

unsigned long solve(bool add[], int depth)
{
    if (strlen(S) == depth) {
        unsigned long ret = 0;
        int i, seperate;
        for (i = 1, seperate = 0; i <= strlen(S); i++) {
            char tmp[11] = "\0";
            if (!add[i])
                continue;
            strncpy(tmp, S + seperate, i - seperate);
            ret += atol(tmp);
            seperate = i;
        }
        return ret;
    }

    unsigned long tmp[2];
    add[depth] = false;
    tmp[0] = solve(add, depth + 1);
    add[depth] = true;
    tmp[1] = solve(add, depth + 1);

    return tmp[0] + tmp[1];
}


int main(void)
{
    cin >> S;
    bool add[11];
    add[strlen(S)] = true;
    unsigned long ans = solve(add, 1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def digit_sum(x):
    S = str(x)
    dig_sum = 0
    for s in S:
        dig_sum += int(s)

    return dig_sum

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]

    min_sum = sys.maxint
    for A in range(1, N):
        B = N - A
        min_sum = min(min_sum, digit_sum(A) + digit_sum(B))

    print min_sum



if __name__ == '__main__':
    main()

Measured memory_bytes: 6000
#include <iostream>
using namespace std;
int main(void){
  int N,M;
  cin >> N >> M;
  
  int total = (N - M) * 100 + M * 1900;
  
  for(int i=0;i<M;i++){
    total *= 2;
  }
  
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
HN = list(map(int, input().split(" ")))
 
Max = 0
 
i = 0
while i < (N - 1):
    Count = 0
    NowHeight = HN[i]
    for j in range(i+1, N):
        NextHeight = HN[j]
        if NowHeight >= NextHeight:
            NowHeight = NextHeight
            Count = Count + 1
        else:
            break
    if Count > Max:
        Max = Count
    i = i + 1 + Count
 
print(Max)

Measured memory_bytes: 14252