akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))

fx=0
for i in range(1,n):
    if i%2==1:
        fx+=a[i]
ans=[0]*n
ans[0]=sum(a)-2*fx
for i in range(n-1):
    ans[i+1]=2*a[i]-ans[i]
print(*ans)

Measured memory_bytes: 14092
# frozen_string_literal: true

h, w, k = gets.split.map(&:to_i)
c = []
kuro = 0
h.times do
  l = gets.chomp.split('')
  kuro += l.count('#')
  c << l
end
hconb = [*(0...h)]
wconb = [*(0...w)]
res = 0

(0..h).each do |i|
  (0..w).each do |j|
   # memo = Array.new(h) { Array.new(w, 0) }
    hconb.combination(i).each do |arr|

    memo = Array.new(h) { Array.new(w, 0) }
      sum = 0
      arr.each do |raw|
        (0...w).each do |li|
          if c[raw][li] == '#' && memo[raw][li] != 1
            sum += 1
            memo[raw][li] = 1
          end
        end
      end
      tmp = sum
      wconb.combination(j).each do |ar|
 #       p "#{arr} #{ar}"
        sum = tmp
        ar.each do |line|
          (0...h).each do |ra|
            if c[ra][line] == '#' && memo[ra][line] != 1
              sum += 1
        #      memo[ra][line] = 1
            end
          end
        end
        res += 1 if (kuro - sum) == k
      end
    end
  end
end
puts res


Measured memory_bytes: 14344
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll x=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        x^=a[i];
    }
    for(ll i=0;i<n;i++)
        cout<<(a[i]^x)<<" ";


    return 0;
}


Measured memory_bytes: 4668
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		
		System.out.println(replace(str, "peach", "apple"));
	}
	
	static List<Integer> find(String str, String find) {
		List<Integer> result = new ArrayList<Integer>();
		for(int i = 0; i <= str.length() - find.length(); i++) {
			if(str.substring(i, i + find.length()).equals(find)) result.add(i);
		}
		return result;
	}
	
	static String replace(String original, String s1, String s2) {
		StringBuilder result = new StringBuilder(original);
		List<Integer> peach = find(original, s1);
		List<Integer> apple = find(original, s2);
		for(int i: peach) result.replace(i, i + s1.length(), s2);
		for(int i: apple) result.replace(i, i + s2.length(), s1);
		return result.toString();
	}
}

Measured memory_bytes: 17160
/*
Writer: SPD_9X2
https://atcoder.jp/contests/abc158/tasks/abc158_f

このロボットを選ぶと、どのロボットが取り除かれる、がわかったとする
左から選ぶ・選ばないを選択していく
選んだ時、次に選択可能になるのは取り除かれる一番右のロボット+1番目
選ばなければそこが変わるので重複はあり得ない。左からdpすれば終わり～


あとはどのロボットを選ぶと、どこまでのロボットが取り除かれるかを計算する
メモ型再帰で実装できそう。0個の場合はそれで終わり。そうでなければ・・・あれ
→むりやん

別の方法…→右から決めていくのはそうで、区間最大値を取ればよい
→セグ木のRMQ

pythonで書いたがTLEするのでC++でセグ木を作るついでに書き直し
*/

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 998244353;

//firstで初期化された、葉がn要素を超えるように2のべき乗個用意されたリストを返す
vector<int> make_ST(int n,int first){

    int i = 0;
    vector<int> ret(0,0);

    while ((1<<(i-1)) < n){
        
        for (int j = 0 ; j < (1<<i) ; j++){
            ret.push_back(first);
        }

        i++;

    }

    return ret;
}

void RMQ_update_point(int num,int point,vector<int>& tree){

    int i = (tree.size()-1)/2 + point;
    tree[i] = num;
    while (i > 0){
        i = (i-1)/2;
        tree[i] = min(tree[i*2+2] , tree[i*2+1]);
    }
    return ;
}

int RMQ_query(int a,int b,int k,int l,int r,vector<int>& tree){

    if ((r <= a) || (b <= l)) return INT_MAX;
    if ((a <= l) && (r <= b)) return tree[k];

    int c1 = RMQ_query(a,b,2*k+1,l,(l+r)/2,tree);
    int c2 = RMQ_query(a,b,2*k+2,(l+r)/2,r,tree);

    return min(c1,c2);
}


