akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from numpy.fft import rfft,irfft
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
class Counter:
    def __init__(self):
        self.dict = {}

    def add(self,x):
        if x in self.dict: self.dict[x] += 1
        else: self.dict[x] = 1

    def decrement(self,x):
        self.dict[x] -= 1
        if self.dict[x] <= 0:
            del self.dict[x]

    def get_dict(self):
        return self.dict




def fft(A,B,fft_len=2*10**5):
    x = irfft(rfft(A,fft_len) * rfft(B,fft_len))+0.5
    return x.astype(int)


def main():
    N,M=mi()
    A=list(mi())

    counter = Counter()
    for a in A: 
        counter.add(a)
    
    count_map = counter.get_dict()
    F=[0]*2*10**5
    for a,count in count_map.items():
        F[a] = count
    
    G = fft(F,F,fft_len=1<<18)

    ans = 0
    handshake = M
    for x in range(len(G)-1,1,-1):
        if G[x] <= 0: continue
        count = G[x]
        if count > handshake:
            ans += handshake * x
        else:
            ans += count * x

        handshake = max(handshake-count,0)
        if handshake == 0:
            break

    print(ans)



if __name__ == "__main__":
    main()

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

using ll = long long;

using namespace std;

int main(){

    ll a,b;
	
	cin >> a >> b;
	
	if (a>=13){
		cout << b << endl;
	} else if (a>=6){
		cout << b/2 << endl;
	} else {
		cout << 0 << endl;
	}

    return 0;
}

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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int,int>>> edges(n);
	for(int i = 0; i < m; i++){
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		edges[l].emplace_back(r, d);
		edges[r].emplace_back(l, -d);
	}
	vector<int> done(n);
	vector<int> x(n);
	for(int i = 0; i < n; i++){
		if(done[i]) continue;
		done[i] = 1;
		vector<int> bfs{i};
		for(int s = 0; s < int(bfs.size()); s++){
			int v = bfs[s];
			for(auto z : edges[v]){
				int w = z.first;
				int nx = z.second + x[v];
				if(!done[w]){
					done[w] = 1;
					x[w] = nx;
					bfs.push_back(w);
				} else if(x[w] != nx){
					cout << "No" << '\n';
					exit(0);
				}
			}
		}
	}
	cout << "Yes" << '\n';
}


Measured memory_bytes: 13436
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<int>vec(N);
    for (int i=0; i < N; i++) {
        cin >> vec.at(i);
    }

    int sum = 0;
    sort(vec.begin(),vec.end(),greater<int>());
    for (int i=0; i < K; i++) {
        sum += vec[i];
    }

    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int inv(int a) {
	return a == 1 ? 1 : (long long) (MOD - MOD/a) * inv(MOD%a) % MOD;
}

ll f(ll n, ll m) {
	if (m < 0 || n < m) return 0;
	if (m > n - m) m = n - m;
	ll up = 1, down = 1;

	for (ll i = 0; i < m; i++) {
		up = up * (n-i) % MOD;
		down = down * (i+1) % MOD;
	}
	return up * inv(down) % MOD;
}

int main() {

	ll x, y; scanf("%lld%lld", &x, &y);
	if (x > y) swap(x, y);
	if ((2*y - x) % 3 == 0) {
		ll a = (2 * y - x) / 3;
		ll b = (x - a) / 2;
		printf("%lld", f(a+b, a));
	} else printf("0\n");

	return 0;
}

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

