akhauriyash/Code-Regression huggingface dataset:
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  ll n,k;
  cin>>n>>k;
  
  vector<ll> A(n+1);
  rep(i,n) cin>>A[i+1];
  
  for(int i=k+1;i<=n;i++){
    if(A[i]>A[i-k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 4840
#include <iostream>
#include <deque>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;
deque<ll> d,q;
ll a[200010],ans = 0;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=1;i<n-1;i++){
		d.push_back(a[i]);
	}
	q.push_back(a[0]); q.push_back(a[n-1]);
	ans += a[n-1] - a[0];
	while(!d.empty()){
		ll m1 = d.front(),m2 = d.back(),m3 = q.front(), m4 = q.back();
		ll mx1 = abs(m1-m3),mx2 = abs(m1-m4),mx3 = abs(m2-m3),mx4 = abs(m2-m4);
		ll mx = max({mx1,mx2,mx3,mx4});
		ans += mx;
		if(mx==mx1){
			q.push_front(m1); d.pop_front();
		}else if(mx==mx2){
			q.push_back(m1); d.pop_front();
		}else if(mx==mx3){
			q.push_front(m2); d.pop_back();
		}else{
			q.push_back(m2); d.pop_back();
		}
	}
	cout << ans << endl;
}

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


int main(){

    int n, m, c[25], dp[50010] = {};
    cin >> n >> m;
    for(int i=0;i<m;i++) cin >> c[i];
    for(int i=1;i<=n;i++) dp[i] = 500010;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<m;j++) {
            if(i >= c[j]) {
                if(dp[i] > dp[i-c[j]]+1){
                    dp[i] = dp[i-c[j]]+1;
                }
            }
        }
    }
    cout << dp[n] << endl;

}



Measured memory_bytes: 3304
#include <iostream>




using namespace std;



int main() {
	int a[5], k;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
	

	bool is = true;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			if (abs(a[i] - a[j]) > k) {
				is = false;
				break;
			}
		}

		if (!is) {
			break;
		}
	}

	if (!is) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}


	//system("pause");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i =0; i<n; ++i)
		cin>>a[i];
	int ans = 0;
	for(int i =1; i<n-1; i++){
		if(a[i] > min(a[i], min(a[i-1], a[i+1])) && a[i] < max(a[i], max(a[i-1], a[i+1]))) ans++;
	}
	cout<<ans;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())), reverse=True)
Y = sorted(list(map(int, input().split())), reverse=True)
MOD = 10 ** 9 + 7

X_sum = 0
for i, x in enumerate(X, start=1):
    X_sum += x * (N - i - i + 1)
    X_sum %= MOD

Y_sum = 0
for i, y in enumerate(Y, start=1):
    Y_sum += y * (M - i - i + 1)
    Y_sum %= MOD

print(X_sum * Y_sum % MOD)


Measured memory_bytes: 18556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int N, K;
  cin >> N >> K;
  vi p(N);
  REP(i, N) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int r = 0;
  REP(i, K) {
    r += p.at(i);
  }
  cout << r << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n;
map<ll,int> mp;

