akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end(), less<char>());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout <<  "No" << endl;
    }
    return 0;
}

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

using namespace std;

using int64 = long long;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

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

  int n, m;
  cin >> n >> m;
  auto graph = ReadUndirectedGraph(n, m, true);

  int r1 = 0;
  int r2 = graph[r1][0].to;
  vector<int> visited(n);
  visited[r1] = 1;
  visited[r2] = 1;

  auto find_path = [&](int r) -> vector<int> {
    vector<int> path({r});
    int v = r;
    while (true) {
      bool is_end = true;
      for (const auto& e : graph[v]) {
        if (visited[e.to]) continue;
        is_end = false;
        path.push_back(e.to);
        visited[e.to] = 1;
        v = e.to;
        break;
      }
      if (is_end) break;
    }
    return path;
  };
  auto p1 = find_path(r1);
  auto p2 = find_path(r2);
  reverse(p1.begin(), p1.end());

  cout << p1.size() + p2.size() << endl;
  for (int v : p1) {
    cout << v + 1 << " ";
  }
  for (int v : p2) {
    cout << v + 1 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 7288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define lPair pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define debug(a) cout << a << endl;
const ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,M;
ll a,b,c;
struct edge{ll from,to,cost;};
vector<edge> es;
ll d[1000];
ll V,E;
//頂点sからの最大距離
bool BellmanFord(ll s){
    for(int i = 0; i < V; i++) d[i] = -INF;
    d[s] = 0;
    for(int i = 0; i < V-1; i++){ //**
        for(int j = 0; j < E; j++){
            edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from]+e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    ll dv = d[V-1];
    for(int i = 0; i < V; i++){ //**
        for(int j = 0; j < E; j++){
            edge e = es[j];
            if(d[e.to] != -INF && d[e.to] < d[e.from]+e.cost){
                d[e.to] = d[e.from]+e.cost;
            }
        }
    }
    if(d[V-1] > dv) return 0;
    else return 1;

}

int main(){
    cin >> V >> E;
    for(int i = 0; i < E; i++){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back({a,b,c});
    }
    if(BellmanFord(0)) cout << d[V-1] << endl;
    else cout << "inf" << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int N,s[100000];

int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=N)return 0;
  res=solve(i+1,m)||solve(i+1,m-s[i]);
  return res;
}

int main(){
  
  int i,j,N2,flag=0,m;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&N2);
  
  for(j=0;j<N2;j++){
    scanf("%d",&m);
    flag=solve(0,m);
    if(flag==1)printf("yes\n");
    else printf("no\n");
  }
  
  return 0;  
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
using namespace std;
const long long mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;

int main(){
    int H1,M1,H2,M2,K;
    cin >>H1>>M1>>H2>>M2>>K;
    cout <<60*H2+M2-60*H1-M1-K<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

int main(){
	char card[1000], temp[1000];
	int i,j,k;
	int c_num,s_num,shuffle;
	
	while(1){
		for(i=0;i<1000;i++){
			scanf("%c", &card[i]);
//			printf("%d ", i);
			if(card[i] == '\n'){
				c_num = i;
				break;
			}
			if(card[0] == '-'){
				break;
			}
		}
			
		if(card[0] == '-'){
				break;
		}
		
		scanf(" %d", &s_num);
				
		for(j=0;j<s_num;j++){
			scanf("%d\n", &shuffle);
			for(k=0;k<shuffle;k++){
				temp[c_num - shuffle + k]=card[k];
//				printf("%d%c%d ", k, temp[c_num - shuffle + k],c_num - shuffle + k);
			}
//			printf("\n");
			for(k=0;k<c_num-shuffle;k++){
				temp[k]=card[shuffle + k];
//				printf("%d%c%d ", k, temp[k], shuffle + k);
			}
//			printf("\n");
			for(k=0;k<c_num;k++){
				card[k]=temp[k];
			}
			
		}
		
		for(i=0;i<c_num;i++){
			printf("%c", temp[i]);
		}
		
		printf("\n");
}	
    return 0;

}

Measured memory_bytes: 564
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
	a = max(a,b);
}

void solve(){	
  double r;cin>>r;
  printf("%.12lf\n", 2*M_PI*r);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //int t; cin >> t;
    //while(t--) solve();
    //
    solve();
    return 0;
}

Measured memory_bytes: 3812
import kotlin.math.*

fun main() {
    println(solve())
}

val solve: () -> Any = {
    val N = readInt()
    val L = readIntList().sorted()
    var res = 0
    for (i in 0 until N) {
        val a = L[i]

        for (j in i until N) {
            val b = L[j]
            if (a == b) continue

            for (k in j until N) {
                val c = L[k]
                if (b == c) continue
                if (a+b > c)
                    res++
            }
        }
    }
    res
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = this.toDouble().pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a

fun <T> T.ifOrThis(bool: (T) -> Boolean, trans: (T) -> T) = if (bool(this)) trans(this) else this
fun <T> T.ifOrThis(bool: Boolean, trans: (T) -> T) = if (bool) trans(this) else this

Measured memory_bytes: 40680
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  ll N;
  cin >> N;
  string S;
  map<string,ll>m;
  for (ll i = 0; i < N; i++) {
    cin >> S;
    m[S] += 1;
  }

  int maxv = 0;
  for (const auto& x : m) {
    int v = x.second;
    if (v > maxv) maxv = v;
  }

  for(auto i = m.begin(); i != m.end(); i++) {
    if(i->second == maxv){
      cout << i->first << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 25216
N,M = [int(s) for s in input().split()]
light=[0 for i in range(M)]
for i in range(M):
  lst= [int(s) for s in input().split()]
  light[i]=lst
mod= [int(s) for s in input().split()]
swi=[[]]
for i in range(N):
  p0=[s+[0] for s in swi]
  p1=[s+[1] for s in swi]
  swi=p0+p1
count=0
for i in range(2**N):
  flag=1
  for j in range(M):
    k=light[j][0]
    add=0
    for l in range(1,k+1):
      add=add+swi[i][light[j][l]-1]
    if(add%2!=mod[j]):
      flag=0
      break
  count=count+flag
print(count)

Measured memory_bytes: 3188
#                               #
    # author : samars_diary #
    # 16-09-2020 │ 18:28:11 #
#                               #

import sys, os.path, math

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

mod =  1000000000+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii();print((pow(10,a,mod)+pow(8,a,mod)-2*pow(9,a,mod))%mod)
for _ in range(1):
    solve()

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
using namespace std;

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

    if(n >= 10)print(r);
    else print(r + 100 * (10 - n) );

}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

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; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int n , m ; 
	cin >>  n >> m ; 
	int p[m];
	string s[m];
	rep(i,m) cin >> p[i] >> s[i];
	//入力ここまで
	//ACが出なかったらそれまでのwaを足さないことに注意です。
	vector<int> a(n,0);//ACが出てくるまでのwaの数を足していく
	vector<bool> dep_ac(n,false);
	int ac = 0 ;
	int wa = 0 ;
	rep(i,m){
		//今見てるプロブレムp[i]について
		if(dep_ac[p[i]]) continue;
		else{
			if(s[i] =="AC"){
				dep_ac[p[i]] = true;
				ac ++ ;
				wa +=a[p[i]];
			}else{
				a[p[i]] ++ ;
			}
		}
	}
	cout << ac <<" " << wa << endl;

}


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

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  for (int i = N - 1; i != 0; --i) {
    if (H[i - 1] > H[i] + 1) {
      cout << "No" << endl;
      return 0;
    } else if (H[i - 1] == H[i] + 1) {
      H[i - 1] = H[i];
    } else {
      continue;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		List<Integer> TList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			TList.add(sc.nextInt());
		}
		Collections.sort(TList);

		int cnt = 0;
		int bus = 0;
		int start = TList.get(0);

		for (int i : TList) {
			if (cnt < C && i <= start + K) {
				cnt ++;
				continue;
			}
			cnt = 1;
			start = i;
			bus++;
		}
		bus++;
		System.out.println(bus);
	}
}


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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

static constexpr uint32_t mul_inv(uint32_t n, int e = 5, uint32_t x = 1) {
  return e == 0 ? x : mul_inv(n, e - 1, x * (2 - x * n));
}


int main() {
  int X;
  cin >> X;
  if(X >= 30) cout << "Yes\n";
  else cout << "No\n";
}



Measured memory_bytes: 3644
package main

import "fmt"

func main() {

	//入力
	var n int
	fmt.Scan(&n)
	var flag  = true
	//初回だけスカ
	var height_now int
	fmt.Scan(&height_now)
	height_now = 1

	for i:= 1 ; i < n ; i++{
		//入力
		var height_next int
		fmt.Scan(&height_next)

		if(height_now < height_next){

			height_now = height_next - 1

		}else if (height_now > height_next) {

			flag = false
			break

		}
	}

	if(flag){
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Sun Dec  3 21:10:11 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t cost(vector<vector<uint32_t>> F, vector<vector<int32_t>> P, vector<uint32_t> ret)
{
  int32_t c = 0;
  if (ret.size() > 0) {
    for (uint32_t n = 0; n < F.size(); n++) {
      uint32_t count = 0;
      for (uint32_t i = 0; i < ret.size(); i++) {
        if (F[n][ret[i]] == 1) {
          count += 1;
        }
      }
      c += P[n][count];
    }
    return c;
  } else {
    return INT32_MIN;
  }
}

int32_t comb(vector<vector<uint32_t>> F, vector<vector<int32_t>> P, int32_t i, vector<uint32_t> ret)
{
  if (i == 10) {
    return cost(F, P, ret);
  } else {
    vector<uint32_t> ret1(ret);
    ret1.push_back(i);
    return max(comb(F, P, i + 1, ret), comb(F, P, i + 1, ret1));
  }
}

int32_t main()
{
  uint32_t N;
  cin >> N;

  vector<vector<uint32_t>> F(N);
  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = 0; j < 10; j++) {
      uint32_t f;
      cin >> f;
      F[i].push_back(f);
    }
  }

  vector<vector<int32_t>> P(N);
  for (uint32_t i = 0; i < N; i++) {
    for (uint32_t j = 0; j <= 10; j++) {
      int32_t p;
      cin >> p;
      P[i].push_back(p);
    }
  }

  vector<uint32_t> ret;
  cout << comb(F, P, 0, ret) << endl;

  return 0;
}


Measured memory_bytes: 640
N = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))

