akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2 == 0){
  	cout << (a+b)/2 << endl;
  }else{
    cout << (a+b)/2+1 << endl;
  }
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>

#pragma GCC optimize("O3")

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repd(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define FOR(i, a, b) for(ll i = a; i <= ll(b); ++i)
#define FORD(i, a, b) for(ll i = a; i >= ll(b); --i)
#define loop while(true)
#define asort(array, size) std::sort(array, array + size)
#define cauto const auto&
#define bit(n) (1LL << (n))

int main()
{
    ll X;
    ll K;
    ll D;
    cin >> X >> K >> D;
    X = abs(X);
    auto dec = X / D; // 最小値への回数
    if (dec >= K) cout << X - D * K << endl;
    else {
        auto num = K - dec;
        if (num % 2) cout << abs((X - D * dec) - D) << endl;
        else cout << (X - D * dec) << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	int ed[100],ee[100];
	REP(i, 100) {
		ed[i] = INF;
		ee[i] = INF;
	}
	string a, b;
	cin >> a >> b;
	REP(i, a.size()) {
		if (ed[a[i] - 'a'] == INF) ed[a[i] - 'a'] = b[i] - 'a';
		else if (ed[a[i] - 'a'] != b[i] - 'a') {
			cout << "No" << endl;
			return 0;
		}
	}
	REP(i, a.size()) {
		if (ee[b[i] - 'a'] == INF) ee[b[i] - 'a'] = a[i] - 'a';
		else if (ee[b[i] - 'a'] != a[i] - 'a') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

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

   while(op != '?'){
      if(op == '+'){
         printf("%d\n",a+b);
      }
      else if(op == '-'){
         printf("%d\n",a-b);
      }
      else if(op == '*'){
         printf("%d\n",a*b);
      }
      else if(op == '/'){
         printf("%d\n",a/b);
      }
      cin >> a >> op >> b;
   }

   return 0;
}



Measured memory_bytes: 3240
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N = Scanner.int()
    T = Scanner.map_int()
    V = Scanner.map_int()
    T = list(map(lambda x: x * 2, T))
    time = sum(T) + 1
    maxv = [INF] * time
    i = 0
    ct = 0
    for i in range(N):
        for j in range(ct, ct + T[i] + 1):
            maxv[j] = min(V[i], maxv[j])
        ct += T[i]
    maxv[0] = 0
    maxv[-1] = 0
    for t in range(1, time):
        maxv[t] = min(maxv[t], maxv[t-1] + 0.5)
    for t in reversed(range(time - 1)):
        maxv[t] = min(maxv[t], maxv[t + 1] + 0.5)
    print(sum(maxv) * 0.5)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 42092
#include<stdio.h>

int main(){
  while(1){
    char ans[201];
    int m,h;
    int i,k,j,string_size=0;
    char work;
    
    scanf("%s",ans);

    if(strcmp(ans, "-") == 0) break;
    
    for(i=0; i<201; ++i){
      if(ans[i] == '\n' || ans[i] == '\0') break;
      ++string_size;
    }
    
    scanf("%d",&m);
    
    for(i=0; i<m; ++i){
      scanf("%d",&h);
      
      for(k=0; k<h; ++k){
	work = ans[0];
	
	for(j=0; j<string_size-1; ++j){
	  ans[j] = ans[j+1];
	}
	ans[string_size-1] = work;
      }
    }

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



Measured memory_bytes: 2068
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 double a=(double)n/(double)3;
 double s=a*a*a;
 printf("%.10lf\n",s);
 
 return 0;}



Measured memory_bytes: 3732
N,K=list(map(int, input().split()))
h=list(map(int, input().split()))
history=[0]*N
if N-1<=K:#無理久保なんですけど～～～
	print(abs(h[N-1]-h[0]))
else:#可能久保
	for made in range(1,K):#自明な履歴つくりまーっす
		kouho=[]
		for kara in range(0,made):
			kouho.append(history[kara]+abs(h[made]-h[kara]))
		history[made]=min(kouho)
	for made in range(K,N):#履歴踏まえのみ履歴を作りながら進む
		kouho=[]
		for kara in range(made-K,made):
			kouho.append(history[kara]+abs(h[made]-h[kara]))
		history[made]=min(kouho)
	print(history[N-1])
#print(history)


Measured memory_bytes: 52448
import sys

while 1:
    n = int(raw_input())
    if n == 0: break

    map = {}
    for i in range(n):
        vs = raw_input().split()
        map[vs[0]] = vs[1]

    n = int(raw_input())
    for i in range(n):
        ch = raw_input().strip()
        e = map.get(ch)
        if e is None:
            e = ch
        sys.stdout.write(e)
    sys.stdout.write('\n')

Measured memory_bytes: 7380
import scala.math._

object Main {
	def gcd(a: Int, b: Int): Int = if(b==0) a else gcd(b, a%b)
	def lcm(a: Int, b: Int): Int = a*b/gcd(a,b)
	def lcm(array: Array[Int]): Int = {
		var tmp = array(0)
		for(i <- 1 until array.length) tmp = lcm(tmp, array(i))
		return tmp
	}
	
	def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		val n = sc.nextInt
		sc.nextLine
		val nums = sc.nextLine.split(' ').map(_.toInt)
		println(lcm(nums))
		
	}

}

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

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

using namespace std;
typedef long long ll;

int T[5005][5005];

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

    vector<int> x(n),y(n),vx(n),vy(n);
    rep(i,n) {
        cin >> x[i] >> y[i];
        vx[i] = x[i];
        vy[i] = y[i];
    }

    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());

    vx.erase(unique(vx.begin(),vx.end()),vx.end());
    vy.erase(unique(vy.begin(),vy.end()),vy.end());
    

    rep(i,n) {
        x[i] = lower_bound(vx.begin(),vx.end(),x[i]) - vx.begin();
        y[i] = lower_bound(vy.begin(),vy.end(),y[i]) - vy.begin();
    }

    memset(T,0,sizeof(T));
    rep(i,n) {
        T[x[i]+1][y[i]+1]++;
    }

    int h = vx.size();
    int w = vy.size();

    rep(i,h+1) {
        REP(j,1,w+1) {
            T[i][j] += T[i][j-1];
        }
    }
    
    REP(i,1,h+1) {
        rep(j,w+1) {
            T[i][j] += T[i-1][j];
        }
    }


    rep(i,m) {
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;

        int nx1 = lower_bound(vx.begin(),vx.end(),x1) - vx.begin();
        int ny1 = lower_bound(vy.begin(),vy.end(),y1) - vy.begin();

        int nx2 = upper_bound(vx.begin(),vx.end(),x2) - vx.begin();
        int ny2 = upper_bound(vy.begin(),vy.end(),y2) - vy.begin();
        
        // cout << T[nx2][ny2] << endl;
        // cout << T[nx1][ny2] << endl;
        // cout << T[nx2][ny1] << endl;
        // cout << T[nx1][ny1] << endl;

        cout << T[nx2][ny2] - T[nx1][ny2] - T[nx2][ny1] + T[nx1][ny1] << endl;
        
    }


    return 0;
}

Measured memory_bytes: 99148
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	double N, K;
	cin >> N >> K;
	cout << ceil(N / K) - (int) N / (int)K << endl;
}



Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	if (S[K - 1] == 'A') {
		S[K - 1] = 'a';
	}
	else if (S[K - 1] == 'B') {
		S[K - 1] = 'b';
	}
	else if (S[K - 1] == 'C') {
		S[K - 1] = 'c';
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
int main(void)
{   
    int i;   
    int card[128][14]={{0}};
            int n, m;   char c;   
            scanf("%d", &n);   
            for(i=0; i<n; i++){
                scanf("%c", &c);
                scanf("%c %d", &c, &m);       
                card[c][m]=1; 
                
            }   
            for(i=1;i<=13; i++)   {
                if(card['S'][i]==0){       
                    printf("S %d\n", i);
                } 
                
            }    
            for(i=1;i<=13; i++)   {
                if(card['H'][i]==0){       
                    printf("H %d\n", i);  
                    
                } 
                
            }    
            for(i=1;i<=13; i++)  {  
                if(card['C'][i]==0){      
                    printf("C %d\n", i); 
                    
                }  
                
            }    
            for(i=1;i<=13; i++)   { 
                if(card['D'][i]==0){       
                    printf("D %d\n", i); 
                    
                }  
                
            }   
            return 0;
    
}


Measured memory_bytes: 2128
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 2007;
const LD EPS = 1e-7;

int A[MAXN], B[MAXN];

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	int n;
	LL x, ans = LINF;
	cin >> n >> x;
	REP(i, n)
	{
		cin >> A[i];
		B[i] = INF;
	}
	REP(k, n)
	{
		REP(i, n)
			B[i] = min(B[i], A[(i - k + n) % n]);
		LL cur = k * x;
		REP(i, n)
			cur += B[i];
		ans = min(ans, cur);
	}
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner //標準入力
{
    string[] s;
    int i;

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

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

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

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

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

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main(string[] args) {
        int N = cin.Int();
        int C = cin.Int();
        int K = cin.Int();
        var T = new int[N];
        for (int i = 0; i < N; i++) {
            T[i] = cin.Int();
        }
        Array.Sort(T);

        int first = 0, cnt = 0;
        while (true) {
            if (first >= N) break;
            else if (first + C - 1 >= N) {
                if (T[N - 1] <= T[first] + K) { //残り全員乗れる
                    cnt++;
                    first = N;
                    break;
                }
                else {
                    int index = first;
                    while (T[index] <= T[first] + K) index++;
                    first = index;
                    cnt++;
                }
            }
            else {
                if (T[first + C - 1] <= T[first] + K) { //C人ちょうど乗れるとき
                    cnt++;
                    first += C;
                }
                else { //来るのが遅くて最初の人からK経った人までを乗せるとき
                    int index = first;
                    while (T[index] <= T[first] + K) index++;
                    first = index;
                    cnt++;
                }
            }
        }
        Console.WriteLine(cnt);
        Console.ReadLine();
    }
}

Measured memory_bytes: 15444
import java.util.Scanner;

public class Main {

	private static int cnt;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean checkTime = false;
		long stime = 0;

		int n = sc.nextInt();

		if (checkTime) {
			stime = System.currentTimeMillis();
			System.out.println("Time: " + (System.currentTimeMillis() - stime));
		}

		int[] data = new int[n];
		
    	for (int i = 0; i < n; i++) {
    		data[i] = sc.nextInt();
    	}
    	
		if (checkTime) {
			System.out.println("Time: " + (System.currentTimeMillis() - stime));
		}
    	// Shell Sort
    	cnt = 0;
    	int[] g;

//    	int m = (n - 1) / 3 + 1;
//    	if (m > 100) {
//    		m = 100;
//    	}
//    	g = new int[m];
//    	for (int i = m - 1; i >= 0; i --) {
//    		g[i] = 3 * i + 1;
//    	}
    	
    	int m = (int)Math.pow(n, 1.25);
    	if (m > 100) {
    		m = 100;
    	}
		g = new int[m];
		int ii = 0;
		g[ii] = 1;
		for (ii = 1; ii < m; ii++) {
			int next = g[ii - 1] * 3 + 1;
			if (next > n) {
				break;
			}
			g[ii] = next;
		}
		m = ii;
    	
    	for (int i = 0; i < m; i++) {
    		insertionSort(data, n, g[m - 1 - i]);
    	}

		if (checkTime) {
			System.out.println("Time: " + (System.currentTimeMillis() - stime));
		}

		// m
    	System.out.println(m);
    	// g
		StringBuffer printData = new StringBuffer();
		for (int i = 0; i < m; i++) {
			printData.append(g[m - 1 - i]);
			printData.append(" ");
		}
		printData.delete(printData.length() - 1, printData.length());
		System.out.println(printData);
    	// cnt
    	System.out.println(cnt);

		if (checkTime) {
			System.out.println("Time: " + (System.currentTimeMillis() - stime));
		}

    	// data
    	StringBuffer output = new StringBuffer();
		String cr = System.getProperty("line.separator");
		for (int i = 0; i < data.length; ) {
			for (int j = 0; j < 100000 && i < data.length; j++) {
				output.append(data[i]);
				output.append(cr);
				i++;
			}
	    	System.out.print(output);
	    	output.setLength(0);
		}

    	sc.close();

    	if (checkTime) {
			System.out.println("Time: " + (System.currentTimeMillis() - stime));
		}
	}
	
	private static void insertionSort(int[] data, int n, int g) {
		for (int i = g; i < n; i++) {
			int v = data[i];
			int j = i - g;
			int tmp;
//			for (; j >= 0 && data[j] > v;) {
//			    data[j + g] = data[j];
			for (; j >= 0 && (tmp = data[j]) > v;) {
				data[j + g] = tmp;
				j -= g;
				cnt++;
			}
			data[j + g] = v;
		}
		return;
	}
}

