akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:usize,
        x:i64,
        an:[i64;n],
    }
    let mut dist = vec![];
    for j in 0..n {
        let diff = (x-an[j]).abs();
        dist.push(diff);
    }
    let ans = dist.iter().fold(dist[0],|y,&x|gcd(y, x));
    println!("{}",ans);
}
fn gcd(a:i64,b:i64) -> i64{
    if b == 0 {
        a
    } else {
        gcd(b, a%b)
    }
}

Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int Q = sc.nextInt();
		int[] Y = new int[N + 2];
		String[] name = new String[N + 1];
		name[0] = "kogakubu10gokan";
		for (int i = 0; i < N; ++i) {
			Y[i + 1] = sc.nextInt();
			name[i + 1] = sc.next();
		}
		Y[N + 1] = 100;
		for (int i = 0; i < N + 1; ++i) {
			if (Y[i] <= Q && Q < Y[i+1]) {
				System.out.println(name[i]);
				break;
			}
		}
	}

}

Measured memory_bytes: 18208
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <functional>
#include <map>
#include <string>
#include <cmath>
using namespace std;
#define INF 1000000000;
#define MOD 1000000007;
typedef long long int ll;
int main(void){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        if(i>=k){
            ans+=1.0/(double)n;
        }else{
            int cnt=0;
            int now=i;
            while(now<k){
                now*=2;
                cnt++;
            }
            double prob=pow(0.5,cnt);
            //cout<<prob<<endl;
            ans+=(1.0/(double)n)*prob;
        }
    }
    printf("%.9f\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char* argv[])
{
int i;
int atai[3];
for (i = 0; i < 3; i++) {
char num[5];
scanf("%s",&num);
atai[i] = atoi(num);
}
int  ans;
ans = (atai[0] + atai[1]) * atai[2] / 2;
printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int sum[100005];
int x[100005], y[100005];

int abs(int x) {
    return max(x, -x);
}

int dis(int i, int j) {
    if (i <= 0 || j <= 0) return 0;
    return abs(x[i] - x[j]) + abs(y[i] - y[j]);
}
int main() {
    int n, m, d, tmp;
    scanf("%d%d%d", &n, &m, &d);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            scanf("%d", &tmp);
            x[tmp] = i;
            y[tmp] = j;
        }
    }
    for (int j = d + 1; j <= n * m; ++j) {
        sum[j] = sum[j - d] + dis(j, j - d);
    }
    int Q;
    scanf("%d", &Q);
    for (int i = 1; i <= Q; ++i) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", sum[r] - sum[l]);
    }
    return 0;
}

Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var n = Sarray()[0];
            var ans = "";
            while(0<n)
            {
                n -= 1;
                ans += (char)('a' + n % 26);
                n /= 26;
            }
            WriteLine(string.Join("",ans.Reverse()));
        }
    }
}


Measured memory_bytes: 18892
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
// other libs

signed main(int argc, char* argv[]) {
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
}


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

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


#define ll long long

int n, c = 0;

void dfs(ll i,int t,int f,int s) {
	if (i > n) return;
	if (t && f && s) ++c;
	dfs(i*10+3,t+1,f,s),
	dfs(i*10+5,t,f+1,s),
	dfs(i*10+7,t,f,s+1);
}

int main() {
	scanf("%d", &n);
	dfs(0,0,0,0),

	printf("%d\n", c);
	return 0;
}



Measured memory_bytes: 128
A, B, C, D, E, F = map(int, input().split())
dp = [-1]*(F+1)
dp[0] = 0

amount, ans = 1, 0
for i in range(1, F+1):
    if i < A*100:
        continue

    if i >= A*100 and dp[i-A*100] != -1:
        dp[i] = max(dp[i], dp[i-A*100])
    if i >= B*100 and dp[i-B*100] != -1:
        dp[i] = max(dp[i], dp[i-B*100])

    if i >= C and dp[i-C] != -1 and (dp[i-C]+C)/(i-C-dp[i-C]) <= E/100:
        dp[i] = max(dp[i], dp[i-C]+C)
    if i >= D and dp[i-D] != -1 and (dp[i-D]+D)/(i-D-dp[i-D]) <= E/100:
        dp[i] = max(dp[i], dp[i-D]+D)

    if ans/amount <= dp[i]/i:
        amount = i
        ans = dp[i]
