akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

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

void solve() {
    lli n, ans = 0;
    cin >> n;
    vector<string> v;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(all(s));
        v.push_back(s);
    }

    sort(all(v));
    lli i = 1, cnt = 0;

    while (i < n) {
        if (v[i] == v[i - 1]) {
            cnt++;
        } else{
            ans += (cnt * (cnt + 1)) / 2;
            cnt = 0;
        }
        i++;
    }
    
    ans += (cnt * (cnt + 1)) / 2;
    
    cout << ans << endl;
}

int main()
{
    IOS;
    //comment it out
    //freopen("input.txt", "r", stdin);
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

int main() {
  int N,K,i,j;
  cin >> N >> K;
  j=1;
  for(i=0;i<N;i++){
    if(j<K){
      j=j*2;
    }else{
      j=j+K;
    }
  }
  cout << j << endl;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    int a[105];
    memset(a, 0, sizeof(a));
    vector<int> b;
    for(int i = 0; i < n - 1; ++i){
        int x; cin >> x;
        b.push_back(x);
    }
    for(int i = 0; i < n - 1; ++i){
        
        if(i == 0){
            a[i] = b[i];
            a[i + 1] = b[i];
            continue;
        }
        else{
            if(b[i] < a[i]) a[i] = b[i];
            a[i + 1] = b[i];
            continue;
        }
    }
    int sum = 0;
    for(int i = 0; i < n; ++i)
        sum += a[i];
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#import math
n,m=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
mdiv = make_divisors(m)
mdiv.sort()
#print(mdiv)

ans = m
for i in mdiv:
    if i >= n:
        ans = i
        break
print(m//ans)

Measured memory_bytes: 38640
use std::io;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let (a, b) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    if b < a {
        println!("{}", a - 1);
    } else {
        println!("{}", a);
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  //ifstream cin("in.txt");
  map<string, int> mp;
  int q;
  cin >> q;
  while (q--) {
    int op;
    cin >> op;
    if (op == 0) {
      string name;
      int val;
      cin >> name >> val;
      mp[name] = val;
    } else if (op == 1) {
      string name;
      cin >> name;
      cout << mp[name] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 27824
import sys
N, Y = map(int,input().split())

for k in range(N+1):
	for j in range(N+1 - k):
		i = N - k -j
		if k*10000 + j*5000 + i*1000 == Y:
			print(k, j, i)
			sys.exit()
print("-1 -1 -1")

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1,ans=0;
vll_t a,b;
// void solve(int n,int k,int a,int b,int c){
// 	if(a>n||b>n||c>n){
// 		return ;
// 	}
// 	if(((a+b)%k==0)&&((b+c)%k==0)&&((a+c)%k==0)){
// 		ans++;
// 	}
// }
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt	
 //    freopen("output.txt", "w", stdout);
	// #endif
	long long int n,k;
	long long int ans=0;
	cin>>n>>k;
	vector<long long int>arr(k,0);
	for(long long int i=1;i<=n;i++){
		arr[i%k]++;
	}
	for(long long int i=0;i<k;i++){
		if(arr[i]!=0){
			if(2*i%k==0){
				ans+=arr[i]*arr[i]*arr[i];
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		List<Integer> A = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		// BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
		int N = Integer.parseInt(br.readLine());
		String[] s_in = br.readLine().split(" ");
		for (String s : s_in)
			A.add(Integer.parseInt(s));
		
		int cnt_swap = 0;
		for (int i = 0; i < N; i++) {
			// A[0..i-1]??????????????????
			int mini = i;
			for (int j = i + 1; j < N; j++)
				if (A.get(j) < A.get(mini))
					mini = j;
			if (mini != i) {
				int tmp = A.get(i);
				A.set(i, A.get(mini));
				A.set(mini, tmp);
				cnt_swap++;
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for (int n : A) {
			sb.append(n);
			sb.append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		sb.append('\n');
		sb.append(cnt_swap);
		System.out.println(sb);
	}
}

Measured memory_bytes: 17812
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define mid(l, r) ((l + r) >> 1)
#define assign(x,val) memset(x,val,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
long long mod = 1000000007;
const ll N = (int)1e5 + 1;
 
 
 
void solve(){
	int n;cin>>n;
	int dp[n+1];
	dp[1] = 0;
	int h[n+1];
	for1(i,n) cin>>h[i];
	dp[2] = abs(h[1] - h[2]);
	forg(i, 3, n+1){
		dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
	}
	cout<<dp[n]<<endl;
}
int main(){
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "rt", stdin);
 
    //freopen("output.txt", "w", stdout);
#endif       
    ll t=1;
    //cin>>t;
    for0(i,t) solve();
    //cout<<1<<endl;
#ifndef ONLINE_JUDGE
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> l(2*n);
    for (int i=0; i<2*n; i++) {
        cin >> l.at(i);
    }
    sort(l.begin(), l.end());
    int ans = 0;
    for (int i=0; i<2*n; i+=2) {
        ans += l.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
r1,c1,r2,c2=map(int,input().split());mod=10**9+7;N=2000010
def inv(x):return pow(x,mod-2,mod)
Fact=[0 for i in range(N+1)];Fact[0]=1
for i in range(N):Fact[i+1]=((i+1)*Fact[i])%mod
def f(r,c):return (Fact[r+c]*inv(Fact[r])*inv(Fact[c]))%mod
print((f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,c1))%mod)

Measured memory_bytes: 82200
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;

		int count = 0;
		int r = 0;
		int c = 0;
		int[][] sheet = null;
		try {
			while ((buffer = reader.readLine())  != null) {
				String[] strings = buffer.split(" ");

				if (count == 0) {
					r = Integer.valueOf(strings[0]);
					c = Integer.valueOf(strings[1]);
					sheet = new int[r + 1][c + 1];
				}
				else if (count <= r) {
					for (int i = 0; i < c; i++) {
						sheet[count - 1][i] = Integer.valueOf(strings[i]);
					}
				}
				if (count == r) {
					for (int w = 0; w < c; w++) {
						int sum = 0;
						for (int h = 0; h < r; h++) {
							sum += sheet[h][w];
						}
						sheet[r][w] = sum;
					}

					for (int h = 0; h < r + 1; h++) {
						int sum = 0;
						for (int w = 0; w < c; w++) {
								sum += sheet[h][w];
								System.out.print(sheet[h][w] + " ");
							if (w + 1 == c) {
								System.out.println(sum);
							}
						}
					}

				}

				count++;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}



Measured memory_bytes: 31104
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String s = br.readLine();
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < s.length(); i++){
            sb.append("x");
        }
        
        out.println(sb);
        out.close();
        
    }
}

Measured memory_bytes: 32884
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>
#include<array>
#include<stdio.h>
#include<cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 1e15;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

vvi adjLst(1e5+5,vi());
vb vstd(1e5+5,0);
vi dp(1e5+5,1);


void dfs(int u)
{
    vstd[u] = 1;
    for(int i = 0 ; i < adjLst[u].size() ; ++i)
    {
        if(!vstd[adjLst[u][i]])
            dfs(adjLst[u][i]);

        dp[u] = max(dp[u], dp[adjLst[u][i]] +1);
    }
}


int main()
{
    //cout << LLINF ;
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, u, v;
    cin >> n >> m;
    for(int i = 0; i < m ; ++i)
    {
        cin >> u >> v;
        adjLst[u].push_back(v);
    }

    int mx = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        if(!vstd[i])
            dfs(i);
    }

    for(int i = 1; i <= n ; ++i)
        mx = max(mx,dp[i]);

    cout << mx-1;

    return 0;
}


Measured memory_bytes: 12200
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, k := io.NextInt(), io.NextInt()
	a := io.NextInts(n)
	ans := solve(n, k, a)
	io.Println(ans)
}

func solve(n, k int, a []int) int {
	divConut := func(x float64) int {
		if x == 0 {
			panic("division by zero")
		}
		cnt := 0
		for i := range a {
			if float64(a[i]) <= x {
				continue
			}
			cnt += int(math.Ceil(float64(a[i])/x)) - 1
		}
		return cnt
	}
	x := sort.Search(maxIter, func(x int) bool { return divConut(float64(x+1)/10) <= k })
	if x == maxIter {
		panic("reached max iteration")
	}
	return int(math.Ceil(float64(x+1) / 10))
}

const maxIter = 1e12

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 13096
#include <bits/stdc++.h>
using namespace std;
const int N = 102;

int n;
long double a[N];

int main()
{
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(7);
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    long double sum = 0;
    for (int i = 1; i <= n; ++i)
        sum += (1.0 / a[i]);
    sum = (1.0 / sum);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int[][] g;
    static int[][] e;
    static boolean[] used;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        used = new boolean[n];
        g = buildGraph(sc, n, n-1);
        Map<Integer, Map<Integer, Integer>> map = new HashMap<>();
        used[0] = true;
        dfs(0, 0, map);
        StringBuilder sb = new StringBuilder();
        int max = 0;
        for (int i = 0; i < n-1; i++) {
            int c = map.get(e[i][0]).get(e[i][1]);
            sb.append(c).append("\n");
            if(max < c) max = c;
        }
        System.out.println(max);
        System.out.print(sb.toString());
        sc.close();

    }

    private static void dfs(int v, int pre, Map<Integer, Map<Integer, Integer>> map) {
        int c = 1;
        for(int nv : g[v]){
            if(used[nv]) continue;
            if(c == pre) c++;
            int min = Math.min(v, nv);
            int max = Math.max(v, nv);
            if(!map.containsKey(min)) map.put(min, new HashMap<>());
            map.get(min).put(max, c);
            used[nv] = true;
            dfs(nv, c++, map);
        }
    }

    public static int[][] buildGraph(Scanner sc, int n, int m) {
        int[][] graph = new int[n][];
        e = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            e[i][0] = a;
            e[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = e[i][0];
            int b = e[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }

}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

ll mpow(ll x, ll n, ll m) {
	ll ans = 1; x %= m;
	while (n != 0) {
		if (n & 1) ans = ans * x % m;
		x = x * x % m;
		n = n >> 1;
	}
	return ans;
}

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> as(n+1);
	rep(i, n) cin >> as[i+1];

	vector<int> history;
	int current = 1;
	history.push_back(current);
	vector<int> visit(n+1, -1);
	visit[1] = 0;
	for (ll i = 1; i <= k; i++) {
		auto next = as[current];
		if (visit[next] >= 0) {
			ll rest = k - i;
			ll loop = history.size() - visit[next];
			rest %= loop;
			cout << history[visit[next] + rest] << endl;
			//end
			return 0;
		}
		history.push_back(next);
		visit[next] = i;		
		current = next;
	}
	cout << history.back() << endl;
	return 0;
}


Measured memory_bytes: 6532
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int main()
{
    int a = 1;
    int ans = 0;
    string s, t;
    cin >> s;
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    while (a)
    {
        cin >> t;
        if (t == "END_OF_TEXT")
            a = 0;
        else
        {
            transform(t.begin(), t.end(), t.begin(), ::toupper);
            if (t == s)
                ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int INF=1000000000;

void chmin(int &a, int b){if (a>b) a=b;}

int N,A,B,C;
vector<int> L;

int rec(int i,int a, int b,int c){
    if(i==N){
        if(!a || !b || !c) return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    
    int res=rec(i+1,a,b,c);
    chmin(res, rec(i+1,a+L[i],b,c)+(a ? 10 : 0));
    chmin(res, rec(i+1,a,b+L[i],c)+(b ? 10 : 0));
    chmin(res, rec(i+1,a,b,c+L[i])+(c ? 10 : 0));
    
    return res;
}

int main(){
  cin>>N>>A>>B>>C;
  L.resize(N);
  for(int i=0;i<N;i++) cin>>L[i];
  
  cout<<rec(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        k: usize
    }
    if k <= a {
        println!("{} {}", a - k, b);
    } else if k <= a + b {
        println!("{} {}", 0, a + b - k);
    } else {
        println!("0 0")
    }
}


Measured memory_bytes: 2200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int D = Integer.parseInt(sc.next());
        var c = new int[26];
        for(int i = 0; i < 26; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        var s = new int[D][26];
        for(int i = 0; i < D; i++){
            for(int j = 0; j < 26; j++){
                s[i][j] = Integer.parseInt(sc.next());
            }
        }
        
        var sb = new StringBuilder();
        for(int i = 0; i < D; i++){
            sb.append(1 + i%26).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

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

ans = 0
minDiff = float('inf')
for i, H in enumerate(Hs, 1):
    temp = T - 0.006 * H
    if abs(temp - A) < minDiff:
        ans = i
        minDiff = abs(temp - A)

print(ans)


Measured memory_bytes: 3060
a,b,c,x,y = map(int,input().split())
ans = 0
d = a+b
if d>2*c:
    while min(x,y)>0:
        ans += 2*c
        x -= 1
        y -= 1
else:
    while min(x,y)>0:
        ans += d
        x -= 1
        y -= 1
        

if x == 0:
    sus = min(2*c,b)
    while y>0:
        ans += sus
        y -= 1

        
else:
    sus = min(a,2*c)
    while x>0:
        ans += sus
        x -= 1
        
print(ans)
        

Measured memory_bytes: 3064
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

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

const long long INF = 1e18;

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    for(int i=0;i<n;++i){
        cin >> a[i];
        ans += ((a[i] % 2 == 1) && (i % 2 == 0));
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        double n;
        cin >> n;
        vector<double> v(n);
        rep(i, n) cin >> v[i];

        sort(all(v));
        double now = (v[0] + v[1]) / 2;
        for (ll i = 2; i < n; ++i) {
            now = (now + v[i]) / 2;
        }
        cout << now << endl;
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define It it=se.begin();it!=se.end();it++
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define unmap unordered_map
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define sh short int
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
int k,ans;
int a[9];
int main(){
    cin>>a[0]>>a[1]>>a[2]>>k;
    ans += min(k,a[0]);
    k -= min(k,a[0]);
    k -= min(k,a[1]);
    ans -= min(k,a[2]);
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include<math.h>
long double Ma=3.1415926535;
long double radian(int H,int M){
    long double t;
    t=fabs(30.*H-5.5*M);
    //printf("%20.20Lf",t);
    return t;
}
int main(void){
    // Your code here!
    int A,B,H,M;
    long double t;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&H);
    scanf("%d",&M);
    t=radian(H,M);
    long double d=sqrt((long double)(A*A+B*B-2*A*B*cos(Ma*t/180.)));
    printf("%20.20Lf",d);
    return 0;
}

Measured memory_bytes: 2588
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var h, w int
	fmt.Scanf("%d %d\n", &h, &w)

	slice := make([]string, h)
	res := make([][]int, h+2)

	for i := 0; i < h+2; i++ {
		res[i] = make([]int, w+2)
	}

	for i := 0; i < h; i++ {
		fmt.Scanf("%s\n", &slice[i])
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if string(slice[i][j]) == "#" {
				for di := -1; di <= 1; di++ {
					for dj := -1; dj <= 1; dj++ {
						res[i+di+1][j+dj+1]++
					}
				}
			}
		}
	}

	for i := 0; i < h; i++ {
		outline := ""
		for j := 0; j < w; j++ {
			if string(slice[i][j]) == "#" {
				outline += "#"
			} else {
				outline += strconv.Itoa(res[i+1][j+1])
			}
		}
		fmt.Println(outline)
	}

}


Measured memory_bytes: 1940
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<map>
#define N_MAX 1002
#define M_MAX 100002
using namespace std;
struct Bar{
	Bar():i(0),h(0),li(N_MAX),ri(N_MAX){}
	int i;
	int h;
	int li;
	int ri;
	bool operator<(const Bar &t)const{return h<t.h;}
};
int main()
{
	while(true){
		int non_erase = 0;
		int ans=0,maxdiff=0;
		int n,m,h,k;
		int s[N_MAX];
		int end_id[N_MAX];
		map<int,int> ms;
		Bar *bars;
		scanf("%d%d%d%d", &n, &m, &h, &k);
		if(n==0&&m==0&&h==0&&k==0)
			break;
		bars = new Bar[m+1];
		for(int i = 1; i <= n; ++i){cin>>s[i]; end_id[i] = i;}
		for(int i = 1; i <= m; ++i){cin>>bars[i].i>>bars[i].h;}
		
		sort(bars+1,bars+m+1);

		for(int i = 1; i <= m; ++i){
			swap( end_id[ bars[i].i ], end_id[ bars[i].i+1 ] );
			bars[i].li = end_id[ bars[i].i ];
			bars[i].ri = end_id[ bars[i].i + 1 ];
		}
		reverse(bars+1,bars+m+1);
		for(int i = 1; i <= m; ++i){
			swap( s[ bars[i].i ], s[ bars[i].i+1 ] );
		}
		for(int i = 1; i <= m; ++i){
			if( bars[i].li > k && bars[i].ri <= k && s[ bars[i].li ] < s[ bars[i].ri ] ||
				bars[i].li <= k && bars[i].ri > k && s[ bars[i].li ] > s[ bars[i].ri ] ){
					maxdiff = max( maxdiff, abs( s[ bars[i].li ] - s[ bars[i].ri ] ) );
			}
		}

		ans -= maxdiff;
		for(int i = 1; i <= k; ++i){
			non_erase += s[ i ];
			ans += s[i];
		}

		printf("%d\n", min(non_erase, ans));
		delete [] bars;
	}
	return 0;
}

Measured memory_bytes: 2540
# B - Five Dishes
import math

n = []
for _ in range(5):
    n.append(int(input()))

time = 0
mini = 10
for x in n:
    rest = x%10
    if rest != 0:
        mini = min(rest, mini)
    while x%10 != 0:
        x = math.ceil(x/10)*10
    time += x
print(time-10+mini)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

// return the minimum number of t s.t., d*(2**t)>=x
int f(int d, int x) {
  int t = 0;
  while(d * (1 << t) < x) t++;
  return t;
}

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0.0;
  rep(i, n) {
    int dice = i + 1;
    ans += (1.0) / (double)(1LL << f(dice, k));
  }
  ans *= (1.0 / (double)n);
  printf("%.20f\n", ans);
  return 0;
}

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

using namespace std;

int main()
{

    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int count=0;
    for(int i=0; i<=a; i++)
    {
        for(int j=0; j<=b; j++)
        {
            for(int k=0; k<=c; k++)
            {
                if(((i*500)+(j*100)+(k*50))== x)
                count++;
            }
            
        }
            
    }
    cout<<count<<endl;
    return 0;
}

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

unsigned long long gcd(unsigned long long x, unsigned long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

unsigned long long lcm(unsigned long long x, unsigned long long y) {
  return x / gcd(x, y) * y;
}

int main() {
  int N;
  cin >> N;
  vector<unsigned long long> T(N);
  for (int i=0; i<N; i++) cin >> T[i];
  unsigned long long ans = 1LL;
  for (int i=0; i<N; i++) {
    ans = lcm(ans, T[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

#define N 100000

int n, m, x, y, a[N + 9];
bool u[N + 9];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) a[i] = 1;
	u[1] = true;
	while (m--) {
		scanf("%d%d", &x, &y);
		u[y] |= u[x];
		if (!--a[x]) u[x] = false;
		++a[y];
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) ans += u[i];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    unsigned char x[10000]={0};
    int i;
    int joi_ans=0,ioi_ans=0;

    while(scanf("%s",x)!=EOF){
    for(i = 0;x[i] != '\0'; i++){
        if(x[i] == 'J' && x[i+1] == 'O' && x[i+2] == 'I')joi_ans += 1;
        else if(x[i] == 'I' && x[i+1] == 'O' && x[i+2] == 'I')ioi_ans += 1;
    }
    printf("%d\n%d\n",joi_ans,ioi_ans);
    joi_ans=0,ioi_ans=0;
    }
    return 0;
}

Measured memory_bytes: 560
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  int key;
  struct node *r;
  struct node *l;
  struct node *p;
};

typedef struct node * Node;

Node root;

void insert(int v){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=v;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;

    if(z->key < x->key) x=x->l;
    else x=x->r;
  }

    z->p=y;

    if(y==NIL) root=z;
    else if(z->key < y->key) y->l=z;
    else y->r=z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->l);
    preorder(u->r);
  }
}

int main(){
  int n,i,x;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

  if(com[0]=='i'){
    scanf("%d",&x);
    insert(x);
  }
  else if(com[0]=='p'){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
  }
  }
  return 0;
}

Measured memory_bytes: 24040
#include<cmath> 
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int n,a[55];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int mx=1;
    for(int i=2;i<=n;i++) if(abs(a[i])>abs(a[mx])) mx=i;
    printf("%d\n",2*n); 
    if(a[mx]>=0)
    {
        printf("%d %d\n",mx,n);
        printf("%d %d\n",mx,n);
        for(int i=1;i<n;i++)
        {
            printf("%d %d\n",n,i);
            printf("%d %d\n",n,n);
        }
    }
    else
    {
        printf("%d %d\n",mx,1);
        printf("%d %d\n",mx,1);
        for(int i=n;i>1;i--)
        {
            printf("%d %d\n",1,i);
            printf("%d %d\n",1,1);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	return !printf("%d\n", (N - 2) / (K - 1) + 1);
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
import numpy as np
##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    A, B = rip()
    def gcd(a, b):
        return b if a == 0 else gcd(b % a, a)
    g = gcd(A, B)
    print(A // g * B)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12236
#include <iostream>

using namespace std;

int main(void){

  int w;
  int a, b;

  cin >> w >> a >> b;

  if(b + w < a) cout << a - (b + w) << endl;
  else if((a <= b + w && b + w <= a + w) || (a <= b && b <= a + w)) cout << 0 << endl;
  else cout << b - (a + w) << endl;

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#define ROOM 10
#define FLOOR 3
#define BUILDING 4
int main()
{
  int count[BUILDING][FLOOR][ROOM]={0};
  int i, j, k, n, b, f, r, v;
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    count[b-1][f-1][r-1]+=v;
  }

  for(i=0; i<BUILDING; i++) {
    if(i) printf("####################\n");
    for(j=0; j<FLOOR; j++) {
      for(k=0; k<ROOM; k++) {
        printf(" %d", count[i][j][k]);
      }
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int H[N];
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  int top = H[0];
  int ans = 1;
  for(int i=1; i<N; i++){
    if(H[i] >= top){
      ans++;
      top = H[i];
    }
  }
  cout << ans << endl;
  return 0;
}

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

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



int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    
    int ans=0;
    rep(i,n){
        if(h[i] >= k){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    
    
}


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

#include <string.h>

using namespace std;

typedef long long ll;

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

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

const int MAX_X = 1000000; // 10 ** 6

int memo[MAX_X + 1];

bool solve(const int x) {
    if (memo[x] == 1) {
        return true;
    } else if (memo[x] == 0) {
        return false;
    }

    if (x < 100) {
        return false;
    }

    if (solve(x - 100) || solve(x - 101) || solve(x - 102) || solve(x - 103) || solve(x - 104) || solve(x - 105)) {
        memo[x] = 1;
        return true;
    } else {
        memo[x] = 0;
        return false;
    }
}

int main(void) {
    int X;
    cin >> X;

    memset(memo, -1, sizeof(memo));

    memo[100] = 1;
    memo[101] = 1;
    memo[102] = 1;
    memo[103] = 1;
    memo[104] = 1;
    memo[105] = 1;

    if (solve(X)) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d,k;
    cin>>a>>b>>c>>d>>k;
    int cnt1=a*60+b,cnt2=c*60+d;
    int diff=cnt2-cnt1;
    cout<<diff-k<<endl;
}

Measured memory_bytes: 3688
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        StringTransformation solver = new StringTransformation();
        solver.solve(1, in, out);
        out.close();
    }

    static class StringTransformation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            char[] t = in.next().toCharArray();

            HashMap<Character, Integer> smap = new HashMap<>();
            HashMap<Character, Integer> tmap = new HashMap<>();

            for (int i = 0; i < s.length; i++) {
                smap.put(s[i], smap.getOrDefault(s[i], 0) + 1);
                tmap.put(t[i], tmap.getOrDefault(t[i], 0) + 1);
            }
            List<Integer> sa = new ArrayList<>(smap.values());
            List<Integer> ta = new ArrayList<>(tmap.values());
            Collections.sort(sa);
            Collections.sort(ta);
            for (int i = 0; i < sa.size(); i++) {
                if (!sa.get(i).equals(ta.get(i))) {
                    out.print("No");
                    return;
                }
            }
            out.print("Yes");
        }

    }
}



Measured memory_bytes: 48800
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, 1, n + 1){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    int ans = INF;
    rep(i, 1, n){
        chmin(ans, abs(a[i] - a[n] + a[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
// A - Grouping 2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//


#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int N, x;

	cin >> N;

	x = N / 3;

	cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
d, g = ri_()
p, c = [0] * d, [0] * d
for i in range(d):
    p[i], c[i] = ri_()
ans = 1000
for bit in range(1 << d):
    pro = 0
    poi = 0
    L = []
    for i in range(d):
        if bit & (1 << i):
            pro += p[i]
            poi += p[i] * (i + 1) * 100 + c[i]
        else:
            L.append(i)
    for i in L[::-1]:
        if poi < g:
            tmp = min(p[i], -(-(g - poi) // (100 * (i + 1))))
            pro += tmp
            poi += tmp * 100 * (i + 1)
        else:
            break
    if poi >= g:
        ans = min(ans, pro)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n,a,b;
  scanf("%lld %lld %lld",&n,&a,&b);
  n-=a;
  ll t=n;
  printf("%lld\n",n%b);

    return 0;
}


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

int main() {
  int H, W, ch, dh, cw, dw;
  cin >> H >> W >> ch >> cw >> dh >> dw;
  vector<vector<int>> S(H, vector<int>(W));
  char c;
  rep(i, H) rep(j, W) {
    cin >> c;
    S.at(i).at(j) = c == '.' ? -1 : -2;
  }

  deque<T> dq;
  dq.push_front(T(ch - 1, cw - 1, 0));

  int i, j, cost;
  while (!dq.empty()) {
    auto tp = dq.front();
    tie(i, j, cost) = tp;
    dq.pop_front();
    if (S.at(i).at(j) != -1) continue;

    S.at(i).at(j) = cost;
    if (i < H - 1 && S.at(i + 1).at(j) == -1) dq.push_front(T(i + 1, j, cost));
    if (j < W - 1 && S.at(i).at(j + 1) == -1) dq.push_front(T(i, j + 1, cost));
    if (i > 0 && S.at(i - 1).at(j) == -1) dq.push_front(T(i - 1, j, cost));
    if (j > 0 && S.at(i).at(j - 1) == -1) dq.push_front(T(i, j - 1, cost));

    for (int k = max(0, i - 2); k <= min(H - 1, i + 2); k++)
      for (int l = max(0, j - 2); l <= min(W - 1, j + 2); l++)
        if (S.at(k).at(l) == -1) dq.push_back(T(k, l, cost + 1));
  }

  cout << S.at(dh - 1).at(dw - 1) << endl;
}


Measured memory_bytes: 7772
A=input()
B=[]
for i in range(len(A)):
    B.append(A[i])
    B.sort()
flg=0
for i in range(len(A)-1):
    if B[i]==B[i+1]:
        flg=+1
if flg>0:
    print("no")
else:
    print("yes")

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

int main() {
  int N;
  cin >> N;
  
  string s;
  bool isFour = false;
  for (int i=0; i<N; i++) {
    cin >> s;
    if (s == "Y") {
      isFour = true;
      break;
    }
  }
  
  if (isFour) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

#define int long long

signed main(void){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        if(a%2==0){
            if(!(a%3==0 || a%5==0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n;
int one, two, four;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>n;
  for (int i=0; i<n; i++) {
    int x; cin>>x;
    if (x%4==0) {
      four++;
    } else if (x%2==0) {
      two++;
    } else {
      one++;
    }
  }

  if (four==0) {
    if (one>0) out("No");
    out("Yes");
  }

  if (one <= four) out("Yes");
  if (one > four+1) out("No");

  assert(one==four+1);

  // can't do 1 4 1 4 1 2
  if (two>0) out("No");
  cout<<"Yes"<<endl;
  return 0;
}
// don't forget to read in the input :^)


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

int main()
{
    int diff = 'a' - 'A';
    char str[1200];

    scanf("%[^\n]",str);

    for(int i = 0; i < sizeof(str) /sizeof(char); i++)
    {
        if(str[i] >= 65 && str[i] <= 90)
        {
            str[i] += diff;
        }
        else if(str[i] >= 97 && str[i] <= 122)
        {
            str[i] -= diff;
        }
    }

    printf("%s\n", str);
    
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,n-1){
    if(s[i]!=s[i+1]) ans++;
  }
  cout<<ans+1<<endl;

  return 0;
}


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

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp = Console.ReadLine();
            string[] tmpSplit = tmp.Split();
            int[] x = new int[5];
            int answer = 0;

            for (int i = 0; i < 5; i++)
            {
                x[i] = int.Parse(tmpSplit[i]);
                if (x[i] == 0)
                {
                    answer = i + 1;
                    break;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27148
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

int main() {
	int n, w, h;
	int ans = 0, x = 0, y = 0;
	cin >> w >> h >> n;
	cin >> x >> y;
	x--; y--; n--;

	while (n--) {
		int nx, ny, d = 0;
		cin >> nx >> ny;
		nx--; ny--;

		if (nx > x && ny > y) {d = min(nx - x, ny - y); x += d; y += d;}
		else if (nx < x && ny < y) {d = min(x - nx, y - ny); x -= d; y -= d;}
		else if (nx > x && ny != y) {d = nx - x; x += d;}

		d += abs(nx - x) + abs(ny - y);
		x = nx; y = ny;
		ans += d;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160