akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

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

        int n = sc.nextInt();

        int cnt = 0;

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

            if (a == b) {
                cnt++;
            } else {
                cnt = 0;
            }
            if (cnt > 2) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");

        sc.close();

        }

    }



Measured memory_bytes: 36052
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	li a[5];
	
	rep(i,5)cin>>a[i];
	sort(a,a+5);
	
	rep(i,5){
		cout<<a[4-i];
		if(i<4)cout<<" ";
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 1176
#include <cstdlib>
#include <string>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
       string a;
       int b=0,c=0,ans=0;
       cin >> a;
      b= a.length();
      for(int i=0 ; i < b;i++){
         if(a[i]!=a[b-1]){
            ans++;

         }
         b--;
      }
      cout << ans;
      }
    



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,t,mn,j;
	while(scanf("%d", &mn) != EOF){
		t = 0;
		int n[mn + 1];
		for (i=2; i<=mn; i++){
				n[i]=1;
		}
		for (i=2; i<=mn; i++){
				if (n[i]==1){
					 t++;
				}
			for (j=i; j<=mn; j+=i){
				n[j]=0;
			}
		}
		printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 4500
import Control.Monad
main=do
 s<-concat<$>replicateM 3 (map read.words<$>getLine)
 putStrLn$if (s!!0+s!!4+s!!8)==(s!!1+s!!5+s!!6) && (s!!1+s!!5+s!!6)==(s!!2+s!!3+s!!7) then "Yes" else "No"


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main(){
    int n, m, q;
    scanf("%d %d %d", &n, &m, &q);
    auto mat=vector<vector<int>>(n+1, vector<int>(n+1, 0));
    for(int i=0; i<m; ++i){
        int l, r;
        scanf("%d %d", &l, &r);
        for(; r<=n; ++r){
            ++mat[l][r];
        }
    }
    for(int i=0; i<q; ++i){
        int pi, qi;
        scanf("%d %d", &pi, &qi);
        int ans=0;
        for(; pi<=n; ++pi){
            ans+=mat[pi][qi];
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
int main(){
	double max,min,tmp;
	scanf("%lf",&max);
	min = max;
	while(scanf("%lf",&tmp)!=EOF){
	//for(int i=0;i<5;i++){
		scanf("%lf",&tmp);
		if(tmp>max) max = tmp;
		if(tmp<min) min = tmp;
	}
	printf("%lf",max-min);
	return 0;
}

Measured memory_bytes: 644
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        ArrayList<String> s = new ArrayList<>();

        HashMap<String, Long> strMap = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] temp = sc.nextLine().split("");
            Arrays.sort(temp);
            s.add(String.join("", temp));

            if(strMap.containsKey(s.get(i))){
                strMap.put(s.get(i), strMap.get(s.get(i)) + 1);
            } else {
                strMap.put(s.get(i), Long.parseLong("1"));
            }
        }

        for(String key : strMap.keySet()){
            long l = strMap.get(key);
            ans += l * (l - 1) / 2;
        }

        System.out.println(ans);
        return;
    }
}


Measured memory_bytes: 164024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	int water_max = f, sugar_max = 0, sugar_limit = f / (100 + e) * e;
	vector<bool> dp(sugar_limit + 1);
	dp[0] = true;
	rep (i, sugar_limit + 1) if (i - c >= 0 && dp[i - c]) dp[i] = true;
	rep (i, sugar_limit + 1) if (i - d >= 0 && dp[i - d]) dp[i] = true;
	for (int i = 0; i * a * 100 <= f; i++) {
		for (int j = 0; (i * a + j * b) * 100 <= f; j++) {
			int water = (i * a + j * b) * 100;
			for (int k = min(water * e / 100, f - water); k >= 0; k--) {
				if (dp[k]) {
					if (sugar_max * (k + water) <= k * (sugar_max + water_max)) {
						sugar_max = k;
						water_max = water;
					}
					break;
				}
			}
		}
	}
	cout << water_max + sugar_max << " " << sugar_max << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s,t;
	cin >> s >> t;
	int n = s.length();
	int ctr = 0;
	for (int i = 0; i < n; i++) {
		ctr += (s[i]!=t[i]);
	}
	cout << ctr;
	return 0;
}

