akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadLong;
            var n = N - 1;
            WriteLine((n * (n + 1)) / 2);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

typedef long long ll;

vector<int>neg;
vector<int>pos;
int zeros = 0;

ll count(ll mid)
{
	ll result = 0;
	if(mid >= 0)
	{
		result = 1ll * pos.size() * neg.size() + 1ll * zeros * (pos.size() + neg.size()) + 1ll * zeros * (zeros - 1) / 2;
	}
	else
	{
		if(neg.size() > 0 && pos.size() > 0)
		for(int i = 0; i < neg.size(); i++)
		{
			int lo = 0, hi = pos.size() - 1;
			while(lo + 1 < hi)
			{
				int m = (lo + hi) / 2;
				ll p = 1ll * pos[m] * neg[i];
				if(p > mid) lo = m + 1;
				else hi = m;
			}
			if(1ll * neg[i] * pos[lo] <= mid) result += pos.size() - lo;
			else if(1ll * neg[i] * pos[hi] <= mid) result += pos.size() - hi;
		}
	}
	if(mid > 0)
	{
		if(neg.size() > 1)
		for(int i = 0; i < neg.size() - 1; i++)
		{
			int lo = i + 1, hi = neg.size() - 1;
			while(lo + 1 < hi)
			{
				int m = (lo + hi) / 2;
				ll p = 1ll * neg[i] * neg[m];
				if(p > mid) hi = m - 1;
				else lo = m; 
			}
			if(1ll * neg[hi] * neg[i] <= mid) result += hi - i;
			else if(1ll * neg[lo] * neg[i] <= mid) result += lo - i;
		}
		if(pos.size() > 1)
        for(int i = 0; i < pos.size() - 1; i++)
        {
            int lo = i + 1, hi = pos.size() - 1;
            while(lo + 1 < hi)
            {
                int m = (lo + hi) / 2;
                ll p = 1ll * pos[i] * pos[m];
                if(p > mid) hi = m - 1;
                else lo = m;
            }
			if(1ll * pos[hi] * pos[i] <= mid) result += hi - i;
			else if(1ll * pos[lo] * pos[i] <= mid) result += lo - i;
        }
	}
	return result;	
}