int main() {
  int A, B, Rn, S;
  cin >> A >> B;
  
  for (int i=1; i<10; i++) {
    for (int j=0; j<10; j++) {
      for (int k=0; k<10; k++) {
        Rn = 10000*i+1000*j+100*k+10*j+i;
        if (Rn >= A && Rn <= B) {
          S += 1;
        }
      }
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
//就職させてください!!!!
signed main(){
    int n,m,d;cin>>n>>m>>d;
    double a=n, b=m;
    double h=(b-1)/a;
    if(d==0){
        cout<<setprecision(15)<<h<<endl;
        return 0;
    }
    else {
       int j=n-2*d;
    int k=n-j;
    int g=2*j+k;
        double t=g;t/=n;t/=n;
    double ans=(b-1)*t;
    cout<<setprecision(15)<<ans<<endl;
    return 0; 
    }
}

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

using namespace std;


int cal(int n) {

    int count = 0;

    while (1) {
        if (n % 2 == 0) {
            n = n / 2;
            count++;
        } else {
            break;
        }
    }
    return count;
}

int main() {

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

    vector<int> s(N, 0);
    for (int i = 0; i < N; ++i) {
        s[i] = cal(a[i]);
    }


    // 数列aiを約数に分解->2の乗数を算出->1~nまで集計する
    int ans = 0;

    for (int i = 0; i < N; ++i) {
        ans += s[i];
    }

    cout << ans << endl;

}
// 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912

Measured memory_bytes: 384
import bisect
def resolve():
    N, M = list(map(int, input().split()))
    A = sorted(list(map(int, input().split(" "))))
    BC = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x: x[1], reverse=True)
    ptr = 0
    total = 0
    for i in range(M):
        num, val = BC[i]
        _ptr = min(ptr+num, bisect.bisect_left(A, val))
        if _ptr > ptr:
            total += val*(_ptr-ptr)
            ptr = _ptr
    total += sum(A[ptr:])
    print(total)

if '__main__' == __name__:
    resolve()

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

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

    long long N;
    cin >> N;
    int h, n;
    for (h = 1; h <= 3500; ++h) {
        for (n = 1; n <= 3500; ++n) {
            if (4 * h * n - N * n - N * h <= 0) continue;
            if (N * h *n % (4 * h * n - N * n - N * h) == 0) {
                long long w = N * h *n / (4 * h * n - N * n - N * h);
                printf("%d %d %lld", h, n, w);
                return 0;
            };
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int A, B, C;
  int flag = 0;
  int judge = 0;

  scanf("%d %d %d", &A, &B, &C);

  if (A < B)flag = 1;

  if (flag == 1){
    if (A<C && C<B){
      judge = 1;
    }
  }else {
    if (B<C && C<A){
      judge = 1;
    }
  }

  if (judge == 1){
    printf("Yes\n");
  }else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }

    let mut max_nums = vec![];

    for &i in &a {
        let len = max_nums.len();
        match bin_search(&max_nums, i) {
            MAX => {
                max_nums.insert(0, i);
            }
            0 => {
                if max_nums[0] < i {
                    max_nums[0] = i;
                } else {
                    max_nums.insert(0, i);
                }
            }
            num => {
                max_nums[num] = i;
            }
        }

        //println!("{:?}", max_nums);
    }

    println!("{}", max_nums.len());
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
// 二分探索 vは単調増加 v[x] <= aとなる最小のxを返す
fn bin_search(v: &[usize], a: usize) -> usize {
    if v.is_empty() || a <= v[0] {
        return MAX;
    }
    let mut min = 0;
    let mut max = v.len();
    while max - min > 1 {
        let mid = (min + max) / 2;
        if v[mid] < a {
            min = mid;
        } else {
            max = mid;
        }
    }
    min
}


Measured memory_bytes: 10620
class Dice():
    directions = "EEENEEENEEESEEESEEENEEEN"

    def __init__(self, lst):
        self.top = lst[0]
        self.front = lst[1]
        self.right = lst[2]
        self.left = lst[3]
        self.back = lst[4]
        self.bottom = lst[5]

    def rotate(self, direction):
        if direction == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        if direction == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        if direction == "S":
            self.top, self.front, self.bottom, self.back = self.back, self.top, self.front, self.bottom
        if direction == "W":
            self.top, self.left, self.bottom, self.right = self.right, self.top, self.left, self.bottom

    def fit_top_front(self, num_top, num_front):
        for direction in Dice.directions:
            if self.top == num_top and self.front == num_front:
                break
            self.rotate(direction)


def main():
    dice_nums = list(map(int, input().split()))
    dice = Dice(dice_nums)

    num_questions = int(input())

    for _ in range(num_questions):
        nums = list(map(int, input().split()))
        dice.fit_top_front(nums[0], nums[1])
        print(dice.right)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5604
import java.util.Scanner;


public class Main {

	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int result = 0;
			int n = Integer.parseInt(stdIn.next());
			for(int a=0;a<10;a++){
				for(int b=0;b<10;b++){
					for(int c=0;c<10;c++){
						for(int d=0;d<10;d++){
							if(n == (a+b+c+d)) result++;
						}
					}
				}
			}
			System.out.println(result);
		}
		stdIn.close();
	}

}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    sort(A.begin(), A.end(), greater<int>());
    priority_queue<int> que;
    for(int i = 0; i < N; ++i) {
        que.push(A[i]);
        if(i) que.push(A[i]);
    }
    int64_t ans = 0;
    for(int i = 0; i < N - 1; ++i) {
        ans += que.top();
        que.pop();
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6088
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>
using namespace std;

int main() {
	long long int a, b, r, x, tmp;
	cin >> a >> b;

	long long int A = a, B = b;

	x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	
	cout << x / b << endl;
	
	
	

	return 0;
}









Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long a = sc.nextLong();
	long b = sc.nextLong();
	long x = sc.nextLong();
	if(a == 0) {
		System.out.println(b / x + 1);
	} else {
		System.out.println((b / x) - ((a - 1) / x));		
	}
}
}


