akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int a, b, c, hishi=0, cho=0;
	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if(a==b)
			hishi++;
		if(fabs(pow(a,2)+pow(b,2)-pow(c,2))<1e-10)
				cho++;
	}
	printf("%d\n%d\n", cho, hishi);
	return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String a = br.readLine();
		String b = a;
		b = a.toUpperCase();
		if (a == b) {
			System.out.print("A");
		} else {
			System.out.print("a");
		}
	}
}

Measured memory_bytes: 32580
#include <iostream>

using namespace std;

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

  bool flag = false;
  for (int i = 1; i <= 9; ++i)
    for (int j = 1; j <= 9; ++j)
      if (i * j == n)
        flag = true;

  cout << (flag ? "Yes" : "No") << endl;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, M; cin >> N >> M;
    vector<int> A(N + 1, -1);
    REP(i, M) {
        int s, c; cin >> s >> c;
        if (A[s] == -1) {
            A[s] = c;
        } else if (A[s] != c) {
            cout << -1 << "\n";
            return 0;
        }
    }
    string ans = "";
    for (int i = N; i > 0; i--) {
        if(A[i] >= 0) {
            ans = to_string(A[i]) + ans;    
        } else {
            if(N > 1 && i == 1) {
                ans = "1" + ans;
            } else {
                ans = "0" + ans;
            }
        }
    }
    if (N > 1 && count(ans.begin(), ans.end(), '0') == N) {
        ans = "-1";
    }
    cout << stoi(ans) << "\n";
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int INF = 1e9 + 5;
void solve()
{
		int n;
		cin >> n;
		vector <int> h(n, 0);
		int k;
		cin >> k;
		for(int &x : h)
			cin >> x;
			
		vector <int> dp(n, INF);
		dp[0] = 0;
		for(int i = 0; i<n; i++)
		{
			for(int j = i+1; j<=i+k; j++)
			{
				if(j < n)
				{
					dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]));
				}
			}
		}
		
		cout << dp[n-1];
		
}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	return 0;
}


Measured memory_bytes: 1024
n, m = [int(i) for i in input().split()]
li = [0] * m
for i in range(n):
    a = [int(i) for i in input().split()][1:]
    for j in a:
        li[j-1] += 1