int main()
{
	int N, x;
	ll K;	
	scanf("%d%lld", &N, &K);
	for(int i = 0; i < N; i++)
	{
		scanf("%d", &x);
		if(x < 0) neg.push_back(x);
		else if(x == 0) zeros++;
		else pos.push_back(x);
	}
	sort(neg.begin(), neg.end(), greater<int>());
	sort(pos.begin(), pos.end());
	ll lo = -1e18, hi = 1e18;
	while(lo < hi)
	{
		ll mid = lo < 0 ? (lo + hi - 1) / 2 : (lo + hi) / 2;
		ll cnt = count(mid);
		if(cnt >= K) hi = mid;
		else lo = mid + 1;	
	}
	cout << lo << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> F(n * 10);
    rep(i, 10 * n) cin >> F[i];
    vector<ll> P(n * 11);
    rep(i, 11 * n) cin >> P[i];

    ll res = -1e17;
    rep(pat, 1 << 10) {
        if (pat == 0) {
            continue;
        }
        vector<int> c(n);
        rep(t, 10) {
            int j = t / 2;
            int k = t % 2;
            int open = (pat >> t) & 1;
            rep (i, n) {
                if (open * F[10 * i + 2 * j + k] > 0) {
                    c[i]++;
                }
            }
        }

        ll sum = 0;
        rep(i, n) {
            sum += P[11 * i + c[i]];
        }

        if (res < sum) {
            res = max(res, sum);
        }
    }
    put(res)

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(c.Distinct().Count());

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {
        
    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 13280
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>

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

using namespace std;
typedef long long ll;

vector<string> split(const string &str, char delim) {
    vector<string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != string::npos) {
        res.push_back(string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(string(str, current, str.size() - current));
    return res;
}

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

    ll n;
    cin >> n;

    string s = S;

    vector<string> T = split(S,'+');
    vector<int> v;
    rep(i,T.size()) {
        vector<string> t = split(T[i],'*');
        rep(j,t.size()) {
            stringstream ss;
            ss << t[j];

            int temp;
            ss >> temp;
            v.push_back(temp);
        }
    }

    vector<char> t;
    rep(i,S.size()) {
        if(S[i] == '+' || S[i] == '*') t.push_back(S[i]);
    }
    
    ll b;
    stringstream ss;
    ss << v[0];
    ss >> b;

    rep(i,t.size()) {
        int r;
        stringstream ss2;

        ss2 << v[i+1];
        ss2 >> r;

        if(t[i] == '+') {
            b += r;
        }
        else b *= r;
    }

    while(true) {
        bool F = true;
        rep(i,t.size()) {
            if(t[i] == '*') {
                F = false;
                int l = v[i];
                int r = v[i+1];
                
                vector<int> temp;
                rep(j,i) {
                    temp.push_back(v[j]);
                }
                temp.push_back(l*r);

                REP(j,i+2,v.size()) {
                    temp.push_back(v[j]);
                }

                v.clear();
                copy(temp.begin(),temp.end(),back_inserter(v));

                vector<char> temp2;
                rep(j,i) temp2.push_back(t[j]);
                REP(j,i+1,t.size()) temp2.push_back(t[j]);
                t.clear();
                copy(temp2.begin(),temp2.end(),back_inserter(t));
                break;
            }
        }

        if(F) break;
    }

    ll a = 0;
    rep(i,v.size()) {
        a += v[i];
    }

    if(a == n && b == n) cout << "U" << endl;
    else if(a == n) cout << "M" << endl;
    else if(b == n) cout << "L" << endl;
    else cout << "I" << endl;

    return 0;
}

Measured memory_bytes: 1276
a, b, c = map(int, input().split())
d = {}
for i in range(a, min(a + c, b+1)):
    d[i] = 1
for i in range(b, max(b - c, a-1), -1):
    d[i] = 1
d = sorted(d.keys())
for i in d:
    print(i)


Measured memory_bytes: 3188
from sys import stdin
from collections import Counter
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))
    a.sort()

    a_max=max(a)+1
    table=[False]*a_max
    cnt=0
    s=set()
    t=set()
    for i in range(n):
        a_i=a[i]
        if table[a_i]==False:
            s.add(a_i)
            if table[a_i]==False:
                cnt+=1
            for x in range(a_i,a_max,a_i):
                table[x]=True
        else:
            if a_i in t:
                pass
            elif a_i in s:
                cnt-=1
                t.add(a_i)

    print(cnt)

if __name__=="__main__":
    main()

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

import math
N = int(input())
li = []
for i in range(N):
    li.append(input().split())
    
def distance(x1,y1,x2,y2):
    return math.sqrt((float(x1)-float(x2))**2+(float(y1)-float(y2))**2)

import itertools
li1 = list(itertools.permutations(li))
Sum_Sum = 0
for i in range(len(li1)):
    Sum = 0
    for j in range(len(li1[i])-1):
        Sum += distance(li1[i][j][0],li1[i][j][1],li1[i][j+1][0],li1[i][j+1][1])
    Sum_Sum += Sum
print("{:.10f}".format(Sum_Sum/len(li1)))
        
    


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

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

    int result = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '+') {
            result++;
        }else{
            result--;
        }
    }
    cout << result << endl;
}

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

  public static void main (String[] args) {
	
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    sc.close();

    if(X < A){
      System.out.println(0);
    } else {
      System.out.println(10);
    }

  }

}

Measured memory_bytes: 23764
from collections import Counter
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    """
    2     3
    1(-1) 1
    """
    N = read_int()
    A = read_ints()
    counter = [0]*max(A)
    for a in A:
        counter[a-1] += 1
    remove = 0
    twos = 0
    for a in counter:
        if a > 0:
            if a%2 == 0:
                remove += (a-2)
                twos += 1
            else:
                remove += (a-1)
    if twos%2 == 0:
        remove += twos
    else:
        remove += twos+1
    return N-remove


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 84440
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, a[200005];
bool check(int l,int k)
{
    int cnt=0;
    for(int i=0;i<n;i++)
    {
       
        cnt+= (a[i]-1)/l;
    }
    if(cnt<=k)return true;
    return false;
}
signed main()
{
   int k;
   cin>>n>>k;
   int l=1,r=1e9, mid,ans=-1;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
  // int mx=p.top();
  while(l<=r)
  {
      mid= l+(r-l)/2;
      if(check(mid,k))
      {
          ans= mid;
          r=mid-1;
      }
      else
      {
          l=mid+1;
      }
  }
  cout<<ans;
    return 0;
}