print(amount, ans)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n;
    cin >> n;
    vector<int> l(2*n);
    rep(i, 2*n) cin >> l[i];

    sort(l.begin(), l.end());

    int ans = 0;
    for(int i = 0; i < 2*n; i+=2) ans += l[i];

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

struct block {
    ll w, s, v;

    block() : w(0), s(0), v(0) {}

    bool operator<(const block& other) const {
        return w + s > other.w + other.s;
    }
};

const int MAXN = 1000, MAXS = 10000;

int N;
ll dp[MAXN + 1][MAXS + 1];
vector<block> b;

ll tower(int i, int j) {
    if (i == N || j == 0)
        return 0;
    if (dp[i][j] == -1) {
        dp[i][j] = tower(i + 1, j);
        if (b[i].w <= j)
            dp[i][j] = max(dp[i][j], b[i].v + tower(i + 1, min(b[i].s, j - b[i].w)));
    }
    return dp[i][j];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    b.resize(N);
    for (int i = 0; i < N; i++)
        cin >> b[i].w >> b[i].s >> b[i].v;
    sort(b.begin(), b.end());
    memset(dp, 0, sizeof dp);
    for (int i = N - 1; i >= 0; i--) {
        for (int j = MAXS; j >= 0; j--) {
            dp[i][j] = dp[i + 1][j];
            if (b[i].w <= j)
                dp[i][j] = max(dp[i][j], b[i].v + dp[i + 1][min(b[i].s, j - b[i].w)]);
        }
    }
    ll result = 0;
    for (int i = 0; i < N; i++)
        result = max(result, b[i].v + dp[i + 1][b[i].s]);
    cout << result << endl;
}


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

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();

        line = line.replaceAll("apple", "pea-ch");
        line = line.replaceAll("peach", "apple");
        line = line.replaceAll("pea-ch", "peach");

        System.out.println(line);
    }
}


Measured memory_bytes: 24064
#include<bits/stdc++.h>
using namespace std;
#define PI          acos(-1)
#define INF         0x3f3f3f3f
#define sc(n)       scanf("%d",&n);
#define ssc(n)      scanf("%s",n);
#define lsc(n)      scanf("%lld",&n);
#define dsc(n)      scanf("%lf",&n);
#define LL          long long int
#define UI          unsigned int
#define ULL         unsigned long long int
#define DB          double
#define pii         pair<int,int>
#define VI          vector<int>
#define MII         map<int,int>
#define PB          push_back
#define MP          make_pair
#define M(mx,a)     mx=max(mx,a)
#define IT          ::iterator
#define all(a)      a.begin(),a.end()
#define mems(a,b)   memset(a,b,sizeof(a))
#define F(i,a,b)    for(i=a;i<b;i++)
#define IN(n,aa)    for(i=0;i<n;i++)scanf("%d",&aa[i]);
#define PNT(n,aa)   for(i=0;i<n;i++)printf("%lld ",aa[i]);
#define mod         1000000007
#define NUM         100009
#define NUM2        1000000000



