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

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[][] card = new int[M+1][3];

            for(int i = 1 ; i <= M ; i++){
                card[i][1] = sc.nextInt();
                card[i][2] = sc.nextInt();
            }
        sc.close();

        int min = 100000;
        int max = 1;
        for(int i = 1 ; i <= M ; i++){
            max = Math.max(max,card[i][1]);
            min = Math.min(min,card[i][2]);
        }

        int ans = Math.max(min-max+1,0);
        System.out.println(ans);

   }
}


Measured memory_bytes: 89024
# -*- coding: utf-8 -*-
n = int(input())

guidebook = {}
for i in range(n):
    s, p = input().split()
    p = int(p)

    if s in guidebook:
        guidebook[s].append((p, i+1))
    else:
        guidebook[s] = [(p, i+1)]

for city in sorted(guidebook.items(), key=lambda x: x[0]):
    for p, i in sorted(city[1], reverse=True):
        print(i)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

ll v = 1e5+10;
vector<ll> cnt(2, 0);
vector<vector<ll>> Graph(v*2);
vector<bool> visited(v*2, false);

void dfs (ll V) {
    if (visited[V]) return;
    visited[V] = true;
    cnt[V/v]++;
    for (auto e : Graph[V]) {
        dfs(e);
    }
}

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

    ll N;
    cin >> N;
    Rep (i, N) {
        ll x, y;
        cin >> x >> y;
        y += v;
        Graph[x].push_back(y);
        Graph[y].push_back(x);
    }

    ll ans = 0;
    Rep (i, v*2) {
        if (visited[i]) continue;
        cnt = vector<ll>(2, 0);
        dfs(i);
        ans += cnt[0] * cnt[1];
    }

    // cout << ans << "\n";

    cout << ans - N << "\n";
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,x;
    cin >> k >> x;
    if (k*500 >= x) cout << "Yes"; else cout << "No";
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    ll a, b, c;

    cin >> a >> b >> c;

    cout << (ll)max(0LL, (c - (a - b))) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	long long n, s = 0, m;

	scanf ("%lld", &n);

	m = n;

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

	if (m % s == 0) printf ("Yes");
	else printf ("No");

	return 0;
}


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

int main(){

  int n, a, q, m;
  int dp[2001] = {};

  cin >> n;
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    cin >> a;
    for(int j = 2000; j >= 0; j--){
      if(dp[j]) dp[j + a] = 1;
    }
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> m;
    cout << (dp[m] ? "yes" : "no") << endl;
  }
  return 0;
}


Measured memory_bytes: 3100
def solve(A, K):
    flag = False
    duplicate = False
    ret = -1
    for k, v in A.items():
        if set(K) & set(v) == set(K):
            if flag:
                duplicate = True
            else:
                flag = True
                ret = k
    if duplicate:
        return -1
    else:
        return ret


while True:
    N = int(input())
    if N == 0:
        break
    A = {i: [] for i in range(1, N + 1)}
    for i in range(N):
        M = list(map(int, input().split()))
        A[i + 1] = M[1:]
    K = list(map(int, input().split()))
    K = K[1:]
    print(solve(A, K))



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl


int main(){
    string s;
    cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')COUT("Yes");
    else COUT("No");
    return 0;
} 


Measured memory_bytes: 3616
#UnionFind
class UnionFind(object):
  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]

  def find(self, x):
    #x が属するグループを探索
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def union(self, x, y):
    #x と y のグループを結合
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x

  def is_same(self, x, y):
    #x と y が同じグループか否か
    return self.find(x) == self.find(y)
#uf=UnionFind(N) uf.union(A,B)のように使う

N, Q = map(int, input().split())

uf = UnionFind(N)
for _ in range(Q):
    P, A, B = map(int, input().split())
    # 連結クエリ
    if P == 0:
        uf.union(A, B)
    # 判定クエリ
    else:
        if uf.is_same(A, B):
            print(1)
        else:
            print(0)


