akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int m = scn.nextInt();
		long ans = 0;
		int c = scn.nextInt();
		int count = 0;
		int[]b = new int[m];
		for(int i = 0;i<m;i++) {
			b[i]=scn.nextInt();
		}
		for(int i = 0;i<n;i++) {
			ans= c;
			for(int j = 0;j<m;j++) {
				ans+=b[j]*scn.nextInt();
			}
			if(0<ans)count++;
		}
		System.out.println(count);
		scn.close();
	}
}

Measured memory_bytes: 22996
def solve(sa, sb):
    d = 0
    for a, b in zip(sa, sb):
        if a >= b:
            d += a - b
        else:
            d -= (b - a) // 2
    return d <= 0


n = input()
sa = map(int, input().split())
sb = map(int, input().split())

print('Yes' if solve(sa, sb) else 'No')


Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() { 
	int n,m;
	cin>>n;
	int a[n+1]={0};
	for(int i=1,tmp;i<n;i++){
		cin>>tmp;
		a[tmp]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
}


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

    public static void main(String[] args) {
        Scanner  yomi = new Scanner(System.in);
        long n = yomi.nextLong();
        long a = 0;
        for(long i = 1;i<=n;i++){
            if (i%3!=0 && i%5!=0){
                a = a+i;
            }
        }
        System.out.println(a);


    }
}


Measured memory_bytes: 35732
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
	char eigo;
	int mozi[26];
	for(int dor = 0;dor < 26;dor++)mozi[dor] = 0;
	while(cin >> eigo){
		if(eigo >= 'a' && eigo <= 'z'){
			eigo -= 'a';
		}else if(eigo >= 'A' && eigo <= 'Z'){
			eigo -= 'A';
		}
		mozi[eigo]++;
	}
	for(int dor = 0;dor < 26; dor++)printf("%c : %d\n",dor+'a',mozi[dor]);
	return 0;
}

Measured memory_bytes: 1124
N, K, Q = map(int, input().split())
A = [0]*Q
for i in range(0,Q):
    A[i] = int(input())
B = [K-Q]*N
for i in range(0,Q):
    B[A[i]-1] = B[A[i]-1]+1
for i in range(0,N):
    if B[i] > 0:
        print ("Yes")
    else:
        print ("No")

Measured memory_bytes: 10480
#include <bits/stdc++.h>
using namespace std;
# define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define Mod 998244353
#define ha "YES"
#define na "NO"
#define sp " "
typedef long long ll;

void IO()
{
#ifndef ONLINE_JUDGE
	freopen("pracin.txt", "r", stdin);
	freopen("pracout.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	fast;
}
vector<bool> used;
vector<vector<int>> adj;
vector<int> dir[200005];
vector<int> a, b;
//bipartite graph or not using bfs

void bfs(int i)
{
	queue<int> q;
	q.push(i);
	used[i] = 1;
	a.push_back(i);
	while (!q.empty())
	{	i = q.front();
		q.pop();
		for (auto vertex : adj[i])
		{
			if (used[vertex] == -1)
			{
				used[vertex] = used[i] ^ 1;
				if (used[vertex] == 1) a.push_back(vertex);
				else b.push_back(vertex);
				q.push(vertex);
			}
			if (used[vertex] == used[i]) {
				cout << -1;
				exit(0);
			}

		}


	}
}
// binnary exponention (logn)
ll binary_exponention(ll a, ll b) {
	if (b == 0)
		return 1;
	ll res = binary_exponention(a, b / 2);
	if (b % 2)
		return res * res * a % Mod;

	return res * res % Mod;

}

// remember the question's fine details
// BE CAREFUL OF EDGE CASES....
// always check for edges cases
//  n == 1, n = size - 1, n is prime ,we



void solve()
{

	int n; cin >> n; long double  a[n];
	for (int i = 0; i < n; i++) cin >> a[i];

	long double dp[n + 1][n + 1];
	memset(dp, 0.0, sizeof(dp));
	dp[0][0] = 1.0;
	for (int i = 1; i <= n; i++)
		for (int j = 0 ; j <= n; j++)
			if (j == 0)
			{
				dp[i][j] = (1.0 - a[i - 1]) * dp[i - 1][j];
			}
			else dp[i][j] = (1.0 - a[i - 1]) * dp[i - 1][j] + (a[i - 1]) * dp[i - 1][j - 1];



	long double ans = 0.0;
	for (int i = n / 2 + 1; i <= n; i++)
		ans += dp[n][i];

	cout << setprecision(10) << ans << endl;


}



int main()
{
	IO();

	// int t; cin >> t; while (t--)
	solve();
}

Measured memory_bytes: 149020
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
  static void Main(string[] args)
  {   
    var num = int.Parse(Console.ReadLine());
    var rList = new List<Restaurant>();
    for (int i = 0; i < num; i++)
    {
      var input = Console.ReadLine().Split();
      rList.Add(new Restaurant(i + 1, input[0], int.Parse(input[1])));
    }
    var orderedList = rList.OrderBy(r => r._name).ThenByDescending(r => r._point);
    foreach (var item in orderedList)
      Console.WriteLine(item._index);
  }
}
public class Restaurant
{
  public int _index { get; set; }
  public string _name { get; set; }
  public int _point { get; set; }
  public Restaurant(int index, string name, int point)
  {
    _index = index;
    _name = name;
    _point = point;
  }
}