ans = 0
anstemp = 2**20
temp = 0
for i in range(len(H)):
	temp = T - H[i] * 0.006
	if abs(temp - A) <= abs(anstemp - A):
		ans = i
		anstemp = temp

print(ans+1)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
        a[i] = sc.nextInt();
        }
        String delimitor = "";
        for (int i = a.length - 1; i >= 0; i--) {
            System.out.print(delimitor);
            System.out.print(a[i]);
            delimitor = " ";
        }
        System.out.printf("\n");

        // 以下で配列aの中身を逆順に表示しよう
        // 改行なしで表示する時は System.out.print(表示する値) を使おう
        // 改行だけを表示する時は System.out.println() を使おう
        sc.close();
        }
        }


Measured memory_bytes: 26420
# coding=utf-8
import itertools


def main():
    while True:
        n, t = map(int, raw_input().split())
        if n + t == 0:
            break
        print sum([1 if sum(three) == t else 0 for three in itertools.combinations(xrange(1, n+1), 3)])


if __name__ == '__main__':
    main()

Measured memory_bytes: 5792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
	    String line = Io.read();
	    int[] info = parse(line);

        Explorer exp = new Explorer(info);

        Io.write(exp.compute());
    }

    private static int[] parse(String line) {
        String[] inputsStr = line.split(" ");
        int[] result = new int[inputsStr.length];

        for (int i = 0; i < inputsStr.length; i++) {
            result[i] = Integer.parseInt(inputsStr[i]);
        }

        return result;
    }
}