int main()
{
    n=read();
    ll ans=0,s=0;mp[0]=1;
    rep(i,1,n)
    {
        int x=read();s+=x;
        ans+=mp[s];mp[s]++;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 12800
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int h, w;
    int k;
    boolean[][] board;
    int[][] map;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        h = sc.nextInt();
        w = sc.nextInt();
        k = sc.nextInt();
        board = new boolean[h][w];
        map = new int[h + 1][w + 1];


        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                board[i][j] = s.charAt(j) == '1';
                map[i + 1][j + 1] += (board[i][j] ? 1 : 0) - map[i][j + 1] - map[i + 1][j] + map[i][j];
            }
        }

        int ans = 1 << 30;
        for (int i = 0; i < (1 << (h - 1)); i++) {
            int from = 0;
            int cnt = Integer.bitCount(i);
            from = ok(i, from);
            if (from < 0) continue;
            while (from < w) {
//                debug("", from);
                cnt++;
                from++;
                from = ok(i, from);
            }
//            debug(Integer.toBinaryString(i), cnt);
            ans = Math.min(ans, cnt);
        }

        out.println(ans);
        out.flush();
    }

    int ok(int S, int from) {
        int sp = Integer.bitCount(S) + 1;
        int[] sum = new int[sp];
        int start = from;
        while (start < w) {
            int st = 0;
            for (int j = 0; j < h; j++) {
                sum[st] += board[j][start] ? 1 : 0;
                if (((S >> j) & 1) == 1) {
                    st++;
                }
            }
//            debug("", sum, start);
            for (int i = 0; i < sp; i++) {
                if (sum[i] > k) return start != from ? start - 1 : -1;
            }
            start++;
        }

        return start;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

Measured memory_bytes: 22228
#!/usr/bin/ruby
#encoding: utf-8

#input 
n,x = gets.split.map(&:to_i)
L_kari = gets.split.map(&:to_i)

L = Array.new(n+1,-1)
(1..n).each do |i|
  L[i] = L_kari[i-1]
end

d = Array.new(n+2,-1)

d[1] = 0
(2..n+1).each do |i|
  d[i] = d[i-1] + L[i-1]
end

cnt = 0
(1..n+1).each do |i|
  if d[i] <= x then 
    cnt += 1
  end
end

puts cnt


Measured memory_bytes: 1788
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 200005;
const int MAXM = 1000005;
const int MOD = 1000000007;
const int MAMOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double EPS = 1e-8;
#define endl "\n"
#define de(x) cout<<#x<<"="<<x<<endl
int a[MAXN], b[MAXN];

int main()
{
    int k, n;
    cin >> k >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 1; i < n; ++i)
        b[i] = a[i + 1] - a[i];
    b[n] = a[1] + k - a[n];
    int maxx = 0;
    for (int i = 1; i <= n; ++i)
        maxx = max(maxx, b[i]);
    cout << k - maxx << endl;
    return 0;
}

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 200005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll minim(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;      
     x = x % p;    
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
            y = y>>1;  
            x = (x*x) % p;   
    } 
    return res; 
}

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 


ll lcm(ll a,ll b){
  return (a*b)/__gcd(a,b);
}

bool comp(const point &p1,const point &p2){
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second<p2.second;
}