Measured memory_bytes: 297160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct Edge {
    int from, to; string spell;
    Edge(int f, int t, string s)
         :from(f), to(t), spell(s){}
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, S, G;
    while(cin >> N >> A >> S >> G && N){
        vector<Edge> es;
        int x_, y_; string s;
        rep(i, A){
            cin >> x_ >> y_ >> s;
            es.push_back(Edge(y_, x_, s));
        }
        vector<string> dist(N, "~"); dist[G] = "";
        bool fail = false;
        rep(repnum, N * 6){
            bool update = false, update_s = false, toolong = false;
            for(const Edge& e : es)
              if(dist[e.from] != "~" && dist[e.to] > e.spell + dist[e.from]){
                  dist[e.to] = e.spell + dist[e.from];
                  update = true;
                  if(e.to == S) update_s = true;
              }
            if(!update) break;
            if(repnum == N && dist[S] == "~") break;
            if(repnum >= N && update_s){
                fail = true;
                break;
            }
        }
        if(dist[S] == "~" || fail) cout << "NO" << '\n';
        else cout << dist[S] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3276
n=int(input())
a=[int(_) for _ in input().split()]
b=[int(_) for _ in input().split()]
cnt=0
for i in range(n):
	cnt+=min(a[i]+a[i+1],b[i])
	if b[i]<a[i]+a[i+1]:
		a[i+1]=min(a[i]+a[i+1]-b[i],a[i+1])
	else:a[i+1]=0
print(cnt)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a,b;
int main(){
	cin >> n >> a >> b;
	
	cout << min(a,b) << " ";
	
	if(n >= a + b){
		cout << 0;
		return 0;
	}
	cout << a + b - n;;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
using llint = long long int;
using lint = long int;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;

int gcd(int a, int b) {
	while (true) {
		if (a < b) {
			swap(a, b);
		}
		if (b == 0) {
			break;
		}
		a %= b;
	}
	return a;
}

int main() {
	int n;
	cin >> n;
	vector<lint> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	array<int, 3> dp = {0,0,0};
	rep(i, n) {
		dp[0] = max(gcd(a[i], dp[0]), gcd(a[i], dp[1]));
		dp[1] = dp[2];
		dp[2] = gcd(dp[2], a[i]);
	}
	cout << *max_element(all(dp)) << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		int n=s.nextInt(),m=s.nextInt();
		int[] in=new int[n];
		int[] r=new int[n];
		ArrayList<ArrayList<Integer>> g=new ArrayList<>(n);
		for(int i=0;i<n;i++)
			g.add(new ArrayList<>());
		for(int i=0;i<n-1+m;i++){
			int f=s.nextInt()-1,t=s.nextInt()-1;
			in[t]++;
			g.get(f).add(t);
		}
		int root=0;
		for(int i=0;i<n;i++)
			if(in[i]==0) root=i;
		
		ArrayDeque<Integer> q=new ArrayDeque<>();
		q.add(root);
		while(!q.isEmpty()){
			int p=q.poll();
			for(int o:g.get(p)){
				if(--in[o]==0){
					r[o]=p+1;
					q.add(o);
				}
			}
		}
		
		Arrays.stream(r).forEach(System.out::println);
	}
}

Measured memory_bytes: 103092
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();

		int[] X = new int[N];
		for(int i=0; i<N; i++) {
			X[i] = scan.nextInt();
		}
		scan.close();

		Arrays.sort(X);

		int[] Y = new int[N-K+1];

		//System.out.println("N:" +N);
		//System.out.println("K:" +K);
		for(int i=0; i<N; i++) {
			if(N <= i+K-1) {
				break;
			}
			//System.out.println(i+K-1);
			Y[i] = X[i+K-1] - X[i];

		}

		Arrays.sort(Y);
		System.out.println(Y[0]);
	}
}