int main()
{
    int T=1,QQ=0;
    //cin >> T ;
    while(T--)
    {
        LL n,m;
        lsc(n)lsc(m)
        n%=m;
        n=min(n,m-n);
        cout << n ;
    }
}
//printf("Case %d: ",++QQ);


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int H, W, h, w;
    std::cin >> H >> W >> h >> w;

    std::cout << H*W - W*h - (H-h)*w << std::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++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    ll a,b,n;cin >> a >> b >> n;
    ll l = 0, r = n;
    auto calc =[&](ll num){
        return (a*num)/b -  a * (num/b);
    };
    int cnt = 0;
    while(r - l > 1 && cnt <= 100000){
        ll left = (2*l + r) / 3;
        ll right = (l + 2*r) / 3;
        ll A = calc(left), B = calc(right);
        if(A == B){
            break;
        }
        else if(A < B){
            l = left;
        }else{
            r = right;
        }
        ++cnt;
    }
    ll ans = max({calc(l), calc(r)});
    for(int i=0;i<=min(10000000LL, n);++i){
        chmax(ans, calc(i));
    }

    for(int i=n;i>=max(0LL, n-10000000LL);--i){
        chmax(ans, calc(i));
    }
    if(b-1 <= n){
        chmax(ans, a*(b-1)/b);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;


int main(){

  string s;
  cin >> s;
  vector<bool> a(26, false);
  for(int i=0; i<s.size(); i++){
    a[s[i]-'a'] = true;
  }

  for(int i=0; i<26; i++){
    char c = 'a' + i;
    if( !a[i] ){
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;


  return 0;
}





//


Measured memory_bytes: 512
import math
def near_sqrt(a,b):
  c = a * b
  d = math.floor(math.sqrt(c))
  if d*(d+1) < c:
    return d
  else:
    return (d-1)
  
q = int(input())
for i in range(q):
  a,b = map(int, input().split())
  c = near_sqrt(a,b)
  d = (a*b)%(c+1)
  if d == 0 and a!=b:
    print(math.floor((a*b)/(c+1))+c-2)
  else:
    print(math.floor((a*b)/(c+1))+c-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;

string s;
int x, y;
vector<int> vecx, vecy;

bool dp[4005][16005];

bool calcDP(vector<int> &vec, int dst)
{
	const int zero = 8002;
	for(int i = 0; i <= vec.size(); i++){
		for(int j = 0; j < 16005; j++){
			dp[i][j] = false;
		}
	}
	dp[0][zero] = true;
	
	for(int i = 0; i < vec.size(); i++){
		for(int j = 0; j < 16005; j++){
			if(!dp[i][j]) continue;
			if(j - vec[i] >= 0) dp[i+1][j - vec[i]] = true;
			if(j + vec[i] < 16005) dp[i+1][j + vec[i]] = true;
		}
	}
	
	if(zero + dst >= 16005 || zero + dst < 0) return false;
	return dp[vec.size()][zero + dst];
}

int main(void)
{
	cin >> s;
	cin >> x >> y;
	s += "T";
	
	bool flag = false;
	int cnt = 0, dir = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'T'){
			if(!flag){
				x -= cnt;
				flag = true;
			}
			else{
				if(!dir) vecx.push_back(cnt);
				else vecy.push_back(cnt);
			}
			cnt = 0, dir = !dir;
		}
		else cnt++;
	}
	
	if(calcDP(vecx, x) && calcDP(vecy, y)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 62336
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,x,l;
	cin >> n >> x;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	ll tmp;
	if (a[0] > x) {
		tmp = a[0] - x;
		a[0] -= tmp;
		ans += tmp;
	}
	for(int i = 1; i < n; i++) {
		if (a[i - 1] + a[i] > x){
			tmp = a[i] - (x - a[i - 1]);
			a[i] -= tmp;
			ans += tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    ll A = 1,B = 1;
    rep(i,0,N){
        ll x,y;
        cin >> x >> y;
        ll xi = (A + x - 1) / x;
        ll yi = (B + y - 1) / y;
        x *= max(xi,yi);    
        y *= max(xi,yi);
        A = x;B = y;
    }
    cout << A + B << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(c>=a&&c<=b){
			System.out.println("Yes");
		}
		else System.out.println("No");
	}
}

Measured memory_bytes: 21716
import java.util.*;

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


        for (int i=0; i<s.length(); i++) {
            s = s.replace(s.charAt(i),'x');
        }

        System.out.println(s);

    }
}


Measured memory_bytes: 23764
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int n,m,k,a[105][105];
int main(){
	splay(n),splay(m),splay(k);
	int x=1,y=1,p=1;
	for(int i=1;i<=k;i++){
		int t;splay(t);
		for(int j=1;j<=t;j++){
			a[x][y]=i;
			y+=p;
			if(y==0||y==m+1){
				if(y==0)y=1;
				else y=m;
				x++;p=-p;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			printf("%d ",a[i][j]);
		}
		puts("");
	}
}

Measured memory_bytes: 384
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}
const int N=1e5+5;
ll arr[N];
void solve(){
	int n;
	cin>>n;
	map < int , int > m1,m2;
	set< int > s;
	for ( int i=0;i<n;i++){
		cin>>arr[i];
		s.insert( arr[i]);
		if ( i%2)
			m1[arr[i]]++;
	}
	sort( arr,arr+n);
	for ( int i=0;i<n;i++){
		if ( i%2)
			m2[arr[i]]++;
	}
	int tot=0;
	for ( auto i: s){
		tot+=abs(m1[i]-m2[i]);
	}
	cout<<tot/2<<'\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

Measured memory_bytes: 18488
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string S;
  cin >> S;
  int N = stoi(S);
  int sn = 0;
  for(int i = 0; i <S.size();i++){
    sn += (int) (S[i] - '0');
    // cout << sn << endl;
  }
  // cout << sn << endl;
  if (N % sn == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPD(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define INF 100000000000000

ll m, n;
ll answer;


int code(){
    answer = ((m*(m-1))/2) + ((n*(n-1))/2);

    return 0;
}

int main(){
    cin >> m >> n;
    code();
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 632
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
min_temp = 10**10

for i in range(n-k+1):
  temp = h[i+k-1] - h[i]
  if min_temp > temp:
    min_temp = temp
    
print(min_temp)

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

struct log{
  int month, day, hour, minute;
  char e;
  int p;
};

int myabs(int n){ return n >= 0 ? n : -n; }

int i_to_sit(string::iterator s, string::iterator e){
  int ans = 0;
  for(string::iterator t = s; t != e; t++){
    ans *= 10;
    ans += (*t - '0');
  }
  return ans;
}

int difftime(log a, log b){
  return myabs((a.hour * 60 + a.minute) - (b.hour * 60 + b.minute));
}

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    string input;
    vector<log> logbook;
    vector<log> goddess;
    int lastp = 0;    
    for(int i = 0; i < n; i++){
      log in;
      
      cin >> input;
      in.month = i_to_sit(input.begin(), input.begin() + 2);
      in.day = i_to_sit(input.begin() + 3, input.end());

      cin >> input;
      in.hour = i_to_sit(input.begin(), input.begin() + 2);
      in.minute = i_to_sit(input.begin() + 3, input.end());

      cin >> input;
      in.e = input[0];
      
      cin >> input;
      in.p = i_to_sit(input.begin(), input.end());
      
      logbook.push_back(in);
      lastp = lastp > in.p ? lastp : in.p;
    }
    ++lastp;
    
    vector<vector<int> > imos(lastp, vector<int>(n + 1, 0));
    for(int i = 0; i < n; i++)
      imos[logbook[i].p][i] = (logbook[i].e == 'I') ? 1 : -1;
    for(size_t i = 0; i < imos.size(); i++)
      for(size_t j = 1; j < imos[i].size(); j++)
        imos[i][j] += imos[i][j - 1];

    vector<int> blessed(lastp, 0);    
    for(int i = 1; i < lastp; i++)
      for(size_t j = 0; j < imos[i].size() - 1; j++)
        if(imos[i][j] == 1 && imos[0][j] == 1)
          blessed[i] += difftime(logbook[j], logbook[j + 1]);

    int maxp = 0, maxtime = 0;
    for(int i = 0; i < lastp; i++){
      if(blessed[i] > maxtime){
        maxtime = blessed[i];
        maxp = i;
      }
    }

    cout << blessed[maxp] << endl;    
  }

  return 0;
}

Measured memory_bytes: 4920
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define L_MAX 1e18
using ll = long long;
using ld = long double;
using ii = pair<ll,ll>;
using iii = tuple<ll,ll,ll>;
using matrix = vector<vector<ll>>;
using arr = vector<ll>;
using vs = vector<string>;
using pv = vector<ii>;
using umap = unordered_map<ll,ll>;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
void showArr(arr a){
    for(auto i : a) cout<<i<<" ";
    cout<<endl;
}
ll dx[]={-1,1,-1,1,0,0,-1,1};
ll dy[]={-1,1,0,0,-1,1,1,-1};
int main(){
    fast;
    ld r;
    cin>>r;
    cout<<fixed<<setprecision(5)<<2*3.1415926535*r<<endl;
    
    
    return 0;
}

Measured memory_bytes: 3808
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let S: Vec<char> = read_line().chars().collect();
    let mut good = true;
    for i in 0..S.len()-1 {
        if S[i] == S[i+1] {
            good = false;
            break;
        }
    }
    if good {
        println!("Good");
    } else {
        println!("Bad");
    }
}


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

using namespace std;

int main(int argc, char *argv[])
{
    

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int n;
    cin >> n;
    
    int a[30];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    int q;
    cin >> q;
    
    set<int> sum;
    
    
    for (int i = 0; i < ((1 << n) - 1); i++) {
        bitset<30> flag(i);
        int temp = 0;
        for (int k = 0; k < n; k++) {
            if (flag.test(k)) {
                temp += a[k];
            }
        }
        sum.insert(temp);
    }
    
    
    
    while (q--) {
        int test;
        cin >> test;
        if (sum.count(test) > 0) {
            cout << "yes" << endl;
            continue;
        }
        cout << "no" << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	using tiii = tuple<int, int, int>;
	int N; cin >> N;
	int tc = 0, xc = 0, yc = 0;
	bool f = true;
	rep(i, N) {
		int t, x, y; cin >> t >> x >> y;
		int dt = t - tc, d = abs(x - xc) + abs(y - yc);
		if (dt < d || (dt - d) % 2 == 1) {
			f = false;
			break;
		}
	}
	Yn(f);
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        if (N%2 == 1) {
            System.out.println("No");
            return;
        }
        boolean ans = true;
        for (int i = 0; i < N/2; i++) {
            if (S.charAt(i) != S.charAt(N/2+i)) {
                ans = false;
                break;
            }
        }
        System.out.println(ans ? "Yes" : "No");
    }
}


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

const int inf = 1<<29;
int n;
vector<int> d(110, inf);
vector< vector<bool> > G(110, vector<bool>(110, false));

void bfs(int s){

    queue<int> q;
    d[s] = 0;
    q.push(s);

    while(!q.empty()){
        int now = q.front(); q.pop();
        for(int i=1; i<=n; ++i){
            if(G[now][i] == true && d[now]+1 < d[i]){
                d[i] = d[now] + 1;
                q.push(i);
            }
        }
    }

}

int main(){
    cin >> n;

    for(int i=0; i<n; ++i){
        int id, k; cin >> id >> k;
        for(int j=0; j<k; ++j){
            int v; cin >> v;
            G[id][v] = true;
        }
    }

    bfs(1);

    for(int i=1; i<=n; ++i){
        cout << i << " ";
        if(d[i] == inf) cout << -1;
        else cout << d[i];
        cout << endl;
    }
}


Measured memory_bytes: 3156
n = int(input())

ans = float('inf')
for a in range(1, n):
    num = 0
    b = n - a
    if b < a:
        break
    while a:
        num += a % 10
        a = a // 10
    while b:
        num += b % 10
        b = b // 10
    ans = min(ans, num)

print(ans)




Measured memory_bytes: 3060
import math

a,b,c = map(int,raw_input().split())
c = math.radians(c)
s = (a*b*math.sin(c))/2
h = b*math.sin(c)
L = a+b+math.sqrt(math.pow(a,2)+math.pow(b,2)-2*a*b*math.cos(c))
print(s)
print(L)
print(h)

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


// 137_b
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] h = new long[n];
        // ArrayList<Integer> al = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            // al.add(sc.nextInt());
            h[i] = sc.nextInt();
        }

        Arrays.sort(h);

        for (int i = 0; i < k; i++) {
            if (!(n - 1 - i < 0)) {
                h[n - 1 - i] = 0;
            }
        }
        long count = 0l;
        for (int i = 0; i < n; i++) {
            count += h[i];
        }

        out(count);

    }

    /*
     * 以下メソッド集
     */

    static long gcd(long a, long b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {

        return (b == 0) ? a : gcd(b, a % b);
    }

    static void out(String info) {

        System.out.println(info);
    }

    static void out(int info) {

        System.out.println(info);
    }

    static void out(double info) {

        System.out.println(info);
    }

    static void out(long info) {

        System.out.println(info);
    }

}