li = [1 for l in li if l == n]
print(len(li))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    int i,j,k,l,m,n,a,b,c,x,y,z,five,seven;
  	while(cin>>a>>b>>c)
    {
        five = 0;
        seven = 0;
      	if(a==5)
      	    five++;
      	else if(a==7)
      	    seven++;
        if(b==5)
      	    five++;
      	else if(b==7)
      	    seven++;
        if(c==5)
      	    five++;
      	else if(c==7)
      	    seven++;
      	if(five == 2 && seven == 1)
      	    cout<<"YES"<<endl;
      	else cout<<"NO"<<endl;
      	
    }
   
    return 0;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	 int k;cin>>k;
	 string s;cin>>s;
	if(s.length()>k) {
		repi(i,k) cout<<s[i];cout<<"...\n";
	}
	else cout<<s<<endl;
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3672
n = int(input())
ans = 0
for i in range(9):
  j = i+1
  a = 100*j + 10*j + j
  if n <= a:
    ans = a
    break
  if n > a:
    k = j+1
    b = 100*k + 10*k + k
    if n < b:
      ans = b
      break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main() {
	string str;
	int n;
	cin >> str;
	n = str.length();
	for(int i = n - 1; i >= 0; i--) {
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1172
def fn(a):
  alist =[]
  for i in range(1,a+1):
    if a%i == 0:
      alist.append(i)
  return len(alist)
n = int(input())
anslist =[]
for i in range(1,n+1):
  if fn(i) == 8 and i%2 == 1:
    anslist.append(i)
print(len(anslist))


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn = 4200; 
struct Edge{
    int v,w,nxt;
}edge[maxn];
int V[maxn], ecnt, incnt[maxn],cir[maxn] , inq[maxn];
ll dist[maxn];
queue<int> q;
int n,m;
void adde(int u,int v, int w){
    ++ecnt;
    edge[ecnt].v = v; edge[ecnt].w = w; 
    edge[ecnt].nxt = V[u]; V[u] = ecnt;
}
int main(){
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        adde(a, b, c);
    }
    for(int i = 1; i <= n; ++i)dist[i] = -1e16;
    q.push(1); dist[1] = 0;
    bool failflag = false;
    int scnt = 0;
    while(!q.empty()){
        int u = q.front(); q.pop();
        inq[u] = 0;
        if(incnt[u] > n){
            cir[u] = 1;
            if(u == n)break;
        }
        for(int p = V[u]; p; p = edge[p].nxt){
            int v = edge[p].v, w = edge[p].w;
            if(dist[u] + w > dist[v]){
                dist[v] = dist[u] + w;
                if(!inq[v]){
                    incnt[v]++;
                    q.push(v);
                    inq[v] = 1;
                }
            }
        }
        ++scnt;
        if(scnt > (n + 1) * (m + 1))break;
    }
    if(cir[n]){
        cout << "inf" << endl;
    }else{
        cout << dist[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();

		if (a.equals(b)){
			System.out.println("H");
		}else{
			System.out.println("D");
		}
	}
}


Measured memory_bytes: 22868
A,B,M=input().split()
A=int(A)
B=int(B)
M=int(M)

a=[int(i) for i in input().split()]
b=[int(j) for j in input().split()]

z=min(a)+min(b)
m=0
while m<M:
  s=[int(k) for k in input().split()]
  x=s[0]
  y=s[1]
  c=s[2]
  p=a[x-1]+b[y-1]-c
  if p<=z:
    z=p 
  m=m+1
print(z)

Measured memory_bytes: 18488
N = int(input())
A = [int(s) for s in input().split()]

def main():
    sum_n = sum(A)
    mid = sum_n / 2
    a = 0
    abs_list = []
    for i in range(N - 1):
        a += A[i]
        abs_list.append((abs(mid - a), i))    
    abs_list.sort()
    idx = abs_list[0][1]

    left = sum(A[:idx + 1])
    right = sum(A[idx + 1:])
    print(abs(left - right))

if __name__ == '__main__':
    main()


Measured memory_bytes: 36564
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#h,w
def main():
	l,r = map(int,input().split())
	if(r-l+1>2018):
		print(0)
		exit()
	else:
		min = 2020
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				if(min>i*j%2019):
					min=i*j%2019
	print(min)
	exit()


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 64108
A = input().split()
S, top = [0], 0


def push(x):
    global top, S
    top += 1
    if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x


def pop(x):
    global top, S
    top -= 2
    if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2]))


for i in range(len(A)):
    if str(A[i]).isdigit():
        push(int(A[i]))
    else:
        pop(A[i])
print(S[1])



Measured memory_bytes: 5604
n, m = map(int, input().split())

stairs = []
is_continuous = False
for i in range(m):
    stairs.append(int(input()))
    if i > 0 and stairs[i] - 1 == stairs[i - 1]:
        is_continuous = True
        break

if is_continuous:
    print(0)
else:
    countup_num = [0] * (n + 1)
    countup_num[0] = 1
    countup_num[1] = 1
    for i in range(2, n + 1):
        countup_num[i] = (countup_num[i - 1] + countup_num[i - 2]) % 1000000007
    res = 1
    diff = 0
    now = 0
    for i in range(m):
        diff = stairs[i] - now - 1
        now = stairs[i] + 1
        res *= (countup_num[diff]) % 1000000007
        # print(res, now)
    if m == 0:
        res = countup_num[n]
    else:
        diff = n - stairs[-1] - 1
        res *= (countup_num[diff]) % 1000000007

    res %= 1000000007
    # print(countup_num)
    print(res)


Measured memory_bytes: 14812
"All Green"