Measured memory_bytes: 3824
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let ell: f64 = sc.cin();
    let a = ell / 3.0;
    put!(a * a * a);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}

int main(){
	int n;
	int i,j,k;
	cin>>n;
	if(n==3){
		cout<<2<<endl;
		cout<<1<<" "<<3<<endl;
		cout<<2<<" "<<3<<endl;
	}else if(n==4){
		cout<<4<<endl;
		cout<<1<<" "<<2<<endl;
		cout<<1<<" "<<3<<endl;
		cout<<4<<" "<<2<<endl;
		cout<<4<<" "<<3<<endl;
	}else if(n%2==0){
		cout<<n*2<<endl;
		for(i=0;i<n/2;i++){
			j=i+1;
			if(j==n/2)j=0;
			cout<<i+1<<" "<<j+1<<endl;
			cout<<i+1<<" "<<n-j<<endl;
			cout<<n-i<<" "<<j+1<<endl;
			cout<<n-i<<" "<<n-j<<endl;
		}
	}else{
		cout<<n*2-2<<endl;
		n--;
		for(i=0;i<n/2-1;i++){
			j=i+1;
			cout<<i+1<<" "<<j+1<<endl;
			cout<<i+1<<" "<<n-j<<endl;
			cout<<n-i<<" "<<j+1<<endl;
			cout<<n-i<<" "<<n-j<<endl;
		}
		n++;
		cout<<n/2<<" "<<n<<endl;
		cout<<n/2+1<<" "<<n<<endl;
		cout<<1<<" "<<n<<endl;
		cout<<n-1<<" "<<n<<endl;
	}
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    ll ans = 0;
    for (ll i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int x = h1*60+m1;
    int y = h2*60+m2;
    int ans = 0;
    REP(i, x, y) {
        if(i+k < y) ++ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
    int a,b,h,i=3;
    cin>>a>>b>>h;
    if(a==b&&a==h)i=i-2;
    if(a==h&&a!=b)i=i-1;
    if(a==b&&a!=h)i=i-1;
    if(b==h&&b!=a)i=i-1;
    cout<<i<<endl;
}

Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main(){
	string s;
	cin >> s;
	long long int l = s.length();
	long long int k;
	k = (l+1)/2;
	//printf("ret = %lld\n",ret);
	
	long long int i = l/2-1;
	long long int j = l%2==0 ? i+1 : i+2;
	//printf("i = %lld, j = %lld\n",i,j);
	//printf("s[i] = %c, s[j] = %c\n",s[i],s[j]);
	
	if ((l%2!=0 && s[i]!=s[i+1])||(s[i]!=s[j])){
		cout << k << endl;
		return 0;
	}
	
	REP(m,l/2){
		if ((s[i]!=s[i-1])||(s[j]!=s[j+1])){
			k += m+1;
			cout << k << endl;
			return 0;
		}else{
			i--; j++;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[104];
	int minord=9999999;
	int sum=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=1;i<=100;i++){
		sum=0;
		for(int j=1;j<=n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<minord) minord=sum;
	}
	cout<<minord;
} 

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

void swap(string &a, string &b){
	string tmp = a;
	a = b;
	b = tmp;
}
void swapi(int &a, int &b){
	int tmp = a;
	a = b;
	b = tmp;
}

int getn(string &s){
	char c = s.at(1);
	return c-'0';
}

int main(){
	int n;
	string a[101];
	string b[101];
	string c[101];
	int indb[101];
	int indc[101];
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		b[i] = a[i];
		c[i] = a[i];
		indb[i] = i;
		indc[i] = i;
	}

	for(int i=0; i<n; i++){
		for(int j=n-2; j>=i; j--){
			if(getn(b[j])>getn(b[j+1])){
				swap(b[j], b[j+1]);
				swapi(indb[j], indb[j+1]);
			}
		}
	}

	for(int i=0; i<n; i++){
		int mn= getn(c[i]);
		int mni = i;
		for(int j=i; j<n; j++){
			if(mn>getn(c[j])){
				mn = getn(c[j]);
				mni = j;
			}
		}
		if(i!=mni){
			swap(c[i], c[mni]);
			swapi(indc[i], indc[mni]);
		}
	}

	int fs = 1;
	for(int i=0; i<n-1; i++){
		if(getn(b[i])==getn(b[i+1]) && indb[i]>indb[i+1]) fs = 0;
	}
	for(int i=0; i<n-1; i++){
		cout << b[i] << " ";
	}
	cout << b[n-1] << endl;
	if(fs==0) cout << "Not stable" << endl;
	else cout << "Stable" << endl;

	fs = 1;
	for(int i=0; i<n-1; i++){
		if(getn(c[i])==getn(c[i+1]) && indc[i]>indc[i+1]) fs = 0;
	}
	for(int i=0; i<n-1; i++){
		cout << c[i] << " ";
	}
	cout << c[n-1] << endl;
	if(fs==0) cout << "Not stable" << endl;
	else cout << "Stable" << endl;
	return 0;
}

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

int N;
char S[114514];
string T;

int main() {
  scanf("%s", S);
  N = strlen(S);
  for (int i=0; i<N; i++) {
    if (S[i] != 'x') T += S[i];
  }

  int m = T.size();
  for (int i=0; i<m; i++) {
    if (T[i] != T[m-1-i]) {
      puts("-1");
      return 0;
    }
  }

  if (T.size() == 0) {
    puts("0");
    return 0;
  }

  int k = m/2;
  int cnt = 0;
  int l, r;
  for (int i=0; i<N; i++) {
    if (S[i] != 'x') {
      if (m%2 == 0) {
        if (k-1 == cnt) l = i;
        if (k == cnt) r = i;
      } else {
        if (k == cnt) {
          l = i;
          r = i;
        }
      }
      cnt++;
    }
  }
  //printf("m %d idx :%d k %d cnt %d\n", m, idx, k, cnt);

  int ans = 0;
  //printf("l, r: %d %d\n", l, r);
  while (r < N || l >= 0) {
    if (r < N && l >= 0) {
      if (S[r] != S[l]) {
        if (S[r] == 'x') {
          ans++;
          r++;
        } else if (S[l] == 'x') {
          ans++;
          l--;
        } else assert(0);
      } else {
        r++;
        l--;
      }
    } else if (r < N) {
      assert(S[r] == 'x');
      ans++;
      r++;
    } else if (l >= 0) {
      assert(S[l] == 'x');
      ans++;
      l--;
    }
  }

  printf("%d\n", ans);
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
int k,x;
cin >> k >> x;

for (int i = max(x-k +1,-1000000); i <= min(x+k-1,1000000); ++i){
	printf("%d ", i);
}
cout << "\n";

return 0;
}


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

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


const int MAX_V = 100010;
struct edge {
    int to,cost;
};

int n;
vector<edge> G[MAX_V];  //重み付き有効グラフの隣接リスト表現
int d[MAX_V];


void dijkstra(int s){
    //greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>,greater<P> > que;
    fill(d,d+n,inf);
    d[s] = 0;
    que.push(P(0,s));

     while(!que.empty()){
         P p = que.top(); que.pop();     // firstは最短距離、secondは頂点の番号
         int v = p.second;
         if(d[v] < p.first) continue;  
         for(int i = 0; i < G[v].size(); i++){
             edge e = G[v][i];
             if(d[e.to] > d[v] + e.cost){
                // 現在のd[]の要素とくらべて小さいものだけ追加するため、高速に計算可能
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to],e.to));    
             }
         }
    }
}