Measured memory_bytes: 5108
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
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 INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll r; cin>>r; 
  cout<<r*r<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

if __name__=='__main__':
    r, c = map(int, raw_input().split())

    bottom = [0]*c
    for _ in range(r):
        s = raw_input()
        n = map(int, s.split())
        print '{} {}'.format(s, sum(n))
        for j in range(c):
            bottom[j] += n[j]

    print '{} {}'.format(' '.join(map(str, bottom)), sum(bottom))




Measured memory_bytes: 4648
program three_variables_game
  implicit none
  integer :: n, r(4) = 0, x(100001) = 0, i, j, p(2) = 0
  character(1) :: c(4) = (/ "A", "B", "X", "C" /)
  character(2) :: s
  read(*,*) n, r(1), r(2), r(4)
  if (sum(r) == 0) then
    write(*,'(a)') "No"
    stop
  end if
  do i = 1, n
    read(*,*) s
    x(i) = hash(s)
  end do
  if (sum(r) == 1) then
    j = maxloc(r,1)
    call simulate(.false.)
    r = 0
    r(j) = 1
    call simulate(.true.)
    stop
  end if
  p = get_index(x(1))
  if (r(p(1)) == 0 .and. r(p(2)) == 0) then
    write(*,'(a)') "No"
    stop
  else
    write(*,'(a)') "Yes"
  end if
  do i = 1, n
    p = get_index(x(i))
    j = 1
    if (sum(r) == 2 .and. r(p(1))*r(p(2)) == 1 .and. &
    & i < n .and. x(i) /= x(i+1) .and. p(2) == and(x(i),x(i+1))) then
      j = 2
    else if (r(p(1)) > r(p(2))) then
      j = 2
    end if
    r(p(j)) = r(p(j))+1
    r(p(3-j)) = r(p(3-j))-1
    write(*,'(a)') c(p(j))
  end do
contains
  integer function hash(s)
    character(2), intent(in) :: s
    if (s == "AB") hash = 3
    if (s == "AC") hash = 5
    if (s == "BC") hash = 6
  end
  function get_index(x) result(p)
    integer, intent(in) :: x
    integer :: p(2), i, k
    i = 0
    do k = 0, 2
      if (.not.btest(x,k)) cycle
      i = i+1
      p(i) = lshift(1,k)
    end do
  end
  subroutine simulate(out)
    logical, intent(in) :: out
    integer :: j
    if (out) write(*,'(a)') "Yes"
    do i = 1, n
      p = get_index(x(i))
      if (r(p(1)) /= 0) then
        j = 2
      else if (r(p(2)) /= 0) then
        j = 1
      else
        write(*,'(a)') "No"
        stop
      end if
      r(p(3-j)) = r(p(3-j))-1
      r(p(j)) = r(p(j))+1
      if (out) write(*,'(a)') c(p(j))
    end do
  end
end program three_variables_game

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;