"""
考え方
その点数の問題を全て解く or 1問も解かないをbit全探索で分けて処理を行い、目標点に到達していない
ならば、配点の高い問題から一問ずつ解いて確認していく。
"""

D, G = map(int, input().split())  # 与えられる問題数のスコアのレンジD, 目標の点数G

PC = []  # 100i点の問題の個数とコンプリートボーナス
ans = 99999999
for i in range(D):
    p, c = map(int, input().split())
    score = (i+1)*100
    PC.append([score, p, c])

for mask in range(1 << D):  # D種類の問題について解くか解かないかの二択を考える
    solved_amount = 0
    my_score = 0
    for i in range(D):
        score, p, c = PC[i]  # その問題のscore, 問題数のp, コンプリートしたらc
        if (mask >> i) & 1:  # ビットが立つならその問題を全て解くことにする
            solved_amount += p  # 解いた問題数を増やして
            my_score += score * p + c  # スコアを加算する

    for i in range(D-1, -1, -1):  # 目標点Gに達していない時の処理、配点の高い問題から考えている
        if my_score >= G:  # すでに目標点数に到達していたら終了して、解いた問題の量を保持しにいく
            break

        if (mask >> i) & 1:  # すでにその問題を解いていたらもう解けないので次の配点の問題へ
            continue

        score, p, c = PC[i]  # 今部分的に解こうとしている問題のscore, 問題数のp, コンプリートしたらc
        # 今スコアは超えていない状態
        for _ in range(p):
            # 一問ずつ解いて超えるラインを探す
            solved_amount += 1
            my_score += score
            if my_score >= G:
                break
    if my_score >= G:
        ans = min(ans, solved_amount)

print(ans)


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

typedef vector<int> vi;
typedef vector<vi> vvi;
const int INF = 2e9;

int n;
vi h;
vvi dp;
int solve(int idx, int prev) {
    if (idx >= n) {
        if (prev == n-1) return 0;
        else return INF;
    };
    if (dp[idx][idx-prev] != -1) return dp[idx][idx-prev];

    int ans = abs(h[idx] - h[prev]);
    ans = min(
        ans + solve(idx+1,idx),
        ans + solve(idx+2,idx)
    );

    dp[idx][idx-prev] = ans;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin>>n;
    h = vi(n);
    dp = vvi(n,vi(3,-1));
    for (int i=0; i<n; i++)
        cin>>h[i];

    cout << solve(0,0) << '\n';
    return 0;
}