Measured memory_bytes: 6044
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll mx=INT_MAX;
ll mn=INT_MIN;

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll i;
    for(i=0;i<n;i++)
        cin>>a[i];
    ll dp[n]={0};
    //dp[0]=a[0];
    dp[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
'''     ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     '''


# [abc049_b.py] => [27-07-2020 @ 21:56:34] 
# Author & Template by : Udit "luctivud" Gupta
# https://www.linkedin.com/in/udit-gupta-1b7863135/


import math;   from collections import *
import sys;    from functools import reduce
import time;   from itertools import groupby

# sys.setrecursionlimit(10**6)

def input()         : return sys.stdin.readline()
def get_ints()      : return map(int, input().strip().split())
def get_list()      : return list(get_ints())
def get_string()    : return list(input().strip().split())
def printxsp(*args) : return print(*args, end="")
def printsp(*args)  : return print(*args, end=" ")


DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)] 
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1),\
              (+1, +1), (+1, +0), (+1, -1), (+0, +1)]


CAPS_ALPHABETS = {chr(i+ord('A')) : i for i in range(26)}
SMOL_ALPHABETS = {chr(i+ord('a')) : i for i in range(26)}
INF = float('inf')


# Custom input output is now piped through terminal commands.


S34t = time.time()
# for _testcases_ in range(int(input())): 

n, m = get_ints()

for i in range(n):
    s = input()
    print(s, end="")
    print(s, end="")



S34p = time.time()
# print("Time Elapsed: {}".format(float(S34p-S34t)))


Measured memory_bytes: 68476
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

int main() {
    string t;
    cin >> t;
    rep(i, t.size()) {
        if (t[i] == 'P')
            cout << 'P';
        else
            cout << 'D';
    }
    cout << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;

bool is_odd_digits(int n){
    int d = 0;
    while(n>0){
        n /= 10;
        d++;
    }
    return d % 2 == 1 ? true : false;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(is_odd_digits(i))ans++;
    }
    cout << ans << endl; 
}

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

int main()
{
  ll a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  ll ans = 0;
  if (a == 0)
  {
    ans = 1;
  }
  else if (b == 0)
  {
    ans = 2;
  }
  else if (c == 0)
  {
    ans = 3;
  }
  else if (d == 0)
  {
    ans = 4;
  }
  else
  {
    ans = 5;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] a = new int[n + 2];

		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}

		int sum = 0;

		for (int i = 0; i <= n; i++) {
			sum += Math.abs(a[i + 1] - a[i]);
		}

		for (int i = 1; i <= n; i++) {
			int tmp = sum;
			int ans = tmp - (Math.abs(a[i + 1] - a[i]) + Math.abs(a[i] - a[i - 1])) + Math.abs(a[i + 1] - a[i - 1]);
			System.out.println(ans);
		}

		sc.close();
	}
}

Measured memory_bytes: 66084
#include <iostream>

using namespace std;

int main()
{
	int N, X;
	cin >> N >> X;

	int num_bounce = 1;
	int d = 0;

	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		d += l;
		if (d <= X) {
			num_bounce++;
		}
	}
	printf("%d\n", num_bounce);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int hp = scan.nextInt();
		int damage = scan.nextInt();
		
		if (hp % damage == 0) {
			System.out.println(hp / damage);
		} else {
			System.out.println(hp / damage + 1);
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include "Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	ll n = read(), Ans = INF;
	for (ll i = 2; i * i <= n; ++i) 
		if (n % i == 0) Ans = min(Ans, i + n / i - 2);
	return wln(min(Ans, n - 1)), 0;
}

/*

*/






Measured memory_bytes: 256
//write：Sakura
//id：
//problem：
//note：

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

const int MAX = 100005;
int a[MAX];

