akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, s.size()) {
      if (s[i] == '9') {
        s[i] = '1';
      } else if (s[i] == '1') {
        s[i] = '9';
      }
    }

    cout << s << '\n';

    return 0;
}


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

int N, M;
int A[100000];
vector<int> G[100000];
bool used[100000];
multiset<int> ms[100000];

void DFS(int from, int prev, int start) {
  used[from] = true;
  ms[start].insert(A[from]);
  for(int to : G[from]){
    if (to == prev || used[to]) continue;
    DFS(to, from, start);
  }
}

int main() {
  cin >> N >> M;
  if (M + 1 == N) {
    cout << 0 << endl;
    return 0;
  }
  
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<int> tr;
  for (int i = 0; i < N; ++i) {
    if (used[i]) continue;
    tr.push_back(i);
    DFS(i, -1, i);
  }
  
  long long sum = 0;
  vector<int> v;
  for (int i = 0; i < tr.size(); ++i) {
    multiset<int>& z = ms[tr[i]];
    sum += *z.begin();
    for (auto it = next(z.begin()); it != z.end(); ++it) {
      v.push_back(*it);
    }
  }
  
  sort(v.begin(), v.end());
  if(v.size() < tr.size() - 2) {
    cout << "Impossible" << endl;
    return 0;
  }
  
  for(int i = 0; i < tr.size() - 2; ++i) {
    sum += v[i];
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 16256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
ll n,ans,x,y,d,c;
int main(){FAST;xRand;
cin>>n;
for(int j=1;j<=n;j++){
	cin>>d>>c;
	x+=d*c;
	y+=c;
}
ans=(y-1)+(x-1)/9;
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

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

    cout << (b/a < c ? b/a : c) << endl;
}

Measured memory_bytes: 764
import java.util.Scanner;

class Main{

	public static void main(String[] args) {


		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();


		for(int i =0;i < S.length();i++){
			if(S.equals(T)){
				System.out.println("Yes");
				return;
			}else{
				T =  rotate(T);
			}
		}
		System.out.println("No");


	}

	static String rotate(String T){
		String aa = T.substring(1)+T.substring(0, 1);
		return aa;



	}


}








Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  int N,K,cnt=0;
  cin>>N>>K;
  vector<int> d(K),ans(N+5,0);
  vector<vector<int>> A(K);
  for(int i=0;i<K;i++){
    cin>>d[i];
    for(int j=0;j<d[i];j++){
      int a;
      cin>>a;
      ans[a]++;
    }
  }
  for(int i=1;i<=N;i++){
    if(ans[i]==0) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main()
{
	int i=0,j=0,n;/*待数、スイッチ*/
	int train[100],es[100];/*待ち電車、出発した電車*/

	while(scanf("%d",&n) != EOF)
	{
		if((i==0 && n==0) || (n<0 || n>10))
			continue;
		else if(n==0)
		{
			i--;
			es[j]=train[i];
			j++;
		}
		else
		{
			train[i]=n;/*納車*/
			i++;
		}
	}
	
	for(i=0;i<j;i++)
	{
		printf("%d\n",es[i]);
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r;
    cin >> r;
    if(r < 1200)
    {
        cout << "ABC";
    }
    else if(r < 2800)
    {
        cout << "ARC";
    }
    else
    {
        cout << "AGC";
    }
    
    return 0;
}

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

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] p = new int[n];
    int max = 0;
    int sum = 0;
    for(int i=0; i<n; i++) {
      p[i] = Integer.parseInt(in.readLine());
      max = Math.max(p[i],max);
      sum += p[i];
    }
    System.out.println(sum-(max/2));
  }
}

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

using namespace std;

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int n, f[N][2];
vector <int> g[N];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

void dfs (int u, int p) {
    f[u][0] = f[u][1] = 1;
    for (auto v: g[u]) {
        if (v == p) continue;
        dfs(v, u);
        f[u][0] = 1LL * f[u][0] * f[v][1] % mod;
        f[u][1] = 1LL * f[u][1] * (f[v][0] + f[v][1]) % mod;
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v); g[v].push_back(u);
    }
    
    dfs(1, 1);
    cout << (f[1][0] + f[1][1]) % mod;
    return 0;
}