Measured memory_bytes: 11604
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(h: [i64]));
    let mut prev = 0;
    for &x in &h {
        if x > prev {
            prev = x - 1;
        } else if x == prev {
            prev = x;
        } else if prev > x {
            return "No".to_string();
        }
    }
    "Yes".to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "5\n1 2 1 1 3\n" => "Yes\n",
    test2: "4\n1 3 2 1\n" => "No\n",
    test3: "5\n1 2 3 4 5\n" => "Yes\n",
    test4: "1\n1000000000\n" => "Yes\n",
}


Measured memory_bytes: 10492
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

func main() {
	N := getStdinInt()
	A := getStdinIntArr64()
	Abig := make([]*big.Int, N)
	for i := 0; i < N; i++ {
		Abig[i] = big.NewInt(A[i])
	}

	for i := 0; i < len(A); i++ {
		if A[i] == 0 {
			fmt.Printf("0\n")
			return
		}
		if A[i] > 1000000000000000000 {
			fmt.Printf("-1\n")
			return
		}
	}

	ans := big.NewInt(1)
	cmp := big.NewInt(1000000000000000000)
	for i := 0; i < len(Abig); i++ {
		ans = ans.Mul(ans, Abig[i])
		if ans.Cmp(cmp) == 1 {
			fmt.Printf("-1\n")
			return
		}
	}
	fmt.Printf("%s\n", fmt.Sprint(ans))
	fmt.Printf("\n")
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 14976
#include <stdio.h>

int main(void)
{
    char S[210000],T[210000];
    int i,s;
    s = 0;
    scanf("%s%s",S,T);
    for(i = 0;S[i] != '\0';i++){
        if(S[i] != T[i]){
            S[i] = T[i];
            s++;
        }
    }
    printf("%d",s);
	return 0;
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    ll s;
    cin >> s;
    vector<ll> dp(s + 1, 0);
    dp[0] = 1;
    dp[1] = 0;
    dp[2] = 0;
    for(int i = 3; i <= s; i++) {
        dp[i] = dp[i - 1] + dp[i - 3];
        dp[i] %= MOD;
    }
    cout << dp.back() << endl;
}

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

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> mp;
    for(ll i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    ll count = 0;
    for(auto e:mp)
    {
        if(e.second % 2 == 1)count++;
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6528
import java.io.*;

class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputLine = br.readLine().split(" ");
        int n = Integer.valueOf(inputLine[0]), y = Integer.valueOf(inputLine[1]);
        int b10th = 0, b5th = 0, b1th = y / 1000;
        int redundant = b1th - n;

        for (int i = 0; i <= n; i++) {
            if (redundant < 4) {
                break;
            } else if (redundant % 9 == 0 && 10 * (redundant / 9) <= b1th) {
                b10th = redundant / 9;
                b1th -= 10 * b10th;
                break;
            } else {
                redundant -= 4;
                b5th += 1;
                b1th -= 5;
            }
        }

        if (b10th + b5th + b1th != n) {
            b10th = -1; b5th = -1; b1th = -1;
        }

        System.out.println(b10th + " " + b5th + " " + b1th);
    }
}


Measured memory_bytes: 22740
#include <cstdio>

int main(){
    int a[3], b[3];
    for(int i = 0; i < 3; i++){
        scanf("%d %d", &a[i], &b[i]);
    }

    int c[4];
    for(int i = 0; i < 4; i++){
        c[i] = 0;
    }
    for(int i = 0; i < 3; i++){
        c[a[i] - 1]++;
        c[b[i] - 1]++;
    }

    int count_1 = 0, count_2 = 0;
    for(int i = 0; i < 4; i++){
        if (c[i] == 1){
            count_1++;
        }else if(c[i] == 2){
            count_2++;        }
    }

    if(count_1 == 2 && count_2 == 2){
        printf("YES\n");
    }else{
        printf("NO\n");
    }    

    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>){
    val (N, M) = readLine()!!.split(' ').map{ it.toLong()}
    val store = (1..N).map { readLine()!!.split(' ').map{ it.toLong() } }.sortedBy { it.first() }
 
    var cnt = M
    var ans = 0L
 
    for (i in store) {
        when {
           cnt < i[1] -> {
               ans += i[0] * cnt
               println(ans)
               return
           }
            else -> {
                ans += i[0] * i[1]
                cnt -= i[1]
            }
        }
    }
 
    println(ans)
 
 
}

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

int main(){
  int num,f=0,num2;
  cin >> num;
  num2 = num;
  while(true){
    f += num % 10;
    num/=10;
    if(num == 0)break;
  }
  
  if(num2 % f ==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;
using PAIR = pair<string, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> dp(n + 10, 0);
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (dp[i] != -1)
        {
            if (i != 1)
            {
                if (dp[i - 1] == -1 && dp[i - 2] == -1)
                {
                    cout << 0 << endl;
                    return 0;
                }
                dp[i] = (max(dp[i - 1], 0ll) + max(dp[i - 2], 0ll)) % mod;
            }
            else
            {
                dp[i] = max(dp[i - 1], 0ll);
            }
        }
    }
    cout << dp[n] % mod << endl;

    return 0;
}

Measured memory_bytes: 1024
A,B,C = map(int,input().split())
dic = {(A,B,C):True}
def twice(_num):
    count = 0
    while _num%2 == 0:
        count += 1
        _num //= 2
    return count
ans = 0
while True:
    if A%2 == 1 or B%2 == 1 or C%2 == 1:
        print(ans)
        break
    ans += 1
    preA = A
    preB = B
    preC = C
    A = preB // 2 + preC // 2
    B = preA // 2 + preC // 2
    C = preB // 2 + preA // 2
    if (A,B,C) in dic:
        print(-1)
        break
    else:
        dic[(A,B,C)] = True


Measured memory_bytes: 3064
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int n;

int dp[2005][2005];

int suri(int idx,int iav,VII64 &v)
{
	if(idx==n)
		return 0;
	int &ans=dp[idx][iav];
	if(ans!=-1)
		return ans;
	ans=(abs(iav-v[idx].S)*v[idx].F)+suri(idx+1,iav+1,v);
	int jav=n-1-(idx-iav);
	ans=max(ans,(abs(jav-v[idx].S)*v[idx].F)+suri(idx+1,iav,v));
	return ans;
}

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int i,j;
		cin>>n;
		VII64 v(n);
		for(i=0;i<n;i++)
		{
			cin>>v[i].F;
			v[i].S=i;
		}
		memset(dp,-1,sizeof dp);
		sort(ALL(v),greater<pair<int,int>>());
		cout<<suri(0,0,v)<<endl;
	}

	return 0;
}