Measured memory_bytes: 8448
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
# define x first
# define y second
using namespace std;
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; }

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

  int need = 0;
  while(a >= b){
    need++;
    b *= 2;
  }
  while(b >= c){
    need++;
    c *= 2;
  }

  if(need <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main{
  		    
	
	    public static void kstones(int k,int arr[]){
	    	
	    	boolean dp[]=new boolean[k+1];
	    	
	    	for(int i=1;i<=k;i++) {
	    		for(int j=0;j<arr.length;j++) {
	    			if(i-arr[j]>=0) {
	    				if(!dp[i-arr[j]]) {
	    					dp[i]=true;
	    					break;
	    				}
	    			}
	    		}
	    	}
	    	
	    	if(dp[k]) {
	    		System.out.println("First");
	    	}
	    	else {
	    		System.out.println("Second");
	    	}
	    	
	    }
	    
	    
	    
		  
		    
	    
	    
	    
	    
	    
	    
	   
public static void main(String[]args) {
	Scanner s=new Scanner(System.in);
	
	int n=s.nextInt();
	int k=s.nextInt();
	int arr[]=new int[n];
	for(int i=0;i<n;i++) {
		arr[i]=s.nextInt();
	}

kstones(k,arr);
}
	   

}


Measured memory_bytes: 37096
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

constexpr int INF = 1'000'000'001;

class arc092_e {
private:
    vector<int> solve(set<int> &take, vector<int> &a) {
        vector<int> res;
        int n = a.size();
        vector<int> keep(n, 0);
        for (int i = 0; i < n; ++i) {
            keep[i] = take.count(i);
        }
        while (keep.size() > 1U) {
            int m = keep.size();
            if (!keep[m - 1]) {
                res.push_back(m);
                keep.pop_back();
            } else if (!keep[0]) {
                res.push_back(1);
                keep.erase(begin(keep));
            } else {
                for (int i = 1; i + 1 < m; ++i) {
                    if (keep[i - 1] && keep[i + 1]) {
                        keep[i - 1] = 1;
                        res.push_back(i + 1);
                        keep.erase(begin(keep) + i, begin(keep) + i + 2);
                        break;
                    } else if (!keep[i - 1] && !keep[i + 1]) {
                        assert(!keep[i]);
                        keep[i - 1] = 0;
                        res.push_back(i + 1);
                        keep.erase(begin(keep) + i, begin(keep) + i + 2);
                        break;
                    }
                }
            }
        }
        return res;
    }
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i];
        }
        set<int> take0, take1;
        for (int i = 0; i < N; ++i) {
            if (a[i] >= 0) {
                if (i % 2) take1.insert(i);
                else take0.insert(i);
            }
        }
        if (take0.empty()) {
            int mx = -INF, ind = -1;
            for (int i = 0; i < N; i += 2) {
                if (a[i] > mx) {
                    mx = a[i];
                    ind = i;
                }
            }
            take0.insert(ind);
        }
        if (take1.empty()) {
            int mx = -INF, ind = -1;
            for (int i = 1; i < N; i += 2) {
                if (a[i] > mx) {
                    mx = a[i];
                    ind = i;
                }
            }
            take1.insert(ind);
        }
        long long sum0 = 0, sum1 = 0;
        for (int i : take0) sum0 += a[i];
        for (int i : take1) sum1 += a[i];
        vector<int> res;
        if (sum0 >= sum1) {
            res = solve(take0, a);
        } else {
            res = solve(take1, a);
        }
        out << max(sum0, sum1) << "\n" << res.size() << "\n";
        for (int x : res) {
            out << x << "\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc092_e solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
/**
 *    Author  : Ador
 *    Created : 24.07.2020
**/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cctype>
typedef long long int ll ;
typedef unsigned long long int ull ;
using namespace std ;
int main(void)
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
        //freopen("input.txt", "r", stdin) ;
        //freopen("output.txt", "w", stdout) ;
    ll n , a , b , i , flag = 0 ; cin >> n ;
    ll result = n - 1 ;
    for(i = 1 ; i <= sqrt(n) ; ++i)
    {
        if(!(n % i))
        {
            a = i ;
            b = n / i ;
            flag = 1 ;
            result = min(result , ((a - 1) + (b - 1))) ;
        }
    }
    if(flag) cout << result << "\n" ;
    else cout << n - 1 << "\n" ;
    return 0 ;
}


Measured memory_bytes: 3664
import numpy as np
x = int(input())
tmp_list=[]
c=0
tmp_2=0
while(1):
    tmp_1=c**5
    if (tmp_1 - tmp_2)<=x:
        tmp_list+=[tmp_1]
    else:
        break
    tmp_2=tmp_1
    c+=1
 
def せいがわ(target:list,x) -> list:
    for i in np.flipud(target):
        for j in target:
            tmp=i+j
            if tmp==x:
                return [int(i**(1/5)),int(j**(1/5))*-1]
            if tmp>x:
                break
    return 0
 
def ふがわ(target:list,x) -> list:
    for i in np.flipud(target):
        for j in target:
            tmp=i-j
            if tmp==x:
                return [int(i**(1/5)),int(j**(1/5))]
            if tmp<x:
                break
    return 0
  
ans=ふがわ(tmp_list,x)
if ans==0:
    ans=せいがわ(tmp_list,x)
print(ans[0],ans[1])

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