class Explorer {
    final private int mod = 1000000000 + 7;

    private int height;
    private int width;

    private int blockHeight;
    private int blockWidth;

    private long[] modFactorial;
    private long[] invModFactorial;

    public Explorer(int[] info) {
        height = info[0];
        width = info[1];

        blockHeight = info[2];
        blockWidth = info[3];

        modFactorial = new long[height + width + 1];
        invModFactorial = new long[height + width + 1];

        modFactorial[0] = 1;
    }

    public int compute() {
        initModFactorial();
        initInvModFactorial();

        long sum = 0;
        for (int i = 0; i < width - blockWidth; i++) {
            long first = combMod(blockWidth + height - blockHeight + i - 1, blockWidth + i) % mod;
            long second = first * combMod(width - blockWidth - i + blockHeight - 2, blockHeight - 1) % mod;

            sum += second;
        }

        return (int)(sum % mod);
    }

    private void initModFactorial() {
        for (int i = 1; i <= height + width; i++) {
            modFactorial[i] = (i * modFactorial[i - 1]) % mod;
        }
    }

    private void initInvModFactorial() {
        long lastInvModFactorial = binaryPower(modFactorial[height + width], mod - 2);
        invModFactorial[height + width] = lastInvModFactorial;

        for (int i = height + width; i > 0; i--) {
            invModFactorial[i - 1] = (invModFactorial[i] * i) % mod;
        }
    }