int main()
{
    string s;
    cin >> s;
    string t;
    int n = s.size();
    int g = 0,p = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'g'){
            if(p+1 <= g){
                t += 'p';
                p++;
            }else{
                t += 'g';
                g++;
            }
        }else{
            if(p+1 <= g){
                t += 'p';
                p++;
            }else{
                t += 'g';
                g++;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'g' && t[i] == 'p')ans++;
        if(s[i] == 'p' && t[i] == 'g')ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<iostream>
#include<map>
using namespace std;

map<char,int> mp;

string S;
int main (){
    cin >> S;
    for(int i=0;i<4;i++) mp[S[i]]++;
    if(mp.size() == 2 && mp[S[0]] == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 764
import collections


class Solution:
    def solve(self, N: int, a) -> int:

        def numFactor(n: int, d: int) -> int:
            if d < 2:
                return -1
            else:
                cnt = 0
                tmp = n
                while tmp % d == 0:
                    cnt += 1
                    tmp //= d

                return cnt

        answer = 0

        for ai in a:
            answer += numFactor(ai, 2)

        return answer


if __name__ == '__main__':

    # standard input
    N = int(input())

    a = list(map(int, input().split()))

    # solve
    solution = Solution()
    ans = solution.solve(N, a)

    print(ans)


Measured memory_bytes: 4524
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		String S = fs.next();

		if(S.charAt(2)==S.charAt(3)&&S.charAt(4)==S.charAt(5))
		System.out.println("Yes");
		else
		System.out.println("No");
		
 
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

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

	}
	
}


Measured memory_bytes: 21204
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

// https://atcoder.jp/contests/abc146/tasks/abc146_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		sc.close();


		String[] day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

		List<String> list = Arrays.asList(day);
		System.out.println(day.length-list.indexOf(S));

	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N){
  ll ans=0;
  if(N%2){
    op(0)
    return;
  }
  for(ll i=10;i<=N;i*=5){
    ans+=N/i;
  }
  op(ans)
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i) --)