Measured memory_bytes: 50376
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
cnt = 0
for i in range(n-1, 1, -1):
    for j in range(i-1, 0, -1):
        plus = l[i]+l[j]
        minus = l[i]-l[j]
        bir = min(j, bisect.bisect(l, plus))
        bil = bisect.bisect(l, minus)
        if bir > bil:
            cnt += bir-bil
print(cnt)

Measured memory_bytes: 45708
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int x;
    cin >> x;
    int find=1;
    while(find){
        int check=1;
        for(int i=2;i<x;i++){
            if(x%i==0) {
                check=0;
                break;
            }
        }
        if(check) {
            cout << x << endl;
            break;
        }else{
            x++;
        }
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long int
#define MOD 1000000007
using namespace std;
void solve() {
        int n;
        cin >> n;
        vector <float> v;
        for(int i=0;i<n;i++) {
                int x;
                cin >> x;
                v.push_back(x);
        }
        float sum, term, res;
        sum = 0;
        for(int i=0;i<n;i++) {
                term = 1/v[i];
                sum = sum + term;
        //      res = 1/sum;
        }
        res = 1/sum;
        cout << res << endl;
        return ;
}

int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        solve();
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#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>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;
map<ll,ll> m;

int main()
{
	ll x=0, y=0;
	ll n;
	cin >> n;
	
	for (int i = 0; i < n; i++){ 
		ll t;
		cin >> t;
		a.push_back(t);
		m[i] = 0;
	}
	
	for (ll i = 0; i < n; i++){
		m[a[i]] = m[a[i]] + 1;
	}

	for (ll i = m.size() - 1; i >= 1; i--)
	{
		ll maxv = m.rbegin() -> first;
		if (m[maxv] >= 4) {
			x = maxv;
			cout << x * x << endl;
			return 0;
		}
		else if (m[maxv] > 1) {
			x = maxv;
			m.erase(maxv);
			break;
		}
		m.erase(maxv);
	}
	for (ll i = m.size() - 1; i >= 1; i--) {
		ll maxv = m.rbegin()->first;
		if (m[maxv] > 1) {
			y = maxv;
			m.erase(i);
			break;
		}
		m.erase(maxv);
	}

	if (x != 0 && y != 0) {
		cout << x*y << endl;
	}
	else {
		cout << "0" << endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 13556
import sys
input = sys.stdin.readline

d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]
# T = [int(input()) for i in range(d)]
c = 26
# m = int(input())
# Q = [list(map(int,input().split())) for i in range(m)]

ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  # この中には0-25を入れる
K = [[] for i in range(d)]  # この中は0-indexed
pp = 6

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ANSS = [[ANS[j], j] for j in range(c)]
    ANSS.sort(reverse=True)
    for j in range(pp):
        # if j > 0 and ANSS[j][0] < 0:
        #     break
        K[i].append(ANSS[j][1])
    ind = ANSS[0][1]
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    # print(ans)
    # print(ind + 1)
    T[i] = ind

fans = ans
# print("fans",fans)
# print(L)
# print(T)

KP = [[0] * pp for i in range(d)]

# cp = 3
# dp = 3

# CC = [[C[i], i] for i in range(c)]
# CC.sort(reverse=True)
# for i in range(d):
#     for k in range(cp):
#         K[i].append(CC[k][1])

# for i in range(d):
#     DD = [[S[i][j], j] for j in range(c)]
#     DD.sort(reverse=True)
#     for k in range(dp):
#         K[i].append(DD[k][1])

# print("K",K)
    
from random import randint

m = 10*10**5

# Q = [[0] * 2 for i in range(m)]
# for i in range(m):
#     dd = randint(0, d-1)
#     # print("dd",dd)
#     # print(dd-1,randint(0, len(K[dd-1])-1))
#     q = K[dd][randint(0, len(K[dd])-1)]
#     Q[i][0] = dd
#     Q[i][1] = q

# print(Q)

ndd = -1
nq = -1

for i in range(m):
    # print(*T)
    # print(Q)
    dd = ndd if ndd != -1 else randint(0, d-1)
    qind = randint(0, len(K[dd])-1)
    q = nq if nq != -1 else K[dd][qind]
    nans = ans
    # print("dd",dd)
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        # print("j",j)
        if T[j] == q:
            # print("break")
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        # print("j",j)
        if T[j] == old:
            # print("break")
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    # print(nans, ans)

    if nans < ans:
        KP[dd][qind] += 1
        if KP[dd][qind] == 10:
            _ = K[dd].pop(qind)
        if i != m-1:
            ndd = dd
            nq = old
        else:
            T[dd] = old
    else:
        ndd = -1
        nq = -1
    
    ans = nans

# print(max(ans,fans))
for i in T:
    print(i+1)

# print(K)

Measured memory_bytes: 86916
#include <iostream>

int area(int n, int m);

int main()
{

	int n;

	while (std::cin >> n)
	{
		std::cout << area(n, 600) << std::endl;
	}


}

int area(int n, int m)
{
	int area = 0;
	while (m > 0)
	{
		area += (m - n) * (m - n) * n;
		m -= n;
	}

	return area;
}


Measured memory_bytes: 3120
N, M = map(int, input().split())
# N, M = 100000, 100000

mod = 10 ** 9 + 7
if N > M:
    N, M = M, N

if M - N >= 2:
    print(0)
elif M - N == 1:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print((prod * prod * M) % mod)
else:
    prod = 1
    for i in range(1, N + 1):
        prod = (prod * i) % mod
    print((2 * prod * prod) % mod)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main() {
int P,Q,R;
  cin >> P >> Q >> R;
int L[3];
L[0]= P+Q;
L[1]= P+R;
L[2]= R+Q;
if(L[0] < L[1] && L[0] < L[2]){
	cout << L[0] << endl;
}
else if(L[1] < L[2]){
  cout << L[1] << endl;
}  
else {
	cout << L[2] <<endl;
}
  return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  vector<string> s(3);
  cin >> s[0] >> s[1] >> s[2];
  string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string alp="abcdefghijklmnopqrstuvwxyz";
  for(int i=0;i<3;i++){
    for(int j=0;j<26;j++){
      if(s[i][0]==alp[j]){
        cout << ALP[j];
      }
    }
  }
}


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

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

  int n;
  cin >> n;
  map<string, int> counter;
  int max_num = 0;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    if(counter.count(s)) counter.at(s)++;
    else counter[s] = 1;
    max_num = max(max_num, counter.at(s));
  }
  for (auto elem : counter)
  {
    auto value = elem.second;
    if(max_num == value) cout << elem.first << "\n";
  }
  return 0;
}