    private long binaryPower(long x, long p) {
        if (p == 0) {
            return 1;
        } else if((p & 1) == 1) {
            return (x * binaryPower((x * x) % mod, p / 2)) % mod;
        } else {
            return binaryPower((x * x) % mod, p / 2) % mod;
        }
    }

    private long combMod(int n, int p) {
        return (((modFactorial[n] * invModFactorial[p]) % mod) * invModFactorial[n - p]) % mod;
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        return line;
    }

    /**
     * 標準出力
     * @param line
     */
    public static void write(int line)
    {
        System.out.println(line);
    }
}

Measured memory_bytes: 23636
#include<stdio.h>
#include<stdlib.h>
int main(void){

int a , b ;
char op;
while(op!='?'){
scanf("%d %c %d",&a,&op,&b);
switch(op){
case '+':
	printf("%d\n",a+b);
	break;
case '-':
	printf("%d\n",a-b);
	break;
case '*':
	printf("%d\n",a*b);
	break;
case '/':
	printf("%d\n",a/b);
	break;
}
}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
  ll N,L; cin >> N >> L;
  if( 1 - N <= L && L <= 0){
    cout << N*(L-1) + (N*(N+1))/2 << endl;}
  else if( L > 0){
     cout << N*(L-1) + (N*(N+1))/2 - L << endl;}
  else if( L < ( 1 - N)){
    cout << N*(L-1) + (N*(N+1))/2  - ( L + N - 1) << endl;}
  
  return 0;}
   
 

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll x, y;
  cin >> x >> y;
  ll cnt = abs(abs(x) - abs(y));
  if ((x > 0 and y < 0) or (x < 0 and y > 0)) ++cnt;
  if (x > y and x <= 0 and y <= 0) cnt += 2;
  if (x > y and x >= 0 and y >= 0) cnt += 2;
  if (x > 0 and y == 0) --cnt;
  if (x == 0 and y < 0) --cnt;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
string s;
int ans,num;
int main()
{
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i]=='A' || s[i]=='G' || s[i]=='T' || s[i]=='C') num++;
			else num = 0;
		ans = max(ans,num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def warshall_floyd(cost):
    # cost[i][j] : iからjへの最短距離
    for k in range(10):
        for i in range(10):
            for j in range(10):
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
    return cost


h, w = map(int, input().split())
cost = [list(map(int, input().split())) for _ in range(10)]
a = tuple(tuple(map(int, input().split())) for _ in range(h))

cost = warshall_floyd(cost)

ans = 0
for r in range(h):
    for c in range(w):
        frm = a[r][c]
        if frm == -1:
            continue
        ans += cost[frm][1]
print(ans)


Measured memory_bytes: 3316
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 07/Mar/20 05:45:59 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	deque< char > s;
	string t;
	cin >> t;
	for (auto& i : t) {
		s.push_back (i);
	}

	int q;
	cin >> q;
	bool flag = 0;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			flag = 1 ^ flag;
		} else {
			int f;
			char c;
			cin >> f >> c;
			if (f == 1) {
				if (!flag) {
					s.push_front (c);
				} else {
					s.push_back (c);
				}
			} else {
				if (!flag) {
					s.push_back (c);
				} else {
					s.push_front (c);
				}
			}
		}
	}
	if (flag) {
		reverse (all (s));
	}
	for (auto& i : s)
		cout << i;
	cout << endl;
	return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <vector>

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