Measured memory_bytes: 89788
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

#Union-Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N, M = map(int, input().split())
AB =  [list(map(int, input().split())) for _ in range(M)]
ans = 0
uf = UnionFind(N)

for i in range(M):
    uf.union(AB[i][0]-1, AB[i][1]-1)

for i in range(N):
    ans = max(ans,uf.size(i))

print(ans)


Measured memory_bytes: 109716
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  int n;
  int m=100000;
  cin>>n;
  rep(i,n){
    m*=1.05;
	if(m%1000)m+=1000;
	m-=m%1000;
  }
  cout<<m<<endl;
}
  

Measured memory_bytes: 1160
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int cnt = 0;
	rep(i, n-2) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'B' && s[i + 2] == 'C') {
				cnt += 1;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 


int main(){
    int n;cin >> n;
    vector<LL> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    LL ans = 0;
    vector<vector<LL>> dp(n+1);
    for (int i = 1; i < n; i++) {
        dp[i].pb(0);
        set<int> st;
        bool f = false;
        for (int j = 1; j < (n-1)/i; j++) {
            if(f||n-1-i*j==i*j||st.find(n-1-i*j)!=st.end()||st.find(i*j)!=st.end()){
                dp[i].pb(0);
                f=true;
            }
            else{
                st.insert(i*j);
                st.insert(n-1-i*j);
                dp[i].pb(dp[i][j-1]+s[n-1-i*j]+s[i*j]);
            }
        }
    }
    for (int c = 1; c < n-1; c++) {
        for (int k = 1; k < (n-1)/c; k++) {
            ans = max(ans,dp[c][k]);
        }
    }
    cout << ans << endl;
    return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N; cin >> N;
  string S; cin >> S;

  ll ans = 0;
  REP(a, 10) REP(b, 10) REP(c, 10) {
    auto pos = S.find((char)('0'+a));
    if (pos != string::npos) pos = S.find('0'+b, pos+1);
    if (pos != string::npos) pos = S.find('0'+c, pos+1);
    if (pos != string::npos) ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	
	class UnionFind{
		int [] par, rank;
		int num;
		public UnionFind(int n) {
			par = new int[n];
			rank = new int[n];
			for(int i = 0 ; i < n; i++){
				par[i] = i;
				//rank[i] = 0;
			}
			num = n;
		}
		int find(int x){
			if(par[x] == x)return x;
			else return par[x] = find(par[x]);
		}
		void unite(int x, int y){
			x = find(x);
			y = find(y);
			if(x == y) return ;
			if(rank[x] < rank[y]) par[x] = y;
			else{
				par[y] = x;
				if(rank[x] == rank[y]) rank[x]++;
			}
			num--;
		}
		boolean same(int x, int y){
			return find(x) == find(y);
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			
			UnionFind uf = new UnionFind(n+1);
			for(int i = 0; i <m; i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				uf.unite(a, b);
			}
			
			
			HashMap<Integer, HashSet<Integer>> map = new HashMap<>();
			for(int i = 1; i <= n; i++){
				int res = uf.find(i);
				if(map.containsKey(res)){
					map.get(res).add(i);
				}
				else{
					map.put(res, new HashSet<>());
					map.get(res).add(i);
				}
			}
//			for(Integer key: map.keySet()){
//				debug(key, map.get(key));
//			}
			
			int sum = 0;
			for(int i = 0; i < n; i++){
				if(map.get(uf.find(i+1)).contains(data[i])){
					sum++;
				}
			}
			System.out.println(sum);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 115724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ll cnt = 1, ic=0;
    bool fi = false, fd = false;
    if(A[0] <= A[1]) fi = true;
    for(int i = 1; i < N; i++){
        if(A[i-1] == A[i]) continue;
        if(A[i-1] < A[i]){
            fi = true;
            if(fd == true){
                fd = false;
                fi = false;
                cnt++;
            }
        }
        if(A[i] < A[i-1]){
            fd = true;
            if(fi == true){
                fd = false;
                fi = false;
                cnt++;
            }
        }
    }
    //if(!fd && !fi) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "stack"
#include "functional"

using namespace std;
using ll = long long int;
using PII = pair<ll, ll>;

struct Edge {
	int to, cost;
	Edge(int a, int b) {
		to = a;
		cost = b;
		return;
	}
};

struct Node {
	int num, cost, day;
	bool operator<(const Node&n)const {
		return make_pair(cost, day) < make_pair(n.cost, n.day);
	}
	bool operator>(const Node&n)const {
		return make_pair(cost, day)>make_pair(n.cost, n.day);
	}
	Node(int a, int b, int c) {
		num = a, cost = b, day = c;
		return;
	}
};

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

	int N, M;
	cin >> N >> M;
	vector<long long int>num(N);
	for (auto &i : num)cin >> i;
	vector<vector<Edge>>edge(N);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		edge[a].push_back(Edge(b, c));
		edge[b].push_back(Edge(a, c));
	}
	vector<pair<int, int>>dist(N, { 1000000000,1000000000 });
	dist[0] = make_pair( 0,0 );
	priority_queue<Node, vector<Node>, greater<Node>>PQ;
	PQ.push(Node(0, 0, 0));
	while (!PQ.empty()) {
		int cn = PQ.top().num;
		int c = PQ.top().cost;
		int cd = PQ.top().day;
		PQ.pop();
		for (auto i : edge[cn]) {
			if (dist[i.to] > make_pair(c + i.cost, cd + 1)) {
				dist[i.to] = make_pair(c + i.cost, cd + 1);
				PQ.push(Node(i.to, dist[i.to].first, dist[i.to].second));
			}
		}
	}
	int K;
	cin >> K;
	vector<vector<int>>tapi(N, vector<int>(20, -1));
	for (int i = 1; i < N; i++) {
		int nx = -1;
		for (auto j : edge[i]) {
			if (dist[j.to].first + j.cost == dist[i].first&&dist[j.to].second + 1 == dist[i].second) {
				if (nx == -1)nx = j.to;
				else if (num[nx] > num[j.to])nx = j.to;
			}
		}
		if (nx != -1) {
			tapi[i][0] = nx;
		}
	}
	for (int j = 1; j < 20; j++) {
		for (int i = 0; i < N; i++) {
			if (tapi[i][j - 1] == -1)continue;
			tapi[i][j] = tapi[tapi[i][j - 1]][j - 1];
		}
	}
	while (K--) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		int step = max(0, dist[a].second - b);
		int ans = dist[a].first;
		int node = a;
		for (int i = 0; i < 20; i++) {
			if ((step >> i) & 1) {
				node = tapi[node][i];
			}
		}
		ans -= dist[node].first;
		ans += max(0, dist[node].first - c);
		cout << ans << endl;
	}
}


Measured memory_bytes: 32588
def fib(n):
    memo = [0] * n
    memo[0:2] = [2, 1]
    for i in range(2, n):
        memo[i] = memo[i - 1] + memo[i - 2]
    return memo[n - 1]


def solve():
    N = int(input())
    print(fib(N + 1))
    

solve()

Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N;
	scanf("%d", &N);
	int a[100];
	int max1 = 0;
	int max2 = 0;
	int max = 0;
	int b = 0;
	int count = 0;

	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}


	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[j] > max) {
				max = a[j];
				b = j;
			}
		}

		if (count % 2 == 0) {
			max1 += max;
		}
		else {
		max2 += max;
	}
		max = 0;
		a[b] = 0;
		count++;
	}

	printf("%d\n", abs(max1 - max2));



	return 0;

}