Measured memory_bytes: 23808
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int minute, second;;
		
		minute = 0;
		second = 0;
		for (int i = 0; i < 4; i++) {
			second += sc.nextInt();
		}
		
		minute = second / 60;
		second %= 60;
		
		System.out.println(minute);
		System.out.println(second);
	}
}

Measured memory_bytes: 12000
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);

  ll ans = 0;
  ll mx = a[0];
  rep(i, n) {
    cin >> a[i];
    if (i != 0) {
      if (a[i] < mx) {
        ans += mx - a[i];
      }
    }
    mx = max(mx, a[i]);
  }
  cout << ans;
  return 0;
}


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

using namespace std;

int main()
{
	int n;
	int count = 1;
	int under;
	
	cin >> n;

	vector<int> data(n);

	for (int i = 0; i < n; i++)
		cin >> data.at(i);

	sort(data.begin(), data.end(), greater<int>());

	under = data.at(0);

	for (int i = 1; i < data.size(); i++) {
		if (under > data.at(i)) {
			under = data.at(i);
			count++;
		}
	}

	cout << count << endl;

}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   rep(i, n) cin>>a[i];

   ll m=1000;
   rep(i, n-1){
      if(a[i]<a[i+1]){
         ll num=m/a[i];
         m+= -a[i]*num+a[i+1]*num;
      }
   }

   cout<<m<<endl;

   return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    string s;
    while(cin>>s){
        for(int i=0;s[i];i+=2){
            printf("%c",s[i]);
        }
        printf("\n");
    }