int main(){
  int n, l, j = 0, k = 1, c = 0;
  bool p = false;
  vector<int> ls(200010, -1);
  cin >> n;
  REP(i, n) {
    cin >> l;
    ls[i] = l;
  }
  while (ls[j] != -1) {
    if (ls[j] != k) {
      ls[j] = 0;
    } else {
      p = true;
      ++k;
    }
    ++j;
  }

  if (!p) {
    cout << -1 << endl;
    return 0;
  }

  REP(i, n) {
    if (ls[i] == 0) ++c;
  }

  cout << c << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>

using namespace std;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    if(n*a < b){
        cout << n*a << "\n";
    }else {
        cout << b << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n;
    cin >> n;
    bool z = true;
    bool exist0 = false;
    ll ans = 1;
    vi a(n);
    rep(i, n){
      cin >> a[i];
      if(a[i]==0){
        exist0 = true;
        ans = 0;
      }
    }
    if(exist0){
        print(0);
    }
    else{
      rep(i,n){
          if(1000000000000000000/ans<a[i]){
              z = false;
              break;
          }
          ans *= a[i];
      }
      if(z){
          print(ans);
      }
      else{
          print(-1);
      }
    }
}

Measured memory_bytes: 4048
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,k;
    std::cin >> n>>k;
    
    // あまりが全て同じ
    // あまり*2 = K or 0;
    // kは偶数
    // あまりがk/2であるものの数の三条が答え
    ll result = (ll)pow(n/k,3);
    
    ll cou = 0;
    if(k%2==0){
        for (int i = 1; i <= n; i++) {
            if(i%k == k/2){
                cou++;
            }
        }
        result += (ll)pow(cou,3);
    }
    std::cout << result << std::endl;
}


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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
void solve() {
	int a, p; cin >> a >> p; p += 3 * a; cout << p / 2;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 200000
int main()
{
  int n,i,l,j,k,q;
  int p[101];
  int m[101][101];

  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&p[i-1],&p[i]);
    }

  
  for(i=1;i<=n;i++)
    m[i][i]=0;
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  j=i+l-1;
	  m[i][j] = INF;
	  for(k=i;k<=j-1;k++)
	    {
	      q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	      if(m[i][j]>q) m[i][j]=q;
	    }
	}
    }

  printf("%d\n",m[1][n]);
  
  return 0;
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    unordered_map<int, pair<int, int>> m;
    int a[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
            m[a[i][j]] = make_pair(i, j);
        }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        if (m.find(b) != m.end()) {
            a[m[b].first][m[b].second] = -1;
        }
    }
    for (int i = 0; i < 3; i++) {
        if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) {
            cout << "Yes\n";
            return 0;
        }
        if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) {
            cout << "Yes\n";
            return 0;
        }
    }
    if ((a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) || (a[0][2] == -1 && a[1][1] == -1 && a[2][0])) {
        cout << "Yes\n";
        return 0;
    } else {
        cout << "No\n";
        return 0;
    }
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define sum accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
ll n,m,k,ko;
bool ok = false;
vvl que;
ll arr[10];

void solve(ll i ,ll j)
{
    if(i==n)
    {
        ll c=  0;
        for(ll p = 0 ; p<k ; p++)
        {
            if(arr[que[p][1]-1] - arr[que[p][0]-1]==que[p][2])
            {
                c+=que[p][3];
            }
        }
        ko = max(ko,c);
        return;
    }
    for(ll p = j ; p<=m ; p++)
    {
        arr[i] = p;
        solve(i+1,p);
    }
}
int main()
{
    FastIO ;
    PRECISION(10) ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    //string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n>>m>>k;
    ko = minf;
    que.resz(k);
    for(i=0 ; i<k ; i++)
    {
        rep(j,0,4)
        {
            cin>>a;
            que[i].pb(a);
        }
    }
    y = 0;
    x = 0;
    for(i=1 ; i<=m ; i++)
    {
        arr[0] = i;
        solve(1,i);
    }
    cout<<ko;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int n, m;
        cin >> n >> m;
        if(n == 0) break;
        vector<int> a(n);
        for(int i = 0; i < n; ++i){
            cin >> a[i];
        }
        int ma = 0;
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                if(i == j) continue;
                if(a[i] + a[j] <= m) ma = max(ma, a[i] + a[j]);
            }
        }
        cout << (ma == 0 ? "NONE" : to_string(ma)) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3268
#(N-1)*N+K
#N,N,N,N,--NからN-1,N-1,,,N-1はN回
K=int(input())
N=50
S=K//N
T=K%N
L=[N-1+S for i in range(N)]
for i in range(T):
  L[i]+=N+1