int main() {
	int n; scanf("%d", &n);
	int maxabs = -1; int id = 0;
	for (int i=1; i<=n; i++) { 
		scanf("%d", &a[i]); 
		if (abs(a[i]) > maxabs) { maxabs = abs(a[i]); id = i; }
	}
	vector<int> x, y;
	for (int i=1; i<=n; i++) {
		x.push_back(id); y.push_back(i);
		a[i] += a[id];
	}
	if (maxabs == 0) { printf("0\n"); return 0; }
	if (a[1] < 0) {
		for (int i=n; i>=2; i--) {
			x.push_back(i); y.push_back(i-1);
		}
	}
	else {
		for (int i=1; i<n; i++) {
			x.push_back(i); y.push_back(i+1);
		}
	}
	printf("%d\n", (int)x.size());
	for (int i=0; i<x.size(); i++) {
		printf("%d %d\n", x[i], y[i]);
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string s;
    cin >> s;
    ll N = s.size();
    REP(i, N-1){
    	if(s[i] == s[i+1]){
    		cout << i+1 << " " << i+2 << endl;
    		exit(0);
    	}
    }
    REP(i, N-2){
    	if(s[i] == s[i+2]){
    		cout << i+1 << " " << i+3 << endl;
    		exit(0);
    	}
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  ll n,t,a;
  cin >> n >> t >> a;
  double MIN=10000000000000;
  ll ans=0;
  rep(i,n){
    ll h;cin >> h;
    double tem=t-0.006*h;
    MIN=min(MIN,abs(tem-a));
    if(MIN==abs(tem-a))ans=i+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.to_i
arr = [s]
ans = 0
i = 1
loop do
  res = arr[i-1] % 2 == 0 ? arr[i-1] / 2 : 3 * arr[i-1] + 1
  if arr.include?(res)
    ans = i + 1
    break
  end
  arr << res
  i += 1
end
puts ans

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	ll n;
	cin >> n;
	ll a[3][n];
	rep(i, n) cin >> a[0][i] >> a[1][i] >> a[2][i];
	ll dp[3][n+1];
	dp[0][0] = a[0][0];
	dp[1][0] = a[1][0];
	dp[2][0] = a[2][0];
	
	FOR(i, 1, n - 1)
		rep(j, 3) {
			dp[j][i] = 0;
			rep(k, 3)
				if (k != j) dp[j][i] = max(dp[j][i], dp[k][i-1] + a[j][i]);
		}

	cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]) << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

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

    vl A(N);

    for(int i=0; i<N; i++) cin >> A.at(i);

    ll c = 0;
    int flag = 0;

    while(1){
        for(int i=0; i<N; i++){
            if(A.at(i) % 2 ==1){
                flag = 1;
                break;
            }
            A.at(i) = A.at(i)/2;
        }
        if(flag==1){
            break;
        }
        c++;


    }

    cout << c << endl;
}

Measured memory_bytes: 256
while true
  w, h = gets.split.map(&:to_i)
  break if w == 0
  xh = {}; yh = {}
  xa = []; ya = []
  xa << 0; xa << w
  ya << 0; ya << h
  points = []
  gets.to_i.times do
    point = gets.split.map(&:to_i)
    points << point
    xa << point[0]; xa << point[2]
    ya << point[1]; ya << point[3]
  end
  xa.uniq!; xa.sort!; ya.uniq!; ya.sort!
  xs = xa.size; ys = ya.size
  xa.each_with_index{ |a, i| xh[a] = i+1 }
  ya.each_with_index{ |b, i| yh[b] = i+1 }
  fld = Array.new(ys+1){ Array.new(xs+1, true) }
  fld[0].fill(false); fld[ys].fill(false)
  fld.map{ |arr| arr[0] = arr[xs] = false }

  for point in points
    x1, y1, x2, y2 = point
    for a in (yh[y1]...yh[y2])
      for b in (xh[x1]...xh[x2])
        fld[a][b] = false
      end
    end
  end
  ret = 0
  for y in (1...ys)
    for x in (1...xs)
      next unless fld[y][x]
      arr = []
      arr << [y, x]
      until arr.empty?
        ny, nx = arr.shift
        [[-1,0],[0,-1],[1,0],[0,1]].each do |dy, dx|
          px = nx+dx; py = ny+dy
          if fld[py][px]
            arr << [py, px] 
            fld[py][px] = false
          end
        end
      end
      ret += 1
    end
  end
  p ret
end

Measured memory_bytes: 14164
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,dp[111][111],p[111];

int rec(int i,int j){
  int Min=2*1e9;
  for(int k=0;k<i-1;k++){
    Min=min(Min,dp[j+1][j+k+1]+dp[j+k+2][j+i]+p[j]*p[j+k+1]*p[j+i]);
  }
  return Min;
}

signed main(){
  cin>>n;
  cin>>p[0]>>p[1];
  for(int i=2;i<=n;i++){
    cin>>p[i]>>p[i];
  }
  for(int i=0;i<n;i++){
    dp[i][i]=0;
    if(i)dp[i][i+1]=p[i-1]*p[i]*p[i+1];
  }

  for(int i=3;i<=n;i++){
    for(int j=0;j+i<=n;j++){
      dp[j+1][j+i]=rec(i,j);
    }
  }
  cout<<dp[1][n]<<endl;
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    string S;
    cin >> K >> S;
    if(S.size() > K) {
        S.resize(K);
        S += "...";
    }
    cout << S << endl;
    return 0;
}


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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

ll n;

void solve()
{
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll sum =0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum;
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 5212
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string s,t;
    cin>>s>>t;
    if(t.substr(0,t.length()-1)==s)
    cout<<"Yes";
    else
    cout<<"No";}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
    int r, c, sum;

    scanf("%d %d", &r, &c);

    int sheet[r+1][c+1];

    for (int i = 0; i < r; i++) {
        sum = 0;
        for (int j = 0; j < c; j++) {
            scanf("%d", &sheet[i][j]);
            sum += sheet[i][j];
        }
        sheet[i][c] = sum;
    }

    for (int i = 0; i < c + 1; i++) {
        sum = 0;
        for (int j = 0; j < r; j++) {
            sum += sheet[j][i];
        }
        sheet[r][i] = sum;
    }

    for (int i = 0; i < r + 1; i++) {
        for (int j = 0; j < c + 1; j++) {
            if (j == c) printf("%d\n", sheet[i][j]);
            else printf("%d ", sheet[i][j]);
        }
    }

    return 0;
}


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