return 0;}


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

int main(){
    int A,B;
    cin >> A >> B;
    if(A <= B){
        cout << "1" << endl;
    }
    else if(A%B > 0){
        cout << A/B +1 << endl;
    }
    else cout << A/B << endl;
}

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

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

  if(S.length() == 1)
    {
      std::cout << 0 << std::endl;
      return 0;
    }

  uint64_t a = 0;
  uint64_t b = 0;
  // transform 1010
  for(size_t i = 0;
      i < S.length();
      ++i)
    {
      if(i % 2 == 0)
        {
          if(S[i] == '0')
            {
              ++a;
            }
        }
      else
        {
          if(S[i] == '1')
            {
              ++a;
            }
        }
    }

  // transform 0101
  for(size_t i = 0;
      i < S.length();
      ++i)
    {
      if(i % 2 == 0)
        {
          if(S[i] == '1')
            {
              ++b;
            }
        }
      else
        {
          if(S[i] == '0')
            {
              ++b;
            }
        }
    }

  if(a < b)
    {
      std::cout << a << std::endl;
    }
  else
    {
      std::cout << b << std::endl;
    }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(B / A, C) << endl;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimize("Os")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("Os")
*/
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld; 

#define X first
#define Y second
#define MP make_pair

using namespace std;
    