#define endl '\n'
#define all(x) x.begin(),x.end()
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back

#define M 1000000007

#define pi 3.1415926535897932384626433832795028
#define F first
#define S second
int gcd(int a,int b){
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
ll lcm(ll a, ll b){
	return (a*b)/gcd(a,b);
}
ll fast_exp(ll base, ll exp){
	ll res = 1;
	while(exp>0){
		if(exp%2==1) res = ((res%M)*(base%M))%M;
		base = ((base%M)*(base%M))%M;
		exp/=2;
	}
	return res%M;
}
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
vector < int > A[26];
int main(){
	std::ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	rep(i,s.length()-1){
		//cout<<s[i]<<" "<<s[i+1]<<endl;
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
	}
	rep(i,s.length()-2){
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}
	cout<<"-1 -1"<<endl;
	return 0;
}

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

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, 0, n) cin >> l[i];
    sort(all(l));
    reverse(all(l));
    int ans = 0;
    rep(i, 0, k){
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun c87(args: Array<String>) {
    val numList = args.drop(1).map { it.split(" ").map { it.toInt() } }

    fun dfs(x: Int, y: Int): Int {
        when {
            x == numList.size - 1 && y == numList[0].size - 1 ->
                return numList[x][y]
            x == numList.size - 1 ->
                return numList[x][y] + dfs(x, y + 1)
            y == numList[0].size - 1 ->
                return numList[x][y] + dfs(x + 1, y)
            else ->
                return Math.max(
                        numList[x][y] + dfs(x, y + 1),
                        numList[x][y] + dfs(x + 1, y))
        }
    }

    println(dfs(0, 0))
}

fun main(args: Array<String>) {
    c87(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

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

using namespace std;

typedef long long int lli;

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

    string s;
    cin >> s;
    int len = s.size();
    vector<int> ans(len, 0);

    // R->L
    for (int i=0; i<len-1; i++) {
        if (s[i] == 'R' && s[i+1] == 'L') {
            for (int j=1; (i+j)<len && s[i+j]=='L'; j++) {
                ans[i+(j%2)]++;
            }
        }
    }

    // L->R
    for (int ri=0; ri<len-1; ri++) {
        int i = len-ri-1;
        if (s[i] == 'L' && s[i-1] == 'R') {
            for (int j=1; (i-j)>-1 && s[i-j]=='R'; j++) {
                ans[i-(j%2)]++;
            }
        }
    }

    for (int i=0; i<len; i++) cout << ans[i] << ((i!=len-1) ? " " : "\n");

    return 0;
}


Measured memory_bytes: 1104
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li a;
    cin >> a;
    li ans = 0, aa = a;
    for (int i = 0; i < 3; ++i) {
        ans += aa;
        aa *= a;

    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e6 + 21;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
 
int n, m, mn[N], f[N];
string t[N];
char s[N];
 
bool cmp (pii a, pii b) {
	return mp(min(a.f, a.s + b.f), a.f) > mp(min(b.f, b.s + a.f), b.f);
}
 
 
main () {
	scanf("%d", &n);
	int bal = 0;
	for (int i = 1; i <= n; ++i) {
		scanf("\n%s", s);
		m = strlen(s);
		for (int j = 0; j < m; ++j) {
			t[i] += s[j]; 
			if (s[j] == '(')
				++bal;
			else
				--bal;
		}
	}
 
	if (bal) {
		cout << "No";
		return 0;
	}

	vpii v;

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < sz(t[i]); ++j) {
			if (t[i][j] == '(')
				++f[i];
			else
				--f[i];	
			mn[i] = min(mn[i], f[i]);
		}		
		 
		v.pb({mn[i], f[i]});
	}	


	sort(all(v), cmp);
	for (auto x : v) {
		if (bal + x.f < 0) {
			cout << "No";
			return 0;
		}
		bal += x.s;			
	}
		
 
	cout << "Yes";
}

Measured memory_bytes: 50376
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll ans = 0, N;

void rec(vector<bool> already, ll now, ll index)
{
  ll res = 0;
  bool t3 = already.at(0), t5 = already.at(1), t7 = already.at(2);
  if (now > N) {
    return;
  }
  if (t3 && t5 && t7) {
    ans += 1;
  }

  rec({true, t5, t7}, now + 3 * pow(10, index), index + 1);
  rec({t3, true, t7}, now + 5 * pow(10, index), index + 1);
  rec({t3, t5, true}, now + 7 * pow(10, index), index + 1);
}

int main()
{
  cin >> N;
  rec({false, false, false}, 0, 0);
  cout << ans << endl;
}


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

long double dp[302][302][302];

long long n;

long double Shushi(long long a,long long b,long long c)
{
        if(dp[a][b][c]!=-1)return dp[a][b][c];
        long double k=a+b+c;
        long double undhu=(long double)n/k;
        long double curr=0;
        if(a>0)
        {
            //1
            curr+=(Shushi(a-1,b,c)+undhu)*(a/k);
        }
        if(b>0)
        {
            //2
            curr+=(Shushi(a+1,b-1,c)+undhu)*(b/k);
        }
        if(c>0)
        {
            //3
            curr+=(Shushi(a,b+1,c-1)+undhu)*(c/k);
        }
        
        return dp[a][b][c]=curr;
}


int main()
{
  for(int i=0;i<=301;i++)
  {
      for(int j=0;j<302;j++)
      {
          for(int k=0;k<=301;k++)
          {
              dp[i][j][k]=-1;
          }
      }
  }
 
    
    cin>>n;
    int arr[n];
    long long c1=0,c2=0,c3=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]==1)
        {
            c1++;
        }
        else if(arr[i]==2)
        {
            c2++;
        }
        else
        {
            c3++;
        }
    }
    

    long double res=Shushi(c1,c2,c3);
    cout<<setprecision(15)<<res<<"\n";
}