for i in range(N):
  L[i]-=T
print(N)
L=list(map(str,L))
print(" ".join(L))

Measured memory_bytes: 9156
d = []
for i in 1..3 do
    b = gets
    d << b.split
end
c = ""
a = []
d.each{|hai|
    a << hai.map(&:to_i)
}

for j in 0..1 do
    for k in j...2 do
        if !((a[j][0]-a[k+1][0]==a[j][1]-a[k+1][1]) && (a[j][0]-a[k+1][0]==a[j][2]-a[k+1][2])) then
             c = "No"
             isBreak = true
            break;
        else
            c = "Yes"
        end
    end
    break if isBreak
end

print c

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

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

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



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

	string s;
	cin >> s;
	string t = "keyence";
	int cnt = 0;
	for (auto i : s) {
		if (i == t[cnt]) {
			cnt++;
		}
		else break;
		if (cnt == 7)break;
	}
	if (cnt == 7) {
		cout << "YES\n";
		return 0;
	}
	int box = 6;
	reverse(s.begin(), s.end());
	for (auto i : s) {
		if (i == t[box]) {
			box--;
		}
		else break;
		if (box + 1 == cnt) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    int main(void){    
        int W,H,x,y,r;    
        scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);       
        if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0) {
            printf("Yes\n");}   
        else {printf("No\n");}        
        return 0;    
        
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0; i<n; i++)
 
map<string, int> h;
 
int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
 
int main(){
  h["N"]=0; h["E"]=1; h["S"]=2; h["W"]=3;
 
  while(true){
    int N;
    cin>>N;
    if(N==0)break;
    int mp[21][21];
    memset(mp, 0, sizeof(mp));
    rep(i,N){
      int x, y;
      cin>>x>>y;
      mp[x][y]=1;
    }
 
    int M, nx=10, ny=10;
    int cn=0;
    cin>>M;
    rep(i,M){
      string d;
      int l;
      cin>>d>>l;
      int dd=h[d];
      rep(j,l){
        nx+=dir[dd][0]; ny+=dir[dd][1];
        if(mp[nx][ny]==1){cn++; mp[nx][ny]=0;}
      }
    }
    if(N==cn)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3012
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
  cin>>n;
  int a[n];
  int sum = 0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  double mn = (double)(sum)/(double)(n);
  double mx = 101010.022;
  int ans = 0;
  for(int i=0;i<n;i++)
  {
    if( abs(mn-a[i]) < mx)
    {
      mx = abs(mn-a[i]);
      ans = i;
    }
  }
cout<<ans;
}



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

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

  if(a == 'H') {
    if (b == 'H'){
      cout << 'H' << endl;
    }
    else if (b == 'D'){
      cout << 'D' << endl;
    }
  }
  else if (a == 'D'){
    if (b == 'H'){
      cout << 'D' << endl;
    }
    else if (b == 'D'){
      cout << 'H' << endl;
    }
  }
}


Measured memory_bytes: 256
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,A,B=map(int,pin().split())
  if (B-A)%2==0:
    print((B-A)//2)
    return 
  if A<N-B+1:
    print(A+(B-A-1)//2)
  else:
    print(N-B+1+(B-A-1)//2)
  return 
main()

Measured memory_bytes: 9096
import itertools
import math

n = int(input())

x = []
y = []
for i in range(n):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)

def calcdist(x0, y0, x1, y1):
    return math.sqrt((x0 - x1)**2 + (y0 - y1)**2)

dist_sum = 0
for order in itertools.permutations(range(n), n):
    for i in range(n-1):
        dist_sum += calcdist(x[order[i]], y[order[i]], x[order[i+1]], y[order[i+1]])

print(dist_sum / math.factorial(n))




Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {

  double h[100];
  double h_max,h_min;
  int n=0;
  int i;

  while(scanf("%lf",&h[n])!=EOF) {
    n++;
  }

  h_max=h[0];
  h_min=h[0];
  
  for(i=0;i<n-1;i++) {
    if(h_max<h[i+1]) h_max=h[i+1];
    if(h_min>h[i+1]) h_min=h[i+1];
  }

  printf("%.1lf",h_max-h_min);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<int> l(q),r(q);
    for(int i=0;i<q;i++){
        cin>>l[i]>>r[i];
        l[i]--;r[i]--;
    }
    vector<int> cnt(n);
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            cnt[i+1]=cnt[i]+1;
        }
        else cnt[i+1]=cnt[i];
    }
    for(int i=0;i<q;i++){
        cout<<cnt[r[i]]-cnt[l[i]]<<endl;
    }
}