Measured memory_bytes: 13440
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if(S.substring(2,3).equals(S.substring(3,4))&&S.substring(4,5).equals(S.substring(5,6))){
      System.out.println("Yes");
      return;
    }
    System.out.println("No");
  }
  

  
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		
		if(a+b<=2*c) {
			System.out.println(a*x+b*y);
			return;
		}
		else if(a>=2*c&&b>=2*c){
			System.out.println(Math.max(x,y)*2*c);
			return;
		}
		else if(a<2*c&&b>=2*c) {
			System.out.println(y*2*c+Math.max(0, x-y)*a);
			return;
		}
		else if(b<2*c&&a>=2*c) {
			System.out.println(x*2*c+Math.max(0, y-x)*b);
			return;
		}
		else if(a<2*c&&b<2*c&&a+b>2*c) {
			int m=Math.min(x, y);
			System.out.println(m*2*c+(y-m)*b+(x-m)*a);
			return;
		}
		
		
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int n = 0, m = 0, q = 0;
bool color[2050][2050];
int tot[2050][2050];
int lin[2050][2050][4];
signed main()
{
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1; i <= n; i++)
	{
		char str[2050];
		scanf("%s", str);
		for(int j = 1; j <= m; j++)
			color[i][j] = (str[j - 1] == '1');
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			tot[i][j] = color[i][j] - tot[i - 1][j - 1] + tot[i - 1][j] + tot[i][j - 1];
			lin[i][j][0] = (color[i][j] & color[i - 1][j]) - lin[i - 1][j - 1][0] + lin[i - 1][j][0] + lin[i][j - 1][0];
			lin[i][j][1] = (color[i][j] & color[i + 1][j]) - lin[i - 1][j - 1][1] + lin[i - 1][j][1] + lin[i][j - 1][1];
			lin[i][j][2] = (color[i][j] & color[i][j - 1]) - lin[i - 1][j - 1][2] + lin[i - 1][j][2] + lin[i][j - 1][2];
			lin[i][j][3] = (color[i][j] & color[i][j + 1]) - lin[i - 1][j - 1][3] + lin[i - 1][j][3] + lin[i][j - 1][3];
		}
	for(int i = 1; i <= q; i++)
	{
		int a = 0, b = 0, c = 0, d = 0, s = 0;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		s += tot[c][d] + tot[a - 1][b - 1] - tot[a - 1][d] - tot[c][b - 1];
		s -= lin[c][d][0] + lin[a][b - 1][0] - lin[a][d][0] - lin[c][b - 1][0];
		s -= lin[c][d][2] + lin[a - 1][b][2] - lin[a - 1][d][2] - lin[c][b][2];
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 87808
/*
* CountingSort
*/

#include<iostream>
#include<vector>
using namespace std;

void input(vector<int> &A){
	int n =0;
	cin >> n;
	A.resize(n);
	for(int i=0; i<n ; i++){
	 	cin >> A[i];
	}
}

void output(vector<int> &out){
	 int size = out.size();
	 for(int i=0; i<size ; i++){
	 	cout << out[i];
	 	if(i< size-1){
	 		cout << " ";
	 	}
	 }
	cout << endl;
}

void CountingSort(vector<int> &A, vector<int> &B, int k){
	int n = A.size();
	//0?????????
	vector<int> C(k,0);
//	for(int i=0; i<k; i++){
//		C[i]=0;
//	}
	//C[i] ??? i ???????????°????¨??????????
	for(int j=0; j<n; j++){
		C[A[j]]++;
	}
	// C[i] ??? i ??\????????°???????????°????¨??????????
	for(int i=1; i<k ;i++){
		C[i] += C[i-1];
	}
	for(int j= (n-1); j>=0; j--){
		B[C[A[j]]-1] = A[j];
		C[A[j]]--;
	}
	return;
}

int main(){
	
	vector<int> vecA;
	input(vecA);
	vector<int> vecB(vecA.size(),0);
	CountingSort(vecA, vecB, 10000);
	output(vecB);
	return 0;
}

Measured memory_bytes: 18328
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int main()
{
    int n=read(),d=read(),c;
    d=d+d+1;c=n/d;if(n%d)c++;
    cout<<c<<"\n";
    	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
string s,t;cin >> s >> t;
int cnt=0;
rep(i,3){
    if(s[i]==t[i])cnt++;
}
cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    
    double v[50];
    for(int i=0; i<N; i++){
        cin >> v[i];
    }
    
    sort(v,v+N);
    
    for(int i=1; i<N; i++){
        v[i] = (v[i-1]+v[i])/2;
    }
    
    cout << fixed << setprecision(10) << v[N-1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final long MOD = 1_000_000_007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long m = sc.nextInt();
		long k = sc.nextInt();
		long ans1 = 0;
		long ans2 = 0;
		for (long i=1;i<m;i++) {
			ans1 += (i*(m-i)%MOD);
			ans1 %= MOD;
		}
		ans1 = ans1*n%MOD*n%MOD;
		for (long i=1;i<n;i++) {
			ans2 += (i*(n-i)%MOD);
			ans2 %= MOD;
		}
		ans2 = ans2*m%MOD*m%MOD;
		
		long ans = ans1+ans2;
		for (int i=1;i<=k-2;i++) {
			ans = ans*(n*m-1-i)%MOD;
			ans = div(ans, i);
		}
		System.out.println(ans);
		
	}
	
	static long power (long x, long y) {
		if (y==0) {
			return 1;
		} else if (y==1) {
			return x;
		} else if (y%2==0) {
			long tmp = power(x,y/2);
			return (tmp*tmp)%MOD;
		} else {
			long tmp = power(x,y/2);
			return (((tmp*tmp)%MOD)*x)%MOD;
		}
	}
	
	static long div (long x, long y) {
		return (x*power(y, MOD-2))%MOD;
	}
}




Measured memory_bytes: 22996
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math
import collections

# 標準入力をスペースで区切って、intに変換 listに収納
int_list  = [int(x) for x in stdin.readline().rstrip().split()]

N = int_list[0]
K = int_list[1]
Q = int_list[2]

A = []

for i in range(Q):
    A.append(stdin.readline().rstrip())

c_dict = collections.Counter(A)

border = Q -K  + 1

for i in range(1,N+1):
    if border <= 0:
        print('Yes')
    elif c_dict[str(i)] >= border:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14328
#include <iostream>
#define MAX_LENGTH 100
using namespace std;

char S[MAX_LENGTH] = {0};
char T[MAX_LENGTH] = {0};
char res[MAX_LENGTH << 1] = {0};
int main(int argc, char const *argv[])
{
	int length;
	cin >> length;
	scanf("%s %s", S, T);
	for (int i = 0; i < length; ++i)
	{
		res[i << 1] = S[i];
		res[(i << 1) + 1] = T[i];
	}
	printf("%s", res);
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> h(N), ma(N, 0);
  for (int i = 0; i < N; ++i) cin >> h[i];
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }
  int res = 0;
  for (int i = 0; i < N; ++i) if (h[i] > ma[i]) ++res;
  cout << res << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, m; read(n, m);
	map<int, map<int, int>> hist;

	rep(i, 1, m + 1) {
		int p, y; read(p, y);
		hist[p][y] = i;
	}
	
	vector<string> ans(m + 1);
	
	for (auto p : hist) {
		int ind = 1;
		for (auto p2 : p.second) {
			char buf[13];
			sprintf(buf, "%06d%06d", p.first, ind++);
			ans[p2.second] = string(buf);
		}
	}

	rep(i, 1, m + 1) write(ans[i]);
}