int main(){
  int a,b;
  cin >> a >> b;
  if(a%2 == 0 || b%2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string S;
    cin >> S;
    if(S=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(S=="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny"<< endl;
    }
    return 0;

}

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

typedef pair<char, int> P;
vector<P> v;

char N2C(char num, int cnt){
	if(num == '1'){
		if(cnt % 5 == 1) return '.';
		else if(cnt % 5 == 2) return ',';
		else if(cnt % 5 == 3) return '!';
		else if(cnt % 5 == 4) return '?';
		else if(cnt % 5 == 0) return ' ';
	}
	else if(num == '2'){
		if(cnt % 3 == 1) return 'a';
		else if(cnt % 3 == 2) return 'b';
		else if(cnt % 3 == 0) return 'c';
	}
	else if(num == '3'){
		if(cnt % 3 == 1) return 'd';
		else if(cnt % 3 == 2) return 'e';
		else if(cnt % 3 == 0) return 'f';
	}
	else if(num == '4'){
		if(cnt % 3 == 1) return 'g';
		else if(cnt % 3 == 2) return 'h';
		else if(cnt % 3 == 0) return 'i';
	}
	else if(num == '5'){
		if(cnt % 3 == 1) return 'j';
		else if(cnt % 3 == 2) return 'k';
		else if(cnt % 3 == 0) return 'l';
	}
	else if(num == '6'){
		if(cnt % 3 == 1) return 'm';
		else if(cnt % 3 == 2) return 'n';
		else if(cnt % 3 == 0) return 'o';
	}
	else if(num == '7'){
		if(cnt % 4 == 1) return 'p';
		else if(cnt % 4 == 2) return 'q';
		else if(cnt % 4 == 3) return 'r';
		else if(cnt % 4 == 0) return 's';
	}
	else if(num == '8'){
		if(cnt % 3 == 1) return 't';
		else if(cnt % 3 == 2) return 'u';
		else if(cnt % 3 == 0) return 'v';
	}
	else if(num == '9'){
		if(cnt % 4 == 1) return 'w';
		else if(cnt % 4 == 2) return 'x';
		else if(cnt % 4 == 3) return 'y';
		else if(cnt % 4 == 0) return 'z';
	}
	else return 'A';
}

int main(){
	int n;
	cin >> n;
for(int i=0; i<n; i++){	
	
	string s;
	cin >> s;
	int len = s.size();
	
	int head = 0;
	for(int i=0; i < len; i++){
		if(s[i] == '0') head++;
		else break;
	}
	
	
	int body = -1;
	for(int i=head; i<len; i++){
		body++;
		if(s[i] == '0'){
			if(s[i-1] != '0'){
				v.push_back(P(s[i-1], body));
			}
			body = -1;
		}
	}
	
	for(int i=0; i<(int)v.size(); i++){
		if(N2C(v[i].first, v[i].second) == 'A') continue;
		else cout << N2C(v[i].first, v[i].second);
	}
	cout << endl;
	
	v.clear();
	//debug
	/*
	for(int i=0; i<(int)v.size(); i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
	*/
	
}//end	
	
	return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

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

	void solve() {
		int a = nextInt();
		int b = nextInt();
		int t = nextInt();
		System.out.println(t/a*b);
	}

	private int nextInt() {
		return Integer.parseInt(sc.next());
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,k;
  cin>>n>>k;
  string s,ans;
  cin>>s;
  rep(i,n){
    char buf;
    if(i!=k-1) buf = s[i];
    else{
      if(s[i] == 'A') buf = 'a';
      if(s[i] == 'B') buf = 'b';
      if(s[i] == 'C') buf = 'c';
    }
    cout<<buf;
  }
  cout<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

// 愚直に実装したら間に合わないので工夫した。
// 実際はpriority_queueを使えばよかった。
// 以下のは、途中の計算を二分探索で簡略化してる。

ll N;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N;
}

int solve(){
  input();
  ll sum;
  sum = N*(N-1)/2;
  cout << sum << endl;
  return 0;
}

int main()
{
  solve();
  return 0;
}


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

using namespace std;
 
int main() {
    int H,W;cin>>H>>W;
    int h,w;cin>>h>>w;
    int k = (H-h)*(W-w);
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <iterator>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
ll A, B;

// 約数を列挙
void list_divisors(ll n, set<ll>& result) {
    for (ll a = 1; a * a <= n; a++) {
        if (n % a == 0) {
            result.insert(a);
            if (a != n / a) {
                result.insert(n / a);
            }
        }
    }
}

// 素因数分解
void factorization(ll n, set<ll>& result)
{
    ll a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            result.insert(a);
            n /= a;
        } else {
            a++;
        }
    }
    result.insert(n);
}

int main(int argc, const char * argv[]) {
    cin >> A >> B;

    set<ll> diva, divb, intersect;
    factorization(A, diva);
    factorization(B, divb);
    diva.insert(1);
    divb.insert(1);
    
    std::set_intersection(diva.begin(), diva.end(),
                          divb.begin(), divb.end(),
                          std::inserter(intersect, intersect.end()));

    output(intersect.size());

    return 0;
}

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

string s;
int n;

int count(string l, string r){
    map<char, bool> mp;
    int count = 0;
    for(int i = 0; i < l.size(); i++) mp[l[i]] = true;
    for(int j = 0; j < r.size(); j++){
        if(mp[r[j]]){
            count++;
            mp[r[j]] = false;
        }
    }
    return count;
}

int main(){
    cin >> n >> s;
    int max = 0;
    for(int i = 1; i < n; i++){
        int buf = count(s.substr(0,i), s.substr(i, n - i));
        if(max < buf) max = buf;
    }
    cout << max << endl;
    return 0;
}

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

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

    long long int x[n+1],y[n+1];
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i] ;
    }
    long double k;
    int cnt=0;
    for(int i=0;i<n;i++){
        k = sqrt(x[i]*x[i] + y[i]*y[i]);
        if(k<=d){
            cnt += 1;
        }
        k = 0;
    }
            


    cout << cnt  << endl;

}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b;
	char op;
	vll v;
	while(1){
		cin >> a >> op >> b;
		if(op=='?') break;
		if(op=='+') v.pb(a+b);
		else if(op=='-') v.pb(a-b);
		else if(op=='*') v.pb(a*b);
		else if(op=='/') v.pb(a/b);
	}
	rep(i,SIZE(v)) cout << v[i] << endl;
	return 0;
}