Measured memory_bytes: 430720
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from queue import PriorityQueue as pq

# from itertools import accumulate
# from collections import deque
import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    eprint(l)
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    eprint(l)
    l.sort()
    eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()


Measured memory_bytes: 66156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll factor(ll n) {
  ll res = 0;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      res++;
      if(n / i != i) res++;
    }
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = factor(n - 1) + 1;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i) continue;
    ll m = n;
    while(m % i == 0) m /= i;
    if(m % i == 1) ans++;
  }
  if(n != 2) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char cc[200010];
int main(){
	scanf("%s",cc);
	int i,j,k,l=strlen(cc);
	for(i=0;i<l;i++){
		if(cc[i]=='?'){
			cout<<"D";
		}
		else cout<<cc[i];
	}
}

Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>

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

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,k;
    int count = 0;
    vector<int> a;
    std::vector<int>::iterator itr = a.begin();

    cin >> N;
    REP(i,N) {
        cin >> k;
        a.push_back(k);
    }

    for(auto itr = a.rbegin(); itr != a.rend(); ++itr) {
        *itr;
        while(*itr%2 == 0){
            count++;
            *itr = *itr/2;
        }
    }

    cout << count << endl;


    

    return 0;
}

Measured memory_bytes: 384
#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,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
vector<mint> dp(110000);
int main(){
    ll n,k;cin>>n>>k;
    mint ans=0;
    for(ll i=k;i>0;i--){
        dp[i]=mint(k/i).pow(n);
        for(ll j=2*i;j<=k;j+=i){
            dp[i]-=dp[j];
        }
        ans+=dp[i]*i;
    }
    cout<<ans.x<<endl;
    return 0;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{

    ll n;
    cin>>n;
    ll ans=0;
    ll d=n-1;
    int i=1;
    while(d>=sqrt(n))
    {
        i+=1;
        if(n/d==n%d)
        {
            ans+=d;

        }
        d=(n-1)/i;     
    }
    cout<<ans;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==1){
    ll a=(ll)B.at((N-1)/2)-(ll)A.at((N-1)/2)+(ll)1;
    ll b=(ll)A.at((N-1)/2)-(ll)B.at((N-1)/2)+(ll)1;
    cout<<max(a,b)<<endl;
  }
  if(N%2==0){
    ll a=(ll)B.at(N/2)+(ll)B.at(N/2-1)-((ll)A.at(N/2)+(ll)A.at(N/2-1))+(ll)1;
    ll b=(ll)A.at(N/2)+(ll)A.at(N/2-1)-((ll)B.at(N/2)+(ll)B.at(N/2-1))+(ll)1;
    cout<<max(a,b);
  }
}