Measured memory_bytes: 35232
import java.util.Scanner;
class Main {
    public static void main( String[] args ) {
Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int r ;

        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        System.out.println(b);
    }
}


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

using namespace std;

string template_matching (vector<string> &A, vector<string> &B, int N, int M) {

    bool exist;
    for (int i = 0; i <= N - M; i++) {
        for (int j = 0; j <= N - M; j++) {
            exist = true;
            for (int k = 0; k < M; k++) {
                for (int l = 0; l < M; l++) {
                    if (A[i + k][j + l] != B[k][l]) {
                        exist = false;
                    }
                }
            }
            if (exist) {
                return "Yes";
            }
        }
    }

    return "No";
}

int main () {

    int N, M;
    cin >> N >> M;

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

    vector<string> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    cout << template_matching(A, B, N, M) << endl;

    return 0;
}

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

int dp[3002][3002] = {};

int main(){
    string S, T;
    cin >> S >> T;
    for(int s=1;s<=S.length();s++){
        for(int t=1;t<=T.length();t++){
            if(S[s-1] == T[t-1]){
                dp[s][t] = dp[s-1][t-1] + 1;
            }
            else{
                dp[s][t] = max(dp[s-1][t], dp[s][t-1]);
            }
        }
    }

    string lcs = "";
    int s = S.length();
    int t = T.length();
    while(s && t){
        if(S[s-1] == T[t-1]){
            lcs += S[s-1];
            s--; t--;
        }
        else{
            if(dp[s][t] == dp[s-1][t]){
                s--;
            }
            else{
                t--;
            }
        }
    }
    reverse(lcs.begin(), lcs.end());
    cout << lcs << "\n";

    return 0;
}

Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main() {
	int a, b, n;
	int digitsum;
	int sum=0;

	cin >> n >> a >> b ;
	for (int i = 1; i<=n ; i++) {
		if (1 <= i and i <= 9) {
			digitsum = i;
		}
		else if(10 <= i and i <= 99) {
			digitsum = i / 10 + i % 10;
		}
		else if (100 <= i and i <= 999) {
			digitsum = i / 100 + (i % 100) / 10 + (i % 100) % 10;
		}
		else if (1000 <= i and i <= 9999) {
			digitsum = i / 1000 + (i % 1000) / 100 + ((i % 1000) % 100) / 10 + ((i % 1000) % 100) % 10;
		}
		else if (i == 10000) {
			digitsum = 1;
		};
		if (a <= digitsum && digitsum <= b) {
			sum = sum + i;
		};
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL N, M, ans;
std::map<LL, LL>cnt;

void decompositPrime(LL n)
{
	LL d = 2;
	while (n >= d * d)
	{
		if (n % d == 0)
		{
			++cnt[d];
			n /= d;
		}
		else ++d;
	}
	++cnt[n];
}

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL &x, LL &y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a%b, y, x);
		y -= (a / b)*x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i%m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

int main()
{
	in >> N >> M;
	mod_fact(N + 65, mod);
	decompositPrime(M);
	ans = 1;
	for (auto n : cnt)
	{
		if (n.first == 1) continue;
		LL res = mod_comb(n.second + N - 1, n.second, mod);
		ans *= res;
		ans %= mod;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h> 
int main(void){
  char moji;
  scanf("%c", &moji);
   if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
    printf("A\n");
  }
  return 0;
}

Measured memory_bytes: 1592
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

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

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  
  vector<ll> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  
  vector<ll> left(n + 1, 0);
  for (int i = 0; i < n; i++) {
    left[i + 1] = gcd(left[i], vec[i]);
  }
  vector<ll> right(n + 1, 0);
  for (int i = n - 1; i >= 0; i--) {
    right[i] = gcd(right[i + 1], vec[i]);
  }
  
  ll res = 0;
  for (int i = 0; i < n; i++) {
    res = max(res, gcd(left[i], right[i + 1]));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0;
	int cnt_R = 0;
	rep(i, n)
	{
		if (s[i] == 'R')
			cnt_R++;
	}
	rep2(i, cnt_R, n)
	{
		if (s[i] == 'R')
		{
			//swap(s[i], s[cnt]);
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int c=0;
  for(int i=0;i<n;i++){
    int a =0;
    cin >> a;
    int re =0;
    int ord=0;
    while(re==0){
      re = a%2;
      a/=2;
      ord++;
      }
    if (i==0){
      c=ord-1;
        
      }
    else if(c>ord-1){
      c= ord-1;
        
      }
      
    }
  cout << c << endl;
  }
        
       

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

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

    if (a*b % 2 == 0) cout << "Even";
    else cout << "Odd";
    
    return 0;
}

Measured memory_bytes: 256
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      int i = n%10;
      
      if(i == 3){
         out.println("bon");
      } else if(i == 0 || i == 1 || i == 6 || i == 8){
         out.println("pon");
      } else {
         out.println("hon");
      }
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 32656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int min;
  int r[300005]={};
  int l[300005]={};
  string s;

  cin>>n;
  cin>>s;

  for(int i=1;i<n;i++){
    if(s[i-1]=='W') l[i]=l[i-1]+1;
    else l[i]=l[i-1];
  }

  for(int i=n-2;i>=0;i--){
    if(s[i+1]=='E') r[i]=r[i+1]+1;
    else r[i]=r[i+1];
  }


  min=l[0]+r[0];
  for(int i=1;i<n;i++){
    if(min>r[i]+l[i]){
      min=r[i]+l[i];
    }
  }

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

  

Measured memory_bytes: 3204
a, b, c, x = int(input()), int(input()), int(input()), int(input())//50
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 10*i + 2*j + k == x:
        ans += 1
        
print(ans)

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
      int s,w;
      cin>>s>>w;
      if(w>=s)cout<<"unsafe";
      else cout<<"safe";
}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int n,k;
	int h[E5];
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	sort(h,h+n);
	ll ans = 1e18;
	for (int i = 0; i <= n-k; ++i) {
		ans = min(ans,0LL + h[i+k-1] - h[i]);
	}
	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

#define DB(x) cerr << #x << " = " << (x) << " "
#define ENDL cerr << "\n"
#define FOR(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define DBA(x, a, b) { cerr << #x << " = "; for (int _ = (a); _ <= (b); _++) cerr << x[_] << ' '; ENDL }
#define DBS(x) { cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl; }

using namespace std;

template<typename T, typename U> static void rmin(T &x, U y) {
    if (y < x) x = y;
}
template<typename T, typename U> static void rmax(T &x, U y) {
    if (x < y) x = y;
}

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define mid ((left + right) >> 1)
#define lson rt << 1, left, mid
#define rson rt << 1 | 1, mid + 1, right

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;

vector<int> G[N];

int sz[N], n, fa[N];
int depth[N];

void dfs(int u, int f, int d) {
    depth[u] = d;
    fa[u] = f;
    for (int v : G[u]) {
        if (v == f) continue;
        dfs(v, u, d + 1);
        sz[u] += sz[v];
    }
    sz[u] += 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1, -1, 0);
    int len = depth[n], id = n;
    len = (len - 1) / 2;
    while(len--) {
        id = fa[id];
    }
    if(sz[id] >= n - sz[id]) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
    return 0;
}



Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 100.0;
double temp_end = 0.001; 
int climb_loop = 300000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }
   
  // simulated annealing
  rep(x,climb_loop) {
    int d = (eng() % D) + 1;
    int q = eng() % 26;
    temp = temp_start + (temp_end - temp_start)*x/climb_loop;
    int diff = s[d][q] - s[d][t[d]];
    int cur = d;
    while(cur <= D && last[cur][t[d]] == d) {
      diff -= c[t[d]] * (d - last[cur-1][t[d]]);
      last[cur][t[d]] = last[cur-1][t[d]];
      cur++;
    }
    cur = d;
    while(cur <= D && last[cur][q] < d) {
      diff += c[q] * (d - last[cur][q]);
      last[cur][q] = d;
      cur++;
    }
    if(diff > 0 || uniform_01(eng) < exp((double)diff/temp)) {
      t[d] = q;
      content += diff;
    } else {
      int day = d;
      while(day <= D && last[day][t[d]] < d) {
        last[day][t[d]] = d;
        day++;
      }
      day = d;
      while(day <= D && last[day][q] == d) {
        last[day][q] = last[day-1][q];
        day++;
      }
    }
  }
  // output
  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
  return 0;
}