const int N = 2e3 + 123;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

int n;
ll a[N], x, dp[N][N];
ll res;

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> x;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		dp[0][i] = a[i];
		res += a[i];
	}

	for(int k = 1;k < n;k++){
		ll now = 0;
		for(int i = 1;i <= n;i++){
			int nxt = i - k;
			if(nxt <= 0)
				nxt += n;
			//cout << nxt << " " << i << "\n";
			dp[k][i] = min(dp[k - 1][i], a[nxt]);
			now += dp[k][i];
		}
		now += k * x;
		res = min(res, now);
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 35072
import Control.Monad
import Data.List
import qualified Data.Vector.Unboxed as V

main=do
    n<-readLn::IO Int
    ts<-map read.words<$>getLine::IO[Int]
    m<-readLn
    pxs<-replicateM m $ map read.words<$>getLine
    --
    let s = sum ts
    putStr.unlines $ map (show.f s (V.fromList ts)) pxs

f s ts [p,x] = s - ts V.! (p-1) + x

Measured memory_bytes: 1020
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long l = 100;
		int count = 0;
		while(l < X) {
			l += l / 100;
			count++;
		}
		System.out.println(count);
		sc.close();
	}
}

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

int main(){
    int N, M; cin >> N >> M;
    int L=0;
    int R=100100;
    for(int i=0; i<M; i++){
        int l1, r1; cin>>l1 >> r1;
        L=max(L,l1);
        R=min(R,r1);
    }
    if(R-L >= 0){
    cout << R-L+1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int mx, my, nx, ny;
	scanf("%d%d%d%d", &mx, &my, &nx, &ny);
	if (mx%nx == 0 && my%ny == 0)printf("No\n");
	else
	{
		printf("Yes\n");
		for (int i = 0; i < mx; i++)
		{
			for (int j = 0; j < my; j++)
			{
				if (mx%nx != 0)
				{
					if (i%nx == 0)printf("999999999 ");
					else if (i%nx == nx - 1)printf("-1000000000 ");
					else printf("0 ");
				}
				else
				{
					if (j%ny == 0)printf("999999999 ");
					else if (j%ny == ny - 1)printf("-1000000000 ");
					else printf("0 ");
				}
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 2816
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m = MII()
    a_lst = [II() for _ in range(m)]
    DIV = 10**9+7
    stairs = [1]*2 + [0]*(n-1)
    for a in a_lst:
        stairs[a] = 'NG'
    cnt = 0
    for i in range(2, n+1):
        if cnt == 2:
            print(0)
            exit(0)
        if stairs[i] == 'NG': cnt += 1; continue
        cnt = 0
        a = stairs[i-1] if stairs[i-1] != 'NG' else 0
        b = stairs[i-2] if stairs[i-2] != 'NG' else 0
        stairs[i] = a + b
    print(stairs[n]%DIV)

if __name__ == '__main__':
    main()


Measured memory_bytes: 460004
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 1000000007;


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl; return 0;
		}
	}
	Bint ans = 1;
	for (ll i = 0; i < N; i++)
	{
		ans *= a[i];
		if (ans > 1000000000000000000) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[10];
    int s = 0;
    for (int i = 0; i < n; ++i)
        cin >> a[i], s += a[i];;

    sort(a, a + n);
    s -= a[n - 1] / 2;
    cout << s;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
#print(a)
H=[]
W=[]
for i in range(h):
    count=0
    for j in range(w):
        if a[i][j]==".":
            count+=1
    if count==w:
        H.append(i)
for i in range(w):
    count=0
    for j in range(h):
        if a[j][i]==".":
            count+=1
    if count==h:
        W.append(i)
for i in range(1,len(H)+1):
    for j in range(w):
        a[H[-1*i]][j]=""
for i in range(1,len(W)+1):
    for j in range(h):
        a[j][W[-1*i]]=""

for i in range(h):
    if not ("." in a[i] or "#" in a[i]):
        continue
    print("".join(a[i]))


Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		char n[] = sc.next().toCharArray();

		boolean result = true;
		for (int i = 0; i < n.length; i++) {
			if (n[i] == (((i + 1) % 2 == 0) ? 'R' : 'L')) {
				result = false;
				break;
			}
		}

		System.out.println(result ? "Yes" : "No");
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
            return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
            }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
            }
        }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
        }

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