int main()
{
	fio;
	ll n,u;cin>>n>>u;
	vl a(n);
	f(n)cin>>a[i];
	vl dp(n,inf);
	dp[0]=0;
	for(ll i=1;i<n;i++){
		for(ll k=1;k<=u;k++){
			if((i-k)>=0)dp[i]=min(dp[i-k]+abs(a[i]-a[i-k]),dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string str;
	int q;
	int a,b;
	string p;
	string query;
	
	
	cin>>str;
	cin>>q;
	for(int i=0;i<q;++i){
		cin>>query;
		cin>>a>>b;
		
		if(query=="print"){
			cout<<str.substr(a,b-a+1)<<endl;
		}else if(query=="reverse"){
			reverse(&(str[a]), &(str[b+1]));
		}else if(query=="replace"){
			cin>>p;
			for(int j=0;j<b-a+1;++j){
				str[a+j] = p[j];
			}
		}
	}
}

Measured memory_bytes: 1220
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    # import copy
    # import numpy as np
    # import math
    # import random
    input = stdin.readline

    a, b, c, d = map(int, input().split())
    MAX = 998244353
    rowcol = [[0]*(d+1) for _ in range(c+1)]
    rowcol[a][b] = 1
    row2 = [[0]*(d+1) for _ in range(c+1)]
    col2 = [[0]*(d+1) for _ in range(c+1)]
    for i in range(b+1, d+1):
        rowcol[a][i] = (rowcol[a][i-1]*a)%MAX
    
    for j in range(a+1, c+1):
        for i in range(b, d+1):
            if i == b:
                rowcol[j][b] = (rowcol[j-1][b]*b)%MAX
            else:
                rowcol[j][i] = ((rowcol[j-1][i]+row2[j-1][i])*(i-1))%MAX
                row2[j][i] = (rowcol[j][i-1]+col2[j][i-1]+row2[j][i-1]*j)%MAX
                col2[j][i] = (rowcol[j-1][i]+col2[j-1][i]*i+row2[j-1][i])%MAX
    
    print((rowcol[c][d]+row2[c][d]+col2[c][d])%MAX)




Measured memory_bytes: 281096
N, K = gets.chop.split.map(&:to_i)
P = gets.chop.split(' ').map(&:to_f)


exp = []
hash = {}
P.each do |i|
  hash[i] ||= (1..i).inject(:+) / i
  exp.push(hash[i])
end

memo = exp[0..K-1].inject(:+)
ans = [memo]

(K..N-1).each do |i|
  memo += (exp[i] - exp[i-K])
  ans.push(memo)
end

puts ans.max


Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    map<int,int> pp, pm;
    rep(i,n){
        pp[p[i]+i+1]++;
        pm[i+1-p[i]]++;
    }
    ll ans=0;
    for(auto &v: pp){
        if(pm[v.first]!=0){
            ans+=ll(v.second)*ll(pm[v.first]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 29896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int a,b;
string ans="";
int main(){
  cin >> a >> b;
  if(a > b){
    for (size_t i = 0; i < a; i++) {
      ans += to_string(b);
    }
  }else{
    for (size_t i = 0; i < b; i++) {
      ans += to_string(a);
    }

  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.emplace_back(i);
			if (i * i != n) res.emplace_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}

	auto div = divisor(sum);

	for (int i = (int)div.size() - 1; i >= 0; i--) {

		int sum = 0;
		vector<int> rem;
		for (int j = 0; j < N; j++) {
			int tmp = A[j] % div[i];
			if (tmp) rem.emplace_back(tmp);
		}
		sort(rem.begin(), rem.end());

		int cnt = 0, ptr1 = 0, ptr2 = (int)rem.size() - 1;
		while (ptr2 - ptr1 > 0) {

			int k = div[i] - rem[ptr2];
			ptr2--;
			cnt += k;

			while (k) {
				if (k >= rem[ptr1]) {
					k -= rem[ptr1];
					ptr1++;
				}
				else {
					rem[ptr1] -= k;
					k = 0;
				}
			}
			
		}
		if (cnt <= K) {
			cout << div[i] << "\n";
			break;
		}
	}

	return 0;
}

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

nm = []
for _ in range(n):
	nm.append(list(map(int,input().split())))

ml = []
for _ in range(m):
	ml.append(list(map(int,input().split())))

for i in range(n):
	ans =''
	for j in range(l):
		num = 0
		for x in range(m):
			num += nm[i][x] * ml[x][j]	
		ans += str(num) + ' '
	print(ans.rstrip(' '))


Measured memory_bytes: 6316
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 50;

class State{
public:
  int mx, my, Mx, My;
  State() {}
  State(int mx, int my, int Mx, int My) : mx(mx), my(my), Mx(Mx), My(My) {}
};

int h, w, col, mx, my, Mx, My, A[7], dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
State state[7];
char data[N][N];
bool used[N][N], ans;
map<char, int> number;
map<int, char> material;

main(){
  int t;
  cin >> t;
  while(t--){
    set<int> upper[7];
    number.clear();
    material.clear();
    cin >> h >> w;
    col = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> data[i][j];
        if(data[i][j] != '.' && number.find(data[i][j]) == number.end()){
          number[data[i][j]] = col;
          material[col++] = data[i][j];
        }
      }
    }
    for(int k=0;k<col;k++){
      state[k] = State(N, N, 0, 0);
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(data[i][j] == material[k]){
            state[k].mx = min(state[k].mx, j);
            state[k].my = min(state[k].my, i);
            state[k].Mx = max(state[k].Mx, j);
            state[k].My = max(state[k].My, i);
          }
        }
      }
    }
    for(int k=0;k<col;k++){
      for(int i=state[k].my;i<=state[k].My;i++){
        for(int j=state[k].mx;j<=state[k].Mx;j++){
          if(data[i][j] == '.'){
            cout << "SUSPICIOUS" << endl;
            goto CONT;
          }
          else if(data[i][j] != material[k]) upper[k].insert(number[data[i][j]]);
        }
      }
    }
    for(int i=0;i<col;i++) A[i] = i;
    ans = false;
    do{
      for(int i=0;i<col;i++){
        for(set<int>::iterator j=upper[i].begin();j!=upper[i].end();j++){
          if(A[i] < A[*j]) goto FAILD;
        }
      }
      ans = true;
      FAILD:;
    }while(next_permutation(A, A+col));
    if(ans || !col) cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
    CONT:;
  }
}

Measured memory_bytes: 904
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
typedef pair<int,pii>ppii;
typedef pair<ppii,ppii> d_pii;
ppii cal(string s){
    ppii temp;
    string a,b,c;
    a=s[0]; a+=s[1];
    b=s[3];b+=s[4];
    c=s[6];c+=s[7];
    temp.first=stoi(a);
    temp.second=pii(stoi(b),stoi(c));
    return temp;
}
int main(){
    int n;
    while(cin>>n,n){
        vector<pair<ll,ll>>v;
        rep(i,n){
            string s,e; cin>>s>>e;
            ppii start,end;
            start=cal(s);
            end=cal(e);
            ll _start=start.first*3600+start.second.first*60+start.second.second;
            ll _end=end.first*3600+end.second.first*60+end.second.second;
            //cout<<start.first<<":"<<start.second.first<<":"<<start.second.second<<endl;
            //cout<<end.first<<":"<<end.second.first<<":"<<end.second.second<<endl;
            v.push_back(make_pair(_start,_end));
        }
        sort(all(v));
        vl u(v.size());
        rep(i,v.size())u[i]=v[i].first;
        ll ans=0;
        ll base=0;
        u.push_back(INF);
        v.push_back(pii(INF,INF));
        rep(i,u.size()){
            ans++;
            base=v[i].second;
            while(true){
                bool update=false;
                vector<ll>::iterator itr=lower_bound(u.begin(), u.end(),base);
                if(itr!=u.end()){
                    int index=(int)(itr-u.begin());
                    update=true;
                    //cout<<*itr<<endl;
                    u.erase(itr);
                    base=v[index].second;
                    v.erase(v.begin()+index);
                }
                if(!update)break;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3340
#include<stdio.h>
int main(void){
    int a,b,c,k,i=0,max;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a>=b&&a>=c){
        max=a;
    }
    else if(b>a&&b>c){
        max=b;
    }
    else if(c>a&&c>b){
        max=c;
    }
    while(i<=k-1){
        max=max*2;
        i++;
    }
    
    if(a>=b&&a>=c){
        printf("%d\n",max+b+c);
    }
    else if(b>a&&b>c){
        printf("%d\n",max+a+c);
    }
    else if(c>a&&c>b){
        printf("%d\n",max+b+a);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

vector<int> bfs(int n, int s, vector<vector<int>> &g) {
    vector<int> color(n, 0);
    vector<int> ret;
    queue<pair<int, int>> que;
    que.push(make_pair(s, 1));
    color[s] = 1;
    while(!que.empty()) {
        pair<int, int> now = que.front();
        que.pop();
        for (auto v: g[now.first]) {
            if (color[v] == 0) {
                color[v] = -color[now.first];
                que.push(make_pair(v, now.second+1));
                ret.push_back(now.second+1);
            }
            if (color[v] != -color[now.first]) {
                ret.clear();
                return ret;
            }
        }
    }
    //for (auto r: ret) {
    //    cout << r << " ";
    //}
    //cout << endl;
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    rep(i, n) rep(j, n) {
        char c;
        cin >> c;
        if (c == '1') g[i].push_back(j);
    }
    int ans = -1;
    rep(i, n) {
        auto ret_v = bfs(n, i, g);
        if (!ret_v.empty()) ans = max(ans, *max_element(ret_v.begin(), ret_v.end()));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;

int main(){
  int64 n; cin >> n;
  int64 a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << *min_element(a, a + n) << " " << *max_element(a, a + n) << " " << accumulate(a, a + n, int64()) << '\n';
  
  return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 200005;
const int MOD = 998244353;

int n, k;
int dp[N], suf[N];
int A[15], B[15];

int query(int x, int y) {
	int ret = suf[x] - suf[y+1];
	ret %= MOD;
	if (ret < 0) ret += MOD;
	return ret;
}

void fillTable() {
	dp[n] = 1;
	suf[n] = 1;
	for (int pos = n-1; pos >= 1; pos--) {
		for (int i = 0; i < k; i++) {
			int lft = pos + A[i];
			if (lft > n) continue;
			int rght = min(n, pos + B[i]);
			dp[pos] = (dp[pos] + query(lft, rght)) % MOD;
		}
		suf[pos] = (dp[pos] + suf[pos+1]) % MOD;
	}
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < k; i++) {
		scanf("%d %d", &A[i], &B[i]);
	}
	fillTable();
	printf("%d\n", dp[1]);
	return 0;
}

Measured memory_bytes: 5280
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int ans = 0;
		
		int k = ((l-1)/2019 + 1)*2019; //L <= k
		if(l == 0){
			k = 0;
		}

		if(k <= r){
			ans = 0;
		}else{
			ans = 2018;
			int min = l % 2019;
			int max = r % 2019;
			for(int i = min ; i < max ; i++)
			{
				for(int j = i+1 ; j <= max ; j++){
					ans = ans > ((i*j) % 2019) ?  ((i*j) % 2019) : ans;
				}
			}
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    string s;
    cin >> s;
    string t;
    cin >> t;

    const int filt_size = t.size();

    for (int sp = s.size()-1; sp >= 0; --sp) {
        // cout << "loop sp:" << sp << endl;
        bool match = true;
        for (int filt_i = 0; filt_i < filt_size; filt_i++) {
            if (s[sp-filt_i] != '?') {
                if (s[sp-filt_i] == t[filt_size-1-filt_i]) {
                    // match ok
                    // cout << "s,t = " << s[sp-filt_i] <<"," << t[filt_size-1-filt_i] << endl;

                } else {

                    // unmatched
                    // cout << "(unmatch)s,t = " << s[sp-filt_i] <<"," << t[filt_size-1-filt_i] << endl;
                    match = false;
                    break;
                }
            } else {
                // ? matches all of chars on the seq t
                // cout << "s,t = " << s[sp-filt_i] <<"," << t[filt_size-1-filt_i] << endl;

            }
        }

        // filter finish
        if (match) {
            // supply chars
            // cout << "match: " << sp << endl;
                for (int fill = 0; fill < filt_size; ++fill) {
                s[sp-fill] = t[t.size()-1-fill];
            }

            replace(s.begin(), s.end(), '?', 'a');

            cout << s << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
ll N, K;
bool d[10];

int main(void)
{
	cin >> N >> K;
	ll ans = 100000;
	FOR(i, 0, K) {
		int u;cin >> u;d[u] = true;
	}
	FOR(i, N, 100000) {
		bool flag=false; int k = i;
		while (k > 0) {
			if(d[k % 10] == true)flag=true;
			k /= 10;
		}
		if (!flag) {
			ans = i;
			break;
		}
	}
	ct(ans);

	return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=a;i<=b;i++){
        int s=i%10;
        int t=i/10000%10;
        int u=i/10%10;
        int r=i/1000%10;
        if(s==t && u==r) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
import math
import collections
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
cumax=(2*10**5)+10
cuml=[0]*cumax
#print(A)
ind=0
l=[]
c=collections.Counter(A)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
lr=[]
v=[]
for i in range(len(key)):
    lr.append([0,l[i][0]])
    v.append(l[i][1])
for i in range(len(v)):
    l=lr[i][0]
    r=lr[i][1]
    cuml[l]=cuml[l]+v[i]
    if r+1<cumax:
        cuml[r+1]=cuml[r+1]-v[i]
for i in range(cumax-1):
    cuml[i+1]=cuml[i+1]+cuml[i]
#print(cuml)
maxind=2*10**5+10
minind=0
while maxind-minind>1:
    piv=minind+(maxind-minind)//2       #pivは握手の幸福度
    cnt=0
    for i in range(N):
        x=piv-A[i]
        cnt=cnt+cuml[max(x,0)]
    if cnt<=M:
        maxind=piv
    else:
        minind=piv
    #print(cnt,maxind,piv,minind)
#print(minind)
thr=minind
cuml2=[0]*(N+1)
A.sort(reverse=True)
for i in range(N):
    cuml2[i+1]=cuml2[i]+A[i]
#print(cuml2,thr,A)
ans=0
counts=0
#print(cuml[0:10])
for i in range(N):
    x=thr-A[i]
    #print(x)
    cnt=cuml[max(x,0)]
    #print(cnt)
    ans=ans+(A[i]*cnt)+cuml2[cnt]
    counts=counts+cnt
ans=ans-(counts-M)*thr
#print()
print(ans)

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

int main(){
 int n,i,k,cnt;
  unsigned long long int p,ans;
  cin>>n>>p;
  if(n==1){
    ans=p;
  }else{
    ans=1;
    for(i=2;i<=sqrt(p);i++){
    cnt=0;
    while(p%i==0){
        p=p/i;cnt++;
    }
    while(cnt>=n){
          ans=ans*i;
          cnt=cnt-n;
    }
    }
  }
  cout << ans <<endl;
 return 0;
}


Measured memory_bytes: 256
from fractions import gcd
H,W,T=map(int, input().split())
gh, gw = gcd(H, T), gcd(W, T)
h, w = H // gh, W // gw
MOD = 1000000007
print(pow(pow(2, h, MOD) + pow(2, w, MOD) + pow(2, gcd(h, w), MOD) - 3, gh * gw, MOD))

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int cnt=0;
  for(int i=1;i<n-1;i++){
    if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1])){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
from itertools import accumulate
from bisect import bisect_left


def read():
    N, M, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    B = list(map(int, input().strip().split()))
    return N, M, K, A, B


def solve(N, M, K, A, B, INF=10**9+1):
    A = [0] + A
    B = [0] + B
    AS = list(accumulate(A))
    BS = list(accumulate(B))
    ans = 0
    axmax = min(bisect_left(AS, K+1)-1, N)
    for ax in range(axmax, -1, -1):
        bx = min(bisect_left(BS, K - AS[ax]+1)-1, M)
        ans = max(ans, ax + bx)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 50528
void main() {
	/*auto S = rs, T = rs;
	foreach(i; 0..S.length) {
		string tmp = S[1..$];
		tmp ~= S[0];
		if(S == T) {
			writeln("Yes");
			return;
		}
		S = tmp;
	}
	writeln("No");*/
	auto S = rs, T = rs;
	S ~= S;
	if(S.canFind(T)) writeln("Yes");
	else writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main() {
  int n;
  cin>>n;
  bool ans=false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==n)
        ans=true;
    }
  }
  
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>

int main()
{
	int N;
	int M;
	std::vector<int> a;
	std::vector<int> b;
	std::vector<int> c;
	std::vector<int> d;
	std::vector<int> answer;

	std::cin >> N >> M;

	a.resize(N);
	b.resize(N);
	for (int i = 0; i < N; i++)
	{
		std::cin >> a[i] >> b[i];
	}

	c.resize(M);
	d.resize(M);
	for (int i = 0; i < M; i++)
	{
		std::cin >> c[i] >> d[i];
	}

	answer.resize(N);
	for (int i = 0; i < N; i++)
	{
		int min_distance = INT_MAX;
		answer[i] = 0;

		for (int j = 0; j < M; j++)
		{
			int distance = std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]);
			if (min_distance > distance)
			{
				min_distance = distance;
				answer[i] = j + 1;
			}
		}
	}

	for (int i = 0; i < N; i++)
	{
		std::cout << answer[i] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3604
import sys
l, r = map(int, input().split())
if r-l>=2019:
    print("0")
elif r%2019==0 or l%2019==0:
    print("0")
else:
    min = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = i*j%2019
            if min > tmp:
                min = tmp
            if min == 0:
                print("0")
                sys.exit()
    print(min)

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

const double pi = 3.141592653589793;

signed main() {
	double a, b, c;
	cin >> a >> b >> c;
	c *= pi / 180;

	double S = a * b * sin(c) / 2;
	double L = sqrt(a * a + b * b - (2 * a * b * cos(c))) + a + b;
	double h = 2 * S / a;

	printf("%.9lf\n", S);
	printf("%.9lf\n", L);
	printf("%.9lf\n", h);
}



Measured memory_bytes: 3384
#include<iostream>
using namespace std;
int main(){
  int A[100][100],B[100];
  int c,n,m;
    cin >> n >> m;
 
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin >> A[i][j];
      }
    }

    for( int j=0;j<m;j++){
      cin >> B[j];}
    

    for(int i=0;i<n;i++){
      c=0;
      for(int j=0;j<m;j++){
	c+=A[i][j]*B[j];
	
      }
      cout << c  << endl; ;
    }


    return 0;}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

int A(int a , int b){
  
  return a + b;
}

int B(int a , int b){
  
  return a - b;
}

int C(int a , int b){
  
  return a * b;
}

int D(int a , int b){
  
  return a / b;
}
  
int main() {
  char op;
  
  int x , y;
  
  while(1){
  
  cin >> x >> op >> y;
    
  if(op == '?'){
    
    break;
  }
  
  if(op == '+'){
    
    cout << A(x , y) << endl;
  }
  
  else if(op == '-'){
   
    cout << B(x , y) << endl;
  }
  
  else if(op == '*'){
    
    cout << C(x , y) << endl;
  }
  
  else if(op == '/'){
    
    cout << D(x , y) << endl;
  }
  }
} 


Measured memory_bytes: 3080
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

/* http://oeis.org/A032981 */

int check(int64_t hoge) {
	int prev = -1;
	while (hoge > 0) {
		int cur = (int)(hoge % 10);
		hoge /= 10;
		if (prev >= 0 && abs(cur - prev) > 1) return 0;
		prev = cur;
	}
	return 1;
}

int64_t cheat[] = {
	0, INT64_C(22111101), INT64_C(76667876), INT64_C(223221112), INT64_C(434323221),
	INT64_C(566545665), INT64_C(777656545), INT64_C(1012101223), INT64_C(2101000111), INT64_C(2323212101)
};

int main(void) {
	int K;
	int64_t i = 0;
	int count = 0;
	int cnum;
	int cmax = (int)(sizeof(cheat) / sizeof(*cheat));
	if (scanf("%d", &K) != 1) return 1;
	cnum = K / 10000;
	if (cnum >= cmax) cnum = cmax - 1;
	i = cheat[cnum];
	count = cnum * 10000;
	if (K >= 79725 && K < 80000) {
		i = 2100000000;
		count = 79725;
	} else if (K >= 94829) {
		i = 3210000000;
		count = 94829;
	}
	while (count < K && ++i) {
		if (check(i)) count++;
	}
	printf("%" PRId64 "\n", i);
	return 0;
}


Measured memory_bytes: 128
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const LL INF = 1e18;
const int N = 100, V = 1e5;
LL dp[V + 5];
LL w[N + 5], v[N + 5];

void hora(int tc) {
	int n,ww;
	cin>>n>>ww;
	for(int i = 0;i < n;i++) cin>>w[i]>>v[i];
	for(int j = 0;j <= V;j++) dp[j] = INF;
	dp[0] = 0;
	for(int i = 0;i < n;i++) {
		for(int j = V;j >= v[i];j--) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
	}
	int res = 0;
	for(int i = 0;i <= V;i++) if(dp[i] <= ww) res = i;
	cout<<res<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}



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

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  
  for(int i=0;i<n;i++){
    int s;
    cin >> s;
    mp[s]++;
  }
  
  if(mp.size()==n){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 9600
import sys

input = sys.stdin.buffer.readline

n, m, limit = map(int, input().split())
infi = 10 ** 15
graph = [[infi] * (n + 1) for _ in range(n + 1)]
step = [[infi] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][a] = c
for i in range(1, n + 1):
    graph[i][i] = 0
for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j])
for i in range(1, n + 1):
    for j in range(1, n + 1):
        if graph[i][j] <= limit:
            graph[i][j] = 1
        elif graph[i][j] == 0:
            graph[i][j] = 0
        else:
            graph[i][j] = infi
for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j])


q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    if graph[a][b] == infi:
        graph[a][b] = 0
    print(graph[a][b] - 1 if graph[i][j] != infi else -1)


Measured memory_bytes: 54748
#include <iostream>
#include <vector>

int main(){
  int N;
  std::string str;
  std::cin >> N;
  std::cin >> str;
  long long  N_R = 0;
  long long  N_G = 0;
  long long  N_B = 0;
  
  for(int i = 0 ; i < N ; i++){
    if(str[i] == 'R') N_R++;
    if(str[i] == 'G') N_G++;
    if(str[i] == 'B') N_B++;
  }
  long long resa = N_R * N_G * N_B;

  for(int i = 0 ; i < N - 2; i++){
    for(int j = 1 ; i + j * 2 < N ; j++){
      if(str[i] != str[i + j] && str[i + j] != str[i + 2 * j] && str[i + 2 * j] != str[i]){
	resa--;
      }
    }
  }

  std::cout << resa << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        a: u64,
        b: u64,
    }
    for i in b * 10..(b + 1) * 10 {
        if (i as f64 * 0.08) as u64 == a {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}

Measured memory_bytes: 4352
def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
  return pflist

mod = (10 ** 9 + 7)
N = int(input())
ans = 0


pf_dict = {}
#素因数がキー、割れる回数を値として用意し、最後に約数の個数を求める
for i in range(2, N+1):

  pflist = getPrimeFactorsList(i)
  pfset = set(pflist)
  for j in pfset:
    if j in pf_dict:
      pf_dict[j] += pflist.count(j)
    else:
      pf_dict[j] = pflist.count(j)
    #count *= (pflist.count(j) + 1)
  
count = 1
for v in pf_dict.values():
  count *= (v + 1)
print(count % mod) 

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main(void) {
  int h, w;
  char mark;
  while(1) {
    cin >> h >> w;
    if(h+w == 0) break;
    rep(i, h) {
      rep(j, w) {
        mark = '.';
        if((i+h-1) % (h-1) == 0) mark = '#';
        if((j+w-1) % (w-1) == 0) mark = '#';
        cout << mark;
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
long double pi=3.1415926535897932384626433832795028;
int main(void){
  long double r;
  cin>>r;
  double ans=2*r*pi;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> pic(H+2, vector<char>(W+2, '#'));
  for(int i = 1; i < H+1; i++){
    for(int j = 1; j < W+1; j++){
      cin >> pic[i][j];
    }
  }
  for(int i = 0; i < H+2; i++){
    for(int j = 0; j < W+2; j++){
      cout << pic[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int n,m,d[100010],ta[200010],nt[400010],to[400010],co[400010],q[100010],u[100010]={};
int main(){
	int a,b,c,r,t,i,j;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)ta[i+1]=-1;
	for(i=0;i<m;i++){
		scanf("%d %d %d",&a,&b,&c);
		nt[i  ]=ta[to[i+m]=a];
		nt[i+m]=ta[to[i  ]=b];
		co[ta[a]=i  ]= c;
		co[ta[b]=i+m]=-c;
	}
	for(i=1;i<=n;i++){
		if(u[i])continue;
		u[q[t=0]=i]=1;
		d[i]=0;
		for(r=1;r-t;t++){//printf(":%d %d\n",q[t],d[q[t]]);
			for(j=ta[q[t]];j+1;j=nt[j]){//printf("%d %d %d\n",q[t],to[j],co[j]);
				if(u[to[j]]){
					if(d[to[j]]-d[q[t]]-co[j])goto END;
				}
				else u[q[r++]=to[j]]=1;
				d[to[j]]=d[q[t]]+co[j];
			}
		}
	}
	printf("Yes\n");
	return 0;
	END:;
	//for(i=0;i<n;i++)printf("%d ",d[i+1]);printf("\n");
	printf("No\n");
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);

void solve() {
  string a,b,c; cin >> a >> b >> c;
  int a_n = a.size()-1;
  int b_n = b.size()-1;
  int c_n = c.size()-1;
  if (a[a_n] == b[0] && b[b_n] == c[0]) {
    cout << "YES" << endl;
  } 
  else {
    cout << "NO" << endl;
  }
}

int main() {
  solve();
  return 0;
}



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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
bool tf(string s) {
    int n = s.length();
    if (s[0] != 'A') return false;
    int cnt = 0;
    int idx = -1;
    For(i, 2, n - 2) if (s[i] == 'C') {
        cnt++;
        idx = i;
    }
    if (cnt != 1) return false;
    For(i, 1, n - 1) {
        if (i == idx) continue;
        if (not('a' <= s[i] and s[i] <= 'z')) return false;
    }

    return true;
}

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ans = tf(s);
    print(ans ? "AC" : "WA");
    return 0;
}


Measured memory_bytes: 256