Measured memory_bytes: 21972
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

bool comp(const P& lh, const P& rh) {
    if (lh.second == rh.second) return lh.first < rh.first;
    else return lh.second < rh.second;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<P> as(n);
  map<ll, ll> dp;
  ll count = 0;
  rep(i, n) {
    int a;
    cin >> a;
    // as[i] = P(i+1, a);
    int k = i + 1 - a;
    if (dp.count(k) > 0) count += dp[k];
    int m = i + 1 + a;
    if (dp.count(m) > 0) dp[m] += 1;
    else dp[i + 1 + a] = 1;
  }
  cout << count << endl;
  // std::sort(as.begin(), as.end(), comp);
  // for(auto p : as) {
  //   cout << p.first << ", " << p.second << endl;
  // }
}

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

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   long long a[4], ans = 0;
   for (long long i = 0; i < 3; i++) cin >> a[i]; sort(a, a + 3);
   
   set<tuple<long long, long long, long long>> s1;
   s1.insert(make_tuple(a[0], a[1], a[2]));
   for(;;)
   {
      if ((a[0] & 1) || (a[1] & 1) || (a[2] & 1))
      {
         break;
      }
      long long b[3];
      ans++;
      b[0] = (a[1]+ a[2])/2;
      b[1] = (a[0]+ a[2])/2;
      b[2] = (a[0]+ a[1])/2;

      a[0] = b[0];
      a[1] = b[1];
      a[2] = b[2];
      sort(a, a + 3);
      auto ins = s1.insert(make_tuple(a[0], a[1], a[2]));
      if (!ins.second)
      {
         ans = -1;
         break;
      }
   }
   
   cout << ans << "\n";
   return 0;
}

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

using namespace std;

int n, k;
vector<int> a;
map<tuple<int, int, int>, long long> dp;

long long dfs(int now, int maxheight, int selected) {
	if (selected == k) return 0;
	if (now == n) return numeric_limits<long long>::max();
	auto status = make_tuple(now, maxheight, selected);
	if (dp.count(status)) return dp[status];
	if (maxheight < a[now]) {
		return dp[status] = dfs(now + 1, a[now], selected + 1);
	}
	long long res = dfs(now + 1, maxheight, selected);
	long long res2 = dfs(now + 1, maxheight + 1, selected + 1);
	if (res2 != numeric_limits<long long>::max()) {
		res2 += maxheight + 1 - a[now];
	}
	res = min(res, res2);
	return dp[status] = res;
}

void hawawa()
{
	cin >> n >> k;
	a.resize(n);
	for (auto&& i : a) {
		cin >> i;
	}
	cout << dfs(1, a[0], 1) << "\n";
}

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


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

int main()
{
	int a,b,c,sum=0;
	char s[100];
	
	cin>>a;
    if(a<=999)
        cout<<"ABC"<<endl;
    else
    {
        cout<<"ABD"<<endl;
    }
    
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> color(8);
  int count = 0;
  rep(i, n){
    int index = a[i] / 400;
    if(index >= 8)  count++;
    else color[index]++;
  }
  int used = 0;
  rep(i, 8){
    if(color[i] > 0)  used++;
  }
  int mi = max(used, 1);
  int ma = used + count;
  cout << mi << ' ' << ma << endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[100005],b[100005],c[100005],s[100005],ans;
signed main(){	
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++)cin >> c[i];
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	s[0] = n - (upper_bound(c, c + n, b[0]) - c);
	for(int i=1;i<n;i++){
		s[i]=n-(upper_bound(c,c+n,b[i])-c);
		s[i]+=s[i-1];
	}
	for(int i=0;i<n;i++){
	    ans+=s[n-1]-s[upper_bound(b, b + n, a[i]) - b - 1];
	}
	cout<<ans<<endl;
}


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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  vi a(n);
  rep(i, 0, n) cin >> a[i];

  int ans = 0;
  rep(i, 0, n) {
    if(i + 1 == a[a[i] - 1]) ans++;
  }
  cout << ans / 2 << endl;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        ans += (h <= a && w <= b);
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[A.size() - 1] - A[0] << endl;
}

Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef double d;
ll Sum(ll n)
{
    ll x=0;
    while(n>0)
    {
        x+=(n%10);
        n=n/10;
    }
    return x;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll mv=1000000000000;
    for(ll i=1;i<n;i++)
    {
        ll sum1=Sum(i);
        ll sum2=Sum(n-i);
        if((sum1+sum2)<mv)
        {
            mv=sum1+sum2;
        }
    }
    cout<<mv<<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;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int n,a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
}


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