int main(){
	int m,d,ans,i,tmp = 0;
	while(cin>>m>>d,m != 0){
		ans = 0;
		tmp = 0;
		for(i = m-1;i != 0;i--){
			switch(i){
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
			{
				tmp += 31;
				break;
			}
				case 4:
				case 6:
				case 9:
				case 11:
			{
				tmp += 30;
				break;
			}
				case 2:
			{
				tmp += 29;
				break;
			}
			}
		}
		tmp += d;
		ans = tmp % 7;
		switch(ans){
			case 0:{
				cout<<"Wednesday"<<endl;
				break;
			}
			case 1:{
				cout<<"Thursday"<<endl;
				break;
			}
			case 2:{
				cout<<"Friday"<<endl;
				break;
			}
			case 3:{
				cout<<"Saturday"<<endl;
				break;
			}
			case 4:{
				cout<<"Sunday"<<endl;
				break;
			}
			case 5:{
				cout<<"Monday"<<endl;
				break;
			}
			case 6:{
				cout<<"Tuesday"<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, X;
  int result = 0;
  int k = 0;
  cin >> N >> X;
  vector<int> L(N);
  for(int a = 0;a < N;a++)cin >> L[a];
  for(int a = 1;a <= N;a++){
    k += L[a-1];
    if(k > X){
      cout << a << endl;
      result = 1;
      break;
    } 
    
    
  }
  if(result == 0)cout << N+1 << endl;
}

Measured memory_bytes: 3608
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end
N,M=get_i
ab=array(M)
M.times do|i|
    ab[i]=get_i
end
ab.sort!{|x,y| x[1]<=>y[1]}
prev=-1
ans=0
ab.each do|a,b|
    unless a<prev and prev<=b
      ans+=1
      prev=b
    end
end
puts ans

Measured memory_bytes: 12024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 300005

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,m,q; cin>>n>>m>>q;
    int arr[m]={0},mexcol=0;
    map< int,vector<int> > mp;
    for(int i=0;i<q;i++){
        int x,y; cin>>x>>y;
        x--; y--;
        mp[x].pb(y);
        arr[y]++;
        mexcol=max(mexcol,arr[y]);
    }
    int freq[m+1]={0};
    for(int i=0;i<m;i++) freq[arr[i]]++;
    int ans=0;
    for(auto it : mp){
        int ans1=sz(it.ss),mex1=0,freq1=0;
        for(int t : it.ss){
            if(arr[t]>mex1){
                mex1=arr[t];
                freq1=1;
            }
            else if(arr[t]==mex1) freq1++;
        }
        if(mex1==mexcol && freq1==freq[mex1]) ans1+=mex1-1;
        else ans1+=mexcol;
        ans=max(ans,ans1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 41152
#                         author:  kagemeka 
#                         created: 2019-11-09 16:39:51(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    n, k, *x = (int(i) for i in sys.stdin.read().split())

    minimums = []
    for i in range(n - k + 1):

        left = x[i]
        right = x[i + k - 1]
        mi = min(abs(left) + abs(right - left), abs(right) + abs(left - right))
        minimums.append(mi)
    
    ans = min(minimums)
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 14052
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

int dp[1005][1005];

void solve()
{
    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];
    
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
           if(i==1&&j==1)
               continue;
            if(s[i-1][j-1]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%hell;
        }
    }
    cout<<dp[n][m]<<endl;
    
    
    
    
    
    
    
}


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







Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x,i,j,k,z;
    char c;
    string s,t,u;
    cin>>s>>t;
    for(i=0;i<26;i++){
            u=s;
        c=i+'a';
        u=s+c;
        if(u==t){
           return cout<<"Yes"<<endl,0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}




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

int main(){
        int n;
        cin >> n;
        int arr[n];
        for(int i = 0;i< n;i++)
        {
                cin >> arr[i];
        }
        int ans = 1000000;
        int s_1=0;
        int s_2 = 0;
        for(int i = 1;i<= n;i++)
        {
                for(int j= 0;j<i;j++)
                {
                        s_1+=arr[j];
                }
                for(int j = i;j<n;j++)
                {
                        s_2 += arr[j];
                }
                ans = min(ans, abs(s_1-s_2));
          		s_1 = 0;
          		s_2 = 0;
        }
        cout <<ans<< endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    while (true)
    {
        cin >> n >> m;
        if (n == 0 && m == 0)
        {
            return 0;
        }
        vector<ll> a(n);
        for (ll i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        ll ans = -INF;
        for (ll i = 0; i < n; i++)
        {
            for (ll j = i + 1; j < n; j++)
            {
                if (a[i] + a[j] <= m)
                {
                    chmax(ans, a[i] + a[j]);
                }
            }
        }
        if (ans == -INF)
        {
            cout << "NONE" << endl;
        }
        else
        {
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3224
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
const int mx = 1e5+123;

vector<int> adj[mx];
bool vis[mx];
void dfs ( int u )
{
    vis[u] =  1;

    for ( auto v : adj[u] ) {
        if ( vis[v] == 0 ) {
            dfs ( v );
        }
    }

    return;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
    l(i,1,m+1)
    {
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);

    }
    memset(vis, false, sizeof(vis));
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (vis[i] == false) {
			dfs(i);
			cnt++;
		}
	}
	cout << cnt-1 << endl;
    //dfs(1);

}


Measured memory_bytes: 9700
/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)

using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pair<int,int>>;

constexpr int mod = 1000000007;
constexpr int N = 2e8 + 5;
constexpr int inf = 1e18 , eps = 1e-6; 


void Onigiri()
{
  int n;
  cin>>n;
  int cnt=0,ok=0;
  rep(i,0,n)
  {
    int x,y;
    cin>>x>>y;
    if(x==y){
      cnt++;
      if(cnt==3)ok=1;
    }
    else cnt=0;
  }
  if(ok)cout<<"Yes";
  else cout<<"No";
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int n, i, d, x, y, c;
int main()
{
    scanf("%d%d", &n, &d);
    for (i = 1; i <= n; ++i)
    {
        scanf("%d%d", &x, &y);
        if (x * (i64)x + y * (i64)y <= d * (i64)d)
            ++c;
    }
    printf("%d", c);
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

//zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N,-1) {}

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        if(par[rx] > par[ry]) swap(rx,ry);
        par[rx] += par[ry];
        par[ry] =rx;  //xとyの根が同じでない(=同じ木にない)時：yの根ryをxの根rxにつける
    }

    bool issame(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        return rx == ry;
    }

    int size(int x) {
        return -par[root(x)];  //初期値が -1 , 木の根の値は木のサイズ* -1
    }
};

//zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);
    vector<vector<int>> no(n);
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        no.at(a).push_back(b);
        no.at(b).push_back(a);
        uf.unite(a,b);
    }
    rep(i,0,k){
        int c,d;
        cin>>c>>d;
        c--;
        d--;
        if(!uf.issame(c,d))continue;
        no.at(c).push_back(d);
        no.at(d).push_back(c);
    }
    rep(i,0,n){
        int ans=uf.size(i)-1;
        //if(!no.at(i).empty()){
            //cout<<ans<<' '<<no.at(i).size()<<' ';
           ans-=no.at(i).size();
        //}
        cout<<ans<<' ';
    }
return 0;
}

Measured memory_bytes: 7936
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


import collections
import itertools
import operator


class UnionFind:
    def __init__(self, elems=None):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)

        if elems is not None:
            for elem in elems:
                _, _ = self.parent[elem], self.rank[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]


def main():
    N, M = readi(2)
    ips = {ip[1]: ip for ip in enumerate(readi(N), 1)}
    uf = UnionFind(ips.values())
    for _ in range(M):
        x, y = readi(2)
        uf.unite(ips[x], ips[y])

    ans = 0
    for g in uf.grouper():
        iss, ps = zip(*g)
        ans += len(iss) - len(set(iss) - set(ps))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 56440
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){



	int w,x,y,z;
	int hit=0,blow=0;
	cin>>w>>x>>y>>z;
	if(w==a)a=-1,hit++;
	else if(w==b)b=-1,blow++;
	else if(w==c)c=-1,blow++;
	else if(w==d)d=-1,blow++;
	if(x==b)b=-1,hit++;
	else if(x==a)a=-1,blow++;
	else if(x==c)c=-1,blow++;
	else if(x==d)d=-1,blow++;
	if(y==c)c=-1,hit++;
	else if(y==b)b=-1,blow++;
	else if(y==a)a=-1,blow++;
	else if(y==d)d=-1,blow++;
	if(z==d)d=-1,hit++;
	else if(z==b)b=-1,blow++;
	else if(z==c)c=-1,blow++;
	else if(z==a)a=-1,blow++;
	cout<<hit<<" "<<blow<<endl;
    }


	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
# coding=utf-8

import sys

s = sys.stdin.readline().strip()
l = [_s is "1" for _s in list(s)]
l_r = l[::-1]
index = 0
for i, (c, n, c_r, n_r) in enumerate(
        zip(l[:len(s) // 2], l[1:len(s) // 2 + 1], l_r[:len(s) // 2], l_r[1:len(s) // 2 + 1])):
    if c ^ n or c_r ^ n_r:
        index = i + 1
print(len(s) - index)

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll bpow(ll x,ll n,ll m=MD,ll r=1LL){for(;n>0;n>>=1,x=x*x%m) if(n&1) r=r*x%m; return r;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n+1), ans(n+1);
	rep(i, n-1) cin >>a[i+2];
	
	rep(i, n+1) ans[a[i]]++;
	
	rep2(i,1,n+1) cout <<ans[i] <<"\n";
	return 0;
}


Measured memory_bytes: 4732
/*input
5
3 3 3 3 3
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <tgmath.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
vector<int> adj_list[100010];
bool visited[10010];

void dfs(int node){
	visited[node] = true;
	for(int n: adj_list[node]){
		if(!visited[n]){
			dfs(n);
		}
	}
}



int main() {
 	int64 n;
 	cin>>n;
 	int64 ma = 1000;
 	int64 count = 0;
 	rep(i,n){
 		int64 a;
 		cin>>a;
 		if(i==0){
 			ma = a;
 		}
 		else{
 			if(ma>a){
 				count+=ma-a;
 			}
 			else{
 				ma = a;
 			}

 		}
 	}
 	cout<<count<<endl;
}



 


Measured memory_bytes: 5988
n=int(input())
d=-1
for i in range(n):
    a,b,c=map(int,input().split())
    if d==-1:
        d=[a,b,c]
    else:
        d=[max(a+d[1],a+d[2]),max(b+d[0],b+d[2]),max(c+d[0],c+d[1])]
print(max(d))

Measured memory_bytes: 3188
s = list(input())
if s[0] == s[1] == s[2] == "R":
    print(3)
elif s[0] == s[1] == "R" or s[1] == s[2] == "R":
    print(2)
elif "R" not in s:
    print(0)
else:
    print(1)

Measured memory_bytes: 9048
import java.util.*;
	class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int j = 0;

        for(int i=1;i<=n;i=i+2){
            int a = 0;
            for(int m=1;m<=i;m++){
                
                if(0==i%m){
                    a++;
                }
                if(a==8){
                    j++;
                }
            }
        }
        System.out.println(j);
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  double dp[100][100];
  int n,m;
  double table[100][100];

  while(1){
    scanf("%d %d",&n,&m);
    if(!n && !m)break;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)scanf("%lf",&table[i][j]);
    }

    for(int i=0;i<n;i++)dp[0][i] = 1.0;
    for(int i=1;i<m;i++){
      for(int j=0;j<n;j++)dp[i][j] = 0.0;
    }

    for(int i=1;i<m;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
	  dp[i][j] = max(dp[i][j],dp[i-1][k] * table[k][j]);
	}
      }
    }

    double ans = 0.0;
    for(int i=0;i<n;i++)ans = max(ans,dp[m-1][i]);

    printf("%.2lf\n",ans);
  }
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;

    int search = 1;
    int sum = 0;
    int s, s_sum, dig;

    while(search <= N){
        s = search;
        s_sum = 0;

        while(s > 0){
            dig = s % 10;
            s_sum = s_sum + dig;
            s = s / 10;
        }

        if (s_sum >= A){
            if (s_sum <= B){
                sum = sum + search;
            }
        }
        search = search + 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -100000007;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 5.9 + c[j] * 5.45;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		cout << p << "\n"; l[p] = i;
	}
}

Measured memory_bytes: 3732
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>

using namespace std;


typedef int INT;
#define int long long

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int sum = 0;
	if (a + b > 2 * c)
	{
		int v = min(x, y);
		x -= v;
		y -= v;
		sum += v * 2 * c;
	}
	if (a > 2 * c)
	{
		int u = x * 2;
		y = max(0LL, y - x);
		x = 0;
		sum += u*c;
	}
	if (b > 2 * c)
	{
		int u = y * 2;
		x = max(0LL, x - y);
		y = 0;
		sum += u*c;
	}
	sum += x*a + y*b;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint X;
  cin>>X;
  cout<<(X/500)*1000+((X%500)/5)*5<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
   int a,b;cin>>a>>b;
   if (a<9&&b<9)
   {
      /* code */
      cout<<"Yay!"<<endl;
   }
   else
   {
      cout<<":("<<endl;
   }
   
   
   }
   


Measured memory_bytes: 256
using System;

public class Ball{
    public static void Main(){
        var input = Console.ReadLine().Split(' ');
        var number = ulong.Parse(input[0]);
        var blue = ulong.Parse(input[1]);
        var red = ulong.Parse(input[2]);
        
        ulong blue_ball = number /(red + blue) * blue +Math.Min(blue, number % (red + blue));
        
        Console.WriteLine(blue_ball);
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include <cstdlib>

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


typedef long long ll;
const int INF = 1001001001;

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


int main() {
	int n;
	cin >> n;
	vector<int>h(100100);
	rep(i, n)cin >> h[i];
	vector<int> dp(100100,INF);
	dp[0] = 0;
	rep(i, n) {
		chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
		//rep(j,n)cout << dp[j] << endl;
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int n;
string start,res;
int main(){
    cin>>n;
    cout << 0 << endl;
    cin >> start;
    if(start=="Vacant"){
        return 0;
    }
    else if(start=="Male"){
        int l=0,r=n-1;
        while(r>l+1){
            int mid=(r+l)/2;
            if(mid%2==0){
                cout << mid << endl;
                cin >> res;
                if(res=="Vacant") return 0;
                else if(res=="Male"){
                    l=mid;
                }
                else{
                    r=mid;
                }
            }
            else{
                cout<<mid<<endl;
                cin>>res;
                if(res=="Vacant") return 0;
                else if(res=="Male"){
                    r=mid;
                }
                else l=mid;
            }
        }
        cout<<r<<endl;
        cin>>res;
        return 0;
    }
    else if(start=="Female"){
        int l=0,r=n-1;
        while(r>l+1){
            int mid=(r+l)/2;
            if(mid%2==0){
                cout << mid << endl;
                cin >> res;
                if(res=="Vacant") return 0;
                else if(res=="Female"){
                    l=mid;
                }
                else{
                    r=mid;
                }
            }
            else{
                cout<<mid<<endl;
                cin>>res;
                if(res=="Vacant") return 0;
                else if(res=="Female"){
                    r=mid;
                }
                else l=mid;
            }
        }
        cout<<r<<endl;
        return 0;
    }
}

Measured memory_bytes: 852