akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Storable         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine :: IO [Int]
    B.PS p 0 l <- C.filter (\c -> c == '#' || c == '.')
      <$> C.hGetNonBlocking IO.stdin (h*(w+1))
    let mat = U.unsafeFromForeignPtr0 p l
    print $ solve h w mat

solve :: Int -> Int -> U.Vector Word8 -> Int
solve h w mat = subtract 3 . U.maximum $ U.zipWith (+) lr ud
  where
    trans :: U.Vector Int -> U.Vector Int
    trans m = U.unsafeBackpermute m $ U.generate (h * w) $ \ij ->
        let (i, j) = quotRem ij w
        in j * h + i

    lr :: U.Vector Int
    lr = U.concatMap (\i ->
        let row = U.unsafeSlice (i * w) w mat
        in U.zipWith (+)
            (U.postscanl' (\acc c -> if c == B.c2w '#' then 0 else acc + 1) 0 row)
            (U.postscanr' (\c acc -> if c == B.c2w '#' then 0 else acc + 1) 0 row)
        )
        $ U.generate h id

    ud :: U.Vector Int
    ud = trans
        . U.concatMap (\j ->
            let column = U.map (U.unsafeIndex mat) $ U.iterateN h (+w) j
            in U.zipWith (+)
                (U.postscanl' (\acc c -> if c == B.c2w '#' then 0 else acc + 1) 0 column)
                (U.postscanr' (\c acc -> if c == B.c2w '#' then 0 else acc + 1) 0 column)
        )
        $ U.generate w id


Measured memory_bytes: 71036
#include <bits/stdc++.h>
using namespace std;
int n;
int dp[100005][2];
int arr[100005];
int rec(int x, int y){
	if(x >= n) return 1000000005;
	if(x == n-1)return abs(arr[x] - arr[x-y-1]);
	if(dp[x][y] != -1)return dp[x][y];
	if(x == 0) return dp[x][y] = min(rec(x+1, 0), rec(x+2, 1));
	return dp[x][y] = min(rec(x+1, 0), rec(x+2, 1)) + abs(arr[x] - arr[x-1-y]);
	
}
int main(){
	cin >> n;
	for(int i = 0; i <= 100000; i++)dp[i][0] = -1, dp[i][1] = -1;
	for(int i = 0; i < n; i++)cin >> arr[i];
	cout << rec(0,0);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
int main() {
    int l, k; scanf("%d%d", &l, &k);
    vector<ll> dp(l + 1);
    REP (i, l + 1) {
        if (i == 1 or i == k) dp[i] += 1;
        if (i - 2 >= 0) dp[i] += dp[i - 2];
        if (i - k - 1 >= 0) dp[i] += dp[i - k - 1];
    }
    ll result = accumulate(ALL(dp), 0ll);
    printf("%lld\n", result);
    return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N; cin >> N;
  set<int> st;
  for (int i = 0; i < N; i++) { int a; cin >> a; st.insert(a); }
  int ans = int(st.size());
  if (ans % 2 != N % 2) ans--;
  cout << ans << '\n';
}

Measured memory_bytes: 4992
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

void Solve(){
	int n,M;	cin >> n >> M;
	map <int,int> m;
	int x,k;
	Rep(i,0,n){
		cin >> x;
		Rep(i,0,x){
			cin >> k;
			if(!m[k]){
				m[k] = 0;
			}
			m[k]++;
		}
	}
	int ans = 0;
	for(auto c : m){
		if(c.second == n){
			ans++;
		}
	}
	cout << ans << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	Solve();
	return 0;
}

Measured memory_bytes: 256
work = []

n = int(input())

for _ in range(n):
    work.append(tuple([int(x) for x in input().split()]))

# print(work)

work_sorted_by_b = sorted(work, key=lambda t: t[1])

# print(work_sorted_by_b)

sum_a = 0
for t in work_sorted_by_b:
    sum_a += t[0]
    if sum_a > t[1]:
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 33456
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 ans        PIC Z(9)9(1).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B.
  MULTIPLY A BY B GIVING ans.
  DISPLAY FUNCTION TRIM(ans).
  STOP RUN.


Measured memory_bytes: 3876
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <set>
// #include <unordered_set>
#include <map>
// #include <unordered_map>
#include <cmath>
#include <deque>
#include <queue>
#include <string>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define V vector

int n, m;


int main() {
    cin >> n >> m;
    if(n%2 == 1) {
        REP(i, 1, m+1) {
            cout << i << " " << n+1-i << "\n";
        }
    } else {
        REP(i, 1, min(m+1, (int)n/4+1)) {
            cout << i << " " << (n>>1)+1-i << "\n";
        }
        if(m > n/4) {
            REP(i, 1, m+1 - (int)n/4) cout << i + int(n/2) << " " << n-i << "\n";
        }
    }

    return 0;
}
/*

 */

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long 
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using o_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);
}
int32_t main()
{
 c_p_c();
 int n;
 cin>>n;
 vector<int>a(n);
 for(int i=0;i<n;i++){
  cin>>a[i];
 } 
 int ans=0;
 sort(a.begin(),a.end());
 for(int i=0;i<n;i++){
  for(int j=i+1;j<n;j++){
    for(int k=j+1;k<n;k++){
      if(a[i]!=a[j] && a[k]!=a[j]){
        if(a[i]+a[j]>a[k]){
          ans++;
        }
      }
    }
  }
 }
 cout<<ans<<"\n";
     

   
 
 
 return 0;  
 
}

Measured memory_bytes: 3628
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		boolean[] memo1=new boolean[N];
		boolean[] memo2=new boolean[N];



		for (int i = 0; i < M; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;

			if(a==0) {
				memo1[b]=true;
			}else if(b==N-1) {
				memo2[a]=true;
			}

		}

		for (int i = 0; i < N; i++) {

			if(memo1[i]==true && memo2[i]==true) {
				System.out.println("POSSIBLE");
				return;
			}
		}

		System.out.println("IMPOSSIBLE");



	}

	//以下テンプレート

	public static String numtoalpha(int i) {

		String alpha = "abcdefghijklmnopqrstuvwxyz";

		return alpha.substring(i, i + 1);

	}

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


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

int main(){
	
	int S;
	int h, m, s;
	cin >> S;
	
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	s = S % 60;
		
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

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

int main() {
  string s, ans;
  int w;
  cin >> s >> w;
  for (int i = 0; i < s.size(); i+=w) {
    ans += s[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>


using namespace std;
typedef long long ll;

vector<int> int2vec(int n, int l) {
    vector<int> ret;
    while(l > 0) {
        ret.push_back(n % 10);
        n /= 10;
        l--;
    }
    return ret;
}

int vec2int(const vector<int>& v) {
    int d = 1;
    int ret = 0;
    for (int i = 0; i < v.size(); i++) {
        ret += d*v[i];
        d *= 10;
    }
    return ret;
}

int main() {
    while(true) {
        int a, l; cin >> a >> l;
        if (a == 0 && l == 0) break;
        unordered_map<int, int> numbers;
        int i = 0;
        while(true) {
            auto search = numbers.find(a);
            if (search != numbers.end()) {
                cout << search->second << ' ' << a << ' ' << i - search->second << endl;
                break;
            }
            numbers[a] = i;
            vector<int> v = int2vec(a, l);
            sort(v.begin(), v.end());
            int M = vec2int(v);
            reverse(v.begin(), v.end());
            int m = vec2int(v);
            a = M - m;
            i++;
        }
    }
}


Measured memory_bytes: 3144
// Aizu Vol-5 0567: Best Pizza
// 2017.8.31 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int d[102];

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int n, a, b, c, i;
	double ans, p, t;

	scanf("%d%d%d%d", &n, &a, &b, &c);
	p = a, ans = c / p;
	for (i = 0; i < n; i++) scanf("%d", d+i);
	qsort(d, n, sizeof(int), cmp);
	for (i = 0; i < n; i++) {
		if ((t = (c + d[i])/(p + b)) > ans) ans = t, c += d[i], p += b;
		else break;
	}
	printf("%d\n", (int)ans);
	return 0;
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
 
 int main()
 {
  ll n,k;
  cin>>n>>k;
  vector<ll>h;
  for(ll i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    h.pb(x);
  }  ll dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(ll i=2;i<n;i++)
  { ll pre=INT_MAX;
   for(ll j=1;j<=k&&i-j>=0;j++)
    {
    dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),pre);
    pre=dp[i];
    }
  }
  cout<<dp[n-1]<<endl;
 }

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int i;

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

   sort(a, a + N, greater<int>());

   int Alice = 0, Bob = 0;

   for (i = 0; i < N; i++) {
       if (i % 2 == 0) {
           Alice += a[i];
       } else {
           Bob += a[i];
       }
   }

   cout << Alice - Bob << endl;

    return 0;
}

Measured memory_bytes: 256
# 初期入力
import sys
import math 
input = sys.stdin.readline  #文字列では使わない
a,b,c,d = map(int, input().split())
ans =0
if 0 <= a and 0 <= c:
    ans =b*d
elif b <=0  and d <=0 :
    ans =a*c
else:
    ans =max(a*c,a*d,b*c,b*d)
print(ans)

Measured memory_bytes: 9180
<?php
list($n) = ints();
for ($i = 0; $i < $n - 1; ++$i) {
    list($a, $b, $c) = ints();
    --$a;
    --$b;
    $g[$a][$b] = $c;
    $g[$b][$a] = $c;
}
list($Q, $k) = ints();
--$k;
// BFS（幅優先探索）：最短経路アルゴリズムとして活用
$q = new SplQueue(); // キューを用意
$dist = array_fill(0, $n, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

$dist[$k] = 0; // 頂点0からの距離格納配列
$q->enqueue($k); // キューに0を追加

while (!$q->isEmpty()) {
    $v = $q->dequeue();

    foreach ($g[$v] as $next_v => $d) {
        if ($dist[$next_v] !== -1) continue; // 発見済み

        $dist[$next_v] = $dist[$v] + $d;
        $q->enqueue($next_v);
    }
}
for ($i = 0; $i < $Q; ++$i) {
    list($x, $y) = ints();
    --$x;
    --$y;
    echo ($dist[$x] + $dist[$y]) . PHP_EOL;
}

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 57972
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

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

  int n;
  cin >> n;
  int64_t result = 0;
  std::vector<int64_t> a, b;
  a.resize(n);
  b.resize(n);

  for (int i = 0; i < n; i++) {
    int m1, m2;
    cin >> m1 >> m2;
    a[i] = m1;
    b[i] = m2;
  }
  for (int i = n - 1; i >= 0; i--) {
    a[i] += result;
    int64_t temp = a[i] % b[i] == 0 ? 0 : b[i] - (a[i] % b[i]);
    result += temp;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int len = 0;
		LOOP: for (char c : s.toCharArray()) {
			switch (c) {
			case 'C':
				if (len == 0) {
					len = 1;
				}
				break;

			case 'F':
				if (len == 1) {
					len = 2;
					break LOOP;
				}
				break;

			default:
				break;
			}
		}

		String ans = len == 2 ? "Yes" : "No";
		System.out.println(ans);
	}
}


Measured memory_bytes: 9556
S = input()
K = int(input())

# 5000兆 = 5 * 10 ** 12

if K == 1:
  print(S[0])
  exit(0)

for i in range(len(S)):
  if S[i] == "1":
    if i == K-1:
      print(S[0])
      break      
    continue
  print(S[i])
  break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//

ll n, a;
ll dp[51][2501][51];
std::vector<ll> v;
int main() {
  cin >> n >> a;
  REP(i, n) {
    ll b;
    cin >> b;
    v.pb(b);
  }
  dp[0][0][0] = 1;
  REP(i, n) {
    REP(j, 2501) {
      REP(k, i + 1) {
        if (dp[i][j][k] == 0) {
          continue;
        }
        dp[i + 1][j + v[i]][k + 1] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }
  ll ans = 0;
  REP(j, 51) {
    if (!j)
      continue;
    ans += dp[n][j * a][j];
  }

  cout << ans << endl;
}


Measured memory_bytes: 48128
package main
import (
    "fmt"
)

func main(){
    var a, b, c, x int
    fmt.Scan(&a, &b, &c, &x)
    ans := 0
    for i := 0; i <= a; i++ {
        for j := 0; j <= b; j++ {
            for k := 0; k <= c; k ++ {
                if 500 * i + 100 * j + 50 * k == x {
                    ans ++
                }
            }
        }
    }
    fmt.Println(ans)
}

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

int main(){
  string s,t;
  int n,ans=1000;
  cin>>n>>s>>t;
  if(s==t){cout<<s.size()<<endl;exit(0);}
  for(int i=0;i<n;i++){
    string st=s+t.substr(i);
    if(st.substr(st.size()-n)==t) ans = min(ans,(int)st.size());
  }
  cout<<ans<<endl;
  return 0;
}


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

maxvL = 0
minvR = 1000000
for i in range(M):
    L, R = list(map(int, input().split()))
    if maxvL < L:
        maxvL = L
    if minvR > R:
        minvR = R

count = 0
for i in range(N):
    if maxvL <= i + 1 <= minvR:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
int N,K;
scanf("%d",&N);   
scanf("%d",&K);    
int total = 1;        
for(int i = 0;i<N;i++) 
{
    if(total < K)     
    {
        total = total * 2; 
    }
    else{
        total = total + K; 
    }
}
printf("%d\n",total);
return 0;
}


Measured memory_bytes: 1688
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i]-c[i],i+1] for i in range(26)]
	ss.sort(reverse = True)
	data = ss[random.randrange(10)][1]
	sel[i] = ss[data-1][1]
	ans += s[i][data-1]

	for j in range(26):
		if j == data - 1:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j]
			ans -= c[j] * (i - day[i][j] + 1)



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = random.randrange(10)
		if sel[ima] != data+1:
			break
	data = po[data][1]-1
	ppp = 0
	for i in range(26):
		if ima == day[ima][i]:
			now = i
			break
	else:
		while True:
			now = random.randrange(26)
			if now != data:
				break 
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp += (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1

for i in sel:
	print(i)


Measured memory_bytes: 82172
#include <iostream>
#include <cmath>
using namespace std;
 
int main(void){
  long double a,b,c;
  cin >> a >> b >> c;
  long double eps = 1.0E-14;
  cout << ((sqrt(a) + sqrt(b) + eps < sqrt(c))?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3768
N, D = list(map(int, input().split()))
XY = [[] for i in range(N)]
for i in range(N):
    XY[i] = list(map(int, input().split()))

a = 0
for xy in XY:
    ans = (xy[0] **2 + xy[1] **2)
    if ans <= D **2:
        a += 1
print(a)

Measured memory_bytes: 45324
#include<bits/stdc++.h>
using namespace std;
int slove(int x,int y,int n);
int main(void)
{
    int N,Q;
    cin>>N>>Q;
    while(Q)
    {
        Q--;
        int x,y;
        cin>>x>>y;
        if(N==1)
            cout<<min(x,y)<<endl;
        else 
        cout<<slove(x,y,N)<<endl;
    }
    return 0;
}
int slove(int x,int y,int n)
{
    while(x!=y)
    {
        if(x > y)
            x = (x+n-2)/n;
        else if(y > x)
            y = (y+n-2)/n;
    }
    return x;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int num[5];
	
	for (int i = 0; i < 5; i++){
		cin >> num[i];
	}
	
	for (int i = 0; i < 5; i++){
		for (int j = 0; j < 5; j++){
			if (num[i] >= num[j]){
				swap(num[i], num[j]);
			}
		}
	}
	
	cout << num[0];
	for (int i = 1; i < 5; i++){
		cout << " " << num[i];
	}
	cout << endl;
	
	return (0);
}

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

int main() {
    int N;
    cin>>N;
    int *B = new int[N-1];
    for (int i = 0; i < N-1; i++){
        cin>>B[i];
    }
    
    int ans=0;
    for(int i=1;i<N-1;i++){
        if(B[i]>=B[i-1]){
            ans+=B[i-1];
        }else{
            ans+=B[i];
        }
    }
    ans+=B[0];
    ans+=B[N-2];
    cout<<ans<<endl;
    return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
using modint = ModInt< MOD >;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>c(n);
  for(i=0;i<n;i++)cin>>c[i];
  vector<ll>h(250000,-1);
  vector<modint>dp(n);
  dp[0]=1;
  h[c[0]]=0;
  for(i=1;i<n;i++){
    if(h[c[i]]==-1||h[c[i]]==i-1){
      h[c[i]]=i;
      dp[i]=dp[i-1];
    }
    else{
      dp[i]=dp[i-1]+dp[h[c[i]]];
      h[c[i]]=i;
    }
    //cout<<dp[i]<<endl;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 4608
A, B, C, X = int(input()), int(input()), int(input()), int(input())

X //= 50
answer = 0
for a in range(A + 1):
  if a * 10 > X:
    continue
  for b in range(B + 1):
    for c in range(C + 1):
      if a * 10 + b * 2 + c == X:
        answer += 1

print(answer)

Measured memory_bytes: 3060
def A():
    temp = input().split()
    M = int(temp[0])
    D = int(temp[1])

    if D<22:
        print(0)
        return
    
    ans = 0

    for i in range(1, M+1):
        for j in range(22, D+1):
            if (j%10) >= 2 and (j%10)*int(j/10) == i:
                ans += 1
    
    print(ans)

A()



Measured memory_bytes: 3060
V, E = map(int, input().split())
graph = [[] for _ in range(V)]

for _ in range(E):
    s, t, d = map(int, input().split())
    graph[s].append((t, d))

case = 2**V
INF = 10**7

dp = [[-1]*case for _ in range(V)]

def dfs(now, dist, checked):
    if checked==(1<<V)-1:
        if now==s:
            return dist
        else:
            return INF
    r = dp[now][checked]
    if r!=-1:
        return r+dist
    ret = INF
    try:
        for q, d in graph[now]:
            if not (checked>>q)&1 and dist+d<ans:
                ret = min(ret, dfs(q, dist+d, checked|(1<<q)))
    except:
        return ret
    dp[now][checked] = ret - dist
    return ret

ans = INF
# for i in range(V):
s = 0
ans = min(ans, dfs(0, 0, 0))

if ans<=10**6:
    print(ans)
else:
    print(-1)


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

int main(){
  int n;
  cin >> n;
  vector<ll> l(n);
  for(ll i=0; i<n; i++) cin >> l[i];
 
  sort(l.begin(), l.end());
  ll ans = 0;
  for(int i=0; i<n; i++){
  	for(int j=i+1; j<n; j++){
      ll b = l[j];
      ll c = l[i];
      auto wa = lower_bound(l.begin()+j+1, l.end(), b+c);
      ll tmp = wa - (l.begin()+j) -1;
      ans += tmp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


n = I()
A = list(MI())

s = 0
for a in A:
    s ^= a

ans = []
for a in A:
    ans.append(str(s ^ a))

print(*ans)


Measured memory_bytes: 32536
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // sort
  sort(as, as + N);

  // calculate accumulated sum
  long accs[MAX_N + 1];
  accs[0] = 0;
  for (int i = 0; i < N; i++) {
    accs[i + 1] = accs[i] + as[i];
  }

  // solve
  int ans = 1;  // largest organism
  for (int i = N - 2; i >= 0; i--) {
    const long acc = accs[i + 1] - accs[0];
    if (2 * acc >= as[i + 1]) {
      ans++;
    } else {
      break;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(System.getProperty("line.separator"));
        int n = sc.nextInt();
        String SStr = sc.next();
        int q = sc.nextInt();
        String TStr = sc.next();

        int[] S = toIntAry(SStr, n);
        int[] T = toIntAry(TStr, q);

        int cnt=0;
        for(int i=0; i<q; i++){
        	int key = T[i];
        	if(binarySearch(S,key,n))cnt++;
        }

        System.out.println(cnt);

	}





	private static boolean binarySearch(int[] s, int key, int n) {
		int left = 0;
		int right = n;
		while(left<right){
			int mid = (left+right)/2;
			if(s[mid]==key){
				return true;
			}else if(s[mid] > key){
				right = mid;
			}else{
				left = mid +1;
			}
		}

		return false;
	}





	private static int[] toIntAry(String str, int n) {
        String[] tmp = str.split(" ");
        int[] A = new int[n];
        for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(tmp[i]);
		}
        return A;
	}


}

Measured memory_bytes: 49412
#include <bits/stdc++.h>
#define MAX (ll)(4e3 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	cout << (m1 < m2) << "\n";
}
	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int N,A,B;
    std::cin >> N >> A >> B;
    if((B-A)%2==0){
        std::cout << "Alice" << std::endl;
    }else{
        std::cout << "Borys" << std::endl;
    }
}


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

int main(void){
    char c[201];
    int i,j,k,m,h,l;

    while(1){
        scanf("%s",c);
        if(!strcmp(c,"-")) break;

        l=strlen(c);
        
        scanf("%d",&m);
        
        for(i=0;i<m;i++){
            scanf("%d",&h);
            for(j=0;j<h;j++){
                char tmp=c[0];
                for(k=1;k<l;k++){
                    c[k-1]=c[k];
                }
                c[l-1]=tmp;
            }
        }

        printf("%s\n",c);
    }

    return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int N = 1000000;
bool seen[N+1];
int ct[N+1];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
        ct[arr[i]]++;
    }
    sort(arr, arr+n);
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        if(seen[arr[i]])
            continue;
        if(ct[arr[i]] == 1)
            ans++;
        for(int j=arr[i]; j<=N; j+=arr[i])
        {
            seen[j] = true;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 9180
n = gets.to_i

x,y = 0,0

t = 0
while line = gets
	tn,xn,yn = line.split.map &:to_i

	dt = tn - t
	t = tn

	dl = (x - xn).abs + (y - yn).abs
	x = xn
	y = yn
	
	if dl > dt
		puts "No"
		exit
	end
	
	unless (dl - dt) % 2 == 0
		puts "No"
		exit
	end
end

puts "Yes"


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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)

typedef long long ll;

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

 ll n;
  cin >> n;
 vector<ll> a(n);
  rep(i,0,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  ll sum=0,num=0;
  rep(i,0,n-1) {
    sum+=a[i];
    if(2*sum<a[i+1]) num=i+1;
    }
  
  cout << n-num << endl;
  
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>


int main(){
  int n;
  double xa,ya,ra,xb,yb,rb,d;
  std::cin >> n;

  for(int i=0;i<n;i++){
    std::cin >> xa >> ya >> ra
             >> xb >> yb >> rb;
    d = std::sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
    /*if(ra+rb < d){
      std::cout << (int)0 << std::endl;
      break;
    }
    if(ra+d < rb){
      std::cout << (int)-2 << std::endl;
      break;
    }
    if(rb+d < ra){
      std::cout << (int)2 << std::endl;
    }else{
      std::cout << (int)1 << std::endl;
    }*/
    std::cout << (d<=ra+rb?d+rb>=ra?d+ra>=rb?1:-2:2:0) << std::endl;
  }
}

Measured memory_bytes: 3044
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sum=0
for i in range(len(A)-1):
  sum+=B[i]
  if A[i]+1==A[i+1]:
      sum+=C[A[i]-1]
sum+=B[len(A)-1]
print(sum)

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

ll n, a, b;
vector<ll> h;

bool all_delete(ll t, vector<ll> h) {
  for (int i = 0; i < n; i++) {
    h[i] -= b * t;
  }

  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] > 0) {
      cnt += (h[i] + a - b - 1) / (a - b);
    }
  }

  if (cnt <= t) {
    return true;
  }
  else {
    return false;
  }
}

void abc063d() {
  ll ok = 1000000000, ng = -1;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (all_delete(mid, h)) {
      ok = mid;
    }
    else {
      ng = mid;
    }
  }
  cout << ok << '\n';

  return;
}

int main() {
  cin >> n >> a >> b;
  h.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  abc063d();
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 1e9+7;


void solve(){
	fio;
	int n,k;
	cin>>n>>k;
	int ar[n];
	For(i,n) cin>>ar[i];
	vector<bool> dp(k+1);
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-ar[j]>=0 && !dp[i-ar[j]]){
				dp[i]=true;
			}
		}
	}
	if(dp[k]) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

int32_t main(){
	fio;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<":\n";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3620
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

int main()
{
    LL X, Y;
    cin >> X >> Y;
    int ans = 0;
    LL a = X;
    while (true)
    {
        ++ans;
        a *= 2;
        if (a > Y) break;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,cont4=0,cont2=0;
  cin>>N;
  for(int t=0;t<N;t++){
    int temp;
    cin>>temp;
    if(temp%2==0){
      if(temp%4==0){
        cont4++;
      }else{
        cont2++;
      }
    }
  }
  int N2;
  if(cont2>0){
    N2=N-cont2+1;
  }else{
    N2=N-cont2;
  }
  int N3=N2-cont4;

  if(N3-1<=cont4){
    cout<<"Yes"<<"\n";
  }else{
    cout<<"No"<<"\n";
  }
  return 0;
}


Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
memo = {}

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                w = (100 * A) * a + (100 * B) * b
                s = C * c + D * d
                if w == 0:
                    break
                if w + s > F:
                    break
                else:
                    if w / 100 * E >= s:
                        density = 100 * s / (w + s)
                        memo[a, b, c, d] = density

max_v = max(memo.values())

for k, v in memo.items():
    if v == max_v:
        print((100 * A) * k[0] + (100 * B) * k[1] + C * k[2] + D * k[3], C * k[2] + D * k[3])
        break

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

using namespace std;

map<string, int> a;

int n;
string x;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        a[x]++;
    }
    cout<<"AC x "<<a["AC"]<<endl;
    cout<<"WA x "<<a["WA"]<<endl;
    cout<<"TLE x "<<a["TLE"]<<endl;
    cout<<"RE x "<<a["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

int H, W, N;
char c[51][51];
int d[51][51], dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };


int bf() {
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)d[i][j]=1e5;
	d[0][0] = 1;
	queue<pair<int, int>> que;
	que.push(pair<int, int>(0, 0));
	while (que.size()) {
		pair<int, int> p = que.front(); que.pop();
		if (p.first == H - 1 && p.second == W - 1)return d[H - 1][W - 1];
		for (int j = 0; j < 4; j++) {
			int ny = p.first + dy[j], nx = p.second + dx[j];
			if (ny >= 0 && ny < H&&nx >= 0 && nx < W&&d[ny][nx] == 1e5&&c[ny][nx] != '#') {
				d[ny][nx] = d[p.first][p.second] + 1;
				que.push(pair<int, int>(ny, nx));
			}
		}
	}
	return -1;
}


int main() {
	int z = 0;
	cin >> H >> W ;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#')z++;
		}
	}
	int ans = bf();
	if(ans!=-1)cout << H * W - z - ans << endl;
	else cout << -1 << endl;
}