Measured memory_bytes: 2176
#define DEBUG_ON
#define CONDITION true
using namespace std;/*{{{*/

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>

#define INF (1e9)
static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef complex<double> P;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
inline double now(){ struct timeval tv; gettimeofday(&tv, NULL); return ((double)(tv.tv_sec) + (double)(tv.tv_usec) * 1e-6); }

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define REP(i, n) FOR(i, 0, n)

#define IFC(c) if(c) continue;
#define IFB(c) if(c) break;
#define IFR(c, r) if(c) return r;

#define OPOVER(_op, _type) inline bool operator _op (const _type &t) const

#define arrsz(a) ( sizeof(a) / sizeof(a[0]) )

#define F first
#define S second
#define MP(a, b) make_pair(a, b)

#define SZ(a) ((ll)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(c,it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define BIT(n) (1ULL << (n))
#define BITOF(n, m) ((n) >> (m) & 1)

#define RANGE(a, b, c) ((a) <= (b) && (b) <= (c))

#ifdef DEBUG_ON
#define dprt(fmt, ...) if (CONDITION) fprintf(stderr, fmt, __VA_ARGS__)
#define darr(a) if (CONDITION) copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl
#define darr_range(a, f, t) if (CONDITION) copy( (a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ") ); cerr << endl
#define dvec(v) if (CONDITION) copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl
#define darr2(a, n, m) if (CONDITION) FOR(i, 0, (n)){ darr_range( (a)[i], 0, (m) ); }
#define dvec2(v) if (CONDITION) FOR(i, 0, SZ(v)){ dvec( (v)[i] ); }
#define WAIT() if (CONDITION) { string _wait_; cerr << "(hit return to continue)" << endl; getline(cin, _wait_); }
#else
#define cerr if(0) cerr
#define dprt(fmt, ...)
#define darr(a)
#define darr_range(a, f, t)
#define dvec(v)
#define darr2(a, n, m)
#define dvec2(v)
#define WAIT()
#endif
/*}}}*/