Measured memory_bytes: 4356
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> v = {a, b, c};
  sort(v.begin(), v.end());
  printf("%d %d %d\n", v.at(0), v.at(1), v.at(2));
}


Measured memory_bytes: 3236
import Control.Applicative
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

isPrime :: Integral a => a -> Bool
isPrime n = let m = floor . sqrt $ fromIntegral n
              in
                  all ((/= 0) . mod n) [2..m]

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

main = do
    _ <- getLine
    readInts >>= print . foldl' (\ac n -> if isPrime n then succ ac else ac) 0

Measured memory_bytes: 5096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll A[200000];
ll S[200000];

int main()
{
	int N, K;
	map<ll, ll> cnt;
	ll ans = 0;

	cin >> N >> K;
	rep(i, N) cin >> A[i];
	rep(i, N) A[i]--;

	rep(i, N) {
		if (i == 0) S[i] = A[i] % K;
		else {
			S[i] = (S[i - 1] + A[i]) % K;
		}
	}

	rep(i, N) {
		if (i >= K) cnt[S[i - K]]--;

		if (i < K - 1 && S[i] == 0) ans++;
		if (cnt.count(S[i]) > 0) ans += cnt[S[i]];

		if (cnt.count(S[i]) == 0) cnt[S[i]] = 1;
		else cnt[S[i]]++;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;
  int ans = INT_MAX;
  for (int i = 0; i <= max(X, Y); i++) {
    int tmp = C * i;
    if (i < X) tmp += (X - i) * A;
    if (i < Y) tmp += (Y - i) * B;
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, a[1111];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j < n; j++) {
			if (a[j - 1] % i > a[j] % i) swap(a[j - 1], a[j]);
		}
	}
	for (int i = 0; i < n; i++) cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	vector<int> hash;
	vector<int> b;
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	int i = 0;
	while(i<n)
	{
		b.push_back(a[i]);
		int count = 0;
		int j = i;
		while(a[j]==a[i])
		{
			count++;
			j++;
		}
		hash.push_back(count);
		i = j;
	}
	ll sum = 0;
	for(int i=0;i<b.size();i++)
	{
		int x = hash[i-1]*hash[i];
		for(int j=i+1;j<b.size();j++)
		{
			for(int k=j+1;k<b.size();k++)
			{
				if(i!=j && j!=k)
				{
					if(b[i]+b[j]>b[k] && b[i]+b[k]>b[j] && b[j]+b[k]>b[i])
					sum += hash[i]*hash[j]*hash[k];
				}
			}
		}
	}
	cout<<sum;
	return 0;
}

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


