akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<double> p(n);
	for(int i=0;i<n;i++)cin>>p[i];
	vector<vector<double>> dp(n+1,vector<double>(n+1,0));
	dp[0][0]=1;// 0 considered...0 heads
	for(int i=1;i<=n;i++){
		double pp=p[i-1];
		dp[i][0]=(1-pp)*dp[i-1][0];
		for(int j=1;j<=i;j++){
			dp[i][j]=pp*dp[i-1][j-1]+(1-pp)*dp[i-1][j];
		}
	}
	double ans=0;
	for(int i=(n+1)/2;i<=n;i++){
		ans+=dp[n][i];
	}
	cout.precision(12);
	cout<<ans<<endl;
}


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

using namespace std;

const int nmax=100;
int n,v[nmax+5],best;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    reverse(v+1,v+n+1);
    for(int i=1;i<=n;i++)
        if(i%2==1)
            best+=v[i];
        else
            best-=v[i];
    cout<<best;
    return 0;
}
/**
**/


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

int main() {
	int N, K;
	cin >> N>>K;
	int B[200001] = { 0 }, a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		B[a]++;
}
	sort(B, B + N + 1);
	reverse(B, B + N + 1);
	int ans=0,L=0;
	for (int i = 0; i < K; i++)ans+=B[i];
	cout << N-ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ZTP001
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();

            int count = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] != B[i] && B[i] != C[i] && A[i] != C[i]) count += 2;
                else if (A[i] == B[i] && B[i] == C[i] && A[i] == C[i]) { }
                else count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

int w, h;
int side[20];
int front[20];