int main(){

    int N,X,D;
    cin >> N;
    vector<vector<int>> XD(N,vector<int>(2,0));
    vector<int> Xlis(N,0);

    rep(i,0,N){
        cin >> X >> D;
        XD[i][0] = X;
        XD[i][1] = D;
        Xlis[i] = X;
    }

    sort(XD.begin(),XD.end());
    sort(Xlis.begin(),Xlis.end());

    vector<int> tree = make_ST(N,0);
    vector<int> lis(0);

    rep(i,0,N){
        X = XD[N-1-i][0];
        D = XD[N-1-i][1];
        int ind = distance(Xlis.begin(),lower_bound(Xlis.begin(), Xlis.end(), X+D));

        int nans = RMQ_query(N-i-1,ind,0,0,(tree.size()+1)/2,tree);
        nans *= (-1);
        RMQ_update_point(-1 * max(nans,ind),N-i-1,tree);
        lis.push_back(max(nans,ind));
    }

    reverse(lis.begin(),lis.end());

    vector<ll> dp(N+1,0);
    dp[0] = 1;

    rep(i,0,N){

        dp[i+1] += dp[i];
        dp[lis[i]] += dp[i];

        dp[i] %= mod;
        dp[i+1] %= mod;
        dp[lis[i]] %= mod;
    }

    cout << dp[N] % mod << endl; 
}

/////////セグ木テスト用(AOJのRMQ)//////////
/*
int main(){

    int n,q;
    cin >> n >> q;
    vector<int> tree = make_ST(n,INT_MAX);

    int com,x,y;
    rep(i,0,q){

        cin >> com >> x >> y;

        if (com == 0){
            RMQ_update_point(y,x,tree);
        }else{
            cout << RMQ_query(x,y+1,0,0,(tree.size()+1)/2,tree) << endl;
        }

        //rep(i,0,tree.size()) cout << tree[i] << endl;

    }
    
}*/

Measured memory_bytes: 17396
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,k = MAP()

if(k>=n):
    if(k>2*n):
        ans = n
    else:
        ans = k-n
else:
    rem = n%k
    quot = n//k

    ans = n-quot*k

    ans = min(ans, abs(ans-k))

print(ans)

Measured memory_bytes: 71096
INF = 10 ** 9
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  math import factorial


