akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

int N, M;

void solve() {
  cin >> N >> M;
  vector<pair<int, int>> v(N);
  for (auto &p : v) {
    cin >> p.first >> p.second;
  }

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

  int i = 0;
  int ans = 0;
  for (auto &p : v) {
    int n = min(M - i, p.second);
    ans += p.first * n;

    i += n;
    if (i == M) {
      break;
    }
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,l;
	cin>>n>>l;
	vi a(n);
	rep(i,n)cin>>a[i];
	int p=-1;
	rep(i,n-1){
		if(a[i]+a[i+1]>=l){
			p=i;
			break;
		}
	}
	if(p==-1){
		cout<<"Impossible"<<endl;
	}else{
		cout<<"Possible"<<endl;
		range(i,1,p+1)cout<<i<<endl;
		for(int i=n-1;i>p;i--)cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int A, B, M; cin >> A >> B >> M;
    vi a(A); REP(i, A) cin >> a[i];
    vi b(B); REP(i, B) cin >> b[i];
    int ans = INF;
    REP(i, M)
    {
        int x, y, c; cin >> x >> y >> c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    ans = min(ans, *min_element(ALL(a))+*min_element(ALL(b)));
    cout << ans << endl;
}

Measured memory_bytes: 1024
"""
提出 #6475942 を参考に作成
"""

import bisect


def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    color_list = [A[-1]]
    for a in reversed(A[:-1]):
        # a より大きい数の中で一番小さい数の場所を取得する
        c = bisect.bisect_left(color_list, a + 1)
        if c == len(color_list):
            color_list.append(a)
        else:
            color_list[c] = a
    print(len(color_list))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9116
#include<stdio.h>

int N;
int K;
int B[101];

int main(void){
    int i, sum;
    scanf("%d", &N);
    scanf("%d", &K);

   for(i = 0; i < N; i++){
        scanf("%d", &B[i]);
    }
    sum = 0;
    for(i = 0; i < N; i++){
    sum += B[i] < (K-B[i]) ? B[i] : K-B[i];
    }

    printf("%d", sum*2);
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007

bool guusuu(string S) {
	if (S.size() % 2 == 1)return false;
	else {
		for (int i = 0; i < S.size()/2; i++) {
			if (S[i] != S[i + S.size() / 2])return false;
		}
	}
	return true;
}

int main() {
	string s;
	cin >> s;
	int i = s.size()-1;
	while (true) {
		if (guusuu(s.substr(0, i))){
			cout << i << endl;
			return 0;
		}
		i--;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N;
long long K;
long long T[100];

long long GCM(long long a,long long b){
	if(b==0){
		return a;
	}
	return GCM(b,a%b);
}

long long LCM(long long a,long long b){
	return (a/GCM(a,b))*b;
}

int main(){
	cin >>N;
	for(int i=0;i<N;i++){
		cin >>T[i];
	}
	K=T[0];
	for(int i=1;i<N;i++){
		K=LCM(T[i],K);
	}
	cout << K;

		return 0;
}

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

const int N_MAX = 200005;
long long int A[N_MAX];
long long int T[N_MAX];

int main(){
    int n;
    cin >> n;
    memset(T, 0, sizeof(T));
    for(int i = 0; i < n; i++){
        cin >> A[i];
        T[A[i]]++;
    }
    long long int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += T[i] * (T[i]-1) / 2;
    }
    for(int i = 0; i < n; i++){
        cout << ans - (T[A[i]] - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
a,b = map(int, input().split())
bis = [0] * 50
"""
- F(A,B) = F(0,B) ^ F(0,A-1)
- 2m ^ 2m+1 = 1
"""
def F(a):
    if a % 2 == 0:
        x = (a-1)//2
        return (x%2)^a
    else:
        x = a//2
        return x%2
    
ans = F(b)^F(a-1)

print((ans))

Measured memory_bytes: 9120
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int r = sc.nextInt();
	int g = sc.nextInt();
	int b = sc.nextInt();
	
	int x = 100 * r + 10 * g + b;
	
	if( x % 4 == 0){
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
#define BOOST        ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define AZ(x)        x.begin(),x.end()
#define fi           first
#define se           second
#define pb           push_back
#define emp          emplace_back
#define mp           make_pair
#define mt           make_tuple 
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); degub(_it, args); }
#define For(i,a,n)   for(auto i = a; i < n; i++)
#define int          long long
 
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
 
typedef long long ll;
typedef long double ld;
 
 
template<typename T>
// for super_map add a parameter Y above and replace "null_type" with "Y"
 
// set with two additional super powers
    // find_by_order(int k) - returns k'th smallest element (0-indexed)
    // order_of_key(int k) - returns number of elements strictly smaller than k.
using super_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
 
void degub(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>
void degub(istream_iterator<string> it, T a, Args... args) {
    cerr << "[" << *it << " : " << a << "] ";
    degub(++it, args...);
}
 
 
ll power(ll a,ll b)
{
    // a = a;
    ll result = 1;
 
    while(b)
    {
        if(b&1)
            result = (result*a);
        b >>= 1, a = (a*a);
    }
    return result;
}
 
ll super_rand(ll n) // Random number from set [0,n-1]
{
    uniform_int_distribution<ll> uid(0, n - 1);
    return uid(rng);
}
 
 
 
/*
 
 
1. Make sure you're taking all the inputs.
2. In case of nested loops, remember to use different variables.
3. If in doubt, do int -> ll
4. Don't fight the question, try solving the next one.
5. ffs (positon of first set bit), clz (leading 0s, max->32), ctz (trailing 0s), popcount (set bits). Don't use any of these on 0;
 
 
*/
 
 
 
// Don't code anything above this //
 
 
 
 
 
 
const int mod = 1e9+7, N = 1e5 + 5;
const ll INF = (ll)1e18 + 7LL;
 
int32_t main()
{
    BOOST
    
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // cout << "OUTPUT \n";
    // #endif


    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    string ans = "No";
    if(a[0] == a[1] && a[0] != a[2])
        ans = "Yes";
    else if(a[1] == a[2] && a[1] != a[0])
        ans = "Yes";
    cout << ans << "\n";    
    return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = -1;
	for (int p = a[0]; p <= a[n - 1]; p++) {
		int tmp = 0;
		for (int i = 0; i < n; i++) {
			tmp += (a[i] - p) * (a[i] - p);
		}
		ans = ans == -1 ? tmp : min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int count = 0;

            for(int i=a;i<=b;i++){
                if(c%i==0){count++;}
            }
            System.out.println(count);
    }
}


Measured memory_bytes: 26420
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int MAX = 300000;
	boolean[] p;

	void run() {
		Scanner sc = new Scanner(System.in);
		p = new boolean[MAX+1];
		LinkedList<Integer> primes = new LinkedList<Integer>();
		for(int i=2;i<=MAX;i++) if( !p[i] ){
			primes.add(i);
			for(int j=i*2;j<=MAX;j+=i) p[j] = true;
		}
		
		int[] p_ind = new int[primes.size()];
		int s = primes.size();
		for(int i=0;i<s;i++) p_ind[i] = primes.removeFirst();
		
		
		for(;;) {
			int n = sc.nextInt();
			int p = sc.nextInt();
			if( n == -1 && p == -1 ) break;
			
//			debug(s);
			int ind = 0;
			for(;;ind++) {
				if(p_ind[ind] > n ) break;
			}
			
//			debug(p_ind[ind]);
			
			LinkedList<Integer> ans = new LinkedList<Integer>();
			for(int i=ind;i<min(s, ind+100);i++) for(int j=i;j<min(s, ind+100);j++) {
				ans.add(p_ind[i] + p_ind[j]);
			}
			Collections.sort(ans);
//			debug(ans);
			System.out.println(ans.get(p-1));
		}
	}

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

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

Measured memory_bytes: 17000
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m;
struct qwq{
	int num;
	int down;
} a[200010];
int b[200010];
int cmp(qwq a,qwq b){
	return a.num>b.num;
}
int main() {
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].num;
		b[i]=a[i].num ;
		a[i].down=i;
	}
	sort(a+1,a+n+1,cmp);
	int pos1=a[1].num;
	int pos2=a[2].num;
	if(pos1==pos2){
		for(int i=1;i<=n;i++){
			cout<<pos1<<endl;
		}
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(b[i] == pos1){
			cout<<pos2<<endl;
		}
		else cout<<pos1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3968
n = input()
l = len(n)

# print(l)
temp=''
ans=0

if l==1:
	print(int(n))
else:
	for i in range(1,l):
		if i%2==1:
			temp='9'
			temp+='0'*(i-1)
			ans+=int(temp)
			# print(ans)

	if l%2==1:
		ans+=(int(n)-int('9'*(l-1)))

	print(ans)

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

#define ll long long

using namespace std;

ll a, b;
int main() {
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    if ((b - a) % 2 == 1)
        cout << "IMPOSSIBLE";
    else
        cout << a + (b - a) / 2;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	
	if(x-r<0||x+r>W||y-r<0||y+r>H){
		cout <<"No"<<endl;
	} else{
		cout <<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define f first
#define s second
#define FOR(i,s,e) for (ll i = s; i <= (ll)e; i++)
#define DEC(i,s,e) for (ll i = s; i >= e; i--)
#define aFOR(i,s) for (auto i: s)
#define maxn 1001
#define INF 1e9
#define pb push_back
typedef pair <int,int> pi;
typedef pair<pi,int> pii;

int N,K;
int ans = 0;

int main(){
	cin>>N>>K;
	FOR(i,0,N-1){
		int a; cin>>a;
		
		ans += min(abs(a),abs(K - a));
	}
	
	cout<<ans * 2;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxm = 100002;

int n, m;
long long f[maxm];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        int w, v;
        cin >> w >> v;
        for (int j = m; j >= w; --j)
            f[j] = max(f[j], f[j-w] + v);
    }
	
    cout << f[m] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    printf("%.5f\n", sqrt((a-c)*(a-c)+(b-d)*(b-d)));
    return 0;
}



Measured memory_bytes: 3184
use input::{Input, ReadMode};

fn main() {
    let mut input = Input::new(ReadMode::Line);

    let a: i32 = input.parse();
    let b: i32 = input.parse();
    let _c: i32 = input.parse();
    let k: i32 = input.parse();

    let mut ans = a.min(k);
    let x = k - ans;
    if x > 0 && b < x {
        ans += b - x;
    }

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

#[allow(dead_code)]
pub mod input {
    use std::io::{BufRead, Read};

    pub enum ReadMode {
        Full,
        Line,
    }

    pub struct Input<'a> {
        lock: std::io::StdinLock<'static>,
        iter: Option<std::str::SplitAsciiWhitespace<'a>>,
        mode: ReadMode,
    }

    impl<'a> Input<'a> {
        fn naive_read(&mut self) -> Option<std::str::SplitAsciiWhitespace<'a>> {
            let mut s = Box::leak(Box::new(String::new()));
            let res = match self.mode {
                ReadMode::Full => self.lock.read_to_string(&mut s),
                ReadMode::Line => self.lock.read_line(&mut s),
            };
            res.ok().expect("failed to read");
            Some(s.split_ascii_whitespace())
        }
        pub fn new(mode: ReadMode) -> Self {
            let lock = Box::leak(Box::new(std::io::stdin())).lock();
            let iter = None;
            Self { lock, iter, mode }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.lock.read_line(&mut s).ok().expect("failed to read");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            match &mut self.iter {
                Some(iter) => {
                    let x = if let Some(x) = iter.next() {
                        x
                    } else {
                        self.iter = self.naive_read();
                        self.iter.as_mut().unwrap().next().expect("reached EOF")
                    };
                    x.parse().ok().expect("failed to parse")
                }
                None => {
                    self.iter = self.naive_read();
                    self.parse()
                }
            }
        }
    }
}


Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {
	
	static int binarySearch(int[] a, int[] b) {
		int counter = 0;
		int mid = 0;
		for(int i=0; i<b.length; i++){
			int L = 0;
			int R = a.length-1;
			
			while(L<=R)
			{
				mid = (L+R)/2;
//				System.out.println("mid: "+ mid);
				if(b[i]==a[mid])
				{
					counter++;
					break;
				}
				else if(b[i]<a[mid])
				{
					R = mid-1;
				}
				else if(b[i]>a[mid])
				{
					L = mid+1;
				}
			}		
		}
		return counter;
	}
	
    public static void main(String argv[]) {

        Scanner in = new Scanner(System.in);
        int num1 = in.nextInt();

        int intArray1[];    //declaring array
        intArray1 = new int[num1];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray1.length; i++){
        	intArray1[i] = in.nextInt();
        }
        
        int num2 = in.nextInt();
        int intArray2[];    //declaring array
        intArray2 = new int[num2];  // allocating memory to array
        
     // accessing the numbers in the second line
        for (int i = 0; i < intArray2.length; i++){
        	intArray2[i] = in.nextInt();
        }
        
        int res = binarySearch(intArray1, intArray2);

        System.out.println(res);
        in.close();
    }
}


Measured memory_bytes: 80324
#include<iostream>
using namespace std;
int main(){
    int N,a;
    int count1 = 0;
    int count2 = 0;
    int count4 = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> a;
        if(a%4 == 0) count4++;
        else if(a%2 == 0) count2++;
        else count1++;
    }
    if(count1 <= count4 || (count1 == count4+1 && count2 == 0)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> res(N);
    rep(i, N) {
        res[i] = 0;
    }
    int ac = 0;
    int wa = 0;
    vector<int> AC(N);
    vector<int> WA(N);
    rep(i, N) {
        AC[i] = 0;
        WA[i] = 0;
    }
    rep(i, M) {
        int p;
        string S;
        cin >> p >> S;
        p -= 1;
        if (AC[p]) continue;
        if (S == "AC") {
            AC[p] = 1;
            ac += 1;
        } else {
            WA[p] += 1;
        }
    }
    rep(i, N) {
        if (AC[i] == 1) {
            wa += WA[i];
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 1408
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(old, cnt)
  check = 14.times.map{ [false] * 8 }
  res = 0
  (1..12).each do |i|
    (1..6).each do |j|
      unless check[i][j] || old[i][j] == 'O' || old[i][j] == '.'
        puyo_connector(i, j, old){ |arr|
          if arr.size >= 4
            arr.each do |x, y|
              check[x][y] = true
              res = 1
            end
          end
        }
      end
    end
  end

  buf = []
  (1..12).each do |i|
    (1..6).each do |j|
      if check[i][j]
        D.each do |x, y|
          p, q = i + x, j + y
          buf << [p, q] if old[p][q] == 'O'
        end
      end
    end
  end
  buf.each{ |x, y| check[x][y] = true }
  fld = puyo_erase(old, check)
  if res == 1 then puyo_rensa(fld, cnt + 1)
  else cnt
  end
end

def puyo_connector(i, j, fld)
  check = 14.times.map{ [false] * 8 }
  arr = [[i, j]]
  ret = [[i, j]]
  check[i][j] = true
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if !check[p][q] && fld[i][j] == fld[p][q]
        check[p][q] = true
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret)
end

def puyo_erase(fld, check)
  fld = fld.transpose
  nfld = 8.times.map{ [] }
  8.times do |i|
    13.downto(0) do |j|
      unless check.transpose[i][j]
        nfld[i] << fld[i][j]
      end
    end
    (14 - nfld[i].size).times{ nfld[i] << '.' }
    nfld[i].reverse!
  end
  nfld.transpose
end

gets.to_i.times do
  fld = 14.times.map{ ['.'] * 8 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[i+1][j+1] = c
    end
  end
  p puyo_rensa(fld, 0)
end

Measured memory_bytes: 10540
# -*- coding: utf-8 -*-

n, a, b = map(int, input().split())

ans = 0
for i in range(1, n + 1):
    t0 = int(i % 10)
    t1 = int(i % 100 / 10)
    t2 = int(i % 1000 / 100)
    t3 = int(i % 10000 / 1000)
    t4 = int(i / 10000)

    total = t0 + t1 + t2 + t3 + t4
    if a <= total <= b:
        ans += i

print(ans)


Measured memory_bytes: 3060
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B, K] = string_to_int(inputs[0])
    ret = set()
    count = 0
    for v in range(A, B+1):
        if count >= K:
            break
        ret.add(v)
        count += 1
    count = 0
    for v in reversed(range(A, B+1)):
        if count >= K:
            break
        ret.add(v)
        count += 1
    return sorted(list(ret))


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    for r in ret:
        print(r)


Measured memory_bytes: 4068
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<VMAX+1;i++){
    C[i] = 0;
  }
  for(j=1;j<n+1;j++){
    C[A[j]]++;
  }
  for(i=1;i<VMAX+1;i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
  

  return 0;
}



Measured memory_bytes: 9636
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin>>a[i];
  ll ans = LINF;
  
  // even is positive
  // odd is nevgative
  ll sum=0;
  ll num=0;
  rep(i,n) {
    sum+=a[i];
    if (i&1) {
      if (sum>=0) {
        num += (sum + 1);
        sum = -1;
      }
    } else {
      if (sum <= 0) {
        num += (-sum + 1);
        sum = 1;
      }
    }
  }
  chmin(ans, num);
  // even is negative
  // odd is positive
  num = 0;
  sum = 0;
  rep(i,n) {
    sum+=a[i];
    if (i&1) {
      if (sum <= 0) {
        num += (-sum + 1);
        sum = 1;
      }
    } else {
      if (sum>=0) {
        num += (sum + 1);
        sum = -1;
      }
    }
  }
  chmin(ans, num);
  printf("%lld\n", ans);
  return 0;
}

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

const int INF = +100100100;
const ll MO = 1000000007;
const int MX = 1000005;


const int mod = 1000000007;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t)const{
        if(!t)return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1)a *=*this;
        return a;
    }

    mint inv() const{
        return pow(mod-2); 
    }
    mint& operator/=(const mint a){
        return (*this)*=a.inv();
    }
    mint operator/(const mint a)const{
        mint res(*this);
        return res/=a;
    }
    
};

// エラトステネスの篩
struct Sieve{
    int n;
    // f[i]はある値iが素数ならばiを保存し、素数でなければ最小の素因数を保存する
    vector<int> f,primes;
    Sieve(int n = 1):n(n),f(n+1){
        // isPrimeのために、0と1を素数でないとしておく.
        f[0]=f[1]=-1;
        for(ll i = 2; i<=n; ++i){            
            if(f[i])continue;
            for(ll j=i*i;j<=n;j+=i){
                //f[j]にはiが最小になるように設定する
                if(!f[j])f[j]=i;
            }
            primes.push_back(i);
            f[i] = i; 
        }
    }
    bool isPrime(int x){ return x == f[x];}
    // xを素因数分解(ただし、素数の重複を認める)して、vectorを返す.(小さい順)
    vector<int> factorList(int x){
        vector<int> res;
        while(x!=1){
            res.push_back(f[x]);
            x/=f[x];
        }
        return res;
    }
    // xの素因数分解したものの頻度集計を返す
    vector<P> factor(int x){
        vector<int> fl = factorList(x);
        // 0と1の場合何も返したくない
        if(fl.size()==0)return {};
        // 頻度計算
        vector<P> res(1,P(fl[0],0));
        for(int p : fl){
            if(res.back().first==p){
                res.back().second++;
            }else{
                res.emplace_back(p,1);
            }
        }
        return res;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    Sieve sieve(1e6);
    
    map<int,int> mp;
    rep(i,n){ 
        auto f = sieve.factor(a[i]);
        for(auto p :f){

            mp[p.first] = max(mp[p.first],p.second);
        }
    }
    mint lcm = 1;
    for(auto p :mp){
        rep(i,p.second){
            lcm*=p.first;
        }
    }
    mint ans=0;

    rep(i,n){
        mint b = lcm/a[i];
        ans+=b;
    }
    cout << ans.x << endl;
    return 0;
    
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> lis(n);
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis));
    if(lis[n-1] < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if(n == 1){
        if(lis[0] == k){
            cout << "POSSIBLE" << endl;
            return 0;
        }
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    REP(i, 0, n-1){
        if(lis[i+1] != lis[i]){
            lis.pb(lis[i+1]-lis[i]);
        }
    }
    sort(ALL(lis));
    int f = 0;
    REP(i, 1, lis.size()){
        if(lis[i] % lis[0] != 0){
            f = 1;
            break;
        }
    }
    if(f == 1){
        cout << "POSSIBLE" << endl;
    }else{
        ll mid = lis[0];
        REP(i, 1, lis.size()){
            mid = gcd(mid, lis[i]);
        }
        if(k % mid == 0){
            cout << "POSSIBLE" << endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mod 1000003
inline int quickpow(int base,int ind)
{
	base%=mod;
	int ans=1;
	while(ind>0)
	{
		if(ind&1)ans=ans*1ll*base%mod;
		ind>>=1;
		base=base*1ll*base%mod;
	}
	return ans;
}
inline int inv(int x)
{
	return quickpow(x,mod-2);
}
const int maxn=1e6+500;
const int N=1000002;
int fact[maxn*2],invfac[maxn];
inline int calc(int a,int b,int c)
{
//	cout<<13*1ll*inv(b)%mod<<endl;
	int iv=inv(b);
	int fst=a*1ll*iv%mod;
	int lst=(a+(c-1)*1ll*b%mod)%mod*1ll*iv%mod;
	if(fst==0||lst==0)return 0;
//	cout<<iv<<" "<<fst<<" "<<lst<<endl;
//	cout<<fact[lst]<<" "<<invfac[fst]<<" "<<quickpow(b,c)<<endl;
	fst--;
	return fact[lst]*1ll*invfac[fst]%mod*1ll*quickpow(b,c)%mod;
}
int main()
{
//	cout<<93*1ll*inv(16)%mod<<endl;
	int Q,x,n,d;
	scanf("%d",&Q);
//	cout<<C<<endl;
	fact[0]=1;
	for(int i=1;i<=N;i++)
	{
		fact[i]=fact[i-1]*1ll*i%mod;
	}
	invfac[N]=inv(fact[N]);
	for(int i=N-1;i>=0;i--)
		invfac[i]=invfac[i+1]*1ll*(i+1)%mod;
	while(Q--)
	{
		scanf("%d%d%d",&x,&d,&n);
		if(d==0)
		{
			printf("%d\n",quickpow(x,n));
			continue;
		}
	//	cout<<(x*1ll*inv(d)%mod)<<endl;
		if((x*1ll*inv(d)%mod+n-1)>(mod))
		{
			printf("0\n");
			continue;
		}
		printf("%d\n",calc(x,d,n));
	}
	return 0;
}

Measured memory_bytes: 9088
open Array
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = init h @@ fun _ -> init w @@ fun _ -> Scanf.scanf " %c" @@ fun c -> c
let rows = let rec f i =
  if i >= h then []
  else if to_list css.(i) |> List.for_all ((=) '.') then f @@ i + 1
  else i :: f (i + 1) in f 0 |> of_list
let cols = let rec f i =
  if i >= w then []
  else
    let is_space = ref true in
    for j = 0 to h - 1 do if css.(j).(i) <> '.' then is_space := false done;
    if !is_space then f (i + 1) else i :: f (i + 1) in f 0 |> of_list
let ans = make_matrix (h - length rows) (w - length cols) ' '
let _ =
  for i = 0 to length rows - 1 do
    for j = 0 to length cols - 1 do print_char css.(rows.(i)).(cols.(j)) done;
    print_newline () done

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
const int inf=1e5+9;
int dp[inf];
vector<int> v[inf];

int dfs(int node){

    int &ret=dp[node];
    if(ret!=-1)
        return ret;
    ret=0;
    for(auto o:v[node])
        ret=max(ret,1+dfs(o));

    return ret;
}

int main(){

    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    memset(dp,-1,sizeof(dp));
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=max(ans,dfs(i));

    cout<<ans<<endl;
}

Measured memory_bytes: 7424
#include "bits/stdc++.h"
//#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll& a, const pll& b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i * i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}
ll nCr(ll n, ll r);//コンビネーション
int permutation(int n, int r);//nPk パーミュテーション
int factorial(int k);//階乗

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	//priority_queue<int> q;
	string s = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	ll x[100005] = {};
	ll y[100005] = {};
	string str[200005] = {};
	//char* ch[200005] = {};
	char* ch1 = {};
	//ll z[302][302] = {};
	//std::vector<string> data;
	//sort(data.begin(), data.end());//昇順ソート

	cin >> a;
	cin >> b;
	ans = 1;
	c = b;
	while (a>=b)
	{
		b *= c;
		ans++;
	}

	cout << ans << endl;

	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}

int permutation(int n, int r) {
	int n_sum, r_sum;
	int i;
	r = n - r;
	n_sum = factorial(n);
	r_sum = factorial(r);
	return n_sum / r_sum;
}

ll nCr(ll n, ll r) {
	ll ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int factorial(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

Measured memory_bytes: 1792
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;
vector<long long> dp;
vector<long long> val;
long long nax = (long long)1e18 + 5;
//Copied Errichto's code
void recur(int i, const vector<int>& not_taken, long long score_so_far, int mask, int group) {
    if(i == (int) not_taken.size()) {
        dp[mask] = max(dp[mask], score_so_far + val[group]);
        return;
    }
    recur(i + 1, not_taken, score_so_far, mask, group);
    recur(i + 1, not_taken, score_so_far, mask ^ (1 << not_taken[i]),
        group ^ (1 << not_taken[i]));
}

int main() 
{


long long n;
cin>>n;
long long p[n][n];
for(long long i=0;i<n;i++)
{
  for(long long j=0;j<n;j++)
  {
    cin>>p[i][j];
  }
}

val.resize((1<<n));
for(long long i=0;i<val.size();i++)
{
  long long tmp = 0;
  for(long long j=0;j<n;j++)
  {
    for(long long k=j+1;k<n;k++)
    {
      if((1<<j)&i && (1<<k)&i)
      {
        //cout<<"  = "<<i<<" j = "<<j<<endl;
        tmp+=p[j][k];
      } 
    }
  }
val[i] = tmp;
}

//cout<<endl;
dp.assign(1<<n,-nax);
//dp[i] represents maximum value obtained by having exactily i mask
//dp[0] = 0; // base case
// The answer will be at dp.back(); 
dp[0] = 0;
for(int mask=0;mask<val.size();mask++)
{
  vector<int> not_taken;
  for(int i=0;i<n;i++)
  {
    if(!(mask&(1<<i)))
    {
      not_taken.push_back(i);
    }
  }
  recur(0,not_taken,dp[mask],mask,0);
}

cout<<dp.back()<<endl;


}


Measured memory_bytes: 1408
N = int(input())
X = input()
ans = [1 for _ in range(N)]

l = 0
for k in range(N):
  if X[k] == '1':
    l+=1
if l == 0:
  for _ in range(N):
    print(1)
  exit()
if l == 1:
  if X[-1] == '1':
    for _ in range(N-1):
      ans[_] = 2
  else:
    ans[-1] = 2 
  for k in range(N):
    if X[k] =='1':
      ans[k] = 0 
  for _ in range(N):
    print(ans[_])
  exit()
 
 
intN = int(X, 2)
N1 = intN %(l-1)
N0 = intN % (l+1)
 
 
start = []
if N == 1:
  if X[0] == '1':
    print(0)
    exit()
  else:
    print(1)
    exit()
else:
  s1 = 1
  s0 = 1
  for k in range(N-1, -1, -1):
    if X[k] == '1':      
      ia = (N1 - s1)%(l-1)
    else:
      ia = (N0 + s0)%(l+1)
    start.append(ia)
    s1 = s1*2%(l-1)
    s0 = s0*2%(l+1)
start = start[::-1]
 
poplist = [0 for _ in range(l+1)]
t = 1
while t < l + 2:
  for k in range(t, l+1, 2*t):
    for j in range(t):
      if k+j>l:
        break
      poplist[k+j] += 1
  t *= 2
for k in range(len(start)):
  for count in range(10*5):
    if start[k] == 0:
      ans[k] += count
      break
    else:
      start[k] = start[k] % poplist[start[k]]
 
for k in range(N):
  print(ans[k])

Measured memory_bytes: 101564
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	string x;
	cin >> a >> b >> x;
	for (int i = 0; i <= a + b; i++)
		{
			if (i == a)
				{
					if (x[i] != '-')
						{
							cout << "No\n";
							return 0;
						}
				}
				else
					{
						if (x[i] != '0' && x[i] != '1' && x[i] != '2' && x[i] != '3' && x[i] != '4' && x[i] != '5' && x[i] != '6' && x[i] != '7' && x[i] != '8' && x[i] != '9')
							{
								cout << "No\n";
								return 0;
							}
					}
		}
	cout << "Yes\n";	
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    A += B;
    if(A >= 24) A -= 24;
    cout << A << "\n";
    return 0;
}

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

int main()
{
    string s;
    int f=0;
    cin>>s;
    for(int i=0;i<s.length()/2;i++)
    {
        if(s[i]!=s[s.length()-1-i])
        f++;
    }
    cout<<f;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i=6;
		flag:for(int j=0;j<n;j++){
			while(i<=55555){
				if(isPrime(i)){
					System.out.print(i+" ");
					i+=5;
					continue flag;
				}
				i+=5;
			}
		}
	}
	public static boolean isPrime(int n) {
		if(n < 2) return false;
		if(n == 2) return true;
		if(n % 2 == 0) return false;

		for(int i = 3; i * i <= n; i += 2) {
			if(n % i == 0) return false;
		}
		return true;
	}
}

Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  map<string,int> mp;
  vector<string> ans;
  int mx=0;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
    if(mx < mp[s]) mx=mp[s];
  }
  auto itr=mp.begin();
  for(;itr!=mp.end();itr++){
    //cout<<itr->S<<" "<<itr->F<<endl;
    if(itr->S == mx){
      ans.push_back(itr->F);
    }
  }
  rep(i,ans.size() ){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
	return (f==1)?x:-x;
}
const int maxn=305;
const int mod=1000000007;
int n,a[maxn<<1],op[maxn<<1];
ll f[maxn][maxn],g[maxn][maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=2*n;i++) op[i]=0;
	int cnt=0;
	for(int i=1;i<=2*n;i+=2)
		if(a[i]>0 && a[i+1]>0) op[a[i]]=2,op[a[i+1]]=2;
		else if(a[i]==-1 && a[i+1]==-1) { cnt++; continue; }
		else
		{
			if(a[i]>0) op[a[i]]=1;
			if(a[i+1]>0) op[a[i+1]]=1;
		}
	f[0][0]=1;
	for(int t=2*n;t;t--)
	{
		if(op[t]==2) continue;
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				g[i][j]=0;
		if(op[t]==1)
		{
			// Æ¥ÅäµÄÉÏ½çÊÇ n 
			for(int i=0;i<=n;i++)
				for(int j=0;j<=n;j++)
					if(f[i][j])
					{
						(g[i][j+1]+=f[i][j])%=mod;
						if(i>0) (g[i-1][j]+=f[i][j])%=mod;
					}
		}
		else
		{
			for(int i=0;i<=n;i++)
				for(int j=0;j<=n;j++)
					if(f[i][j])
					{
						(g[i+1][j]+=f[i][j])%=mod;
						if(i>0) (g[i-1][j]+=f[i][j])%=mod;
						if(j>0) (g[i][j-1]+=j*f[i][j])%=mod;
					}
		}
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				f[i][j]=g[i][j];
	}
	ll ans=f[0][0];
	for(int i=1;i<=cnt;i++) (ans*=i)%=mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 5172
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    while (ans * 2 <= n) ans *= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
'''
大工の褒美
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117&lang=jp
'''

town_num = int(input()) # (<= 20)
road_num = int(input()) # (<= 100)

costs = [[100000]*town_num for _ in range(town_num)]

# [a, b, c, d] a から b まで c, 逆は d の交通費がかかる
for a, b, c, d in [list(map(int, input().split(','))) for _ in range(road_num)]:
    costs[a-1][b-1] = c
    costs[b-1][a-1] = d

s, g, v, p = map(int, input().split(','))

# Floyd Warshall
for k in range(town_num):
    for i in range(town_num):
        for j in range(town_num):
            if costs[i][j] > costs[i][k] + costs[k][j]:
                costs[i][j] = costs[i][k] + costs[k][j]

print(v - p - costs[s-1][g-1] - costs[g-1][s-1])




Measured memory_bytes: 5616
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque, defaultdict

    h, w = map(int, readline().split())
    que = deque()
    grid = [["#"] * (w + 2)]

    for row in range(1, h + 1):
        s = input()
        for col, c in enumerate(s, 1):
            if c == "#":
                que.append((row, col, 0))
        grid.append(["#"] + list(s) + ["#"])

    grid.append(["#"] * (w + 2))
    direction = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    cnt = 0

    while que:
        cr, cc, cnt = que.popleft()
        for mr, mc in direction:
            nr, nc = cr + mr, cc + mc
            if grid[nr][nc] == ".":
                que.append((nr, nc, cnt + 1))
                grid[nr][nc] = "#"

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 215228
import collections

N = int(input())
s = [input() for i in range(N)]

M = int(input())
t = [input() for j in range(M)]

S = collections.Counter(s)
T = collections.Counter(t)

S.most_common()
T.most_common()

ans = S - T

try:
    print(ans.most_common()[0][1])
except:
    print('0')

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


struct Node{
    int posH;
    int posW;
    int cost;
    bool operator< (const Node &r) const{
        return cost > r.cost;
    }
};

int main(){
  int h, w;
  cin >> h >> w;

  vector<string> f(h, string(w, '.'));
  rep(i, h) cin >> f[i];

  vector<vector<int>> minns(h, vector<int>(w, 1e9));

  priority_queue<Node> que;
  rep(hx, h){
    rep(wx, w){
      if(f[hx][wx] == '.') continue;
      que.push({hx, wx, 0});
      minns[hx][wx] = 1;
    }
  }

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

  while(!que.empty()){
    Node node = que.top(); que.pop();

    if(minns[node.posH][node.posW] <= node.cost) continue;
    minns[node.posH][node.posW] = node.cost;

    rep(dir, 4){
      if(node.posH+dy[dir] < 0)  continue;
      if(h <= node.posH+dy[dir]) continue;
      if(node.posW+dx[dir] < 0)  continue;
      if(w <= node.posW+dx[dir]) continue;
      que.push({node.posH+dy[dir], node.posW+dx[dir], node.cost+1});
    }
  }

  int maxx = 0;
  rep(hx, h){
    rep(wx, w)  maxx = max(maxx, minns[hx][wx]);
  }

  cout << maxx << endl;
  


  return 0;
}


Measured memory_bytes: 55016
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    long x=readLong(),k=readLong(),d=readLong();
    if(x<0){x*=-1;}
    long r = x/d;
    if(r>=k){
      x-=d*k;
      pl(x+"");
    }else{
      k-=r;
      x-=r*d;
      if(k%2==0){
        pl(x+"");
      }else{
        pl((d-x)+"");
      }
    }
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


Measured memory_bytes: 36520
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],sum=0;
bool cmp(int x,int y){
	return x<y;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1]) sum++;
	if(sum%2==1) sum++;
	printf
	("%d\n",n-sum);
	return 0;
}

Measured memory_bytes: 640
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

import math
N = INT()
m = int(math.sqrt(N))
print(m ** 2)


Measured memory_bytes: 27124
N = int(input())

S = input()

S_list_one = list(S)
S_list_two = list(S)

a = int(N/2)
del S_list_one[a:]
del S_list_two[:a]

if(S_list_one == S_list_two):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, m, k, a[N], b[N], pr[N], cp[N], cm[N];

int fnd(int p) {
	return pr[p]==p ? p : pr[p] = fnd(pr[p]);
}

int main() {
	int i, x, y;
	cin >> n >> m >> k;
	for(i=1; i<=n; i++) pr[i] = i, cp[i] = 1;
	while(m--) {
		scanf("%d%d", &x, &y);
		cm[x]++, cm[y]++;
		x = fnd(x); y = fnd(y);
		if(x != y) {
			pr[y] = x;
			cp[x] += cp[y];
		}
	}
	while(k--) {
		scanf("%d%d", &x, &y);
		if(fnd(x) == fnd(y)) cm[x]++, cm[y]++;
	}
	for(i=1; i<=n; i++) {
		printf("%d ", cp[fnd(i)] - cm[i] - 1);
	}
	return 0;
}


Measured memory_bytes: 2560