#A
def A():
    a,b,c = LI()
    ans = 10 ** 5
    ans = min(ans, a + b)
    ans = min(ans, a + c)
    ans = min(ans, c + b)
    print(ans)
    return

#B
def B():
    n = II()
    w = LI()
    ans = inf
    for i in range(n):
        ans = min(ans, abs(sum(w[:i]) - sum(w[i:])))
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return


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


Measured memory_bytes: 38640
#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>;

int main() {
    int n;
    cin >> n;
    double x = 0;
    x = ceil(n / 1.08);
    if (floor(x * 1.08) == n) cout << x << endl;
    else cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int T, card[16];

bool is_same_number(int a, int b, int c)
{
    if (a == b and b == c) return true;
    return false;
}

bool is_sequence(int a, int b, int c)
{
    if(a + 1 == b and b + 1 == c) return true;
    return false;
}

bool is_good_set(int a, int b, int c)
{
    return is_same_number(a, b, c) or is_sequence(a, b, c);
}

bool is_all_good_set()
{
    return is_good_set(card[0], card[1], card[2]) and \
        is_good_set(card[3], card[4], card[5]) and \
        is_good_set(card[6], card[7], card[8]);
}

int win()
{
    sort(card, card + 9);
    do {
        if (is_all_good_set()) return 1;
    } while (next_permutation(card, card + 9));
    return 0;
}

int main(int argc, char const* argv[])
{
    cin >> T;
    for (int t = 0; t < T; t++) {
        for (int i = 0; i < 9; i++) {
            cin >> card[i];
        }
        string color;
        for (int i = 0; i < 9; i++) {
            cin >> color;
            if (color == "G") card[i] += 10;
            else if (color == "B") card[i] += 20;
        }
        cout << win() << endl;
    }
    return 0;
}

Measured memory_bytes: 3028
from sys import stdin
from collections import deque
n = int(input())
d = [-1] * (n + 1)
G = [0] + [list(map(int, input().split()[2:])) for _ in range(n)]
d[1] = 0
dq = deque([1])
while len(dq) != 0:
    v = dq.popleft()
    for c in G[v]:
        if d[c] == -1 :
            d[c] = d[v] + 1
            dq.append(c)
for i, x in enumerate(d[1:], start=1):
    print(i, x)

Measured memory_bytes: 8108
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.next();
        int count = 0;
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - i - 1)) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 22868
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let n:Int=Int(readLine()!)!
let num=readInts()
var sum:Double=0

for i in 0..<n{sum+=1.0/Double(num[i])}

print(1/sum)

Measured memory_bytes: 8176
main :: IO ()
main = do
  line <- getLine
  print $ divisor_counter $ map (read :: String -> Int) $ words line
  
divisor_counter :: [Int] -> Int
divisor_counter (a:b:c:[]) =
  length [i | i <- [1..c], c `rem` i == 0, a <= i, i <= b]



Measured memory_bytes: 4068