def main():
    t1,t2 = map(int,input().split())
    a1,a2 = map(int,input().split())
    b1,b2 = map(int,input().split())
    if (a1 - b1) * t1 + (a2 - b2) * t2 == 0:
        ans = 'infinity'
    elif a1 == b1 or a2 == b2:
        ans = 'infinity'
    elif (a1 < b1 and a2 < b2) or (a1 > b1 and a2 > b2):
        ans = 0
    else:
        if a1 > b1 and a2 < b2:
            a1,b1 = b1,a1
            a2,b2 = b2,a2
        if (b1 - a1) * t1 + (b2 - a2) * t2 > 0:
            ans = 0
        else:
            x = (a1 - b1) * t1 + (a2 - b2) * t2
            if (b1 * t1 - a1 * t1) < x:
                ans = 1
            elif (b1 * t1 - a1 * t1)%x == 0:
                ans = 1 + 2 * ((b1 * t1 - a1 * t1)//x - 1) + 1
            else:
                ans = 1 + 2 * ((b1 * t1 - a1 * t1)//x)
    print(ans)
if __name__ == '__main__':
    main() 

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 300 + 5, mod = (int) 0;
int a[N], b[N];
int main() {
	memset(a, 63, sizeof a);
	int n;
	cin >> n;
	while (n--) {
		memset(b, 0, sizeof b);
		string s;
		cin >> s;
		for (int j = 0; j < (int) s.size(); ++j)
			b[s[j]]++;
		for (int j = 0; j < N; ++j)
			a[j] = min(a[j], b[j]);
	}
	for (int j = 0; j < N; ++j) {
		while (a[j]) cout << char(j), --a[j];
	}
	cout << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  cout << 48 - n << endl;
}

Measured memory_bytes: 3600
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long abs(long x) {
        return Math.abs(x);
    }

    long max(long ... x) {
        long rs = x[0];
        for(long y: x) rs = Math.max(rs, y);
        return rs;
    }

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        long[] w = new long[n];
        long[] v = new long[n];
        for(int i=0; i<n; i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        long[][] dp = new long[n+1][m+1];
        for(int i=1; i<=n; i++) {
            for(int j=1; j<=m; j++) {
                dp[i][j] = dp[i-1][j];
                if(j-w[i-1]>=0) {
                    dp[i][j] = max(dp[i][j], dp[i-1][(int)(j-w[i-1])] + v[i-1]);
                }
            }
        }
        out.println(dp[n][m]);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 212040
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, K;

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

    int ans;
    if (K == 1)
        ans = 0;
    else
        ans = N - K;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

VI task[112345];

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    REP(i,N){
        int a,b; cin >> a >> b;
        task[a].eb(b);
    }
    priority_queue<int> que;
    LL ans = 0;
    for(int i = 1; i < M+1; i++){
        for(int x : task[i]){
            que.push(x);
        }

        if(!que.empty()){
            ans += que.top(); que.pop();
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 6016
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

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

  std::string a;
  std::string b;
  for (int i = 0; i < 2; ++i)
    a.push_back(S[i]);
  for (int i = 2; i < 4; ++i)
    b.push_back(S[i]);

  int x = std::stoi(a);
  int y = std::stoi(b);

  // std::cout << x << std::endl;
  // std::cout << y << std::endl;
  // Main

  std::string res;
  if (1 <= x and x <= 12 and 1 <= y and y <= 12)
    res = "AMBIGUOUS";
  else if (1 <= x and x <= 12)
    res = "MMYY";
  else if (1 <= y and y <= 12)
    res = "YYMM";
  else
    res = "NA";

  // Output
  std::cout << res << std::endl;

  return 0;
}


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

using namespace std;


int main(){
    int n,dice[7]={0,1,2,3,4,5,6},sum=1;
    char order[6];
    
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        sum=1;
        for(int i=0;i<7;i++)
            dice[i]=i;
        
        for(int i=0;i<n;i++){
            scanf("%s",order);
            
            switch(order[0]){
                case 'N' :
                    dice[0]=dice[1];
                    dice[1]=dice[2];
                    dice[2]=dice[6];
                    dice[6]=dice[5];
                    dice[5]=dice[0];
                    break;
                case 'E' :
                    dice[0]=dice[1];
                    dice[1]=dice[4];
                    dice[4]=dice[6];
                    dice[6]=dice[3];
                    dice[3]=dice[0];
                    break;
                case 'W' :
                    dice[0]=dice[1];
                    dice[1]=dice[3];
                    dice[3]=dice[6];
                    dice[6]=dice[4];
                    dice[4]=dice[0];
                    break;
                case 'S' :
                    dice[0]=dice[1];
                    dice[1]=dice[5];
                    dice[5]=dice[6];
                    dice[6]=dice[2];
                    dice[2]=dice[0];
                    break;
                case 'R' :
                    dice[0]=dice[2];
                    dice[2]=dice[3];
                    dice[3]=dice[5];
                    dice[5]=dice[4];
                    dice[4]=dice[0];
                    break;
                case 'L' :
                    dice[0]=dice[2];
                    dice[2]=dice[4];
                    dice[4]=dice[5];
                    dice[5]=dice[3];
                    dice[3]=dice[0];
                    break;
            }
            sum += dice[1];
        }
        printf("%d\n",sum);
    }
    return 0;
    
}

Measured memory_bytes: 1196
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define MAXN 200000
using namespace std;
struct node
{
	int to;
	node *nxt;
}edges[MAXN*4+5];
node *ncnt=&edges[0],*AdjR[MAXN+5],*AdjB[MAXN+5];
int fro[MAXN+5],to[MAXN+5];
int N,X,Y,dfn[MAXN+5],efn[MAXN+5],tmn;
int dep[MAXN+5],fa[MAXN+5];
int dist[MAXN+5];
bool sppoint[MAXN+5];
bool vis[MAXN+5];
queue<int> que;
void Init()
{
	ncnt=&edges[0];
	memset(AdjR,0,sizeof(AdjR));
	memset(AdjB,0,sizeof(AdjB));
	tmn=0;
	memset(sppoint,0,sizeof(sppoint));
	memset(vis,0,sizeof(vis));
	while(que.empty()==false)
		que.pop();
}
void AddEdgeR(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=AdjR[u];
	AdjR[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=AdjR[v];
	AdjR[v]=q;
}
void AddEdgeB(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=AdjB[u];
	AdjB[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=AdjB[v];
	AdjB[v]=q;
}
void DFS1(int u,int f)
{
	fa[u]=f;
	dfn[u]=++tmn;
	for(node *p=AdjB[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==f)
			continue;
		dep[v]=dep[u]+1;
		DFS1(v,u);
	}
	efn[u]=++tmn;
}
void BFS()
{
	vis[X]=true;
	dist[X]=0;
	que.push(X);
	while(que.empty()==false)
	{
		int u=que.front();
		que.pop();
		for(node *p=AdjR[u];p!=NULL;p=p->nxt)
		{
			int v=p->to;
			if(vis[v]==false)
			{
				dist[v]=dist[u]+1;
				if(dist[v]<dep[v])
				{
					vis[v]=true;
					que.push(v);
				}
			}
		}
	}
}
bool Check(int x,int y)
{
	if(dfn[x]>dfn[y])
		swap(x,y);
	if(dfn[x]<dfn[y]&&efn[x]>efn[y])
	{
		if(dep[y]-dep[x]>=3)
			return true;
		return false;
	}
	if(fa[x]!=fa[y])
		return true;
	return false;
}
int read()
{
	int ret=0;
	char c=0;
	while(c<'0'||c>'9')	c=getchar();
	ret=10*ret+c-'0';
	while(true)
	{
		c=getchar();
		if(c<'0'||c>'9')
			break;
		ret=10*ret+c-'0';
	}
	return ret;
}
int main()
{
//	freopen("coalesce.in","r",stdin);
//	freopen("coalesce.out","w",stdout);
	while(scanf("%d %d %d",&N,&X,&Y)==3)
	{
		Init();
		int u,v;
		for(int i=1;i<N;i++)
			fro[i]=read(),to[i]=read();
		for(int i=1;i<N;i++)
		{
			u=read(),v=read();
			AddEdgeB(u,v);
		}
		dep[Y]=0;
		DFS1(Y,-1);
		for(int i=1;i<N;i++)
			if(Check(fro[i],to[i])==true)
				sppoint[fro[i]]=sppoint[to[i]]=true;
			else
				AddEdgeR(fro[i],to[i]);
		BFS();
		int maxdep=-1;
		bool Find=false;
		for(int i=1;i<=N;i++)
			if(vis[i]==true)
			{
				if(sppoint[i]==true)
				{
					Find=true;
					break;
				}
				else
					maxdep=max(maxdep,dep[i]);
			}
		if(Find==true)
			printf("-1\n");
		else
			printf("%d\n",maxdep*2);
	}
	return 0;
}
/*
*/

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

int a[5][4][11] = {0};
int main() {
	
	int n;
	cin >> n;
	
	int b, f, r, v;
	
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b][f][r] = a[b][f][r] + v;
	}
	
	for (int b = 1; b <= 4; b++) {
		
		if (b > 1) {
			cout << "####################" << endl;
		}
		
		for (int f = 1; f <= 3; f++) {
			
		   	 	for (int r = 1; r <= 10; r++) {
		    		cout << " " << a[b][f][r];
				}
				
				cout << endl;
			}
			
	}

	return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
        if(i%2==0 && S[i]=='L'){
        cout << "No";
        return 0;
        }
        if(i%2==1 && S[i]=='R'){
        cout << "No";
        return 0;
        }
    }
    cout << "Yes";
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;


int main(){
    ll a;
    string b;
    cin >> a >> b;
    int ans = 0;
    rep(i,b.size()){
        char now = b[i];
        if(now=='.')continue;
        ans = ans * 10 + (now-'0');
    }
    ll res = a*ans;
    cout << res/100 << endl;
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = 1001;
int gr[N][N];

int d[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

int main(){
    fastIO;
    int h, w;
    cin >> h >> w;
    for(int i = 0 ; i < N; i ++ ) for(int j = 0 ; j < N ; j ++ )
        gr[i][j] = -1;
    char f;
    queue<pii> ff;
    for(int i = 1; i <= h; i ++ ){
        for(int j = 1; j <= w; j ++ ){
            cin >> f;
            if(f == '#'){
                gr[i][j] = 0;
                ff.push(mp(i,j));
            }
            else
                gr[i][j] = (int)1e9;
        }
    }
    pii ii;
    while(!ff.empty()){
        ii = ff.front();
        ff.pop();
        for(int i = 0 ; i < 4; i ++ ){
            if(gr[ii.fi+d[i][0]][ii.se+d[i][1]] == (int)1e9){
                ff.push(mp(ii.fi+d[i][0],ii.se+d[i][1]));
                gr[ii.fi+d[i][0]][ii.se+d[i][1]] = gr[ii.fi][ii.se] + 1;
            }
        }
    }
    int res = 0;
    for(int i = 1; i <= h ; i ++ )
        for(int j = 1; j <= w; j ++ )
            res = max(res, gr[i][j]);
    cout << res;
    return 0;
}

Measured memory_bytes: 12304
function main() {
  var
  n, m,
  i = 0, j, ans, dp, dp_, x, k, line, xs;
  for(;;) {
    line = input[i++].split(' ').map(parseFloat);
    n = line[0]; m = line[1];
    if (n === 0 && m === 0) break;
    
    xs = [];
    for (j = 0; j < n; j++) {
      xs.push(parseInt(input[i++], 10));
    }
    
    dp = {};
    ans = 0;
    dp[0] = true;
    for (j = 0; j < n; j++) {
      for (k = xs[j]; k <= m; k++) {
        if (dp[k - xs[j]]) {
          dp[k] = true;
          if (ps[k]) ans = Math.max(ans, k);
        }
      }
    }

    console.log(ans || 'NA');
  }
}

function prims(n){
  var
  i, j, flag,
  prims = [false, false];
  for (i = 2; i <= n; i++) prims[i] = true;
  for (i = 2; i <= n; i++) if (prims[i]) {
    for (j = i + i; j <= n; j += i) prims[j] = false;
  }
  return prims;
}

var
ps = prims(1000000);

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 89260
from collections import defaultdict
n=int(input())
A=list(map(int,input().split()))
q=int(input())
b=[]
c=[]
for i in range(q):
    bbuf,cbuf = map(int,input().split())
    b.append(bbuf)
    c.append(cbuf)

d=defaultdict(int)
t=0
for a in A:
    d[a]+=1
    t+=a
for i in range(q):
    be=b[i]
    af=c[i]
    t+=af*d[be]-be*d[be]
    d[af]+=d[be]
    d[be]=0
    print(t)

Measured memory_bytes: 100496
import numpy as np
import itertools

n, d = (int(i) for i in input().split())
X = [[int(i) for i in input().split()] for i in range(n)]

err=0
for i, j in list(itertools.combinations(X, 2)):
  if np.linalg.norm(np.array(i)-np.array(j)).is_integer():
    err+=1
    
print(err)

Measured memory_bytes: 14472
K, N = map(int, input().split())
nums = list(map(int, input().split()))
tmp = 0
for i in range(N-1):
    diff = nums[i + 1] - nums[i]
    tmp = max(diff, tmp)
diff = K - nums[-1] + nums[0]
tmp = max(diff, tmp)
print(K - tmp)

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

typedef long long ll;
typedef pair<int, int> ii;

// binary search

int main()
{
    /*
       8 3
       ACACTACG
       v v  v
       11222333
       012344566
       3 7
       2 3
       1 8
    */

    int n, q;
    scanf("%d %d", &n, &q);

    char inp[n + 3];
    scanf("%s", inp);

    vector<int> s;
    for (int i = 0; i + 1 < n; i++)
        if (inp[i] == 'A' && inp[i + 1] == 'C')
            s.push_back(i + 1);

    for (int i = 0; i < q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);

        // 1 3 6
        // [3,7]
        auto lb = lower_bound(s.begin(), s.end(), l);
        auto rb = lower_bound(s.begin(), s.end(), r);
        printf("%ld\n", distance(lb, rb));
    }

    /*
    int dp[n + 1];
    dp[0] = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
    if (i + 1 < n && inp[i] == 'A' && inp[i + 1] == 'C')
        dp[i + 1] = ++cnt, dp[i + 2] = ++cnt, i++;
    else
        dp[i + 1] = cnt;
    }

    for (int i = 0; i <= n; i++) {
    // printf("%d %d\n", i, dp[i]);
    }

    for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);

    if (inp[l - 1] == 'C')
        l++;
    if (inp[r - 1] == 'A')
        r--;

    if (l <= r)
        printf("%d\n", (dp[r] - dp[l - 1]) / 2);
    else
        printf("0\n");
    }
    */

    return 0;
}


Measured memory_bytes: 1276
fun main(args: Array<String>) {

    // B - i18n
    val str = readLine()
    // 文字列先頭1文字
    val begin = str!!.substring(0, 1)
    // 文字列末尾1文字
    val end = str!!.substring(str!!.length - 1)

    println(begin + (str!!.length - 2) + end)
}


Measured memory_bytes: 31736
#include<bits/stdc++.h>
using namespace std; 
 
long long MOD = 1000000007;

long long pow(long long x, long long y) {
  long long res = 1; 
  while(y>0) {
    if(y%2)
      res = (res*x)%MOD;
    x = (x*x)%MOD;
    y /= 2; 
  }
  return res;
}

int main() {
  int n;
  long long temp;
  cin >> n; 
  long long sum = 0;
  long long squareSum = 0;
  for(int i = 0; i < n; i++) {
    cin >> temp;
    sum = (sum + temp)%MOD;
    squareSum = (squareSum + (temp*temp)%MOD)%MOD;
  }
  
  sum = (sum*sum)%MOD;
  long long ans = sum - squareSum;
  
  while(ans < 0) {
    ans += MOD;
  }
  
  ans = ans%MOD;
  
  long long twoInverse = pow(2*1LL, MOD-2)%MOD;
  
  cout << (ans*twoInverse)%MOD;
  
  return 0; 
}

Measured memory_bytes: 3624
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    r, c, k = map(int, input().split())
    v = [[0] * c for _ in range(r)]
    for _ in range(k):
        i, j, k = map(int, input().split())
        v[i-1][j-1] = k

    # dp[j][n] = j列にいて、n個itemを拾った時のアイテムの価値の合計の最大値
    # 1行ずつdpを更新する
    # 0行目
    value = v[0][0]
    if value == 0:
        dp = [[0] * 4]
    else:
        dp = [[0, value, value, value]]
    for j in range(1, c):
        value = v[0][j]
        if value == 0:
            dp.append(dp[j-1])
            continue
        a = dp[j-1].copy()
        b = [0, a[0]+value, a[1]+value, a[2]+value]
        for k in range(1, 4):
            if a[k] < b[k]:
                a[k] = b[k]
        dp.append(a)

    # i行目
    for i in range(1, r):
        pre = dp[0][3]
        value = v[i][0]
        if value == 0:
            new_dp = [[pre] * 4]
        else:
            new_dp = [[pre, pre+value, pre+value, pre+value]]
        for j in range(1, c):
            value = v[i][j]
            if value == 0:
                a = new_dp[j-1].copy()
                b = [dp[j][3]] * 4
                for k in range(4):
                    if a[k] < b[k]:
                        a[k] = b[k]
                new_dp.append(a)
            else:
                a = new_dp[j-1].copy()
                pre = dp[j][3]
                b = [pre, pre+value, pre+value, pre+value]
                d = [a[0], a[0]+value, a[1]+value, a[2]+value]
                for k in range(4):
                    if a[k] < b[k]:
                        a[k] = b[k]
                    if a[k] < d[k]:
                        a[k] = d[k]
                new_dp.append(a)
        dp = new_dp

    print(dp[c-1][3])

main()

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

using namespace std;

int dif(int a, int b) {

    if(a<b){
        return dif(b, a);
    }else{
        return a-b;
    }

}



int main() {

    int N;
    cin >> N;

    int h[N];
    int dp[N];

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

    dp[0] = 0;
    dp[1] = dif(h[0], h[1]);
    
    for(int i = 2;i < N; i++) {
        dp[i] = min(dp[i-2] + dif(h[i-2], h[i]), dp[i-1] + dif(h[i-1], h[i]));
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a1,a2,a3,aa,b1,b2,bb;
	scanf("%d %d %d %d %d",&a1,&a2,&a3,&b1,&b2);
	if(a1>a2){
		aa=a2;
	}
	else{
		aa=a1;
	}
	if(aa>a3){
		aa=a3;
	}
	if(b1>b2){
		bb=b2;
	}
	else{
		bb=b1;
	}
	printf("%d\n",aa+bb-50);
	return 0;
}


Measured memory_bytes: 2036
#include <cstdio>
#include <vector>
using namespace std;
#define pb push_back
const int maxn = 100001,mod = 1000000007;
int N,K,ans = 1,f[maxn]; vector<int> adj[maxn];
inline int fpow(int b,int e) {
    if (!e) return 1;
    int a = fpow(b,e>>1);
    if (e&1) return 1LL*a*a%mod*b%mod; else return 1LL*a*a%mod;
}
inline int P(int n,int k) {
    if (k > n) return 0;
    return 1LL*f[n]*fpow(f[n-k],mod-2)%mod;
}
void dfs(int cur,int par) {
    if (cur == 1) ans = 1LL*ans*P(K-1,adj[1].size())%mod;
    else ans = 1LL*ans*P(K-2,adj[cur].size()-1)%mod;
    for (int nxt : adj[cur]) if (nxt != par) dfs(nxt,cur);
}
int main() {
    scanf("%d%d",&N,&K);
    f[0] = 1; for (int i = 1;i < maxn;i++) f[i] = 1LL*f[i-1]*i%mod;
    for (int i = 1,x,y;i < N;i++) scanf("%d%d",&x,&y),adj[x].pb(y),adj[y].pb(x);
    dfs(1,0); printf("%lld\n",1LL*ans*K%mod);
    return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 200 * 1000 + 9;

int n;
int a[maxN];
vector<int> se[maxN];

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

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	
	for(int i = 1; i <= n; i++){
		int lo = 1, hi = ans, id = -1;
		while(lo <= hi){
			int mid = (lo + hi) / 2;
			if(se[mid].back() < a[i]){
				id = mid;
				hi = mid - 1;
			} else {
				lo = mid + 1;
			}
		}

		if(id == -1){
			ans++;
			se[ans].push_back(a[i]);
		} else {
			se[id].push_back(a[i]);
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 8448
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");               
    else if(b>=0)puts("Zero");            
    else if((a&1)^(b&1))puts("Positive");  
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
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;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll sz=10005;
  vector<ll>f(sz);
  rep(i,1,105)rep(j,1,105)rep(o,1,105){
    ll k=i*i+j*j+o*o+i*j+j*o+o*i;
    if(k<sz)f[k]++;
  }
  ll n;cin>>n;
  rep(i,1,n+1)cout<<f[i]<<endl;
  return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };
struct Corr {
    int x, y, depth;
};
int main() {
    int h, w,sum=0; cin >> h >> w;
    vector<string> G(h);
    rep(i, h) {
        cin >> G[i];
        rep(j, w) {
            if (G[i][j] == '#') sum++;
        }
    }
    vector<vector<int>> mp(h, vector<int>(w, 1e9));
    mp[0][0] = 0;
    queue<Corr> q;q.push({ 0,0,1 });
    while (!q.empty()) {
        Corr now = q.front(); q.pop();
        rep(i, 4) {
            int nx = now.x + dx[i], ny = now.y + dy[i];
            if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
            if (mp[ny][nx] != 1e9||G[ny][nx]=='#')continue;
            mp[ny][nx] = now.depth + 1;
            q.push({ nx,ny,now.depth + 1 });
        }
    }if (mp[h - 1][w - 1] == 1e9) cout << -1 << endl;
    else cout << h * w - mp[h - 1][w - 1]-sum << endl;
}

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int X;
    cin >> X;
    if(X >= 30) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 3648
from collections import deque
h, w = map(int,input().split())
maze = [[i for i in input()] for _ in range(h)] # h * w
move = [(1, 0), (-1, 0), (0, 1), (0, -1)]

def bfs(i, j):
  dist = [[-1] * w for _ in range(h)]
  d = deque()
  d.append((i, j))
  dist[i][j] = 0
  ret = 0
  while d:
    x, y = d.popleft()
    for m in move:
      i = x + m[0]
      j = y + m[1]
      if i >=0 and i < h and j >= 0 and j < w:
        if maze[i][j] == "#":
          continue
        if dist[i][j] != -1:
          continue
        dist[i][j] = dist[x][y] + 1
        d.append((i, j))
  for i in range(h):
    for j in range(w):
      if ret < dist[i][j]:
        ret = dist[i][j]
  return ret

ans = 0
for i in range(h):
  for j in range(w):
    if maze[i][j] == "#":
      continue
    d = bfs(i, j)
    if ans < d:
      ans = d

print(ans)



Measured memory_bytes: 74904
l,r=map(int,input().split())
if r-l<2019:
    l=l
    r=r
else:
    l=l
    r=l+2019
ans=2019
for i in range(l,r):
    for j in range(i+1,r+1):
        if (i*j)%2019<ans:
            ans=(i*j)%2019
print(ans)

Measured memory_bytes: 3060
n=int(input())
 
t = list(map(int,input().split()))
 
count = 0
 
for i in range(n-2):
    if t[i] <= t[i+1] and t[i+1] <= t[i+2] or t[i] >= t[i+1] and t[i+1] >= t[i+2]:
        count += 1
print(count)    

Measured memory_bytes: 38384
s = list(input())
ans = [s[0]]
cnt = 1
if len(s) == 1:
    print(s[0],end = "")
    print(1)
else:
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            cnt += 1
        else:
            ans.append(cnt)
            ans.append(s[i+1])
            cnt = 1
    if s[-1] == s[-2]:
        ans.append(cnt)
    else:
        ans.append(1)
ans2 = [0]*len(s)
sm = 0
for i in range(len(ans)//2):
    sm += ans[2*i+1]
    if ans[i*2] == "L":
        if ans[2*i+1]%2 == 1:
            ans2[sm-ans[i*2+1]] += (ans[2*i+1]+1)//2
            ans2[sm-ans[i*2+1]-1] += (ans[2*i+1]-1)//2
        else:
            ans2[sm-ans[i*2+1]] += (ans[2*i+1])//2
            ans2[sm-ans[i*2+1]-1] += (ans[2*i+1])//2
    else:
        if ans[2*i+1]%2 == 1:
            ans2[sm-1] += (ans[2*i+1]+1)//2
            ans2[sm] += (ans[2*i+1]-1)//2
        else:
            ans2[sm] += (ans[2*i+1])//2
            ans2[sm-1] += (ans[2*i+1])//2
for i in ans2:
    print(i,end = " ")

Measured memory_bytes: 12180
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from operator import mul
from functools import reduce


def nCr(n, r):
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under % mod


n, k = map(int, read().split())
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    print(nCr(n - k + 1, i) * nCr(k - 1, i - 1) % mod)


Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000000+7;
const int MaxSize = 100005;
int cycle = 0;
int keep[1000] = {};
bool ok = true;
int white = 1;
int black = 2;
bool prime[MaxSize] = {};
bool findPrime(int n)
{
    bool ok = true;
    for(int i = 2; i <= sqrt(n); i++)
    {
        if(n % i == 0)
        {
            ok = false;
            return false;
        }
    }
    return true;
}
int main()
{
   string st;
   cin >> st;
   int dis[] = {7, 6, 5, 4, 3, 2, 1};
   string day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
   for(int i = 0; i < 7; i++)
   {
       if(day[i] == st)
       {
           cout << dis[i] << endl;
           break;
       }
   }
    return 0;
}


Measured memory_bytes: 256
import sys
for dataset in sys.stdin:
    dataset=map(int,dataset.split(","))
    v2=dataset.pop()
    v1=dataset.pop()
    L=sum(dataset)
    s=L/float(v1+v2)
    cross=v1*s
    
    banti=0
    for i in dataset:
        banti+=1
        cross-=i
        if cross<=0:
            print banti
            break

Measured memory_bytes: 4204
N,m,x = (int(i) for i in input().split())
a = list(int(i) for i in input().split())
b = list(0 for i in range(N+1))
for i in a:
    b[i] = 1
sum_left = 0
sum_right = 0
for i in range(N+1):
    if i < x:
        sum_left += b[i]
    else:
        sum_right += b[i]
print(min(sum_left,sum_right))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
signed main () {
    int n;
    cin >> n;
    vector < int > c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; ++i)
        cin >> c[i] >> s[i] >> f[i];
    for (int i = 0; i < n; ++i) {
        int64_t ans = 0;
        for (int j = i; j < n - 1; ++j) {
            ans = max(ans, int64_t(s[j]));
            while (ans % f[j])
                ++ans;
            ans += c[j];
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    ll ret = 0;
    if(a <= k) {
        ret += a;
        k -= a;
    } else {
        ret += k;
        k = 0;
    }

    if(b <= k) {
        k -= b;
    } else {
        k = 0;
    }

    if(c <= k) {
        ret -= c;
        k -= c;
    } else {
        ret -= k;
        k = 0;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	int N, A, B, c, d;
	cin >> N >> A >> B;
	if (A >= B) {
		c = B;
	}
	else if (A < B) {
		c = A;
	}
	d = N - A - B;
	if (d < 0) {
		d = d * -1;
	}
	else {
		d = 0;
	}
	cout << c << endl;
	cout << d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll a, b;
	cin>>a>>b;
	if((a+b)%2 == 1){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<(a+b)/2 <<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(0),cin.tie(0);

int main()
{
	int n, m,res=0;
	cin >> n >> m;
	for (int i = 1; i*i <= m; i++)
	{
		if (m%i == 0)
		{
			if (m / i >= n)res = max(res, i);
			if (i >= n)res = max(res, m / i);
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,i,r;
	while(1){
		r=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i+=4){
			scanf("%d",&a);
			r+=a;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll>a(x+1),b(y+1),c(z+1);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  a[x]=(-(ll)1e17);
  b[y]=(-(ll)1e17);
  c[z]=(-(ll)1e17);
  sort(all(a),greater<ll>());
  sort(all(b),greater<ll>());
  sort(all(c),greater<ll>());
  priority_queue<pair<ll,int>>q;
  unordered_set<int> ma;
  q.push({a[0]+b[0]+c[0],0});
  rep(i,k)
  {
    auto tq=q.top();q.pop();
    ma.insert(tq.second);
    int x[3]={tq.second&1023,tq.second>>10&1023,tq.second>>20&1023};
    int ts;
    rep(j,3)
    {
      x[j]++;
      if(!ma.count(ts=tq.second+(1<<(10*j)))){ma.insert(ts);q.push({a[x[2]]+b[x[1]]+c[x[0]],ts});};
      x[j]--;
    }
    cout<<tq.first<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 768