Measured memory_bytes: 128
#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 all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	n %= 10;

	if (n == 3)cout << "bon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
	else cout << "hon" << endl;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int n,x,numbers[100000];
	ll result=0;

	cin>>n>>x;
	REP(i,n) cin>>numbers[i];

	if(numbers[0]>x){
		result+=(numbers[0]-x);
		numbers[0]-=(numbers[0]-x);
	}
	
	FOR(i,1,n){
		if(numbers[i]+numbers[i-1]>x){
			result+=(numbers[i]+numbers[i-1]-x);
			numbers[i]-=(numbers[i]+numbers[i-1]-x);
		}
	}
	cout<<result<<endl;
	return 0; 
}


Measured memory_bytes: 640
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod = 1000000007;
const ll mx =131080;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1


ll n, m, ara[200007], _1, _2, _3, ans, __;


start;
// op = 0 when n = even
    cin2(n, m);

    rep(i, 1, n+1)
        ara[ i ] += ara[i - 1] + i;

    rep(i, m, n+2){
        _1 = ara[ i - 1]; // 1st theke m ta
        _2 = ara[ n ] - ara[ n - i];
        _3 = _2 - _1 + 1;
        ans += _3;
    }


    coul(ans%mod);

finish


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

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int[] time = new int[86400];
		for(;;)
		{
			int N = sc.nextInt();
			if (N==0)break;
			
			Arrays.fill(time, 0);
			for (int i = 0; i < N; i++)
			{
				int s1 = toSec(sc.next()), s2 = toSec(sc.next());
				for (int s = s1; s < s2; s++) time[s]++;
			}
			int max = 0;
			for (int i = 0; i < 86400; i++) max = Math.max(max, time[i]);
			System.out.println(max);
		}
	}
	
	private static int toSec(String s)
	{
		String[] parts = s.split(":");
		int sec = 0;
		for (int i = 0; i < 3; i++)
		{
			sec = 60 * sec + Integer.parseInt(parts[i]);
		}
		return sec;
	}
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(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-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}