const int mod = 1e9 + 7;
int query(vector<int>& prefix, int x, int y)
{
  if (x <= 0)
    return prefix[y];
  return (prefix[y] - prefix[x-1] + mod) % mod;
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n), dp(k+1), DP(k+1);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  dp[0] = 1;
  for (auto elem : a) {
    DP[0] = dp[0];
    for (int i = 1; i <= k; ++i) {
      DP[i] = (DP[i-1] + dp[i]) % mod;
    }
    for (int i = k; i >= 0; --i)
    {
      dp[i] = query(DP, i - elem, i);
    }

  }

  cout << dp[k] <<'\n';


  return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
    input! {
      s: Chars,
    }

    println!("{}", s.into_iter().take(3).collect::<String>());
}


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

using namespace std;

int main(){
  long long N;
  cin >> N;
  
  if(N % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  
  long long ling = 0;
  long long shi = 10ll;
  for(int i = 0; i < 25; i++){
    ling += N / shi;
    shi *= 5ll;
  }
  cout << ling << endl;
  
  return 0;
}

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

using namespace std;
using int64 = long long;
using IntPair = pair<int, int>;

constexpr int DEBUG = 0;

struct Edge {
  int from;
  int to;
  bool w;
  Edge(int from, int to, bool w) : from(from), to(to), w(w) {}
};

struct PairHash {
  std::size_t operator()(const pair<int, int>& k) const {
    return hash<int>()(k.first) * 1000000007 ^ hash<int>()(k.second);
  }
};

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, m;
  cin >> n >> m;

  vector<int> v1s(m);
  vector<int> v2s(m);
  vector<int> cs(m);
  for (int i = 0; i < m; i++) {
    cin >> v1s[i] >> v2s[i] >> cs[i];
    v1s[i]--;
    v2s[i]--;
  }

  map<IntPair, int> id_map;
  auto build_map = [&]() {
    int id = 0;
    for (int i = 0; i < n; i++) {
      id_map[IntPair(i, 0)] = id++;
    }
    for (int i = 0; i < m; i++) {
      IntPair p1 = IntPair(v1s[i], cs[i]);
      if (id_map.find(p1) == id_map.end()) {
        id_map[p1] = id++;
      }
      IntPair p2 = IntPair(v2s[i], cs[i]);
      if (id_map.find(p2) == id_map.end()) {
        id_map[p2] = id++;
      }
    }
  };
  build_map();
  int s = id_map.size();

  vector<vector<Edge>> graph(s);
  for (int i = 0; i < m; i++) {
    int v1 = v1s[i];
    int v2 = v2s[i];
    int c = cs[i];
    int a1 = id_map[IntPair(v1, 0)];
    int b1 = id_map[IntPair(v1, c)];
    int a2 = id_map[IntPair(v2, 0)];
    int b2 = id_map[IntPair(v2, c)];
    graph[a1].push_back(Edge(a1, b1, true));
    graph[b1].push_back(Edge(b1, a1, false));
    graph[a2].push_back(Edge(a2, b2, true));
    graph[b2].push_back(Edge(b2, a2, false));
    graph[b1].push_back(Edge(b1, b2, false));
    graph[b2].push_back(Edge(b2, b1, false));
  }

  vector<int> ds(s, INT_MAX);
  vector<int> visited(s);
  deque<int> q;
  ds[id_map[IntPair(0, 0)]] = 0;
  q.push_back(id_map[IntPair(0, 0)]);

  while (!q.empty()) {
    int v = q.front();
    q.pop_front();

    if (visited[v]) continue;
    visited[v] = true;
    
    for (const auto& e : graph[v]) {
      int nv = e.to;
      int nd = ds[v] + (e.w ? 1 : 0);
      if (nd < ds[nv]) {
        ds[nv] = nd;
        if (e.w) {
          q.push_back(nv);
        } else {
          q.push_front(nv);
        }
      }
    }
  }

  int ans = INT_MAX;
  for (const auto& kv : id_map) {
    const auto& k = kv.first;
    if (k.first == n - 1) {
      UpdateMin(ans, ds[kv.second]);
    }
  }

  if (ans == INT_MAX) ans = -1;

  cout << ans << endl;
  return 0;
}

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

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int x = a; x <= b; x++) {
    if (x < a + k || b - k < x) {
      cout << x << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    n = int(input())
    numbers=list(map(int,input().split()))
    numbers=np.array(numbers)
    count=0
    
    if np.all(numbers%2==1):
        print(0)
        exit()
    while True:
        if np.all(numbers%2==1)==True:
            break
        else:
            idx=np.where(numbers%2==0)
            count+=np.count_nonzero(numbers%2==0)
            numbers[idx]=numbers[idx]//2
    print(count)

if __name__=="__main__":
    main()

Measured memory_bytes: 27944
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn is_parity(s: &str) -> bool {
    let l = s.len();
    if l % 2 != 0 {
        return false;
    }
    let harf_len = l / 2;

    let s1 = &s[0..harf_len];
    let s2 = &s[harf_len..l];
    return s1 == s2;
}

fn main() {
    let s = getline();
    let len = s.len();

    let mut ans = 0;
    for i in 0..(len-1) {
        let sliced = &s[0..i];

        ans = if is_parity(sliced) { sliced.len() } else { ans }
    }

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


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	vector<int>ss;
	int N;
	scanf("%d",&N);
	while(N--)
	{
		int x;scanf("%d",&x);
		ss.push_back(x);
	}
	sort(ss.begin(),ss.end());
	int s=1;
	if(ss.size()==1)
	printf("1\n");
	else {
	for(int i=1;i<ss.size();i++)
	{
		if(ss[i]==ss[i-1])
		{
			ss[i]=-99;
			s--;
		}
		else s++;
	}
	printf("%d\n",s);
	}
}

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

int main(){
    int n;
    cin>>n;
    rep(i,n){
        int tmp;
        cin>>tmp;
        if(tmp%2!=0) continue;
        if((tmp%3!=0)&&(tmp%5!=0)){
            cout << "DENIED" <<endl;
            return 0;
        }
    }
    cout <<"APPROVED"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll N;
ll K;
template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2){
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        ++num;
        return *this;
    }

    constexpr modint operator ++ (int n){
        modint tmp = *this;
        ++(*this);
        return tmp;
    }

    constexpr modint operator -- (){
        --num;
        return *this;
    }
    constexpr modint operator -- (int n){
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    void modpow(ll y){
        modint tmp = (*this);
        (*this) = 1;
        while(y > 0){
            if(y % 2){
                (*this) *= tmp;
            }
            tmp *= tmp;
            y /= 2;
        }
    }


    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    
    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        long long tmp;
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<1000000007>

ll fsum[200010], bsum[200010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 0; i <= N; i++){
        fsum[i] += i;
        bsum[N - i] += N - i;
        fsum[i + 1] += fsum[i];
        if(i != N) bsum[N - i - 1] += bsum[N - i];
    }
    mint ans = 0;
    for(int i = K; i <= N + 1; i++){
        ans += bsum[N - i + 1] - fsum[i - 1] + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6692
#include<stdio.h>
int main(){
	int a[100],n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	
	for(i=n-1;i>=0;i--){
		if(i==0){
			printf("%d\n",a[i]);
			continue;
		}
		printf("%d ",a[i]);
	}
	return 0;
}



Measured memory_bytes: 2044
l,r = map(int,raw_input().split())

now = [0]*2020

a = l
while a < r+1:
  now[a % 2019] = 1
  a += 1
  if now[0] == 1 or (now[3]==1 and now[673]==1):
    print 0
    exit(0)

ans = 2019*2019
for x in range(2019):
  if now[x] == 1:
    for y in range(2019):
      if now[y] == 1 and x != y:
        buf = (x*y)%2019
        if ans > buf:
          ans = buf
print ans


Measured memory_bytes: 2692
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

bool match(const string& s, int n)
{
    if (n == 0) {
        return true;
    }

    if (n >= 5) {
        string t("dream");
        if (equal(s.begin() + n - t.size(), s.begin() + n, t.begin())) {
            return match(s, n - t.size());
        }
        t = string("erase");
        if (equal(s.begin() + n - t.size(), s.begin() + n, t.begin())) {
            return match(s, n - t.size());
        }
    }

    if (n >= 6) {
        string t("eraser");
        if (equal(s.begin() + n - t.size(), s.begin() + n, t.begin())) {
            return match(s, n - t.size());
        }
    }

    if (n >= 7) {
        string t("dreamer");
        if (equal(s.begin() + n - t.size(), s.begin() + n, t.begin())) {
            return match(s, n - t.size());
        }
    }

    return false;
}

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

    if (match(s, s.size())) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <boost/algorithm/string.hpp>
using namespace std;
int main() {
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    boost::to_upper(s1); boost::to_upper(s2); boost::to_upper(s3);
    cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 3612
<?php
$numbers = preg_split("/[\s,]+/", rtrim(fgets(STDIN)));
$n = intval($numbers[0]);
$q_n = intval($numbers[1]);

// print $q;

$a = []; //二次元配列
$head = [];
$tail = [];
for ($i = 0; $i < $n; $i++){
    $a[] = [];
    $head[$i] = 10000;
    $tail[$i] = 10000;
}

for($i=0; $i < $q_n; $i++) {
  $g = preg_split("/[\s,]+/", fgets(STDIN));
  $q = intval($g[0]);
//   echo $q;
  if ($q === 0) {
      // 9999head
      $a[intval($g[1])][$head[intval($g[1])]] = intval($g[2]);
    //   var_dump($a);
      $head[intval($g[1])]--;
    } else if ($q === 1){
        if($head[intval($g[1])] !== $tail[intval($g[1])]){
            echo $a[intval($g[1])][$tail[intval($g[1])]] . "\n";
        }
        // var_dump($head);
        // var_dump($tail);
    } else {
        // 2のケース
        if($head[intval($g[1])] !== $tail[intval($g[1])]){
            $tail[intval($g[1])]--;
        }
    }
    //   var_dump($a);
    //   print ($a[0][9998]);

}


Measured memory_bytes: 38888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vector<P> p(n);
  rep(i,n){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(),p.end());
  cout << p[n-1].first+p[n-1].second << endl;
}


Measured memory_bytes: 1792
//8 Puzzle
#include <iostream>
#include <string>
#include <queue>
#include <map>

using namespace std;

static const int N = 3;
static const int N2 = 9;
static const char dir[4] = {'u', 'l', 'd', 'r'};
static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < (const Puzzle &p) const {
        for(int i = 0; i < N2; i++) {
            if(f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

bool isTarget(Puzzle p) {
    for(int i = 0; i < N2; i++) {
        if(p.f[i] != (i + 1)) return false;
    }
    return true;
}

string bfs(Puzzle p) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    p.path = "";
    Q.push(p);
    V[p] = true;
    while(!Q.empty()) {
        u = Q.front();
        Q.pop();
        if(isTarget(u)) return u.path;
        int sx = u.space % N;
        int sy = u.space / N;
        for(int r = 0; r < 4; r++) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
            v = u;
            v.space = tx + N * ty;
            swap(v.f[v.space], v.f[u.space]);
            if(!V[v]) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    return "unsolvable";
}

int main() {
    Puzzle in;
    for(int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if(in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }

    cout << bfs(in).size() << endl;
}



Measured memory_bytes: 30596
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
    long long n, m;
    scanf("%lld%lld",&n,&m);
    if(m/2 <= n){
        printf("%lld\n",m/2);
        return 0;
    }
    long long t = (m - n*2)/4;
    m-=t*2;
    n+=t;
    printf("%lld\n",min(n,m/2));
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n;
	while (1) {
		cin >> n;
		if (n == 0)return 0;
		int a, b;
		int ascore = 0, bscore = 0;
		vector<P>card;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b)ascore += a + b;
			else if (b > a)bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		cout << ascore << " "<< bscore << endl;
	}

}

Measured memory_bytes: 3000
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
    int N, K; cin >> N >> K;
    vector<vector<int>> books(10, {0});
    while (N--) {
        int c, g; cin >> c >> g; g--;
        books[g].emplace_back(c);
    }
    vector<int> dp(K + 1);
    for (int i = 0; i < 10; i++) {
        auto &cur = books[i];
        int sz = cur.size();
        sort(cur.begin(), cur.end());
        reverse(cur.begin() + 1, cur.end());
        for (int j = 1; j < sz; j++) cur[j] += cur[j - 1] + (j - 1) * 2;
        vector<int> dp2(K + 1);
        for (int k = 0; k <= K; k++) {
            for (int j = 0; j < sz; j++) {
                if (k + j <= K) chmax(dp2[k + j], dp[k] + cur[j]);
            }
        }
        swap(dp, dp2);
    }
    cout << dp[K] << endl;
    return 0;
}


Measured memory_bytes: 3184
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, groupby
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
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

A = INT()
B = INT()

if A > B:
	print("GREATER")
elif B > A:
	print("LESS")
else:
	print("EQUAL")


Measured memory_bytes: 5200
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count


Measured memory_bytes: 53276
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string str;
  cin >> str;

  if (str == "ABC") {
    cout << "ARC" << endl;
  }else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3136
import math

n = int(input())
res = [0] * 100000
count = 0
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans > 10001:
                break
            if ans <= 10000:
                res[ans] += 1

for i in range(n):
    print(res[i + 1])

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

def distance(x1,y1,x2,y2):
    return ((x1-x2)**2+(y1-y2)**2)**0.5

import itertools
import math
per=list(itertools.permutations(xy))
#print(per)
N=math.factorial(n)
ans=0
for i in range(N):
    sum=0
    p=per[i]
    for j in range(n):
        if j!=n-1:
            sum+=distance(p[j][0],p[j][1],p[j+1][0],p[j+1][1])
    ans+=sum
print(ans/N)

Measured memory_bytes: 8100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N+1], B[N+1], C[N+1];
  for(int i = 0; i <= N; i++) {
    B[i] = 0;
    C[i] = 0;
  }
  A[0] = 0;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  for(int i = N; i >= 1; i--) {
    int w = i + i;
    while(w <= N) {
      if(C[w] ==  1) {
        B[i]++;
      }
      w += i;
    }
    if(B[i] % 2 == 0) {
      C[i] = A[i];
    }
    else {
      if(A[i] == 0) {
        C[i] = 1;
      }
      else {
        C[i] = 0;
      }
    }
  }
  int ans = 0;
  for(int i = 1; i <= N; i++) {
    ans += C[i];
  }
  cout << ans << endl;
  for(int i = 1; i <= N; i++) {
    if(C[i] == 1) {
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#define in(n, m) for (ll i=n; i<m;i++)
#define inj(n, m)for (ll j=n; j<m;j++)
using namespace std;
using ll=long long;
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; }
const ll N=1e5, M = 1e5;
ll dp[100000];
ll a[100000];
const ll INF = 1LL << 60;


int main() {
	ll N,K;
	cin >> N>>K;
	in(0, N) cin >> a[i];
	in(0, 100000) dp[i] = INF;
	dp[0] = 0;
	in(0, N) {
		inj(1, K+1) {
			chmin(dp[i+j], abs(a[i + j] - a[i])+dp[i]);
		}
	}

	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
 
const int N = 1e5 + 5;
 
int a[N] , n;
 
bool cmp(int x , int y) {
	return x > y;
}
 
int main(void) {
	scanf("%d" , &n); for(int i = 1;i <= n;i ++) scanf("%d" , &a[i]);
	sort(a + 1 , a + n + 1 , cmp);
	int res = 0 , cur = -1;
	for(int i = 1;i <= n + 1;i ++) if(a[i] < i) {
		cur = i - 1; break;
	}
	res = 1;
	for(int j = cur + 1;a[j] == cur;j ++) res ^= 1;
	res &= (a[cur] - cur + 1) & 1;
	if(res)
	puts("Second");
	else puts("First");
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	char a[21]={0};
	int i,n=0;
	scanf("%s",a);
	while(a[n]!='\0')++n;
	for(i=n-1;i>=0;i--)printf("%c",a[i]);
	printf("\n");
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int A[N];
    
    for(int a = 0;a<N;a++){
        cin >> A[a];
        if(a!=N-1){
            cout << A[a] << " ";
        }else{
            cout << A[a] << endl;
        }
    }
    for(int i = 1;i<N;i++){
        int v = A[i],j = i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
            A[j+1] = v;
        }
        for(int a = 0;a<N;a++){
            if(a!=N-1){
                cout << A[a] << " ";
            }else{
                cout << A[a] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }

// bool sorter(lld a, lld b)
// {
//     vector<lld> v2;
//     vector<lld> w;
//     // cout<<"A == " <<a<<"  B== "<<b;
//     while(a>=1)
//     {
//         v2.pb(a%10);
//         a/=10;
//     }
//     while(b>=1)
//     {
//         w.pb(b%10);
//         b/=10;
//     }   
       
//     reverse(all(v2));
//     reverse(all(w));
//     lld l1 = v2.size();
//     lld l2 = w.size();
//     lld  l = (l1*l2)/__gcd(l1,l2);
//     // cout<<l1<< " "<<l2<< " "<<l<< " ";
//     for(int i=0;i<l;i++)
//     {
//         if(v2[i%l1]!=w[i%l2])
//         {
//             // cout<< "   "<< (v2[i%l1] > w[i%l2])<<"\n";
//             return v2[i%l1] > w[i%l2];
//         }
//     }
//     // printf("false\n");
//     return false;
// }


lld p1=1e8 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;

void solve()
{

    cin>>n>>x;
    x*=x;
    ans=0;
    for(i=0;i<n;i++)
    {
        lld a,b;
        cin>>a>>b;
        if(a*a+b*b <= x)
            ans+=1;
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    // cin>>t;
    // cout<<t;
     // getfac(p1);
    //check the value by which modulo is to be taken
    // lld ans=0;
    // precompute();
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////

int main(){
    int N,M,Q;
    SCD3(N,M,Q);

    static int x[502][502] = {};

    REP(i,M){
        int l,r;
        SCD2(l,r);
        x[l][r]++;
    }

    static int c[502][502] = {};
    FORq(i,1,N){
        FORq(j,1,N){
            c[i][j] = c[i][j-1] + x[i][j];
        }
    }

    REP(i,Q){
        int p,q;
        SCD2(p,q);
        int ans = 0;
        FORq(k,p,q){
            ans += c[k][q] - c[k][p-1];
        }

        PRINTD(ans);
    }
}

Measured memory_bytes: 2944
#include <stdio.h>
 
int main(void){
	char str[1000];
	int eight,ten;
	int x = -1;
	
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d %d",&eight,&ten);
	
	for(int i = 1000; i > 0; i--){
		if(i * 8/100 == eight && i * 10/100 == ten){
			x = i;
		}
	}
	
	printf("%d\n",x);
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll arr[100005];
int main()
{
    ll n,a,b,ans=0;
    scanf("%lld%lld%lld",&n,&a,&b);
    for(ll i=0;i<n;i++)
    {
        scanf("%lld",&arr[i]);
    }
    for(ll i=1;i<n;i++)
    {
        ll x=arr[i]-arr[i-1];
        if(x*a<b)
        {
            ans+=x*a;
        }
        else ans+=b;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <vector>
#include <cmath>

typedef std::pair<int, int> pii;
typedef std::vector<pii> vpii;

void E_sieve(std::vector<bool> &is_prime);

int main()
{
  int Q;
  std::cin >> Q;
  vpii lr(Q);
  int max = 0;
  for (int i = 0; i < Q; i++)
  {
    std::cin >> lr.at(i).first >> lr.at(i).second;
    max = std::max(max, lr.at(i).second);
  }
  std::vector<bool> is_prime(max+1, true);
  E_sieve(is_prime);
  std::vector<int> prime_num(max+1, 0);
  int num = 0;
  for (int i = 0; i <= max; i++)
  {
   if (is_prime.at(i)) num++;
   prime_num.at(i) = num;
  }
  for (int i = 0; i < Q; i++)
  {
    int ans = prime_num.at(lr.at(i).second) - prime_num.at(lr.at(i).first);
    if (prime_num.at(lr.at(i).first) != prime_num.at(lr.at(i).first-1)) ans++;
    std::cout << ans << std::endl;
  }
}

/* ++++++++++ function ++++++++++*/
void E_sieve(std::vector<bool> &is_prime)
{
  int max = is_prime.size()-1;
  std::vector<int> check;
  is_prime[0] = false;
  is_prime[1] = false;
  for(int i=2; i<=max/i; i++)
  {
    if(is_prime[i])
    {
      for(int j=2; j<=max/i; j++){
        is_prime[i*j] = false;
        if(i*j*2-1 <= max) check.push_back(i*j*2-1);
      }
    }
  }
  is_prime[2] = false;
  for (int i = 0; i < check.size(); i++) is_prime[check.at(i)] = false;
}


Measured memory_bytes: 1776