Measured memory_bytes: 6424
// Dedication has no limitation
// 24 June 2019
// Omori, Japan.
#include <bits/stdc++.h>
using namespace std;

int main(){
string s; cin >> s;
  int cnt = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i] == s[i+1]){
    	cnt++;
    	cout << "Bad" << endl;
    	return 0;
    }
  }

  cout << "Good" << endl;
  return 0;




}


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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))



#define REP(i,n) for(i=0;i<n;i++)
//二次元配列の文字列を使いたくなったので代わりに構造体を使用した。

typedef struct{
  int a;
  char s[15];
  int p;
}Restaurant_t;

int strsort(const void*a, const void*b){//おまじない
  long long P = strcmp(((Restaurant_t*)a)->s,((Restaurant_t*)b)->s);
  long long Q = ((Restaurant_t*)b)->p-((Restaurant_t*)a)->p;
  if(P!=0){//名前が異なる
    return P;
  }else if(Q!=0){
    return Q;
  }else{
    return 0;
  }
}

int main(void)
{
  int i;
  int n;
  scanf("%d",&n);
  Restaurant_t Restaurant[n];
  REP(i,n){
    scanf("%s%d",Restaurant[i].s,&Restaurant[i].p);
    Restaurant[i].a = i+1;
  }
  qsort(Restaurant,n,sizeof(Restaurant_t),strsort);
  REP(i,n){
    printf("%d\n",Restaurant[i].a);
  }

  return 0;
}
/*int i;
i = strcmp("ai","aio");
printf("%d",i);

return 0;*/


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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[100005];
ll finv[100005];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return -1;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll d,t,s;
    cin>>d>>t>>s;
    if(d/s<t||d/s==t&&d%s==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int s(int n){
    return n*(n+1)/2;
}

void run(){
    int n;
    cin>>n;
    cout<<s(n)-s(n/3)*3-s(n/5)*5+s(n/15)*15<<endl;
}

Measured memory_bytes: 3620
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516
#include <iostream>
#include <algorithm>
#include <vector>
#define INF (1<<30)
#define ll long long
using namespace std; 
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (true) {
		ll n, k; cin >> n >> k;
		if (n == 0 && k == 0)break;
		vector<ll> Sum(n + 1);
		Sum[0] = 0;
		for (int i = 1; i <= n;i++) {
			ll N; cin >> N;
			Sum[i] = Sum[i - 1] + N;
		}
		ll ans = -INF;
		for (int i = 1; i <= n - k + 1;i++) {
			ans = max(ans, Sum[i+k-1] - Sum[i - 1]);
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,M,Q;
    cin>>N>>M>>Q;
    int A[509][509];
    int B[509][509];
    int s[200009];
    int g[200009];
    int ans=0;
    for(int i=1;i<=M;i++){
        cin>>s[i]>>g[i];
        A[s[i]][g[i]]+=1;
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            B[i][j]=B[i][j-1]+A[i][j];
        }
    }
    for(int i=1;i<=Q;i++){
        int s,g;
        cin>>s>>g;
        ans=0;
        for(int j=s;j<=g;j++){
            ans+=B[j][g]-A[j][s-1];}
        cout<<ans<<endl;
        
        
    }
}


Measured memory_bytes: 4480
#include <stdio.h>
#include <stdlib.h>
int main(){
  int h,w;
  char a[6];
  scanf("%d%d",&h,&w);
  for(int i=0;i<h;i++)for(int j=0;j<w;j++){
    scanf("%s",a);
    if(!(strcmp(a,"snuke")))printf("%c%d",'A'+j,1+i);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main(){
  string h;
  int A;
 
  for(;;){
    int sum = 1,top = 1,dice[4] = {2,3,4,5};
    cin >> A;
    if(A == 0) break;
    for(int i = 0 ; i < A ; i++){
      cin >> h;
      int tmp = top;
      if( i == 0 ) top = 1;
      if(h == "North"){
    top = dice[0];
    dice[0] = 7 - tmp;
    dice[3] = tmp;
      }
      else if(h == "East"){
    top = dice[2];
    dice[2] = 7 - tmp;
    dice[1] = tmp;
      }
      else if(h == "West"){
    top = dice[1];
    dice[1] = 7 - tmp;
    dice[2] = tmp; 
      }
      else if(h == "South"){
    top = dice[3];
    dice[3] = 7 - tmp;
    dice[0] = tmp;
      }
      else if(h == "Right"){
    tmp = dice[3];
    dice[3] = dice[2];
    dice[2] = dice[0];
    dice[0] = dice[1];
    dice[1] = tmp;
      }
      else{
    tmp = dice[3];
    dice[3] = dice[1];
    dice[1] = dice[0];
    dice[0] = dice[2];
    dice[2] = tmp; 
      }
      sum += top;
    }
    cout << sum << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353
#define dd double
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int> 
#define int long long 
#define pii pair<int,int>
#define mx 1000000000
#define level 15

int get(int x){
    
}

void solve(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int ans=(h2-h1)*60+(m2-m1)-k;
    cout<<ans<<endl;
}

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

    int t=1;
    // cin>>t;
    rep(i,1,t+1){
        solve();
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
bool chk(string s, int k) {
  if (k > 1) {
    int l = k - 2;
    while (l > 0) {
      if (s[l] >= s[k]) {
        return false;
      }
      l--;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  char s[n];
  rep(i,n)
  {
    s[i] = 'a';
  }
  while (true) {
    rep(z,n)
    {
      cout << s[z];
    }
    cout << endl;
    int k = n - 1;
    while (k > 0) {
      if (s[k - 1] < s[k] && chk(s, k)) {
        s[k] = 'a';
        k--;
      } else {
        s[k] += 1;
        break;
      }
    }
    if (k == 0) {
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
string s,t;
int res(string a,string b){
	int cnt=0;
	rep(i,sz(a))
	if(a[i]!=b[i])
	cnt++;
	re cnt;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>s>>t;
	int ans=10000;
	rep(i,sz(s)-sz(t)+1){
		ans=min(res(s.substr(i,sz(t)),t),ans);
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3616
using System;

namespace abc91_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int[] inputs = new int[array.Length];
            for(int i = 0; i < array.Length; i++)
            {
                inputs[i] = int.Parse(array[i]);
            }
            if (inputs[0] + inputs[1] >= inputs[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
struct Record {
	int worker, task, count;
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<Record> records;
	while (true) {
		Record rec;
		std::cin >> rec.worker >> rec.task >> rec.count; if (rec.worker == 0) break;
		--rec.worker; --rec.task; records.push_back(rec);
	}
	int l; std::cin >> l;
	std::vector<long long int> salary(n, 0), cost(m);
	for (auto i = 0; i < l; ++i) {
		std::fill(salary.begin(), salary.end(), 0);
		for (auto& c : cost) std::cin >> c;
		for (const auto rec : records) {
			salary[rec.worker] += rec.count * cost[rec.task];
		}
		for (auto i = 0; i < n; ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << salary[i];
		}
		std::cout << '\n';
	}
}



Measured memory_bytes: 3764