Measured memory_bytes: 20992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 998244353;



///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int X, Y;
int ans = 0;

int main(){
    
    cin>>X>>Y;
    if( X == 1 && Y == 1 ) ans = 1000000;
    else{
        if( X == 1 ) ans += 300000;
        if( X == 2 ) ans += 200000;
        if( X == 3 ) ans += 100000;
        if( Y == 1 ) ans += 300000;
        if( Y == 2 ) ans += 200000;
        if( Y == 3 ) ans += 100000;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a==5 and b==5 and c==7 or a==7 and b==5 and c==5 or a==5 and b==7 and c==5:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	string h=s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++){
		if(s[i]=='b'){
			s[i]='d';
		}
		else if(s[i]=='d'){
			s[i]='b';
		}
		if(s[i]=='p'){
			s[i]='q';
		}
		else if(s[i]=='q'){
			s[i]='p';
		}
	}
	if(s==h){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 512
from bisect import *
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = a[-1]//2
b = bisect_left(a,ans)
if a == [0,100]:
  print(100,0)
  exit()
if abs(ans-a[b]) <= abs(ans-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

Measured memory_bytes: 14052
#include <iostream>
    using namespace std;
    int calc(int x) {
    	int ret = 0;
    	while(x % 100 == 0) {
    		x /= 100;
    		++ret;
    	}
    	return ret;
    }
    int main() {
    	int D, N;
    	cin >> D >> N;
    	int cnt = 0, val = 0;
    	while(cnt < N) {
    		++val;
    		if(calc(val) == D) ++cnt;
    	}
    	cout << val << '\n';
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()

int n;
int32_t main() {
	cin >> n;
	int ans = 0;
	ans += (n/500) *1000;
	n %= 500;
	ans += (n/5) * 5;
	cout << ans;
}









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

int main() {

	int N;
	cin >> N;

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

	int x = 0 , y = 0;

	for (int i = 0; i < N - 1; i++) {
		if (V[i] < V[i + 1]) {
			if (x < y) x = y;
			y = 0;
			continue;
		}
		y++;
	}
	if (x < y) x = y;

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Msolutions2019
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            WriteLine((n - 2) * 180);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vv a(3,vi(3,0));
    vector <vb> b(3,vb(3,false));
    for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    ll n;
    cin>>n;
    while(n--)
    {
        ll x;
        cin>>x;
        for(ll i=0;i<3;i++)
        {
            for(ll j=0;j<3;j++)
            {
                if(a[i][j]==x)
                {
                    b[i][j]=true;
                }
            }
        }
    }
    bool ans=false;
    for(ll i=0;i<3;i++)
    {
        bool alltrue=true;
        for(ll j=0;j<3;j++)
        {
            if(b[i][j]==false)
            {
                alltrue=false;
            }
        }
        if(alltrue)
            ans=true;
        alltrue=true;
        for(ll j=0;j<3;j++)
        {
            if(b[j][i]==false)
                alltrue=false;
        }
        if(alltrue)
            ans=true;
    }
    if(b[0][0] && b[1][1] && b[2][2])
        ans=true;
    if(b[0][2] && b[1][1] && b[2][0])
        ans=true;
    if(ans)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

int main(){

    int n; int d;
    cin >> n >> d;

    vector<vector<int>> dim(n, vector<int>(d));

    for(int i = 0; i < n; i++){
        vector<int> v;
        for(int j = 0; j < d; j++){
            int x; cin >> x;
            v.push_back(x);
        }
        dim[i] =  v;
    }

    int s = 0;

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            float currs = 0;
            for(int k = 0; k < d; k++){
                currs += pow(abs(dim[i][k] - dim[j][k]), 2);
            }
            currs = sqrt(currs);

            if(floor(currs) == ceil(currs)) s++;
        }
    }

    cout <<s << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

const INF = 1001001001

func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

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

func calcCost(N int, hs []int) int {
	// Definition of DP
	dp := make([]int, N)
	// Initialization
	for i := 0; i < N; i++ {
		dp[i] = INF
	}
	// Index zero
	dp[0] = 0

	for i := 1; i < N; i++ {
		chmin(&dp[i], dp[i-1]+abs(hs[i]-hs[i-1]))
		if i > 1 {
			chmin(&dp[i], dp[i-2]+abs(hs[i]-hs[i-2]))
		}
	}

	return dp[N-1]
}

func main() {
	var N int
	fmt.Scan(&N)

	hs := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&hs[i])
	}

	fmt.Println(calcCost(N, hs))
}


Measured memory_bytes: 5376
import itertools
import bisect

if __name__ == "__main__":
    N, M, K = [int(x) for x in input().split(" ")]
    A = list(itertools.accumulate([int(x) for x in input().split(" ")]))
    B = list(itertools.accumulate([int(x) for x in input().split(" ")]))

    max_ = bisect.bisect_right(B, K)

    for i, a in enumerate(A):
        if K - a < 0:
            break
        j = bisect.bisect_right(B, K - a)
        max_ = max(max_, j + i + 1)
    print(max_)


Measured memory_bytes: 117488
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int calc(int N){
    int res=0;
    while(N>0){
        res+=N%10;
        N/=10;
    }
    return res;
}

signed main()
{
    int N; cin>>N;
    int ans=100;
    for(int a=1;a<=N/2;a++){
        ans=min(ans,calc(a)+calc(N-a));
    }
    cout<<ans<<endl;
}


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

long long n,poss;
int main(){
cin>>n;
int min=1001,max=0;
for(int i=1;i<=n;i++){
	cin>>poss;
	if(poss>max){
		max=poss;
	}if(poss<min){
		min=poss;
	}
}
cout<<max-min<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	int n;
	scanf("%d", &n);
	long int power = 1;
	for(int i=1; i<=n; i++){
		power = (long int) power*i;
		power = power%MOD;
	}
	printf("%ld\n", power);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int a[10], b[10], c[10];
int N;
int top1 = -1, top2 = -1;

bool dfs(int i)
{
	if (i == 10)
		return true;
	if (a[i] > b[top1] || top1 == -1)
		b[++top1] = a[i];
	else if (a[i] > c[top2] || top2 == -1)
		c[++top2] = a[i];
	else return false;
	dfs(i + 1);
}

int main()
{
	scanf("%d", &N);
	while (N--)
	{
		for (int i = 0; i < 10; i++)
			scanf("%d", &a[i]);
		if (dfs(0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		memset(b, 0, sizeof(b));
		memset(c, 0, sizeof(c));
		top1 = top2 = -1;
	}
	return 0;
}


Measured memory_bytes: 3140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int k = cin.Int();
			int n = cin.Int();
			var a = cin.ArrayInt(n);

			var dif = new int[n];
			for (int i = 0; i < n - 1; i++) {
				dif[i] = a[i + 1] - a[i];
			}

			dif[n - 1] = (k - a[n - 1]) + a[0];

			int max = dif.Max();
			int ans = k - max;
			Console.WriteLine(ans);
		}
	}

	public static class Helper
	{
		public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
			=> array[index] = Math.Max(array[index], value);
		public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Min(array[index], value);
		public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
			=> array[index] = Math.Max(array[index], value);

		public static T[] Array<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
		public static List<T> List<T>(int n, Func<int, T> init)
			=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 35420
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c>>n;
    rep(i,n+1){
        rep(j,n+1){
            ll now=a*i+j*b;
            if(now>n)continue;
            if((n-now)%c==0)ans++;
        }
    }
    Cout(ans);
    return 0;
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

int main() {
    int n;
    cin >> n;
    vector<ll> hps(n);
    rep(i, n) cin >> hps[i];
    sort(hps.begin(), hps.end());

    ll ans = hps.front();
    for (ll a : hps) ans = gcd(ans, a);
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}
template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T,int>>> que;que.push(P(0,s));
  while(!que.empty()){
    pair<T,int> p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(make_pair(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<double>


double xs, ys, xt, yt;int n;
double x[1100],y[1100],r[1100];
graph<double> g;
signed main(){
  cin>>xs>>ys>>xt>>yt>>n;g.resize(n+2);
  rep(i,n)cin>>x[i]>>y[i]>>r[i];
  rep(i,n){
    repd(j,i+1,n){
      double d = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])) - (r[i]+r[j]);
      chmax(d, 0.0L);
      g[i].push_back(edge<double>(j,d));
      g[j].push_back(edge<double>(i,d));
    }
  }
  rep(i,n){
    double d = sqrt((xs-x[i])*(xs-x[i]) + (ys-y[i])*(ys-y[i])) - (r[i]), 
          d2 = sqrt((xt-x[i])*(xt-x[i]) + (yt-y[i])*(yt-y[i])) - (r[i]);
    chmax(d, 0.0L);chmax(d2, 0.0L);
    g[n].push_back(edge<double>(i,d));
    g[i].push_back(edge<double>(n,d));
    g[n+1].push_back(edge<double>(i,d2));
    g[i].push_back(edge<double>(n+1,d2));
  }
  double d = sqrt((xs-xt)*(xs-xt) + (ys-yt)*(ys-yt));
  g[n].push_back(edge<double>(n+1, d));
  g[n+1].push_back(edge<double>(n, d));
  vector<double> dist = dijkstra(n, g);
  cout << fixed << setprecision(10) << dist[n+1] << endl;
}


Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100009
#define MAXM 30001
#define MOD 1000000007
#define INF 1000000009
#define EPS 1e-7
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int, int> ii;
typedef long long ll;

ll arr[MAXN], v[MAXN];
ll roundtrip[MAXN];

ll calc(int n, ll C) {
	ll ans = 0;
	ll acum = 0;

	FOR(i, n) {
		acum += v[i];
		ans = max(ans, acum - arr[i]);
		roundtrip[i] = acum - 2*arr[i];
		if (i > 0) roundtrip[i] = max(roundtrip[i], roundtrip[i-1]);
	}
//	printf("%lld %lld\n", acum, ans);

	acum = 0;
	for (int i = n-1; i >= 0; i--) {
		acum += v[i];
		ans = max(ans, acum - (C-arr[i]));
		if (i > 0) ans = max(ans, roundtrip[i-1] + acum - (C-arr[i]));
	}
//	printf("%lld\n", )
	return ans;
}

int main() {
	int n; ll c;
	scanf("%d %lld", &n, &c);
	FOR(i, n) scanf("%lld %lld", &arr[i], &v[i]);
	ll a = calc(n, c);
	FOR(i, n) arr[i] = c-arr[i];
	reverse(arr, arr + n);
	reverse(v, v + n);
	ll b = calc(n, c);
	printf("%lld\n", max(a, b));
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String anticipation = sc.next();
		String real = sc.next();
		List<String> AList = Arrays.asList(anticipation.split(""));
		List<String> RList = Arrays.asList(real.split(""));

		int count = 0;
		for (int i = 0; i < 3; i++) {
			String a = AList.get(i);
			String r = RList.get(i);

			if (a.equals(r)) {
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21588
#include<iostream>

using	namespace std;

int main() {
	
	int temp,N,max,count=1;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> temp;
		if (i == 0) {
			max = temp;
		}
		else if (max <= temp) {
			count++;
			max = temp;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

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

    if (x < 0)
    {
        x = (-1) * x;
    }

    long long r=x/d;
    long long temp=k;
    k-=r;
    if (k<=0)
    {
        cout << x-temp*d << endl;
        return 0;
    }
    
    k=temp;
    x-=r*d;
    k-=r;
    if (k%2==0)
    {
        cout << x << endl;
    }else
    {
        cout << d-x << endl;
    }
}



Measured memory_bytes: 3572
#include <algorithm>
#include <climits>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, ans = INT_MAX;
	cin >> N;
	if (N == 1) {
		cout << 1;
		return 0;
	}
	vector<pair<int, int>> xy(N);
	for (pair<int, int>& i : xy) cin >> i.first >> i.second;
	sort(xy.begin(), xy.end());
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int a = 0;
			for (int k = 0; k < N - 1; ++k) {
				int l;
				for (l = k + 1; l < N; ++l) {
					if (xy[i].first - xy[j].first == xy[k].first - xy[l].first && xy[i].second - xy[j].second == xy[k].second - xy[l].second) break;
				}
				if (N != l) ++a;
			}
			ans = min(N - a, ans);
		}
	}
	cout << ans;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    ll ans = 0;
    rep(i, N) {
        int num = i + 1;
        if (num % 3 == 0 || num %5 == 0) continue;
        ans += num;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
n,a,b = gets.strip.split.map(&:to_i)
result = 0

(1..n).each do |n|
  i = n
  sum = 0
  while i > 0
    sum += i % 10
    i = i / 10
  end
    if sum.between?(a, b)
      result += n
    end
end

puts result
    




Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int A[200009];
int B[200009];

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

	int N; cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) B[A[i]] = i;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int num = B[i];
		int cnt = 1;
		while (i < N && B[i] < B[i + 1]) {
			num = B[i + 1];
			i++;
			cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << N - ans << endl;

	return 0;
}

Measured memory_bytes: 2432
N = int(input())
A = list(map(int, input().split()))

minus_cnt = 0
min_abs = 10 ** 15
for i in range(N):
  if A[i] < 0:
    minus_cnt += 1
    A[i] *= -1
  min_abs = min(min_abs, abs(A[i]))

print(sum(A) - 2 * min_abs * (minus_cnt % 2))

Measured memory_bytes: 14224
#include<iostream>

using namespace std;

int main(void)
{
  int a,b,c,d; cin>>a>>b>>c>>d;
  int r1,r2;
  
  r1=a>b?b:a;
  r2=c>d?d:c;
  
  cout<<r1+r2<<endl;
  return 0;
}

Measured memory_bytes: 256
H,W,N = list(map(int,input().split()))
sr,sc = list(map(int,input().split()))
S = list(input())
T = list(input())

ans = True
si = sr
sj = sc

for i in range(N):
    if S[i] == "R":
        sj += 1
    if sj > W:
        ans = False
        break
    if T[i] == "L":
        sj = max(1,sj -1)
si = sr
sj = sc

for i in range(N):
    if S[i] == "L":
        sj -= 1
    if sj < 1 or (not ans):
        ans = False
        break
    if T[i] == "R":
        sj = min(W,sj +1)
si = sr
sj = sc

for i in range(N):
    if S[i] == "D":
        si += 1
    if si > H or (not ans):
        ans = False
        break
    if T[i] == "U":
        si = max(1,si -1)
si = sr
sj = sc

for i in range(N):
    if S[i] == "U":
        si -= 1
    if si < 1 or (not ans):
        ans = False
        break
    if T[i] == "D":
        si = min(H,si +1)

if ans:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 70860
s = int(input())
tmp = [s]
for i in range(2, 10**6+1):

    if tmp[-1] % 2 == 0:
        j = tmp[-1] / 2
    else:
        j = 3 * tmp[-1] + 1

    if j in tmp:
        print(i)
        exit()
    tmp.append(j)

Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline ll ri()
{
	register ll x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(ll x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}

int main()
{
	ll cnt=0,a=ri(),b=ri();
	while(a<=b)
	{
		cnt++;
		a*=2;
	}
	wi(cnt);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=2018,L,R;
    cin >>L>>R;
    vector<ll> exist(2019,0);
    for(ll i=L;i<=min(R,L+2019*2);i++){
        exist[i%2019]++;
    }
    for(ll i=0;i<2019;i++){
        if (exist[i]==0)continue;
        exist[i]--;
        for(ll j=0;j<2019;j++){
            if (exist[j]==0)continue;
            ans=min(ans,(i*j)%2019);
        }
        exist[i]++;
    }


    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
import itertools
import collections

N = int(input())

def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in xrange(2, n + 1):
        if table[i] == 0:
            for j in xrange(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = collections.Counter()
    
    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n /= prime_factor_table[n]
    prime_count[n] += 1
    
    return prime_count

t = prime_factor_table(N)

ans = 0
for c in range(1,N-1):
  ab = N-c
  f = prime_factor(ab,t)
  v = f.values()
  tmp = 1
  for i in range(len(f)):
    tmp *= v[i]+1
  ans += tmp
  
print(ans+1)

Measured memory_bytes: 81852
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll f(ll x){
    if (x==1) return 1LL;
    return 2*f(x/2)+1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h;
    cin >> h;
    cout << f(h) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  int N;
  cin>>N;
  vector<int> P(N*N);
  for(int i=0;i<N*N;i++){
    cin>>P.at(i);
    P.at(i)--;
  }

  vector<vector<int>> dist(N,vector<int>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      dist.at(i).at(j)=min({i,j,N-1-i,N-1-j});
    }
  }

  ll ans=0;
  vector<vector<bool>> leave(N,vector<bool>(N,false));
  for(int k=0;k<N*N;k++){
    int i=P.at(k)/N;
    int j=P.at(k)%N;
    ans+=(ll)dist.at(i).at(j);
    leave.at(i).at(j)=true;
    queue<pair<int,int>> q;
    q.push(make_pair(i,j));
    while(!q.empty()){
      int x=q.front().first;
      int y=q.front().second;
      for(int l=0;l<4;l++){
        int nx=x+dx[l];
        int ny=y+dy[l];
        if(nx<0||ny<0||nx>=N||ny>=N){
          continue;
        }
        if(leave.at(x).at(y)){
          if(dist.at(nx).at(ny)>dist.at(x).at(y)){
            dist.at(nx).at(ny)=dist.at(x).at(y);
            q.push(make_pair(nx,ny));
          }
        }else{
          if(dist.at(nx).at(ny)>dist.at(x).at(y)+1){
            dist.at(nx).at(ny)=dist.at(x).at(y)+1;
            q.push(make_pair(nx,ny));
          }
        }
      }
      q.pop();
    }
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 5324
def amax(l):
    am = 0
    am2 = 0
    for i in range(1, len(l)):
        if l[i] > l[am]:
            am2 = am
            am = i
        elif l[i] > l[am2]:
            am2 = i
    return am, am2

def vacation(abc):
    pa, pb, pc = abc[0]
    for i in range(1, len(abc)):
        a, b, c = abc[i]
        patmp, pbtmp, pctmp = pa, pb, pc
        pa = a + max([pbtmp, pctmp])
        pb = b + max([patmp, pctmp])
        pc = c +  max([patmp, pbtmp])

    return max(pa, pb, pc)

N = int(raw_input())
abc = []
for _ in range(N):
    abc.append(map(int, raw_input().split()))

print(vacation(abc))
        


Measured memory_bytes: 23940
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]

ans=0
for i in range(len(a)):
    aa=a[i]
    ans+=b[aa-1]
    if i<n-1:
        if a[i+1]==a[i]+1:
            ans+=c[aa-1]
print(ans)

Measured memory_bytes: 38256