int main(int argc, char const* argv[])
{
	FOR (i, 1, 10) {
		FOR (j, 1, 10) {
			cout << toString(i) << "x" << toString(j) << "=" << i * j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N;
    sll(N);
    vector<ll> as(N);
    vector<ll> i_ac(N, 0);
    vector<ll> im_ac(N, 0);
    ll prev_a = 1000;

    rep(i, N){
        sll(as[i]);
        if(as[i] > prev_a){
            im_ac[i-1] = 1;
            i_ac[i] = -1;
            // buy at i-1, sell at i
        }else if(as[i] < prev_a && i!=0){
            im_ac[i-1] = -1;
            i_ac[i] = 1;
            // sell at i-1, buy at i
        }

        prev_a = as[i];

    }
    // cout << "i-1:" << im_ac <<endl;
    // cout << "i:" << i_ac <<endl;
    ll now_m = 1000;
    ll now_s = 0;
    ll prev_sell = 0;
    ll prev_buy = 0;
    bool first_buy = true;
    rep(i, N-1){
        if(i==0 || first_buy){
            if(im_ac[i]==1){
                // buy
                now_s = now_m / as[i];
                now_m = now_m - now_s * as[i];
                first_buy = false;
            }
        }else{
            if(im_ac[i]==-1){
                bool found = false;
                for(ll j=i-1;j>=prev_sell;j--){
                    if(im_ac[j] == 1){
                        found = true;
                        break;
                    }
                }
                if(found){
                    prev_sell = i;
                    // sell
                    now_m = now_m + now_s * as[i];
                    now_s = 0;
                }
            }else if(im_ac[i] == 1){
                bool found = false;
                for(ll j=i-1;j>=prev_buy;j--){
                    if(im_ac[j] == -1){
                        found = true;
                        break;
                    }
                }
                if(found){
                    // cout << "found" <<endl;
                    // buy
                    prev_buy = i;
                    ll this_add = now_m / as[i];
                    now_m = now_m - this_add * as[i];
                    now_s += this_add;
                }
            }
            
        }
    }

    // cout << now_s << "," <<now_m <<endl;

    now_m += now_s * as[N-1];

    cout << now_m <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3264
a = input()
b = len(a)

for i in range(b):
  if i % 2 == 0:
    if a[i] == 'R' or a[i] == 'U' or a[i] == 'D':
      continue
    else:
      print('No')
      exit()
  elif i % 2 == 1:
    if a[i] == 'L' or a[i] == 'U' or a[i] == 'D':
      continue

    else:
      print('No')
      exit()
      
print('Yes')


Measured memory_bytes: 3064
import itertools

h, w, k = tuple(map(int, input().split()))
k2 = k
c = ''
for _ in range(h):
    c += input()

grid = []
for i in c:
    if i == '#':
        grid.append(1)
    else:
        grid.append(2)

ans = 0
for i in range(h+1):
    for j in list(itertools.combinations(range(h), i)):
        for k in range(w+1):
            for l in list(itertools.combinations(range(w), k)):
                tmp = grid[:]
                for j2 in j:
                    tmp[w*j2:w*(j2+1)] = [3] * w
                for l2 in l:
                    tmp[l2::w] = [3] * h
                if tmp.count(1) == k2:
                    ans += 1

print(ans)


Measured memory_bytes: 9156
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=400010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,A,B,a[N],tot,cd;
inline bool Check(int X)
{
    int qwq=0;
    for(ri int i=1;i<=n;i++)
    {
        if(a[i]<=X*B) continue;
        if((a[i]-X*B)%cd) qwq+=(a[i]-X*B)/cd+1;
        else qwq+=(a[i]-X*B)/cd;
    }
    return (qwq<=X);
}
signed main()
{
    n=read();
    A=read(), B=read(), cd=A-B;
    for(ri int i=1;i<=n;i++) a[i]=read(), tot+=a[i]/B+1;
    sort(a+1,a+1+n);
    int L=1, R=tot, res=tot;
    while(L<=R)
    {
        int mid=(L+R)/2;
        if(Check(mid)) res=mid, R=mid-1;
        else L=mid+1;
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 4492
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)


int main() {

	int N;
	cin >> N;

	cout << (N + 1) / 2 << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,x,i;
    cin>>k>>x;
    for(i=(x-k)+1;i<=x-1;i++)
        {cout<<i<<" ";}
    for(i=x;i<=x+k-1;i++)
        {cout<<i<<" ";}

return 0;}


Measured memory_bytes: 3636
main :: IO ()
main = do
  [a,b] <- map read . words <$> getLine
  print $ numberOfPalindrome a b

numberOfPalindrome
  :: Int -> Int -> Int
numberOfPalindrome a b = length . filter id . map isP $ [a .. b]

isP 
  :: Int -> Bool
isP n = n == hikkurikaeshi n

hikkurikaeshi
  :: Int -> Int
hikkurikaeshi = read . reverse . show

Measured memory_bytes: 892
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
        
      	int n[] = new int[N];
      	
      	for(int i=0; i<N; i++){
            n[i] =sc.nextInt();//N番目に住んでいる住人を格納
      	} 
      
      	int th = 0;//住人たちの体力の総和
      	int pp[] = new int[101];//体力の総和を格納
      	for(int p=1; p<=100; p++){//集会のP座標をまわす,1~100まで
           th = 0;//体力の総和をリセットすることで,次にまわされる体力の総和が0から入っていく
        for(int i=0; i<N; i++){//N番目に住んでいる住人,0~N-1まで
         	int h =(n[i]-p)*(n[i]-p);//住人が集会P座標に向かうのにいる体力,p=1から入っている
         	th +=h;//住人に必要な体力を足していく
          	pp[p] = th;//thにpp[p]を入れることで100個のthが格納される,p=1から入っている
      	}
        }
      	  int min = pp[1];//最小値を求めるために,pp[1]を最初に最小値の初期値として定める,計算式のときにp=1から使っているからpp[1]から始まる
          for(int m=2; m<pp.length; m++){//100個のthをまわす,2~101まで(比較するときに初期値は1が入っているためmは2から比べ始める)
          if(min>pp[m]){//初期値が次のpp[m]より大きい場合
          min = pp[m];//minの場所にまた新たな最小値を入れていく
          }
          }
          System.out.println(min); 
    }
}

Measured memory_bytes: 21716