Measured memory_bytes: 3144
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>

int main() {
  size_t H, W;
  scanf("%zu %zu", &H, &W);

  std::vector<std::vector<int>> a(H, std::vector<int>(W));
  for (auto& ai: a)
    for (auto& aij: ai)
      scanf("%d", &aij);

  std::vector<std::tuple<size_t, size_t, size_t, size_t>> res;
  for (size_t i = 0; i < H; ++i) {
    for (size_t j = 0; j < W; ++j) {
      if (a[i][j] % 2 == 0) continue;
      if (i+1 == H && j+1 == W) continue;
      size_t ni = i;
      size_t nj = j;
      ++((j+1 == W)? ni:nj);
      res.emplace_back(i+1, j+1, ni+1, nj+1);
      --a[i][j];
      ++a[ni][nj];
    }
  }

  printf("%zu\n", res.size());
  for (const auto& p: res) {
    size_t i, j, ni, nj;
    std::tie(i, j, ni, nj) = p;
    printf("%zu %zu %zu %zu\n", i, j, ni, nj);
  }
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if (A + B <= C*2)cout << A*X + B*Y << endl;
	else {
		int sum = 0;
		int x, y;
		if (X >= Y) {
			x = X;y = Y;
		}
		else {
			x = Y; y = X;
			swap(A, B);
		}
		sum += C*y*2;
		x -= y;
		sum += min(A*x, C*x*2);
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 256
numberOfDataSets = 0
sideLengthList = []

while 1:
	try:
		data = raw_input().split()

		if len(data) == 1 :
			numberOfDataSets = int(data[0])

			if numberOfDataSets != 0 :
				sideLengthList = []

		elif len(data) == 3 and numberOfDataSets != 0:
			numberOfDataSets -= 1
			sideLengthList.append(data)
 
		if numberOfDataSets == 0 :
			# Is it a right triangle?
			for i in range(0, len(sideLengthList)) :

				a = int(sideLengthList[i][0])*int(sideLengthList[i][0])
				b = int(sideLengthList[i][1])*int(sideLengthList[i][1])
				c = int(sideLengthList[i][2])*int(sideLengthList[i][2])

				if a + b == c or b + c == a or c + a == b :
					print"YES"
				else:
					print"NO"

	except:
		break

Measured memory_bytes: 4388
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
 
ll choose2(ll n){
    return n*(n-1)/2;
}
 
int main() {
    ll a,b;
    int k;
    cin>>a>>b>>k;
    vector<ll> ans;

    int loop_max,loop_min;
    if(b - a <= k){
        loop_max = b;
        loop_min = a;
    }
    else{
        loop_max = a + k - 1;
        loop_min = b - k + 1;
    }

    rep(i,a,loop_max){
        ans.push_back(i);
        //cout<<i<<endl;
    }
    rep(i,loop_min,b){
        bool flag = true;
        rep(j,0,ans.size()-1){
            if(i == ans[j]) flag = false;
        }
        if(flag) ans.push_back(i);
    }

    sort(ans.begin(),ans.end());

    rep(i,0,ans.size()-1) cout<<ans[i]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#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 ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n;
int a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	cout << a[n / 2] - a[n / 2 - 1] << endl;
	ggr
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
mod = 10 ** 9 + 7
K = max(N, M)
kaijo = [1] * (K + 1) 

for i in range(K):
    kaijo[i + 1] = ((i + 1) * kaijo[i]) % mod
    
if abs(N - M) > 1:
    print(0)
    
else:
    res = 1
    res *= kaijo[N] * kaijo[M]
    if N == M:
        res *= 2
    
    print(res % mod)

Measured memory_bytes: 6900
let cnt = ref 0

let merge a l m r =
  let x = m - l in
  let ai = Array.make (x + 1) max_int in
  for i = 0 to x - 1 do
    ai.(i) <- a.(l + i)
  done;
  let aj = Array.make (r - m + 1) max_int in
  for i = 0 to r - m - 1 do
    aj.(i) <- a.(m + i)
  done;
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      cnt := !cnt + (x - !i);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) >= r then () else
  let m = (l + r) / 2 in
  merge_sort a l m;
  merge_sort a m r;
  merge a l m r

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 11640
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second
 
#define ler freopen("inspection.in","r",stdin);freopen("inspection.out","w",stdout)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define debug cout<<"ACM ICPC\n"
 
#define pdd pair<ld,ld> 
#define ll long long
#define ld long double
#define vi vector<int> 
#define pii pair<int,int>  
 
#define MAXN 100005
#define LOG 21
#define EPS 1e-6
#define INF 1e12L

int n, m, dist[55][55], cnt;
char g[55][55];
int dx[4]= {0,0,-1,1};
int dy[4]= {1,-1,0,0};
bool inside(int x, int y){ return x>=0 && y>=0 && x<n && y<m;}

int main(){
	cin >> n >> m;
	rep(i,0,n) rep(j,0,m){
		cin >> g[i][j];
		if(g[i][j]=='#') cnt++;
	}
	
	queue <pii> q;
	dist[0][0]= 1;
	q.push(mp(0,0));

	while(!q.empty()){
		int x= q.front().F;
		int y= q.front().S;
		q.pop();
		
		rep(i,0,4){
			int a= x + dx[i];
			int b= y + dy[i];
			if(inside(a,b) && dist[a][b]==0 && g[a][b]=='.'){
				dist[a][b]= dist[x][y] + 1;
				q.push(mp(a,b));
			}
		}
	}
	//cout << cnt << " " << dist[n-1][m-1] << endl;
	if(dist[n-1][m-1]==0) cout << -1 << endl;
	else cout << n*m - cnt - dist[n-1][m-1] << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MX=2e5+5;
int d[MX];
pair<int,int> e[MX];
char c[MX];
const int INF=1e9;
int b[MX];
int n,m;
vector<pair<int,int>> a[MX];
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    int i;
    for(i=1 ; i<=m ;i++)b[i]=INF;
    for(i=1 ; i<=n ; i++)cin>>d[i],e[i]={d[i],i};
    for(i=1 ; i<=m ; i++){
        int u,v;
        cin>>u>>v;
        a[u].push_back({v,i});
        a[v].push_back({u,i});
    }

    sort(e+1,e+n+1);
    for(i=1 ; i<=n ; i++){
        int v=e[i].second;
        if(c[v])continue;
        for(auto j: a[v]){
            int u=j.first;
            if(d[u]<d[v]){
                if(c[u]=='B')c[v]='W';
                else c[v]='B';
                b[j.second]=d[v];
                break;
            }
            if(d[u]==d[v]){
                if(c[u]=='B')c[v]='W';
                else{
                    c[v]='B';
                    c[u]='W';
                }
                b[j.second]=d[v];
                break;
            }
        }
       // cout<<v<<" "<<c[v]<<endl;
    }
    int isok=1;

    for(i=1 ; i<=n ; i++){
       // cout<<c[i]<<endl;
        if(c[i]==0)isok=0;
    }
    if(isok==0){
        cout<<-1;
        return 0;
    }

    cout<<c+1<<endl;
    for(i=1 ; i<=m ; i++){
        cout<<b[i]<<"\n";
    }
    return 0;
}


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

ve<int> seen;

int dfs(ve<ve<int>> &G, int x){
    if(seen[x]!=-1) return seen[x];
    int ans=0;
    for(int next: G[x]){
        ans = max(ans,dfs(G, next)+1);
    }
    seen[x] = ans;
    return ans;
}

int main(){
    int n, m;
    cin >> n >> m;
    ve<ve<int>> G(n);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    seen.resize(n,-1);
    for(int i = 0; i < n; i++){
        if(G[i].empty()) seen[i] = 0;
    }
    for(int i = 0; i < n; i++){
        if(seen[i]!=-1)continue;
        dfs(G,i);
    }
    int ans;
    for(int i = 0; i < n; i++){
        ans = max(ans,seen[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
import math
def koch(d, p1, p2):
    if d == 0:
        return
    x=p2[0]-p1[0]
    y=p2[1]-p1[1]
    s = [(p1[0]*2+p2[0]*1)/3.0,(p1[1]*2+p2[1]*1)/3.0]
    t = [(p1[0]*1+p2[0]*2)/3.0,(p1[1]*1+p2[1]*2)/3.0]
    u = [p1[0]+x/2-y*math.sqrt(3)/6,p1[1]+y/2+x*math.sqrt(3)/6]
    koch(d - 1, p1, s)
    print(*s)
    koch(d - 1, s, u)
    print(*u)
    koch(d - 1, u, t)
    print(*t)
    koch(d - 1, t, p2)
 
n = int(input())
p1=[0,0]
p2=[100,0]
print(*p1)
koch(n,p1,p2)
print(*p2)



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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    if (N % 2 == 0){
        vector<ll> dp1(N + 1, 0);
        vector<ll> dp2(N + 1, 0);
        dp1[0] = A[0];
        dp2[1] = A[1];
        for (ll i = 2; i < N; i += 2){
            dp1[i] = dp1[i - 2] + A[i];
        }
        for (ll i = 3; i < N; i += 2){
            dp2[i] = max(dp2[i - 2] + A[i], dp1[i - 3] + A[i]);
        }
        ans = max(dp1[N - 2], dp2[N - 1]);
    }
    else{
        vector<ll> dp1(N + 1, 0);
        vector<ll> dp2(N + 1, 0);
        vector<ll> dp3(N + 1, 0);
        dp1[0] = A[0];
        dp2[1] = A[1];
        dp3[2] = A[2];
        for (ll i = 2; i < N; i += 2){
            dp1[i] = dp1[i - 2] + A[i];
        }
        for (ll i = 3; i < N; i += 2){
            dp2[i] = max(dp1[i - 3] + A[i], dp2[i - 2] + A[i]);
        }
        for (ll i = 4; i < N; i += 2){
            dp3[i] = max(dp1[i - 4] + A[i], max(dp2[i - 3] + A[i], dp3[i - 2] + A[i]));
        }
        ans = max(dp1[N - 3], max(dp2[N - 2], dp3[N - 1]));
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 9516
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

aa = a % 10
bb = b % 10
cc = c % 10
dd = d % 10
ee = e % 10

a = a - aa
b = b - bb
c = c - cc
d = d - dd
e = e - ee

k = 0

if aa == 0:
    aa = 10
elif aa > 0:
    k += 1
if bb == 0:
    bb = 10
elif bb > 0:
    k += 1
if cc == 0:
    cc = 10
elif cc > 0:
    k += 1
if dd == 0:
    dd = 10
elif dd > 0:
    k += 1
if ee == 0:
    ee = 10
elif ee > 0:
    k += 1

print(a + b + c + d + e + (k - 1) * 10 + min(aa, bb ,cc, dd, ee))

Measured memory_bytes: 3064
const main = (input) => {
  const [s, t] = input.trim().split('\n')
  let count = 0
  for (let i=0; i<s.length; i++) if (s[i] !== t[i]) count++
  return console.log(count)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
    int h, w;
    cin >> h >> w;

    string s[h];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < h; i++) {
        cout << "#" << s[i] << "#" << endl;
    }

    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;

    return 0;
}


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

typedef long long ll;
const ll INF = 3000000000000;
struct edge{int from, to; ll cost;};

int main()
{
  int N, M; cin >> N >> M;
  edge es[M];
  for (int i = 0; i < M; i++) {
    cin >> es[i].from >> es[i].to >> es[i].cost;
    es[i].cost *= -1;
  }

  ll d[N+1];
  fill(d, d + N + 1, INF);
  d[1] = 0;
  bool INF_flag = false;
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < M; i++) {
      int from = es[i].from, to = es[i].to; ll cost = es[i].cost;
      if (d[from] != INF && d[to] > d[from] + cost) {
        d[to] = d[from] + cost;
        if (k == N-1 && to == N)
          INF_flag = true;
      }
    }
  }

  if (INF_flag) cout << "inf" << endl;
  else cout << -d[N] << endl;
}



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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/

/**************************************/

/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x; cin >> x;

    rep1(k,360){
        if(k*x%360==0){
            cout << k << endl;
            return 0;
        }
    }

    return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
#define MOD 998244353
using namespace std;
typedef long long ll;
typedef __int128 lll;

lll w[128];

map<pair<lll,int>,int> dp;
lll s;int n;
char _s[128];

int f(lll s, int n){
	auto p=mp(s,n);
	if(dp.count(p))return dp[p];
	int& r=dp[p];
	if(s&1)r=(2*f(s>>1,n-1))%MOD;
	else r=f(s>>1,n-1);
	for(int i=1;i<=n;i++){ // len
		lll z=s&w[i];
		for(int k=2;i*k<=n;k++){ // cuantos
			z&=(s>>((k-1)*i))&w[i];
			r+=(1LL*f(z,i)*f(s>>(k*i),n-k*i))%MOD;r%=MOD;
		}
	}
	return r;
}

int main(){
	fore(i,1,128)w[i]=((lll)1<<(i-1))|w[i-1];
	dp[mp((lll)0,0)]=1;
	scanf("%s",_s);n=strlen(_s);
	fore(i,0,n)if(_s[i]=='1')s|=(lll)1<<i;
	printf("%d\n",f(s,n));
	return 0;
}

Measured memory_bytes: 4480
#include<stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x-r<0 || x+r>W || y-r<0 || y+r>H){
    printf("No\n");
  }
  if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
    printf("Yes\n");
  }
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=0,s=0,c=0,t;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	s+=a[i];
    }
    for(int i=0;i<n;i++)
    {
    	c=(c+a[i]);
    	t=(s-c)%MOD;
    	t=((a[i]%MOD)*(t%MOD))%MOD;
    	//t=(a[i]*(s-c))%MOD;
    	ans=(ans+t)%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

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

int main()
{
    ll n, m ,x;
    cin >> n >> m >> x;
    vector<vector<ll>> ca(n, vector<ll>(1+m,0));
    rep(i,n) {
        cin >> ca[i][0];
        rep(j,m) {
            cin >> ca[i][j+1];
        }
    }
    ll ans = -1;
    ll price = INF;

    for(int bit = 0; bit< (1 << n); bit++) {
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { 
                S.push_back(i);
            }
        }
        vector<ll> tmp(m+1,0);
        for (int i = 0; i < (int)S.size(); ++i) {
            rep(j,m+1) {
                tmp[j] += ca[S[i]][j];
            }
        }
        int check = 1;
        for(int i = 1; i <= m; i++) {
            if(tmp[i] < x) {
                check = 0;
                break;
            }
        }
        if (check) {
            if (ans < 0)
                ans = tmp[0];
            else
                ans = min(ans, tmp[0]);
        }
    }

        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612