int main()
{
	ll n,a,p1,q1;
	cin>>n;
	ll arr[n+1],p[n+1],q[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
		//p.push_back(p1);
	}
	for(int i=1;i<=n;i++)
	{
		cin>>q[i];
		//q.push_back(q1);
	}
	for(int i=1;i<=n;i++)
	{
		arr[i]=i;
	}
	ll cnt=0,f=0,f1=0,s1=0,g=0;
	while(next_permutation(arr+1,arr+n+1))
	{
		//cout<<
		cnt++;
		// for(int i=1;i<=n;i++)
		// {
		// 	cout<<arr[i]<<" ";
		// }
		f=0;
		g=0;
		for(int i=1;i<=n;i++)
		{

			if(p[i]!=arr[i])
			{
				f=cnt;
				break;
			}
		}
		for(int i=1;i<=n;i++)
		{
			if(q[i]!=arr[i])
			{
				g=cnt;
				break;
			}
		}
		// if(f==0 || g==0)
		// {
		// 	cout<<cnt<<endl;
		// 	//cout<<f1<<" "<<s1<<endl;
		// }
		if(f==0)
		{
			s1=cnt;
			//cout<<f<<endl;
		}
		if(g==0)
		{
			f1=cnt;
			//cout<<g<<endl;
		}
		//cout<<endl;
	}
	cout<<abs(s1-f1)<<endl;
}

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