using namespace std;

int main()
{
    int n,a[100]= {0};
    cin>>n;
    for(int i=1; i<=9; i++)
        for(int j=i; j<=9; j++)
        {
            a[i*j]=1;
        }
    if(a[n]==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<list>
#include<algorithm>

using namespace std;

int n,m;

int main()
{
	while(true)
	{
		list<char> map_1;
		list<char> map_2;
		list<char>::iterator map;
		list<char>::iterator map2;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			char a,b;
			scanf(" %c %c",&a,&b);
			map_1.push_back(a);
			map_2.push_back(b);
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++)
		{
			char c;
			scanf(" %c",&c);
			if(find(map_1.begin(),map_1.end(),c)==map_1.end())
				printf("%c",c);
			else
			{
				map=map_1.begin();
				map2=map_2.begin();
				while(true)
				{
					if(*map==c)break;
					map++;
					map2++;
				}
				printf("%c",*map2);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#C - Colorful Leaderboard 

N = int(input())
A = list(map(int, input().split()))

n = 399
a, b, c, d, e, f, g, h, z = 0,0,0,0,0,0,0,0,0

for i in A:
    if i >= 1 and i <= n:
        a = 1
    elif i >= 400 and i <= n + 400:
        b = 1
    elif i >= 2*400 and i <= 2*400 + n:
        c = 1
    elif i >= 3*400 and i <= 3*400 + n:
        d = 1
    elif i >= 4*400 and i <= 4*400 + n:
        e = 1
    elif i >= 5*400 and i <= 5*400 + n:
        f = 1
    elif i >= 6*400 and i <= 6*400 + n:
        g = 1
    elif i >= 7*400 and i <= 7*400 + n:
        h = 1
    else:
        z += 1

min_num, max_num = 0, 0
        
min_num = a+b+c+d+e+f+g+h


max_num = min_num + z
min_num = max(1, min_num)

print(min_num,max_num)

Measured memory_bytes: 9248
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// cout.presicion(20);

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((b - a) == (c - b)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
/*const int N = 1e5+5;
int a[N]; // our input array */

int main(){


	int a,b;
	cin>>a>>b;
	if( a<=9 && b<=9)
		cout<<a*b<<endl;
	else
		cout<<-1<<endl;
    
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
    int n, l[4] = {0};
    char a[4];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s", a);
        if (a[0] == 'A' && a[1] == 'C')
            l[0]++;
        if (a[0] == 'W' && a[1] == 'A')
            l[1]++;
        if (a[0] == 'T' && a[1] == 'L' && a[2] == 'E')
            l[2]++;
        if (a[0] == 'R' && a[1] == 'E')
            l[3]++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", l[0], l[1], l[2], l[3]);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, K; cin >> N >> K;
	long long X[N], Y[N];
	for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];	
	long long xl[N], xr[N], yu[N], yb[N];
	for (int i = 0; i < N; i++) {
		xl[i] = X[i];
		xr[i] = X[i];
		yu[i] = Y[i];
		yb[i] = Y[i];
	}
	sort(xl, xl + N);
	sort(xr, xr + N);
	sort(yu, yu + N);
	sort(yb, yb + N);
	long long ans = 1LL * (xl[N - 1] - xl[0])*(yu[N- 1] - yb[0]);
	for (int l = 0; l < N - 1; l++) {
		for (int r = l + 1; r < N; r++) {
			for (int b = 0; b < N-1; b++) {
				for (int u = b + 1; u < N; u++) {
					int cnt = 0;
					for (int i = 0; i < N; i++) {
						if (xl[l] <= X[i] && xr[r] >= X[i] && yb[b] <= Y[i] && Y[i] <= yu[u]) cnt++;
					}
					if (cnt >= K) ans = min(ans, 1LL * (xr[r] - xl[l])*(yu[u] - yb[b]));
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n, a, b, x, y;
        in >> n >> a >> b;
        x = n / (a + b);
        y = n % (a + b);
        out << (a*x) + min(a, y) << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,x,ans=10000000000000;
  cin >> n >> x;
  vector<ll> a(n),ta(n);
  ll best[n][n];
  fill(best[0],best[n],10000000000000);
  for(int i=0;i<n;i++){
    cin >> a[i];
    best[i][0] = a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=1;j<n;j++){
      ll v = (i-j+n)%n;
      best[i][j] = min(best[i][j-1],a[v]);
    }
  }
  for(int i=0;i<n;i++){
    ll tmp = 0;
    for(int j=0;j<n;j++){
      tmp += best[j][i];
    }
    tmp += i*x;
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}


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

int N, K;
string S;
int A[100005]; //連続で続く0,1の数を格納(1の数から始まり1の数まで)

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

  int count = 1;
  int l = 0;

  if(S[0]=='0'){ //Sが0始まりならA[0]に0を格納
    A[l] = 0;
    l++;
  }


  for(int i=1; i<S.size(); i++){
    if(S[i]==S[i-1]){
      count++;
    }else{
      A[l] = count;
      count = 1;
      l++;
    }
  }
  A[l] = count;


  if(S[S.size()-1]=='0'){ //Sが0終わりならAの最後に0を格納
    l++;
    A[l] = 0;
  }

  int ans = 0;
  int final_ans = 0;
  if (l/2 <= K){
    for (int i=0; i<=l; i++) final_ans += A[i];
  } else {
    for (int j=2*K; j<=l; j+=2){
      for (int i=j; i>=j-2*K; i--) ans += A[i];
      if (final_ans < ans) final_ans = ans;
      ans = 0;
    }
  }

  cout << final_ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 100100;
const int MOD = 1e9+7;
int count[MAXN]={0};

int solve (int N){
    ll ans = 1;
    if (N % 2 == 1){
        if (count[0]!=1) return 0;
        for (int i=2; i < N; i+=2){
            if (count[i] !=2) return 0;
            (ans *= 2 ) %= MOD;
        }
        return ans;
    }
    else {
         for (int i=1; i < N; i+=2){
            if (count[i] !=2) return 0;
            (ans *= 2 ) %= MOD;
        }
        return ans;

    }
}

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

    
    cout << solve(N) << endl;

}

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

typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < n; i++)

/* print like python */
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

int main()
{
    int v[3];
    cin >> v[0] >> v[1] >> v[2];
    sort(v,v+3);
    
    print(v[0]+v[1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int x;
  string week[] = {"thu","fri","sat","sun","mon","tue","wed"};
  cin >> x;
  cout << week[x % 7] << endl;
  return 0;
}



Measured memory_bytes: 3196
p,w,i,a[50];main(n){for(;scanf("%d%d",&n,&p)*n;i=0)for(w=p;p;i++,i%=n)w?p=++a[i]-p?w--,p:!printf("%d\n",i,a[i]=0):(w=a[i],a[i]=0);}

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

int main(){
	
	//n = ¼üÌ
	int n;
	
	while(cin >>n){
		if(n == 0) break;
		
		//max = ÅåÌóÔÌ
		int max = 2;
		for(int i = 2; i <= n; i++){
			max += i;
		}
		cout <<max <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <queue>
#include <algorithm>

using std::queue;
using std::min;

const int MAXN=305;
int n,m,ans;
int cnt[MAXN],q[MAXN][MAXN];

int main(){
	scanf("%d%d",&n,&m);
	ans=n;
	for(int i=1;i<=n;++i){
		for(int j=1,a;j<=m;++j)
			scanf("%d",&q[i][j]);
	}
	for(int i=1,tmp,now;i<=m;++i){
		for(int j=1;j<=m;++j)
			cnt[j]=0;
		tmp=0;
		for(int j=1,hd;j<=n;++j){
			hd=q[j][1];
			++cnt[hd];
			if(cnt[hd]>tmp){
				tmp=cnt[hd];
				now=hd;
			}
		}
		ans=min(ans,tmp);
		for(int j=1,k;j<=n;++j){
			for(k=1;q[j][k];++k){
				if(q[j][k]==now) break;
			}
			for(;q[j][k+1];++k)
				q[j][k]=q[j][k+1];
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
list = gets.chomp.chars.flat_map{|c|[0,c]}+[0]
renzoku = 0
1.step(list.length,2){|i|
  if list[i] == '<'
    renzoku += 1
    list[i+1] = [renzoku,list[i+1]].max
  else
    renzoku = 0
  end
}
list.reverse!
renzoku = 0
1.step(list.length,2){|i|
  if list[i] == '>'
    renzoku += 1
    list[i+1] = [renzoku,list[i+1]].max
  else
    renzoku = 0
  end
}
p list.each_slice(2).map(&:first).inject(:+)

Measured memory_bytes: 65212
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
const int INF=1e9+7;
int n;
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n;
	cout<<int(sqrt(n))*int(sqrt(n));
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
t = input()
ans = n * 2
for i in range(n):
    flag = True
    for j in range(n - i):
        if s[i + j] != t[j]:
            flag = False
            break
    
    if flag:
        print(ans - (n - i))
        exit()

print(ans)

Measured memory_bytes: 3060
N, T = map(int, input().split())
D = [tuple(map(int, input().split())) for _ in range(N)]
D.sort()
dp = [[0] * T for _ in range(N + 1)]

for i in range(N):
    A, B = D[i]
    for j in range(T):
        here = dp[i][j]
        if j < A:
            dp[i + 1][j] = here
        else:
            dp[i + 1][j] = max(here, dp[i][j - A] + B)

t = 0
ans = 0
for i in range(N - 1, -1, -1):
    ans = max(ans, dp[i + 1][T - 1] + t)
    t = max(t, D[i][1])

print(ans)


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

using namespace std;

const int N=1e6+5,MOD=1e9+7;

typedef long long ll;

int n,c,u,v,k,tc,ans;

char s[N];

int main(){
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	for(int i=0;i<n;i++)
		if (i+1==k)
			printf("%c",s[i]+'a'-'A');
		else
			printf("%c",s[i]);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <string>

int main()
{
	std::ios_base::sync_with_stdio(false);
	
	uint32_t a[10] = {0};
	uint32_t temp = 0;
	
	for(int i = 0; i < 3; i++)
	{
		std::cin >> temp;
		a[temp-1]++;
	}

	if(a[4] == 2 && a[6] == 1) { std::cout << "YES" << "\n"; return 0; }

	std::cout << "NO" << "\n";

	return 0;
}

Measured memory_bytes: 256
n=int(input())
arr=[]

for i in range(n):
  arr.append(int(input()))
a=max(arr)

for i in range(n):
  if arr[i]==a:
    b=max(arr[:i]+arr[i+1:])
    break
    
for i in range(n):
  if arr[i]!=a:
    print(a)
  else:
    print(b)

Measured memory_bytes: 14124
use proconio::{input, marker::Usize1};
fn main() {
    let info = Info::read();
    input!(mut ans: [Usize1; info.day]);
    input!(query: [(Usize1, Usize1)]);
    for (d, q) in query {
        ans[d] = q;
        println!("{}", score(&info, &ans));
    }
}
fn score(info: &Info, ans: &[usize]) -> i32 {
    let mut last = vec![-1; 26];
    ans.iter().enumerate().fold(0, |score, (date, &contest)| {
        last[contest] = date as i32;
        (0..26).fold(score + info.inc[date][contest], |score, contest| {
            score - info.dec[contest] * (date as i32 - last[contest])
        })
    })
}
struct Info {
    day: usize,
    dec: Vec<i32>,
    inc: Vec<Vec<i32>>,
}
impl Info {
    fn read() -> Self {
        input!(d: usize, c: [i32; 26], s: [[i32; 26]; d]);
        Self {
            day: d,
            dec: c,
            inc: s,
        }
    }
}


Measured memory_bytes: 4116
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
typedef pair<int, int>P;

signed main() {
	int n, k; cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; i++) {//b
		int a = (n / i)*max(0ll,i-k);
		int mod = n%i;//0~mod
		if(mod)ans += max(0ll,mod - k+1 );
		
		ans += a;
	}
	if (k == 0)cout << n*n << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    vector<vector<int> > ncr(51,vector<int> (51));

    for(int i = 0;i < 51;i ++){
        ncr.at(i).at(0) = 1;
    }

    for(int i = 1;i < 51;i ++){
        for(int j = 1;j < 51;j ++){
            ncr.at(i).at(j) = ncr.at(i-1).at(j-1) + ncr.at(i-1).at(j);
        }
    }

    int n,p; cin >> n >> p;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int gusu = 0, kisu = 0;
    for(int i = 0;i < n;i ++){
        if(a.at(i) % 2 == 0) gusu ++;
        else kisu ++;
    }

    int ans = 0;
    for(int i = 0;i + p <= kisu;i += 2){
        for(int j = 0;j <= gusu;j ++){
            ans += ncr.at(kisu).at(i+p) * ncr.at(gusu).at(j);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s=list(input())
n=len(s)
l=[0] #自分より左にある＜の数
r=[0] #自分より右にある＞の数
l_num=0
r_num=0
for i in range(n):
    if s[i]=="<":
        l_num+=1
    else:
        l_num=0
    if s[-(i+1)]==">":
        r_num+=1
    else:
        r_num=0
    l.append(l_num)
    r.append(r_num)
ans=0
for i in range(n+1):
    ans+=max(l[i],r[-(i+1)])
print(ans)

Measured memory_bytes: 120948
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

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

    long double e = 1.0E-14; 
    if(sqrt(a)+sqrt(b)+ e<sqrt(c)){
        cout << "Yes" << endl;
    }
    else{
       cout << "No" << endl;
    }
} 



Measured memory_bytes: 3764
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-12;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//AGCばちゃ 1700~
/*
010
101
010
*/
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint i,j,n;cin>>n;
	vector<llint>dp(n+1);dp[0]=1;
	for(i=0;i<n;i++){
		char c;cin>>c;
		if(c=='-'){continue;}
		if(c=='D'){
			for(j=0;j<n;j++){dp[j]=(dp[j]*j+dp[j+1]*(j+1)*(j+1))%mod;}dp[n]=0;
		}else{
			for(j=n;j>0;j--){dp[j]=(dp[j]*j+dp[j-1])%mod;}dp[0]=0;
		}
		//for(j=0;j<=n;j++){cerr<<dp[j]<<" ";}cerr<<endl;
	}
	cout<<dp[0]<<endl;
	return 0;
}



Measured memory_bytes: 3192
import itertools
n,m,q=map(int, input().split())
 
tmp = 0
max = 0
a = []
b = []
c = []
d = []
 
for i in range(q):
  A, B, C, D = map(int, input().split())
  a.append(A)
  b.append(B)
  c.append(C)
  d.append(D)
 
nums = range(1, m + 1)
 
for retsu in itertools.combinations_with_replacement(nums, n): 
    for i in range(q):
        if int(retsu[b[i]-1]) - int(retsu[a[i]-1]) == c[i]:
            tmp = tmp + d[i]
        if max < tmp:
            max = tmp
    tmp = 0
 
print(max)

Measured memory_bytes: 9236
s = input()
ls = len(s)

sc = s[2:-1]
big = 0

import collections
c = collections.Counter(sc)


if s[0]=="A":
    if c["C"]==1:
        for i in range(ls):
            if s[i].isupper():
                big +=1
        if big ==2:
            print("AC")
            exit()

print("WA")

Measured memory_bytes: 9332
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	queue<int>que;
	int n;
	string s1, s2;
	long long int total = 1;
	int a;
	int past;

	cin >> n >> s1 >> s2;

	
	FOR(i, 0, n-1) {
		if (s1[i] == s1[i + 1]) {
			que.push(2);
			i++;
		}
		else {
			que.push(1);
		}
	}
	a = que.front();
	que.pop();
	if (a == 1) {
		total *= 3;
	}
	else {
		total *= 6;
	}
	past = a;

	while (que.empty() == 0) {
		a = que.front();
		que.pop();
		if (a == 1) {
			if (past == 1) {
				total *= 2;
			}
			else {
				total *= 1;
			}
		}
		else {
			if (past == 1) {
				total *= 2;
			}
			else {
				total *= 3;
			}
		}
		past = a;
		if (total >= MOD) {
			total %= MOD;
		}
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int t,x,y;
}N[100010];
int n,s=0;
bool cmp(node x,node y){
	return x.t<y.t;
}
int main(){
	scanf("%d",&n);
	N[0].x=0;N[0].y=0;N[0].t=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&N[i].t,&N[i].x,&N[i].y);
	}
	sort(N+1,N+n+1,cmp);
	for(int i=1;i<=n;i++){
		int t,X,Y;
		X=abs(N[i].x-N[i-1].x);
		Y=abs(N[i].y-N[i-1].y);
		t=N[i].t-N[i-1].t;
		t-=(X+Y);
		if(t%2!=0||t<0){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408