int main() {
    map<string, li> m;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1;
    string s;
    cin >> s;
    cout << m[s] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
int h=12,w=6;
char f[12][9];

int rec(int y,int x,bool e)
{
	char c=f[y][x]; int ret=1;
	f[y][x]='.';
	rep(d,4)
	{
		int ny=y+dy[d],nx=x+dx[d];
		if(ny<0||ny>=h||nx<0&&nx>=w)continue;
		if(e&&f[ny][nx]=='O')f[ny][nx]='.',ret++;
		if(f[ny][nx]==c)ret+=rec(ny,nx,e);
	}
	if(!e)f[y][x]=c;
	return ret;
}

int main()
{
	int CS; scanf("%d",&CS);
	rep(cs,CS)
	{
		rep(i,h)scanf("%s",f[i]);
		int ans=0;
		for(;;ans++)
		{
			bool e=0;
			rep(i,h)rep(j,w)if(f[i][j]!='.'&&f[i][j]!='O')
			{
				if(rec(i,j,0)>3)e=1,rec(i,j,1);
			}
			if(!e)break;
			
			rep(j,w)for(int i=10;i>=0;i--)if(f[i][j]!='.')
			{
				int k=i+1; for(;k<12&&f[k][j]=='.';k++);
				swap(f[i][j],f[k-1][j]);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int max(int yoshio, int kao){
    int a=yoshio+kao;
    int b=yoshio-kao;
    int c=yoshio*kao;
    if(a>=b && a>=c){
        return a;
    }
    else if(b>=a && b>=c){
        return b;
    }
    else return c;
}
int main(){
    int a=0,b=0,kao=0;
    scanf("%d %d",&a,&b);
    kao=max(a,b);
    printf("%d\n",kao);
    return 0;
}

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

def main():
    n = int(input())
    s = input()
    q = int(input())
    K = list(map(int,input().split()))
    # print(s)

    for i in range(q):
        ans = 0
        d = 0
        m = 0
        dm = 0
        k = K[i]
        for j in range(n):

            if j-k >= 0:
                if s[j-k] == "D":
                    d -= 1
                    dm -= m
                elif s[j-k] == "M":
                    m -= 1

            if s[j] == "D":
                d += 1
            elif s[j] == "M":
                m += 1
                dm += d
            elif s[j] == "C":
                ans += dm
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 60508