A_=A.copy()
for n in range(N):
    A_[n] = A_[n]-(n+1)
A_.sort()
# A_s=A_[0]
# A_e=A_[-1]
# A_mean=(A_s+A_e)/2
A_median=A_[int(len(A_)/2)-10:int(len(A_)/2)+10]

def cul_ans(i):
    A_abs_=[]
    for a in A_:
        A_abs_.append(abs(a-i))
    return A_abs_

ans=10**20
for i in A_median:
    if ans>sum(cul_ans(i)):
        ans=sum(cul_ans(i))
print(ans)

Measured memory_bytes: 219540
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX 200000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)

int main(){
    int a,b;
    cin>>a>>b;
    if(a>9||b>9) cout<<-1;
    else cout<<a*b; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 2e5 + 10;
const int INF = 1e9;
using namespace std;

typedef pair<int, int> P;
int n, m, l, r, d;
int vis[maxn], dis[maxn];
vector<P> G[maxn];

bool bfs(int x) {
    queue<int> que;
    que.push(x); dis[x] = 0;
    vis[x] = 1;
    int ansmin = 0, ansmax = 0;
    while(!que.empty()) {
        int u = que.front(); que.pop();
        if(dis[u] > INF) return false;
        ansmin = min(ansmin, dis[u]);
        ansmax = max(ansmax, dis[u]);
        for(int i = 0; i < G[u].size(); i++) {
            P e = G[u][i];
            int to = e.first, w = e.second;
            if(vis[to] && dis[to] != dis[u] + w) return false;
            if(vis[to]) continue;
            vis[to] = 1; que.push(to); dis[to] = dis[u] + w;
        }
    }
    //if(ansmax - ansmin > 1e9) return false;
    return true;
}

int main() {
    while(scanf("%d %d", &n, &m) != EOF) {
        memset(vis, 0, sizeof vis);
        for(int i = 0; i < maxn; i++) G[i].clear();
        for(int i = 1; i <= m; i++) {
            scanf("%d %d %d", &l, &r, &d);
            int sl = G[l].size();
            int sr = G[r].size();
            G[l].push_back(P(r, d));
            G[r].push_back(P(l, -d));
        }
        int flag = 1;
        for(int i = 1; i <= n; i++) if(!vis[i]) {
            flag = bfs(i);
            if(!flag) break;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}
/**
3 3
1 2 1
2 3 1
1 3 2

3 3
1 2 1
2 3 1
1 3 5

4 3
2 1 1
2 3 5
3 4 2

10 3
8 7 100
7 9 100
9 8 100

100 0
*/


Measured memory_bytes: 12928
#include <iostream>

#define rep(i, N) for (LL i = 0; i < N; ++i)
typedef long long int LL;

using namespace std;

int main() {
    LL N, H[100], r = 1;
    cin >> N;
    rep(i, N) cin >> H[i];
    for (LL i = 1; i < N; ++i) {
        bool check = true;
        if (H[i] < H[0]) check = false;
        for (LL j = 0; j < i; j++) {
            if (H[i] < H[j]) {
                check = false;
            }
        }
        if (check) r++;
    }

    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back

void solve() {
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
    
		// 出力
		System.out.println(a == b && b == c ? "Yes" : "No");
	}
}

Measured memory_bytes: 23380
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans, frag = 1, 0
for i in range(n):
    if t[i] == a[i] == t[-1] == a[0]:
        frag = 1
    if 0 < i < n - 1 and t[i - 1] == t[i] and a[i] == a[i + 1]:
        ans = ans * min(t[i], a[i]) % mod
print(ans * frag)


Measured memory_bytes: 97604
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long

using namespace std;

int main(void)
{
        cin.tie(NULL); ios_base::sync_with_stdio(false);
        int N; cin >> N;
        ll acc = 0;
        ll ret = LLONG_MAX;
        vector<ll> cards;

        for(int i = 0; i < N; i++)
        {
                int temp; cin >> temp; cards.push_back(temp);
                acc += temp;
        }

        ll lhs = 0;
        for(int i = 0; i < N - 1; i++)
        {
                lhs += cards[i];
                ll rhs = acc - lhs;
                ret = min(ret, abs(lhs - rhs));
        }
        cout << ret;


        return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()

using namespace std;

const int MX = 1e5 + 5;
const int P1 = 31;
const int P2 = 53;
const int M1 = 1e9 + 7;
const int M2 = 1e9 + 9;

LL h1[MX];
LL h2[MX];
LL po1[MX];
LL po2[MX];
LL inv1[MX];
LL inv2[MX];
int n;
string s;
priority_queue<int> pq;

LL ex(LL x,LL y,int M){
    if(y == 0)
        return 1ll;
    if(y&1)
        return (x * ex(x * x % M,y / 2,M)) % M;
    return ex(x * x % M,y / 2,M);
}

LL inverse(int x,int M){
    return ex(x,M-2,M);
}

PL get(int x,int y){
    LL Res1 = (h1[y] - h1[x - 1] + M1) % M1 * inv1[x] % M1;
    LL Res2 = (h2[y] - h2[x - 1] + M2) % M2 * inv2[x] % M2;
    return make_pair(Res1,Res2);
}

bool f(int x){
    map<PL,int> cnt;
    for(int i=1 ; i<=n-x+1 ; ++i){
        PL P = get(i,i + x - 1);
        if(cnt.count(P) && cnt[P] < i)
            return true; 
        else if(!cnt.count(P))
            cnt[P] = i + x - 1;
    }
    return false;
}

int main(){
    cin >> n;
    cin >> s;
    int ip1,ip2;
    po1[0] = po2[0] = inv1[0] = inv2[0] = 1;
    ip1 = inverse(P1,M1);
    ip2 = inverse(P2,M2);
    for(int i=1 ; i<=n ; ++i){
        po1[i] = po1[i-1] * P1 % M1;
        po2[i] = po2[i-1] * P2 % M2;
        inv1[i] = inv1[i-1] * ip1 % M1;
        inv2[i] = inv2[i-1] * ip2 % M2;
    }
    h1[0] = h2[0] = 0;
    for(int i=1 ; i<=n ; ++i){
        h1[i] = (h1[i-1] + po1[i-1] * (s[i-1] - 'a' + 1)) % M1;
        h2[i] = (h2[i-1] + po2[i-1] * (s[i-1] - 'a' + 1)) % M2;
    }
    int l = 0,r = n;
    while(l < r){
        int m = (l + r) >> 1;
        if(f(m))
            l = m + 1;
        else
            r = m;
    }
    cout << l - 1 << endl;
}  

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

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

    
    ll n;
    cin>>n;
    vector<ll> h(n);
    rep(i,n){
        cin>>h[i];
    }
    ll count=0;
    ll ans=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            count++;
            ans=max(ans,count);
        }
        else{
            count=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
#define MOD 99994711
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[205];
void Solve() {
    read(N);
    for(int i = 1 ; i <= 2 * N ; ++i) read(a[i]);
    sort(a + 1,a + 2 * N + 1);
    int ans = 0;
    for(int i = 2 * N - 1 ; i >= 1 ; i -= 2) {
	ans += a[i];
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

using namespace std;
int main(){
    int n, t , a;
    vector<int> h;
    
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        h.push_back(x);
    }

    int ans = 0;
    double c = 0,ans_num = 0;

    for (int i = 0; i < n; i++){
        c = double(t) - double(h[i]) * 0.006;
        
        if (i == 0){
            ans = i;
            ans_num = c;
        }

        if (abs(a - c) < abs(a - ans_num)){
            ans = i;
            ans_num = c;
        }
        

    }
    cout << ans + 1 << endl;

}


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

ll N, cnt;

bool chk(ll pos)
{
    ll a[10] = {};
    while (pos) {
        ll rem = pos % 10;
        a[rem]++;
        pos /= 10;
    }

    if (a[3] && a[5] && a[7]) return true;
    return false;
}

void dfs(ll pos)
{
    if (pos > N) return;

    if (chk(pos)) cnt++;

    dfs(pos*10 + 3);
    dfs(pos*10 + 5);
    dfs(pos*10 + 7);
}

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

    cout << cnt << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

int next(int x) {
    return ((x * x) / 100) % 10000;
}

int main() {
    int n, s;
    cin >> n;
    for (int i=1; i<=n; ++i) {
        cout << "Case " << i << ":" << endl;
        cin >> s;
        for (int j=0; j<10; ++j) {
            s = next(s);
            cout << s << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String s = sc.next(), t = sc.next();
        char[] s1 = s.toCharArray(), t1 = t.toCharArray();
        int[][] f = new int[s1.length + 1][t1.length + 1],last = new int[s1.length + 1][t1.length + 1];
        StringBuilder sb = new StringBuilder();
        // 第二种 回溯，可以借助一个数组，标记 dp的方向；
        for(int i = 1; i <= s1.length; i ++) {
            for (int j = 1; j <= t1.length; j++) {
                if (s1[i - 1] == t1[j - 1]) {
                    f[i][j] = f[i - 1][j - 1] + 1;
                    last[i][j] = 3; // 记录方向 左上角
                } else {
                    if (f[i][j - 1] > f[i - 1][j]) {
                        f[i][j] = f[i][j - 1];
                        last[i][j] = 1; // 记录方向 左
                    } else {
                        f[i][j] = f[i - 1][j];
                        last[i][j] = 2;// 记录方向 上
                    }
                }
            }
        }
        int x = s1.length - 1, y = t1.length - 1;
        while(f[x + 1][y + 1] > 0){
            if(last[x + 1][y + 1] == 3){
                sb.append(s1[x]);
                x--;
                y--;
            }else if(last[x + 1][y + 1] == 2)x--;
            else y--;
        }

        /*  第一种回溯
        for(int i = 1; i <= s1.length; i ++){
            for(int j = 1; j <= t1.length; j ++){
                if(s1[i - 1] == t1[j - 1])f[i][j] = f[i - 1][j - 1] + 1;
                else {f[i][j] = Math.max(f[i][j - 1],f[i - 1][j]);
            }
        }

        int x = s1.length - 1, y = t1.length - 1;
        while(f[x + 1][y + 1] > 0){
            if(s1[x] == t1[y]){
                sb.append(s1[x]);
                x--;y--;
            }
            else{
                if(f[x + 1][y + 1] == f[x + 1][y])y--;
                else x--;
            }
        }
        */

         System.out.println(sb.reverse().toString());
    }
}

Measured memory_bytes: 132300