Measured memory_bytes: 256
/**
 *   
 *   Date: 31 March 2020
 *   Time: 18:23:26
**/
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;
ll dp[3001][3001][2],ar[3001],n;
ll solve(ll i,ll j,ll x)
{
	if(i>n || j<0 || i>j)
	{

		return 0;
	}
	if(dp[i][j][x] != -1)
		return dp[i][j][x];
	ll ans=0;
	if(x == 0)
	{
		ans=-1e15;
		ans=max(ar[i]+solve(i+1,j,x^1),ar[j]+solve(i,j-1,x^1));
	}
	else
	{
		ans=1e15;
		ans=min(solve(i+1,j,x^1),solve(i,j-1,x^1));
	}
	//return ans;
	return dp[i][j][x]=ans;
}
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll sum=0,x,y;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>ar[i];
		sum+=ar[i];
	}
	memset(dp,-1,sizeof(dp));
	x=solve(1,n,0);
	y=sum-x;
	cout<<x-y<<endl;

	

return 0;
}

Measured memory_bytes: 141184
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long c = 0;
        for(int i=1;i<=n;i++){
                if(0!=i%3 && 0!=i%5){
                c = c + i;
            }
        }
        System.out.println(c);
    } 
 
}

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

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

int main()
{
	int N, K;
	string S;

	cin >> N >> S >> K;

	rep(i, N) {
		if (S[i] != S[K - 1]) S[i] = '*';
	}

	cout << S << endl;

	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> A(W, '#'), B(W + 1, '#');
  
  for (int i = 0; i < W; i++) cout << A.at(i);
  cout << "##" << endl;
  
  for (int i = 0; i < H; i++) {
    
    cout << '#';
    
    for (int j = 0; j < W; j++) {
      cin >> B.at(j);
      cout << B.at(j);
    }
    
    cout << '#' << endl;
  }
  
  for (int i = 0; i < W; i++) cout << A.at(i);
  cout << "##" << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N+1);
    for(int i=1; i<N+1; i++){
      cin >> vec[i];
    }
    vi ans(N+1);
    for(int i=1; i<N+1; i++){
        ll h = vec[i];
        ans[h] = i;
    }
    for(int i=1; i<N+1; i++){
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 1536
#include<stdio.h>
#define X 100
int main(){
	int n,m,l,i,j,k;
	long long int a[X][X]={0},b[X][X]={0},c[X][X]={0};
	scanf("%d%d%d",&n,&m,&l);
	for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(i=0;i<m;i++)for(j=0;j<l;j++)scanf("%d",&b[i][j]);
	for(i=0;i<n;i++)for(j=0;j<l;j++)for(k=0;k<m;k++)c[i][j]=c[i][j]+(a[i][k]*b[k][j]);
	for(i=0;i<n;i++){
		for(j=0;j<l-1;j++)printf("%lld ",c[i][j]);
		printf("%lld\n",c[i][j]);
	}
	return 0;
}



Measured memory_bytes: 2104
using System;
using System.Text.RegularExpressions;
 
namespace Key
{
    class Program
    {
        static void Main(string[] args)
        {
            var rs = new string[] {"[qwertasdfgzxcvb]", "[yuiophjklnm]" };
            string n;
            while ((n = Console.ReadLine()) != "#")
            {
                for(int i = 0; i < 2; i++)
                    n = new Regex(rs[i] + '+').Replace(n, "0");
                Console.WriteLine("{0}", n.Length - 1);
            }
        }
    }
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  set<int> p;
  p.insert(a);
  p.insert(b);
  p.insert(c);
  cout << p.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int h,w,N;
cin>>h>>w>>N;
int sr,sc;
cin>>sr>>sc;
string s;
string t;
cin>>s;
cin>>t;
bool yes=true;
{
    int l=1,r=w;

    for(int i=N-1;i>-1;i--){
        if(t[i]=='L')r=min(w,r+1);
        if(t[i]=='R')l=max(1,l-1);
        if(s[i]=='L')l++;
        if(s[i]=='R')r--;
    if(l>r)yes=false;
    }
    yes&=(l<=sc && sc<=r);

}

{
    int l=1,r=h;

    for(int i=N-1;i>-1;i--){
        if(t[i]=='U')r=min(h,r+1);
        if(t[i]=='D')l=max(1,l-1);
        if(s[i]=='U')l++;
        if(s[i]=='D')r--;
    if(l>r)yes=false;
    }
    yes&=(l<=sr && sr<=r);
    
}
cout<<(yes ? "YES":"NO")<<endl;


 return 0;
}
/*
firsr 解説AC 2h 07m 20s

2 3 3
2 2
RRL
LUD

YES


4 3 5
2 2
UDRRR
LLDUD

NO

5 6 11
2 1
RLDRRUDDLRL
URRDRLLDLRD

NO
*/


Measured memory_bytes: 776
h, w = map(int, input().split())
s = [[i == "#" for i in input()] for _ in range(h)]
dp = [[10**9] * w for _ in range(h)]
dp[0][0] = int(s[0][0])
for i in range(h):
    for j in range(w):
        a = dp[i - 1][j] + (not s[i - 1][j] and s[i][j])
        b = dp[i][j - 1] + (not s[i][j -1] and s[i][j])
        dp[i][j] = min(a, b,dp[i][j])
print(dp[-1][-1])


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

int main(){
  int N = 0,H = 0,b = 0,res = 1;
  cin >> N;
  if(N == 2){
    res = 4;
  }else if(N == 1){
    res = 4;
  }else{
    while(N != 4){
      if(N%2 == 0){
        N = N/2;
        res = res + 1;
      }else{
        N = 3*N +1;
        res = res + 1;
      }
    }
    res = res + 3; 
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,a;
  cin >> n >> a;
  vector<int>x(n);
  rep(i,n){
    cin >> x[i];
    x[i]-=a;
  }
  ll dp[n+10][5000]={};
  dp[0][2500]=1;
  
  rep(i,n){
    for(int j=0;j+x[i]<5000;j++){
      if(dp[i][j]==0)continue;
      dp[i+1][j+x[i]]+=dp[i][j];
      dp[i+1][j]+=dp[i][j];
    }
  }
  ll res = dp[n][2500]-1;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560