int main() {
  while (scanf("%d %d", &w, &h), w|h) {
    for (int i = 0; i < w; i++) {
      scanf("%d", &side[i]);
    }
    for (int i = 0; i < h; i++) {
      scanf("%d", &front[i]);
    }
    sort(side, side + w);
    sort(front, front + h);
    side[w] = 20000;
    front[h] = 20000;
    int index1 = 0;
    int index2 = 0;
    int ans = 0;
    while (index1 != w || index2 != h) {
      if (side[index1] == front[index2]) {
        ans += side[index1];
        index1++;
        index2++;
      } else if (side[index1] < front[index2]) {
        ans += side[index1];
        index1++;
      } else {
        ans += front[index2];
        index2++;
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	string s, ans;
  	int k;
  	cin >> s >> k;
  	for(int i = 0; i < s.size(); i++)
      if (i % k == 0)
        ans += s[i];
  	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{	
	int n,k;
	char s[51];
	scanf("%d %d %s",&n,&k,s);
	if(s[k-1]=='A'){
		s[k-1]='a';
	}
	if(s[k-1]=='B'){
		s[k-1]='b';
	}
	if(s[k-1]=='C'){
		s[k-1]='c';
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int H,W; cin >> H >> W;
  vector<string> s(H);
  rep(i, H) cin >> s[i];

  int l[H][W] = {}, r[H][W] = {}, u[H][W] = {}, d[H][W] = {};
  rep(h, H) rep(w, W){
    if(s[h][w] == '#') {l[h][w] = 0;u[h][w] = 0;}
    else{
      if(h == 0) u[h][w] = 1;
      else u[h][w] = u[h-1][w] + 1;
      if(w == 0) l[h][w] = 1;
      else l[h][w] = l[h][w-1] + 1;
    }
  }
  for (int h = H-1; h >= 0; h--) for(int w = W-1; w >= 0; w--){
    if(s[h][w] == '#') {r[h][w] = 0; d[h][w] = 0;}
    else{
      if(h == H-1) d[h][w] = 1;
      else d[h][w] = d[h+1][w] + 1;
      if(w == W-1) r[h][w] = 1;
      else r[h][w] = r[h][w+1] + 1;
    }
  }

  int ans = 0;
  rep(h, H) rep(w, W){
    chmax(ans,l[h][w]+r[h][w]+u[h][w]+d[h][w]-3);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 66816
int main(){
  int N, i;
  scanf("%d", &N);
  int student[N];
  int b[N];
  for(int i = 0; i<N;i++){
    scanf("%d", b+i);
    student[b[i]-1] = i+1; 
  }
  for(int i = 0; i<N; i++)
    printf("%d ", student[i]);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    double r0,w0,c,r;
    while(cin>>r0>>w0>>c>>r,c){
        int ans=ceil((c*w0-r0)/r);
        cout<<max(ans,0)<<endl;
    }
}

Measured memory_bytes: 3152
N, X, Y = map(int, input().split())

ans_array = [0] * N

for i in range(1, N+1):
    for j in range(i+1, N+1):
        dis1 = j - i
        dis2 = abs(i-X) + 1 + abs(Y-j)
        dis = min(dis1, dis2)
        ans_array[dis] += 1

for i in ans_array[1:]:
    print(i)


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

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) cout << (j % 2 == (i % 2 == 0 ? 0 : 1) ? "#" : ".");
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3080
/*input
2 100
10 10
*/
/**
    Author: Kristopher Paul
    Date Created: 11-01-2020
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//Uncomment for File I/O
/*
#define cin fin
#define cout fout

ifstream fin("input.in");
ofstream fout("input.out");
*/

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n,k;
    cin >> n >> k;
    int arr[n];
    FOR(i,0,n){
        cin >> arr[i];
    }
    int dp[n];
    dp[0] = 0;
    FOR(i,1,n){
        dp[i] = 1e18;
        FORD(j,i-1,i-k){
            if(j < 0){
                break;
            }
            remin(dp[i],dp[j]+abs(arr[j]-arr[i]));
        }
        //dp[i] = min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout << dp[n-1] << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}



Measured memory_bytes: 1792
import statistics

def solve():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(A[i]-(i+1) for i in range(N))
    B.sort()
    b = int(statistics.median(B))
    ##print(b)
    ans = 0
    for i in range(1,N+1):
        ans += abs(A[i-1]-(b+i))
    print(ans)
    ##ans2 = sum([A[i-1]-(b+i) for i in range(1,N+1)])
    ##print(ans2)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 27252
import sys
input = lambda: sys.stdin.readline().rstrip()

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

# ループがあるか見つけ、ループのサイズを見つける
# ループしている場合、残りのｋをループで割ったあまりに置き換える
INF = 10**12
cnt = [-1 for _ in range(n)]
cur = 0
size = INF
idx = 0

for i in range(k):
    if cnt[cur] != -1:
        size = i - cnt[cur]
        idx = i
        for j in range((k - idx) % size):
            next_idx = a[cur] - 1
            cur = next_idx
        print(cur + 1)
        exit()
    cnt[cur] = i
    next_idx = a[cur] - 1
    cur = next_idx
print(cur + 1)

Measured memory_bytes: 99552
#include<stdio.h>

int main(void){

  int s, a, b, c, d;

  scanf("%d", &s);

  a = s / 1000;
  b = s % 1000 / 100;
  c = s % 100 / 10;
  d = s % 10;

  if(a == b){
    printf("Bad\n");
  }
  else if(b == c){
    printf("Bad\n");
  }
  else if(c == d){
    printf("Bad\n");
  }
  else{
    printf("Good\n");
  }

  return 0;
}


Measured memory_bytes: 128
N = gets.to_i
D = gets.split.map(&:to_i)
M = gets.to_i
T = gets.split.map(&:to_i)
res = true
if N < M
    res = false
elsif N== M
    res = D.sort==T.sort
else
    h={}
    D.each do |d|
        if h.has_key?(d)
            h[d]+=1
        else
            h[d]=1
        end
    end
    T.each do |m|
        if h.has_key?(m) && h[m]>0
            h[m]-=1
        else
            res = false
            break
        end
    end
end
puts res ? "YES" : "NO"

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
   
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<"\n";
	return 0;
}

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



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

    unsigned long long x,y,br=0;

    cin>>x>>y;
    while(x<=y)
    {
        br++;
        x*=2;
    }
    cout<<br<<endl;

    return 0;
}


Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let mut p:Vec<u32> = (0..n).map(|_| read()).collect();

    p.sort();

    let mut ans = 0;
    for i in 0..k{
        ans += p[i];
    }

    print!("{}",ans);
    
}

Measured memory_bytes: 2152
#include<iostream>
#include<string>
using namespace std;
int main(){
  unsigned long long int k;
  string s;
  int i=0;
  cin >> s >> k;
  while(s[i]!=0){
    if(s[i]!='1'){
      cout << s[i]<<endl;
      break;
    }else if(i==k-1){
      cout << s[i]<<endl;
      break;
    }
    i++;
  }
  if(s[i]==0) cout <<"E"<<endl;

}


Measured memory_bytes: 384
def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
a,b=input().split()
a=int(a)
b=int(b)
ll=[]
y=-1
s=0
for i in range(b):
    x=input()
    x=int(x)
    ll.append(x)
    if x-y==1:
        s=1
        break
    y=x
ll.append(a+1)
l2=[]
if s==1:
    print(0)
else:
    x=-1
    for i in ll:
        l2.append(Fib(i-x))
        x=i
    ans=1
    for i in l2:
        ans*=i
    print(ans%1000000007)

Measured memory_bytes: 5424
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;

vector<int> tpological(int n, vector<int> g[100005]) {
  vector<int> h(n, 0);
  REP(i, n) {
    REP(j, g[i].size()) h[g[i][j]]++;
  }

  queue<int> que;
  REP(i, n) if(h[i] == 0) que.push(i);

  vector<int> res;
  while(!que.empty()) {
    int t = que.front(); que.pop();
    res.push_back(t);

    for(auto j: g[t]) {
      h[j]--;
      if(h[j] == 0) que.push(j);
    }
  }

  return res;
}

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

  cin >> n >> m;
  vector<int> g[100005];

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
  }

  vector<int> s = tpological(n, g);

  vector<int> dp(n, 0);
  REP(i, s.size()) {
    for(auto& j: g[s[i]]) {
      dp[j] = max(dp[j], dp[s[i]] + 1);
    }
  }

  int ans = 0;
  REP(i, n) ans = max(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define maxn 1000010
using namespace std;
int a[maxn];
bool check(int n, int k, int len)
{
	int need = 0;
	for (int i = 1; i <= n; i++)
	{
		int tmp = a[i] / len;
		if (a[i] % len == 0) need += tmp - 1;
		else need += tmp;
	}
	if (need <= k) return true;
	else return false;
}
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int l = 1, r = 1e9, ans = 0;
	while (l <= r)
	{
		int mid = (l + r) / 2;
		if (check(n, k, mid))
		{
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4532
/// Source : https://atcoder.jp/contests/arc060/tasks/arc060_c
/// Author : liuyubobobo
/// Time   : 2020-09-24

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;


/// Binary Lifting
/// Time Complexity: init: O(nlogn + nlog|max_dis|)
///                  query: O(log|max_dis| * logn)
/// Space Complexity: O(nlog|max_dis|)
class Hotels{

private:
    vector<vector<int>> dp;

public:
    Hotels(int N, int L, vector<int>& hotels) : dp(N){

        for(int i = 0; i < N; i ++){
            vector<int>::iterator iter = lower_bound(hotels.begin(), hotels.end(), hotels[i] + L);
            if(iter == hotels.end() || *iter > hotels[i] + L)
                iter --;
            dp[i].push_back(iter - hotels.begin());
        }
//        cout << "k == 0 completed" << endl;

        for(int k = 1; dp[0].back() != N - 1; k ++){
            for(int i = 0; i < N; i ++)
                dp[i].push_back(dp[dp[i][k - 1]][k - 1]);
        }
//        cout << "init completed" << endl;
    }

    int query(int a, int b){

        a --, b --;
        if(a > b) swap(a, b);

        int cur = a, res = 0;
        while(cur < b){
            int k = lower_bound(dp[cur].begin(), dp[cur].end(), b) - dp[cur].begin();
            if(k == 0) return res + 1;
            res += (1 << (k - 1));
            cur = dp[cur][k - 1];
        }
        return res;
    }

private:
    int binary_search(const vector<int>& v, int target){

        int l = -1, r = v.size() - 1;
        while(l < r){
            int mid = (l + r + 1) / 2;
            if(v[mid] > target) r = mid - 1;
            else l = mid;
        }
        return l;
    }
};

int main() {

//    vector<int> hotels1 = {1, 3, 6, 13, 15, 18, 19, 29, 31};
//    Hotels h1(9, 10, hotels1);
//    cout << h1.query(1, 8) << endl; // 4
//    cout << h1.query(7, 3) << endl; // 2
//    cout << h1.query(6, 7) << endl; // 1
//    cout << h1.query(8, 5) << endl; // 2
//    cout << h1.query(1, 9) << endl; // 5
//
//    for(int a = 1; a < 9; a ++)
//        for(int b = a + 1; b <= 9; b ++)
//            cout << a << " " << b << " : " << h1.query(a, b) << endl;
//    cout << "test completed!" << endl;

    int N;
    scanf("%d", &N);

    vector<int> hotels(N);
    for(int i = 0; i < N; i ++) scanf("%d", &hotels[i]);

    int L;
    scanf("%d", &L);

    Hotels h(N, L, hotels);

    int Q, a, b;
    scanf("%d", &Q);
    while(Q --){
        scanf("%d%d", &a, &b);
        printf("%d\n", h.query(a, b));
    }

    return 0;
}


Measured memory_bytes: 19828
#include <stdio.h>

int gcd(int x,int y);

int main(){
    int x,y,ans;
    scanf("%d %d",&x,&y);
    
    ans=gcd(x,y);
    printf("%d\n",ans);

    return 0;
}

int gcd(int x,int y){
    int d;
    while( (d=x%y) != 0){
        x=y;
        y=d;
    }
    return y;
}



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

int main () {
 int x,y;

 while (cin >> x >> y) {
  if (x == 0 && y == 0) {
   break;
  } else {
   if (x > y) {
    cout << y << ' ' << x <<endl; 
   } else {
    cout << x << ' ' << y <<endl;
   }
  }  
 }

 return 0;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll n; cin >> n;
    while(n) {
    	ll dig = n%10;
    	if(dig == 7) {cout << "Yes"; return 0;}
    	n /= 10;
    }

    cout << "No";
}

Measured memory_bytes: 3556
n,q=map(int, input().split())
s=input()
num_ac=[0 for i in range(n)]
#num_ac[i]はi+1文字目までのACの数？
for i in range(1,n):
    num_ac[i]=num_ac[i-1]
    if s[i]=='C' and s[i-1]=='A':
        num_ac[i]+=1
for i in range(q):
    l,r=map(int,input().split())
    print(num_ac[r-1]-num_ac[l-1])

Measured memory_bytes: 6184
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){
    return ((n + d -1) / d);
}
/*
inline double Sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
*/
// }}}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 1;
    reps(i,n){
        (ans *= i) %= mod;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;



int main(void){
    ll n;
    cin >> n;
    char c[26+1]="abcdefghijklmnopqrstuvwxyz";
    vector<char> v;
    while(n){
        v.push_back(c[(--n)%26]);
        n/=26;
    }
    RREP(i,(int)v.size()-1)
        cout << v[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3584
s = input()

le = len(s)

if le % 2 == 0: #文字列の長さが偶数
  mid = int(le / 2)
  s1 = s[:mid]
  s2 = s[mid:]
  count = 0
  for i in range(mid):
    tmp1 = s1[i]
    tmp2 = s2[len(s2) - 1 - i]
    if tmp1 != tmp2:
      count += 1
  print(count)
  exit()

mid  = le // 2
s1 = s[:mid]
s2 = s[mid + 1: ]
count = 0
for i in range(mid):
  tmp1 = s1[i]
  tmp2 = s2[len(s2) - 1 - i]
  if tmp1 != tmp2:
    count += 1
print(count)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,cnt=0,x,y;
    cin >> n;
    vector<int> v,p(n),q(n);
    for(int i=0;i<n;i++) cin >> p[i];
    for(int i=0;i<n;i++) cin >> q[i];
    for(int i=1;i<=n;i++) v.push_back(i);
    do{
        cnt++;
        if(v==p) x=cnt;
        if(v==q) y=cnt;
    }while(next_permutation(v.begin(),v.end()));
    cout << abs(x-y) << endl;
}

Measured memory_bytes: 3592
#D問題
import math
H,W,D=map(int,input().split())
A=[]
amap=[[-1,-1] for i in range(H*W+D)]
for i in range(H):
    a=list(map(int,input().split()))
    for j in range(W):
        amap[a[j]]=[i,j]
    A.append(a)
Q=int(input())
LR=[list(map(int,input().split())) for i in range(Q)]
syo=int(H*W/D)
dp=[[0 for i in range(syo+1)] for j in range(D)] #dp[modD][/D]=(modDまでの距離)
for i in range(1,syo+1):
    j=0
    if i == syo:
        d=H*W%D
        for j in range(d):
            dp[j][i]=dp[j][i-1]+abs(amap[i*D+j][0]-amap[i*D+j-D][0])+abs(amap[i*D+j][1]-amap[i*D+j-D][1])  
    for j in range(D):
        dp[j][i]=dp[j][i-1]+abs(amap[i*D+j][0]-amap[i*D+j-D][0])+abs(amap[i*D+j][1]-amap[i*D+j-D][1])
for i in range(Q):
    L=LR[i][0]
    R=LR[i][1]
    mod=L%D
    l=int(L/D)
    r=int(R/D)
    print(dp[mod][r]-dp[mod][l])


Measured memory_bytes: 59016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
const ll INF = 1e15;

int main()
{
    int N;
    cin >> N;
    int s[N + 1]={0};

    // REP1(i,N){ cout << s[i] << endl;}
    for (int i = 1; i <= N; i += 2)
    {
        int tmp = i;
        while (tmp <= N)
        {
            s[tmp] += 1;
            tmp += i;
        }
    }
    int ans = 0;
    for (int i = 1; i <= N; i += 2)
    {
        if (s[i] == 8)
            ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
implicit none
integer :: n
integer,allocatable :: a(:)
integer :: i
read *,n
allocate(a(n))
read *,(a(i),i=1,n)

write(6,'(i0)',advance='no') a(n)
if (n == 1)  stop

i = n - 2
do while (i > 0)
   write(6,'(1x,i0)',advance='no') a(i)
   i = i - 2
enddo

i = mod(n,2) + 1
do while (i < n)
   write(6,'(1x,i0)',advance='no') a(i)
   i = i + 2
enddo
stop
end

Measured memory_bytes: 3456
class Node:
    def __init__(self, key, priority):
        self.key = key
        self.priority = priority
        self.parent = None
        self.left = None
        self.right = None


def rightRotate(t):
    s = t.left
    t.left = s.right
    s.right = t
    return s


def leftRotate(t):
    s = t.right
    t.right = s.left
    s.left = t
    return s


def insert(t, key, priority):
    if t is None:
        return Node(key, priority)
    if key == t.key:
        return t

    if key < t.key:
        t.left = insert(t.left, key, priority)
        if t.priority < t.left.priority:
            t = rightRotate(t)
    else:
        t.right = insert(t.right, key, priority)
        if t.priority < t.right.priority:
            t = leftRotate(t)

    return t


def delete(t, key):
    if t is None:
        return None
    if key < t.key:
        t.left = delete(t.left, key)
    elif key > t.key:
        t.right = delete(t.right, key)
    else:
        return _delete(t, key)
    return t


def _delete(t, key):
    if t.left is None and t.right is None:
        return None
    elif t.left is None:
        t = leftRotate(t)
    elif t.right is None:
        t = rightRotate(t)
    else:
        if t.left.priority > t.right.priority:
            t = rightRotate(t)
        else:
            t = leftRotate(t)
    return delete(t, key)


def find(t, key):
    if key == t.key:
        return t

    elif key < t.key:
        if t.left is not None:
            ret = find(t.left, key)
            if ret is not None:
                return ret
    else:
        if t.right is not None:
            ret = find(t.right, key)
            if ret is not None:
                return ret

    return None


def preorder(t, ret):
    ret.append(t.key)

    if t.left is not None:
        preorder(t.left, ret)

    if t.right is not None:
        preorder(t.right, ret)


def inorder(t, ret):
    if t.left is not None:
        inorder(t.left, ret)

    ret.append(t.key)

    if t.right is not None:
        inorder(t.right, ret)


def main():
    m = int(input())
    Treap = None
    for i in range(m):
        cmd, *v = input().split()
        if cmd == "print":
            print(" ", end="")
            inans = []
            inorder(Treap, inans)
            print(*inans)
            print(" ", end="")
            preans = []
            preorder(Treap, preans)
            print(*preans)
        elif cmd == "insert":
            k = int(v[0])
            p = int(v[1])
            Treap = insert(Treap, k, p)
        elif cmd == "find":
            z = int(v[0])
            if find(Treap, z) == None:
                print("no")
            else:
                print("yes")
        else:
            z = int(v[0])
            Treap = delete(Treap, z)


if __name__ == '__main__':
    main()



Measured memory_bytes: 56720
def swappingBibs(a, k):
	for i in range(0, len(a)-1):
		if a[i]%k>a[i+1]%k:
			a[i], a[i+1] = a[i+1], a[i]
	return a


N, M = map(int, input().split())
A = [int(input()) for _ in range(N)]
for m in range(1, M+1):
	A = swappingBibs(A, m)

for j in A: print(j)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N = 100;
int grid[N+1][N+1];
bool vis[N+1][N+1];
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	memset(grid, 0, sizeof(grid));
	memset(vis, false, sizeof(vis));
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		int x,y,h; cin >> x >> y >> h;	
		grid[x][y] = h;
		vis[x][y] = true;
	}
	
	int cx, cy, realH;
	
	bool found = false;
	for (int i = 0; i < N+1; i++){
		for (int j = 0; j < N+1; j++){
			int fakeH = 0;
			for (int x = 0; x < N+1; x++){
				for (int y = 0; y < N+1; y++){
					if (grid[x][y]){
							fakeH = grid[x][y] + abs(x-i) + abs(y-j);
					}
				}
			}
				
			
			bool valid = true;
			for (int x = 0; x < N+1; x++){
				for (int y = 0; y < N+1; y++){
					if (vis[x][y]){
						if (max(0,fakeH-abs(x-i)-abs(y-j)) != grid[x][y]){
							valid = false;
							break;
						}
					}
				}
				if (!valid) break;
			}
			
			if (valid){
				found = true;
				cx = i;
				cy = j;
				realH = fakeH;
			}
		}
	}
	
	cout << cx << " " << cy << " " << realH << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int L, R, d;
  int count = 0;
  cin >> L >> R >> d;
  for (int i = L; i < R+1; i++) {
    if(i%d == 0){
       count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	k, a, b := readInt(), readInt(), readInt()

	for i := a; i < b+1; i++ {
		if i%k == 0 {
			fmt.Println("OK")
			return
		}
	}

	fmt.Println("NG")
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1756
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>

using std::endl;

#define ll long long int
#define loop(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

int A, B;

ll X;

ll ans;

int main()
{
	IN >> A >> B;

	if (B == 100)
	{
		X = sqrt(A * 1000 + B);
		ans = A * 1000 + B;
	}
	else if(10 <= B)
	{
		X = sqrt(A * 100 + B);
		ans = A * 100 + B;
	}
	else
	{
		X = sqrt(A * 10 + B);
		ans = A * 10 + B;
	}

	X = X * X;

	if (ans == X) puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 256
use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        n: usize,
        s: Chars,
    }
    let white = s.iter().filter(|c| **c == 'W').count();
    let mut left_white = 0;
    let mut ans = std::cmp::min(white, n - white);
    for (i, &c) in s.iter().enumerate() {
        if c == 'W' {
            left_white += 1;
        }
        let right_red = n - (i + 1) - (white - left_white);
        let d = std::cmp::min(left_white, right_red);
        ans = std::cmp::min(ans, left_white + right_red - 2 * d + d);
    }
    println!("{}", ans);
}

fn main() {
    run();
}

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

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

  int result = 0;

  for (int i = 0; i < N; ++i) {
    int A, B;
    cin >> A >> B;

    if (A == B) {
      ++result;
    } else if (result < 3) {
      result = 0;
    }
  }

  cout << (result >= 3 ? "Yes" : "No") << endl;

  return 0;
}


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


//???????????????
//???????????????????´???????????°?????????¢?´¢???????????????????????????????´???¨??????????????¢?????´?????????
void SelectionSort(int N, vector <int> list){

	int min,v,count=0;

	for (int i = 0; i < N - 1; i++){
		min = i;
		for (int j = i+1; j < N; j++){
			if (list[min] > list[j]){
				min = j;
			}
	
		}

		if (min!=i){
			v = list[min];
			list[min] = list[i];
			list[i] = v;
			count++;
		}
	
	}

	for (int k = 0; k < N; k++){
		cout << list[k];
		if (k != N - 1)cout << " ";
	}cout << endl;

	cout << count << endl;

}


int main(){

	int N,Num;
	cin >> N;
	vector <int> Sort(N, 0);
	for (int i = 0; i < N; i++){
		cin >> Num;
		Sort[i] = Num;	
	}

	SelectionSort(N, Sort);

	return 0;
}

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

int main() {
	long double n,k;
	cin>>n>>k;
	long double prob=0;
	for(int i=1;i<=n;i++){
		long double x=1;
		prob+=min(x,pow(0.5,ceil(log2(k/i))));
	}
	cout<<fixed<<setprecision(12)<<prob/n;
}

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

int main(){
    int N;
    string s, t;
    cin >> N >> s >> t;
    for(int i=N; i<=2*N; i++){
        if(s.substr(i-N,2*N-i) == t.substr(0,2*N-i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>n;--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000007
#define inf 1e18
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define bye return

int main()
{
    ll h,a,c=0,flag=0,i,n;
    cin>>h>>n;
        
    ll A[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
        /*if(h<=0)
        {
            flag=1;
        }*/
        h=h-A[i];
    }
    //cout<<h<<endl;
    if(h<=0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    //cout<<c<<endl;
    bye 0;

}

Measured memory_bytes: 1024
class Node:
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None


def run():
    n = int(input())
    tail = Node(None)
    node = tail

    for _ in range(n):
        command = input()
        if command.startswith('0'):
            nn = Node(int(command[2:]))
            nn.prev, nn.next = node.prev, node
            if node.prev is not None:
                node.prev.next = nn
            node.prev = nn
            node = node.prev
        elif command.startswith('1'):
            i = int(command[2:])
            if i > 0:
                for _ in range(i):
                    node = node.next
            else:
                for _ in range(-i):
                    node = node.prev
        elif command.startswith('2'):
            p, n = node.prev, node.next
            node.prev, node.next = None, None
            node = n
            if p is None:
                n.prev = None
            else:
                n.prev, p.next = p, n
        else:
            raise ValueError('invalid command')

    st = []
    node = tail.prev
    while node is not None:
        st.append(node.value)
        node = node.prev

    while len(st) > 0:
        print(st.pop())


if __name__ == '__main__':
    run()


Measured memory_bytes: 92988
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}



int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main(void){
	int t, x;
	scanf("%d %d", &t, &x );
	printf("%f", (t*1.0) / (x*1.0));
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int b[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  int operation[n];
  int flag;
  for (int end = n-1; end >= 0; end--) {
    flag = 0;
    for (int j = end; j >= 0; j--) {
      if (b[j] == j+1) {
        flag = 1;
        operation[end] = b[j];
        for (int k = j; k < end; k++) {
          b[k] = b[k+1];
        }
        break;
      }
    }
    if (flag == 0) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", operation[i]);
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 2e6 + 9;
const int mod = 1e9 + 7;

int n, k;
int a;



int main(){

scanf("%d%d", &n, &k);

int g, m;
scanf("%d", &g);
m = g;

for(int i=1; i<n; i++){
    scanf("%d", &a);
    g = __gcd(g, a);
    m = max(m, a);
}

if(k <= m && k % g == 0){
    printf("POSSIBLE\n");
} else{
    printf("IMPOSSIBLE\n");
}

return 0;

}


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

int main(){
        int H, W;
        while(cin >> H >> W && H || W){
                for(int i = 0; i < H; i++){
                        for(int ii = 0; ii < W; ii++){
                                if((i%2==0 && ii%2==0) || (i%2!=0 && ii%2!=0)){
                                        cout << '#';
                                }else{
                                        cout << '.';
                                }
                        }
                        cout << endl;
                }
                cout << endl;
        }
}


Measured memory_bytes: 3112
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))
#define each(itr,v) for(auto (itr):(v))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	long long A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	long long ans =gcd(A[0],A[1]);
	for (int i = 1; i < N; i++) {
		ans=gcd(gcd(A[i],A[i-1]),ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll l,r;
    cin >> l >> r;
    int ans=2018;
    if(r-l>=2019)ans = 0;
    else {
        l %= 2019;
        r %= 2019;
        if(l>r)ans = 0;
        else {
            for(int i = l;i<r;i++){
                for(int j=i+1;j<=r;j++){
                    chmin(ans,(i*j)%2019);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int money = 0;
	int ans = 0;

	cin >> money;

	ans += money / 500 * 1000;
	money %= 500;
	ans += money / 5 * 5;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a, b, c = [], [], []
# dp = [[None] * 3 for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]

for i in range(n):
    v1, v2, v3 = map(int, input().split())
    a.append(v1)
    b.append(v2)
    c.append(v3)

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

def solve(idx, ptn):
    if dp[idx][ptn] > 0:
        return dp[idx][ptn]

    # Select A(0)
    if ptn == 0:
        if idx == 0:
            return a[0]
        a1 = solve(idx - 1, 1) + a[idx]
        a2 = solve(idx - 1, 2) + a[idx]
        dp[idx][0] = max(a1, a2)
        return dp[idx][0]

    # Select B(1)
    if ptn == 1:
        if idx == 0:
            return b[0]
        b1 = solve(idx - 1, 0) + b[idx]
        b2 = solve(idx - 1, 2) + b[idx]
        dp[idx][1] = max(b1, b2)
        return dp[idx][1]

    # Select C(2)
    if ptn == 2:
        if idx == 0:
            return c[0]
        c1 = solve(idx - 1, 0) + c[idx]
        c2 = solve(idx - 1, 1) + c[idx]
        dp[idx][2] = max(c1, c2)
        return dp[idx][2]

ans1 = solve(n-1, 0)
ans2 = solve(n-1, 1)
ans3 = solve(n-1, 2)
print(max(ans1, ans2, ans3))

Measured memory_bytes: 188452
n,m = map(int,input().split())
a = [list(map(int,input().split()))for i in range(m)]

for i in range(10**n):
    tmp = str(i)
    if len(tmp) == n:
        f = True
        for s,c in a:
            if tmp[s-1] != str(c):
                f = False
                break
        if f :
            print(i)
            exit()
print(-1)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cassert>

typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::max;
using std::min;
using std::abs;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
//typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010

     ll N,M;
     ll A,B,C;
     ll K[11],P[11];
     ll ans;
     char S[100];
int main() {
    cin>>A;
    printf("%lf",(A*A*A)/27.00000000);

	return 0;
}


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

int main(void)
{
	int dp[4][64];
	int n;
	int i, j, k;

	memset(dp, 0, sizeof(dp));
	for (i = 0; i < 10; i++){
		dp[0][i]++;
	}
	for (i = 0; i < 3; i++){
		for (j = 0; j <= 27; j++){
			if (dp[i][j] > 0){
				for (k = 0; k < 10; k++){
					dp[i + 1][j + k] += dp[i][j];
				}
			}
		}
	}

	while (~scanf("%d", &n)){
		printf("%d\n", dp[3][n]);
	}

	return (0);
}

Measured memory_bytes: 596