akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define N 2*123460

using namespace std;

int main(){
  int n;
  bool q[N];

  q[0] = false; q[1]=false;
  for( int i=2;i<N;i++ ) q[i]=true;

  for( int i=2;i<N;i++ ){
    if( q[i] ){
      for( int j=2*i;j<N;j+=i )
	if( j%i==0 )
	  q[j] = false;
    }
  }

  while( cin>>n , n ){
    int c=0;
    for( int i=n+1,len=2*n;i<=len&&i<N;i++ ){
      if( q[i] )c++;
    }
    cout << c << endl;
  }

  return 0;
}

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

namespace AtTest.AGC_031
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] cs = new int[n];
            for (int i = 0; i < n; i++) cs[i] = ReadInt();
            var have = new Dictionary<int, int>();
            have.Add(cs[n - 1], n - 1);
            var sums = new long[n];
            long mask = 1000000000 + 7;
            long res = 1;
            for(int i = n - 2; i >= 0; i--)
            {
                sums[i] = sums[i + 1];
                if (have.ContainsKey(cs[i]))
                {
                    if (i + 1 < have[cs[i]])
                    {
                        long next= sums[have[cs[i]]] + 1;
                        res += next;
                        res %= mask;
                        sums[i] += next;
                        sums[i] %= mask;
                    }
                    have[cs[i]] = i;
                }
                else
                {
                    have.Add(cs[i], i);
                }
                //WriteLine(sums[i]);
            }
            WriteLine(res);
        }

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


Measured memory_bytes: 28380
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<stack>

using namespace std;
int main(){
    stack<int> S;
    int a,b,x;
    char s[101];

    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(a+b);
        }else if(s[0]=='-'){
            b=S.top();S.pop();
            a=S.top();S.pop();
            S.push(a-b);

        }else if(s[0]=='*'){
            a=S.top();S.pop();
            b=S.top();S.pop();
            S.push(a*b);
        }else
            S.push(atoi(s));                               
    }                                  
    printf("%d\n",S.top());
    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 111111;
const ll INF = 1000000000000000000LL;

class SEG{
  int n;
  ll dat[2*(1<<18)-1];

public:
  SEG(int _n = MAX){ 
    n = 1;
    while(n < _n) n *= 2;
    fill(dat,dat+2*n-1,0);
  }

  // get k-th
  ll get(int k){
    k += n - 1;
    ll ret = dat[k];
    while(k > 0){
      k = (k - 1) / 2;
      ret += dat[k];
    }
    return ret;
  }

  // add x to [a,b) 
  void query(int a, int b,ll x ){ return query(a, b, x, 0, 0, n);}
  void query(int a, int b, ll x, int k, int l, int r){
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) dat[k] += x;
    else{
      query(a, b, x, k*2+1, l, (l+r)/2);
      query(a, b, x, k*2+2, (l+r)/2, r);
    }
  }
};

SEG seg;
int N,Q;


void calc(ll a,ll b){
  //  cout << "calc : " << a << " " << b << endl;
  ll x = seg.get( a );
  int st = 0, ed = a;
  int r = a;
  while( st <= ed ){
    int h = (st+ed)/2;
    if( seg.get(h) == x ) {
      r = h;
      ed = h-1;
    } else
      st = h+1;    
  }

  ll inv = a-r+1;
  if( r == 0 ){
    seg.query( 0, a+1, b/(a+1) );
    seg.query( 0, b%(a+1), 1 );
  } else {
    ll y = seg.get( r-1 );
    if( b > (y-x) * inv ){
      seg.query( r, a+1, (y-x) );
      calc(a, b-(y-x)*inv);
    } else {
      seg.query( r, a+1, b / inv );
      seg.query( r, r + b % inv, 1 );      
    }
  }
}

int main(){
  cin >> N >> Q;
  for(int i=0;i<Q;i++){
    ll a,b; cin >> a >> b; --a;
    calc( a, b );
  }
  for(int i=0;i<N;i++){
    cout << seg.get(i) << endl;
  }
}


Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = String.valueOf(n);
		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			sum += Integer.parseInt(s.substring(i, i + 1));
		}
		
		if (n % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1000000007;
const int MX=0x3f3f3f3f;

int main(){
    //IOS;
	int n,i;
	cin>>n;
	ll a[n];
	int flag=0;
	REP(i,0,n-1) {
		cin>>a[i];
		if(!a[i]) flag=1;
	}
	ll temp=1;
	if(flag) {
		cout<<0;
		return 0;
	}
	ll inf=1e18;
	REP(i,0,n-1){
		//cout<<(inf+temp-1)/temp<<"\n";
		if(a[i]>inf/temp) {
			cout<<-1;
			return 0;
		}
		temp*=a[i];
		//cout<<temp<<"\n";
	}
	cout<<temp;
    return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e9 + 7;
int main( ){
    int n, k;
    scanf("%d %d", &n, &k);
    int num[n];
    for(auto &i : num)
        scanf("%d", &i);
    vector<int> dp(n, maxN);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = i + 1; j - i <= k && j < n; j++)
            dp[j] = min(dp[j], abs(num[j] - num[i]) + dp[i]);
    cout << dp[n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 4052
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const int MOD = 1000000007;
int main(void) {
	int N, M, p, y, c;
	map<pair<int, int>, ll> num;
	vector<pair<int, int> > data, data2;
	scanf("%d%d", &N, &M);
	rep(i, 0, M) {
		scanf("%d%d", &p, &y);
		data.push_back(make_pair(p, y));
		data2.push_back(make_pair(p, y));
	}
	sort(all(data2));
	p = 0;
	for (auto v : data2) {
		if (v.first == p)c++;
		else c = 1, p = v.first;
		num[v] = c + p * 1000000LL;
	}
	for (auto v : data) {
		printf("%012lld\n", num[v]);
	}
	return 0;
}


Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using Graphe = vector<vector<edge> >;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

Graphi G;
vl ans,w;

void dfs(int v = 0,int p = -1, ll flow = 0){
    ans.at(v) = flow + w.at(v);
    for(auto nv : G.at(v)){
        if(nv == p) continue;
        dfs(nv,v,ans.at(v));
    }
}
int main(){

    int n,q; cin >> n >> q;
    G.resize(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        --a;--b;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    w.assign(n,0);
    rep(i,q){
        int a,b; cin >> a >> b;
        --a;
        w.at(a) += b;
    }
    ans.resize(n);
    dfs();
    rep(i,n) cout << ans.at(i) << endl;

}

Measured memory_bytes: 28928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()
const ll MOD = 2019;

int main(){
	string S;
	cin >> S;
	int N = (int)S.size();
	vector<ll> ama(N+1), ten(N+1);
	
	// 0の個数1eiの2019で割った余り
	ten[0] = 1;
	for(int i=1;i<=N;i++) {
		ten[i] = (ten[i-1] * 10) % MOD;
	}

	vector<ll> memo(MOD+5, 0);
	ama[N] = 0;
	memo[ama[N]]++;
	for(int i=N-1;i>=0;i--) {
		int keta = (int)(S[i]-'0');
		ama[i] = (ama[i+1] + keta * ten[N-1-i]) % MOD;
		memo[ama[i]]++;
	}

	ll ans = 0;
	for(int i=0;i<MOD;i++) {
		ans += (memo[i] * (memo[i] - 1) / 2LL);
	}

	cout << ans << endl;
}

Measured memory_bytes: 6824
#include <iostream>

#define MAX_N 100

using namespace std;

int n, steps = 0;
int numbers[MAX_N];

void swap(int &a, int &b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> numbers[i];

	for (int i = 0; i < n - 1; i ++) {
		int minIndex = i;
		for (int j = i; j < n; j ++) {
			if (numbers[j] < numbers[minIndex]) {
				minIndex = j;
			}
		}
		if (minIndex != i) {
			swap(numbers[minIndex], numbers[i]);
			steps ++;
		}
	}

	for (int i = 0; i < n; i ++) if (i == 0) cout << numbers[i]; else cout << " " << numbers[i];
	cout << endl << steps << endl;

	return 0;
}


Measured memory_bytes: 3056
//RTn_E
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define _file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define sp setprecision 
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define pii pair < int , int >
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
const int maxn = 4e4 + 100;
const ll inf = 1e18;

//Main CODE :/\

char c[2000][2000];
bool mark[2000][2000];
int tim[2000][2000];
queue < pii > t;
void BFS (){
	//cout << t.size() << "\n";
	while (!t.empty()){
		pii x = t.front();
		int i = x.F , j = x.S;
		t.pop();
		if (!mark[i + 1][j] && c[i + 1][j] == '.'){
			t.push(mk(i + 1 , j));
			tim[i + 1][j] = min(tim[i + 1][j] , tim[i][j] + 1);
			mark[i + 1][j] = 1;
		}	
		if (!mark[i - 1][j] && c[i - 1][j] == '.'){
			t.push(mk(i - 1 , j));
			tim[i - 1][j] = min(tim[i - 1][j] , tim[i][j] + 1);
			mark[i - 1][j] = 1;
		}	
		if (!mark[i][j + 1] && c[i][j + 1] == '.'){
			t.push(mk(i , j + 1));
			tim[i][j + 1] = min(tim[i][j + 1] , tim[i][j] + 1);
			mark[i][j + 1] = 1;
		}	
		if (!mark[i][j - 1] && c[i][j - 1] == '.'){
			t.push(mk(i , j - 1));
			tim[i][j - 1] = min(tim[i][j - 1] , tim[i][j] + 1);
			mark[i][j - 1] = 1;
		}
	}
}
int main(){
	int H , W;
	cin >> H >> W;
	memset(tim , 31 , sizeof tim);
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++){
			cin >> c[i][j];
			if (c[i][j] == '#')
				t.push(mk(i , j)) , tim[i][j] = 0;		
		}
	BFS();
	int ans = 0;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			ans = max(ans , tim[i][j]);
	cout << ans << "\n";
	return 0;
}
//The_End																											 
//Game Over :D
																	


Measured memory_bytes: 28944
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef pair<int,int> Pii;
typedef map<int,int> MPii;
typedef vector<int> Vi;

const int INF=INT_MAX/3;
//const int V_MAX=10000,E_MAX=10000;
//int V,E;
const int N=100;
int h[N][N];

int solve(int n){

  Vi shortest[N];
  Vi tallest[N];

  int min,max;
  for(int i=0;i<n;i++){
    min=INF; max=-1;
    for(int j=0;j<n;j++){
      if(h[i][j]<min){
      	min=h[i][j];
	shortest[i].clear();
	shortest[i].push_back(j);
      }
      else if(h[i][j]==min)
	shortest[i].push_back(j);
      
      if(max<h[j][i]){
	max=h[j][i];
	tallest[i].clear();
	tallest[i].push_back(j);
      }
      else if(max==h[j][i])
	tallest[i].push_back(j);
    }
  }

  //shortest[i]: list of shortest student's index in row i
  //tallest[i]: list of tallest student's index in column i

  for(int i=0;i<n;i++){
    for(int j=0;j<shortest[i].size();j++){
      int k=shortest[i][j];
      for(int l=0;l<tallest[k].size();l++)
	if(tallest[k][l]==i) return h[i][k];
    }
  }
  return 0;
}



int main(){

  int n;
  cin>>n;
  while(n!=0){

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	cin>>h[i][j];
    cout<<solve(n)<<endl;
    cin>>n;
  }


  return 0;
}

Measured memory_bytes: 3096
main :: IO ()
main = do
    line <- getLine
    let
        [a, b] = map (\x -> read x :: Int) $ words line
    putStrLn $ eval a b

eval :: Int -> Int -> String
eval x y
    | x < y = "a < b"
    | x > y = "a > b"
    | otherwise = "a == b"

Measured memory_bytes: 3604
# coding: utf-8


def main():
    N = int(input())
    S = [None] * N
    for i in range(N):
        S[i] = input()

    a, b, c, d = "AC", "WA", "TLE", "RE"
    dic = {x: 0 for x in [a, b, c, d]}

    for s in S:
        dic[s] += 1

    for k, v in dic.items():
        print(f"{k} x {v}")


main()


Measured memory_bytes: 15988
a,b,c,x,y=map(int,input().split())

if a+b<2*c:
    print(a*x+b*y)
else:
    ans=0
    if x>=y:
        ans+=y*2*c
        x-=y
        ans+=x*min(2*c,a)
    else:
        ans+=x*2*c
        y-=x
        ans+=y*min(2*c,b)
    print(ans)



Measured memory_bytes: 38384
n, k = map(int,input().split())

v = list(map(int, input().split()))

m = 0

for i in range(n + 1):

    for j in range(n, i - 1 , -1):

        temp = sorted(v[:i] + v[j:], reverse = True)

        count = len(temp)

        if count > k:
            break

        while temp and count < k and temp[-1] < 0:

            temp.pop()

            count += 1

        m = max(m, sum(temp))

print(m)

Measured memory_bytes: 3064
# ABC062A - Grouping
x, y = list(map(int, input().rstrip().split()))
lst = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11]]

for i in lst:
    if x in i and y in i:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 2940
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let _n = input!(usize);
    let a_lst = input!(i64; n);
    let mut odd: i64 = 0;
    let mut even: i64 = 0;
    let mut four: i64 = 0;

    for &a in a_lst.iter() {
        if a % 4 == 0 {
            four += 1;
        } else if a % 2 == 0 {
            even += 1;
        } else {
            odd += 1;
        }
    }

    if even > 0 {
        if odd > four {
            println!("No");
            return;
        }
    } else {
        if odd > four + 1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<long long> ans[10]; 
	for(long long i = 1; i < 10; i++) ans[0].emplace_back(i); 
	for(int d = 0; d < 9; d++){
		for(int i = 0; i < ans[d].size(); i++){
			long long r = ans[d][i] % 10; 
			if(r > 0) ans[d+1].emplace_back(ans[d][i] * 10 + r - 1); 
			ans[d+1].push_back(ans[d][i] * 10 + r); 
			if(r < 9) ans[d+1].emplace_back(ans[d][i] * 10 + r + 1); 
		}
	}
	vector<long long> ANS; 
	for(int d = 0; d < 10; d++){
		for(int i = 0; i < ans[d].size(); i++){
			if(ans[d][i] <= 3333333333) ANS.emplace_back(ans[d][i]); 
		}
	}
	sort(ANS.begin(), ANS.end()); 
	int K; cin >> K; cout << ANS.at(K-1) << endl; 
}

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back

const int MAXN = 200009;
const int T = 4010;
int dp[T][T];
int cnt[T][T];
int k[2 * T];
int n;
int mod = 1e9 + 7;

int binpow(int a, int p)
{
    if (p == 1)
        return a;
    int b = binpow(a, p / 2);
    b = (b * b) % mod;
    if (p % 2)
        b = (b * a) % mod;
    return b;
}

int divide(int a, int b)
{
    return (a * binpow(b, mod - 2)) % mod;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    k[0] = 1;
    for (int i = 1; i < 2 * T; i++)
        k[i] = (k[i - 1] * i) % mod;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        cnt[a + T / 2][b + T / 2]++;
        cnt[-a + T / 2][-b + T / 2]++;
        ans -= divide(k[2 * (a + b)], (k[2 * a] * k[2 * b]) % mod);
        if (ans < 0)
            ans += mod;
    }
    for (int i = 0; i < T; i++)
    {
        dp[0][i] = 0;
        dp[i][0] = 0;
    }
    for (int i = 1; i < T; i++)
    {
        for (int e = 1; e < T; e++)
        {
            dp[i][e] = dp[i - 1][e] + dp[i][e - 1];
            if (dp[i][e] >= mod)
                dp[i][e] -= mod;
            if (i > T / 2 && e > T / 2)
                ans = (ans + dp[i][e] * cnt[i][e]) % mod;
            else
            {
                dp[i][e] += cnt[i][e];
                if (dp[i][e] >= mod)
                    dp[i][e] -= mod;
            }
        }
    }
    if (ans % 2)
        ans += mod;
    ans /= 2;
    cout << ans;
}


Measured memory_bytes: 250752
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
#define size size()

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int a;
    a=100*r+10*g+b;
    if(a%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}







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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int a, b;

int main(){
	cin >> a >> b;
	
	int cnt = 0;
	
	for(int i = a; i <= b; i++){
		if(i / 10000 == i % 10 && (i%10000)/1000 == (i%100)/10)
			cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

bool IsPrime(int x){
  for(int i = 2; i * i <= x; ++i){
    if(x % i == 0)return false;
  }
  return true;
}

int main(){
  int x; cin >> x;
  while(1){
    if(IsPrime(x)){
      cout << x << endl;
      break;
    }
    x++;
  }
  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,d;
  cin >> n >> d;
  vector<vector<int>> a(n,vector<int>(d));
  rep(i,n)rep(j,d)cin >> a[i][j];
  
  int count = 0;
  rep(i,n-1)
    rep2(j,i+1,n){
      double dis=0;
      rep(k,d){
        int t=a[i][k]-a[j][k];
        dis+=t*t;
      }
      rep(l,16000){
      	if(dis==l*l){
          count++;
          //cout << l*l << endl;
          break;
        }
   	   }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long  i = 0; i < (long long)(n); i++)






int main() {
	
	double N;
	cin >> N;
	
	cout << ((N+(int(N))%2)/(2*N))<< endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>

int main(){
    unsigned long N, K, ans = 0, v[100001];
    scanf("%lu%lu", &N, &K);
    for(unsigned long i = 1; i <= K; ++i)v[i] = i;
    for(unsigned long i = 2; i <= K; ++i)if(v[i] == i)for(unsigned long j = i; j <= K; j += i)v[j] = (v[j] / i) * (i - 1);
    for(unsigned long i = 1; i <= K; ++i)v[i] = (v[i] + v[i - 1]) % 1000000007;
    for(unsigned long i = K, p = 0; i; ){
        unsigned long t = K / i, r = 1, n = N, a = t;
        while(n){
            if(n & 1){
                r *= a;
                r %= 1000000007;
            }
            a *= a;
            a %= 1000000007;
            n >>= 1;
        }
        ans += (r + p) * v[i];
        i = K / (t + 1);
        p = 1000000007 - r;
    }
    printf("%lu\n", ans % 1000000007);
    return 0;
}

Measured memory_bytes: 2468
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

static const int MOD = 1000000007;

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

	bool alphabet[26];
	REP(i, 26) alphabet[i] = 0;

	bool found = 0;
	for (char c = 'a';c <= 'z';c++) {
		REP(i, s.length()) {
			if (c == s[i]) {
				found = 1;
			}
		}
		if (found == 0) {
			cout << c << endl;
			return 0;
		}
		found = 0;
	}

	cout << "None" << endl;

	return 0;
}

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

int main(){
int N, M, C, cnt;
  cin >> N >> M >> C;
  cnt = 0;
  int A[M];
  int B[M];
  int ab = 0;
  for(int i = 0;i < M;i++) cin >> B[i];
  
  while(N > 0){
  for(int i = 0;i < M;i++)
    cin >> A[i];
  for(int i = 0;i < M; i++)
    ab += A[i] * B[i];
  if ((ab + C) > 0){
    cnt++;
  }
    ab = 0;
    N--;
}
    cout << cnt << endl;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n;

    cin >> n;



    double x1 = (-1+sqrt(1+(4*2*n)))/2;

    double  x2 = (-1-sqrt(1+(4*2*n)))/2;


    double maxi = max(x1,x2);



    cout << ceil(maxi) << endl;






    return 0;
}



Measured memory_bytes: 256
n,m=list(map(int, input().split()))
root = [[] for _ in range(n)]
answer=[-1]*n
answer[0]=1
for i in range(m):
    c=list(map(int, input().split()))
    root[c[1]-1].append(c[0]-1)
    root[c[0]-1].append(c[1]-1)
count=1#最初から1の部屋はOKにしとく
queue=[0]
#print(root)
newqueue=[]
while(count<n and len(queue)!=0):
    for j in queue:
        for rootnum in root[j]:
            if(answer[rootnum]==-1):
                answer[rootnum]=j
                newqueue.append(rootnum)
                count+=1
    queue=newqueue
    #print(newqueue)
    newqueue=[]
if(count<n):
    print('No')
else:
    print('Yes')
    for l in range(n-1):
        print(answer[l+1]+1)



Measured memory_bytes: 33792
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }

template<typename Ty>
inline Ty gcd(Ty a, Ty b)
{
	Ty r;
	if (a < b) swap(a, b);
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		int N;

		cin >> N;
		if (cin.fail()) break;

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

		int res = 0;
		if (N % 2 == 0) {
			sort(A.begin(), A.end());
			res = A[N / 2] - A[N / 2 - 1];
		}
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
#define int long

signed main() {
	int N;
	cin >> N;
	vector<tuple<string, int, int>> a(N);
	for (int i = 0; i < N; i++) {
		string s;
		int n;
		cin >> s >> n;
		a[i] = make_tuple(s, -n, i + 1);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < N; i++)
	{
		cout << get<2>(a[i]) << endl;;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int sum;
    int count;
    int in_s, in_k;
    int z;

   count = 0;

   scanf("%d %d",  &in_k, &in_s);
   // printf("s = %d k = %d \n", in_k, in_s);

 for (int i = 0; i <= in_k; i++) {
   for(int j = 0; j <= in_k; j++) {
     // for (int k = 0; k <= in_k; k++) {
     //    if (i <= in_k && j <= in_k && k <= in_k) {
     //     sum = i + j + k;
     //     printf("x = %d   y = %d   z = %d  sum = %d\n", i, j, k, sum);
     //     if (sum == in_s) {
     //       count++;
     //     }
     z = in_s - i -j;
     if (z >= 0 && z <= in_k) {
         count++;
        }
      }
    }
  printf("%d\n", count);
}

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

int main(){
  
  int n,m;
  cin>>n>>m;
  long long a[n],b[m],c[m];
  vector<long long> d={};
  pair<long long,long long> P[m];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++){
    cin>>b[i]>>c[i];
    P[i].first=c[i];
    P[i].second=b[i];
  }
  sort(a,a+n);
  sort(P,P+m);
  reverse(P,P+m);
  int j=0;
  bool flg=0;
  for(int i=0;i<m;i++){
    j=0;
    while(j<P[i].second){
      d.push_back(P[i].first);
      j++;
      if(d.size()==n){
        flg=1;
        break;
      } 
    }
    if(flg) break;
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  
  int k=0,l=0;
  long long ans=0;
  while(k<n){
  	if(a[k]<d[l]){
      ans+=d[l];
      k++;
      l++;
    }
    else{
      ans+=a[k];
      k++;
    }
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 5240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");

        List<Integer> converted = convertToNumbers(input);

        StringBuilder builder = new StringBuilder();

        converted.stream().sorted((num1, num2) -> num2 - num1).forEach(num -> builder.append(num + " "));

        System.out.println(builder.delete(builder.length() - 1, builder.length()));

    }

    /**
     * ????????????????????°????????????????????????????????????
     * 
     * @param input
     *            ???????????????
     * @return ??°???????????????
     */
    public static List<Integer> convertToNumbers(String[] input) {

        List<Integer> converted = new ArrayList<>();

        for (String string : input) {
            converted.add(Integer.parseInt(string));
        }

        return converted;
    }

}

Measured memory_bytes: 30692
var
	n,i,j:Longint;
	s:String[50];
	a:array[97..122]of Longint=(99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99);
	b:array[97..122]of Longint;
begin
	readln(n);
	for i:=1 to n do begin
		readln(s);
		for j:=97 to 122 do b[j]:=0;
		for j:=1 to length(s)do inc(b[ord(s[j])]);
		for j:=97 to 122 do if a[j]>b[j]then a[j]:=b[j];
	end;
	for i:=97 to 122 do for j:=1 to a[i]do write(chr(i));
end.


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, mi = 0, ma = 0, ansa = 0, ansb = 0, count = 0, crowdy[101] = {};
	char hairetu[200][200] = {};
	using namespace std;
	int x = 0, y = 0, z = 0, play[200] = {};
	std::string str, strt, str_s;
	bool okada = false;



	cin >> a;
	if (a < 1200) {
		std::cout << "ABC" << endl;
	}
	else if (a < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
		if(a==1&&b==0&&c==0){
			printf("Close\n");
		}
		if(a==0&&b==1&&c==0){
			printf("Close\n");
		}
		if(a==1&&b==1&&c==0){
			printf("Open\n");
		}
		if(a==0&&b==0&&c==1){
			printf("Open\n");
		}
		if(a==0&&b==0&&c==0){
			printf("Close\n");
		}
	return 0;
}
				

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

int main() {
  int x, a, b, c, d;
  cin >> x;
  a = x / 1000;
  b = (x / 100) % 10;
  c = (x / 10) % 10;
  d = x % 10;
  
  if(a + b + c + d == 7){
    cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  }
  else if(a + b + c - d == 7){
    cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  }
  else if(a + b - c + d == 7){
    cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  }
  else if(a + b - c - d == 7){
    cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  }
  else if(a - b + c + d == 7){
    cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  }
  else if(a - b + c - d == 7){
    cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  }
  else if(a - b - c + d == 7){
    cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  }
  else{
    cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
  }
}

Measured memory_bytes: 256
import scala.io.Source

object Main extends App {
  val in = Source.stdin.getLines
  for (line <- in; if line != "0 0") {
    val nk = line.split(' ').map(_.toInt)
    val n = nk(0)
    val s = in.next.split(' ').map(_.toInt)
    val b: Seq[Array[Int]] = in.take(n).map(x => x.split(' ').map(_.toInt)).toSeq
    if (b.foldLeft(s)(subtract).exists(x => x < 0)) {
      println("No")
    } else {
      println("Yes")
    }
  }

  def subtract(a: Array[Int], b: Array[Int]): Array[Int] = {
    a.zip(b).map(x => x._1 - x._2)
  }
}



Measured memory_bytes: 95180
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

d = b-a
cnt = 0
for i in range(d+1):
    cnt += i
print(cnt - b)



Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	int N;
	vector<int> l;
	cin >> N;
	for (int i = 0; i < 2 * N; i++) {
		int ips;
		cin >> ips;
		l.push_back(ips);
	}
	sort(l.begin(), l.end(),greater<int>());
	int sum = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		sum += l[i + 1];
	}
	print(sum);





	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int nax=1e5+5;
const int mod=1e9+7;
#define ll long long

void add_self(int &a,int b)
{
    a+=b;
    if(a>=mod)
    a-=mod;
}

void sub_self(int &a,int b)
{
    a-=b;
    if(a<0)
    a+=mod;
}


int main()
{
    int n,k;
    cin >> n >> k;
    
    vector<int> dp(k+1);
    
    dp[0]=1;
    
    for(int child=0;child<n;++child)
    {
        int a;
        cin >> a;
        vector<int> fake(k+1);
        for(int candies=k;candies>=0;--candies)
        {
            int tmp=dp[candies];
            int l=candies+1;
            int r = candies + min(a,k-candies);
            
            if(l<=r)
            add_self(fake[l],tmp);
            if(r+1<=k)
            sub_self(fake[r+1],tmp);
        }
    int pref_sum=0;
    for(int i=0;i<=k;++i)
    {
        add_self(pref_sum,fake[i]);
        add_self(dp[i],pref_sum);
    }
    }
    cout << dp[k] << endl;
    
    return 0;
} 

Measured memory_bytes: 3964
#include<stdio.h>
int main(void){
  int n,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if ( x % 3 == 0 ){
      printf(" %d",i);
    }else{
      do{
        if ( x % 10 == 3 ){
          printf(" %d",i);
          x=0;
        }
        x /= 10;
      }while( x );
    }
  }
  printf("\n");
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  
  string t;
  cin >> t;
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s < t) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

string S, T;

int main() {
	cin >> S >> T;
	cout << T << S << endl;
}

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

typedef long long LL;

int main() {
    LL K;
    string S;
    cin >> S;
    cin >> K;
    LL counter = 0;
    for (int i=0;i<S.length();i++)
    {
        if (S[i] == '1')
            counter++;
        else
        {
            break;
        }
    }

    if (K > counter)
        cout << S[counter];
    else
        cout << 1;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int B[N-1];
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }
  int ans = B[0];
  for(int i=1;i<N-1;i++){
    if(B[i-1]>=B[i]){
      ans += B[i];
    }else{
      ans += B[i-1];
    }
  }
  ans += B[N-2];
  cout << ans << endl;
  return 0;
}


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


int main(void){
    long long int A,C;
    double B;
    vector<int> E(20);
    cin >> A >> B;
    C=int64_t(B*100+0.5);
    A*=C;
    A/=100;
    cout << A << endl;
    
    
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
    long long n,h,w,count=0;
    cin >> n >> h >> w;
    long long a[n][2];
    for(int i=0;i<n;i++){
        cin >> a[i][0] >> a[i][1];
        if(a[i][0]>=h&&a[i][1]>=w) count++;
    }
    cout << count;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 1010;
const int maxM = 30010;
const int inf = 1000000009;
const ll INF = 1e16+9;

ll a[maxN];
ll b[maxN];
ll c[maxN];
int n1,n2,n3;
int k;
int main()
{
	scanf("%d%d%d%d",&n1,&n2,&n3,&k);
	for(int i=1;i<=n1;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n1);
	reverse(a+1,a+1+n1);
	for(int i=1;i<=n2;i++)
	{
		scanf("%lld",&b[i]);
	}
	sort(b+1,b+1+n2);
	reverse(b+1,b+1+n2);
	for(int i=1;i<=n3;i++)
	{
		scanf("%lld",&c[i]);
	}
	sort(c+1,c+1+n3);
	reverse(c+1,c+1+n3);
	
	multiset<ll> H;
	for(int i=1;i<=n1;i++)
	{
		for(int j=1;j<=n2;j++)
		{
			for(int u=1;u<=n3;u++)
			{
				ll x = a[i]+b[j]+c[u];
				multiset<ll>::iterator it;
				if(!H.empty())
				{
					it = H.begin();
				}
				if (H.size() < k)
					H.insert(x);
				else if (!H.empty() && *it < x)
				{
					H.erase(it);
					H.insert(x);
				}
				else break;
			}
		}
	}
	//sort(p.begin(),p.end());
	//reverse(p.begin(),p.end());
	vector<ll> p;
	for(auto it = H.begin();it!=H.end();it++)
	{
		p.push_back(*it);
	}
	reverse(p.begin(),p.end());
	for(int i=0;i<k;i++)
	{
		cout<<p[i]<<endl;
	}
    return 0;
}

Measured memory_bytes: 512
from sys import stdin
def main():
    readline=stdin.readline
    a,b,x=map(int,readline().split())
    if a==0:
        print(b//x+1)
    elif a==1:
        print(b//x)
    else:
        c=a-1
        print(b//x-c//x)
if __name__=="__main__":
    main()

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


int main()
{
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s)
	{
		a--;
	}
	else
	{
		b--;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w, d;
  cin >> h >> w >> d;
  int tot = h*w;
  vector<pair<int, int>> vp(tot);
  rep(i, h)rep(j, w){
    int in;
    cin >> in;
    vp.at(in-1) = {i, j};
  }
  vector<vector<ll>> sums(d, vector<ll>(1, 0));
  rep(st, d){
    pair<int, int> now = vp.at(st);
    for(int i = st + d; i < tot; i += d){
      pair<int, int> nx = vp.at(i);
      ll add = abs(nx.first - now.first) + abs(nx.second - now.second);
      sums.at(st).push_back(sums.at(st).back() + add);
      now = nx;
    }
  }
  // for(auto v : sums){
  //   for(auto i : v){
  //     cerr << i << " ";
  //   }
  //   cerr << endl;
  // }
  int q;
  cin >> q;
rep(_q, q){
  int l, r;
  cin >> l >> r;
  l--; r--;
  int rd = r % d;
  int rs = r/d;
  ll ans = sums.at(rd).at(rs);
  ll mi = 0;
  int ld = l % d;
  int ls = l / d;
  if(ls >= 0) mi = sums.at(ld).at(ls);
  ans -= mi;
  cout << ans << endl;
}
  return 0;
}

Measured memory_bytes: 8744
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq  priority_queue<double, std::vector<double>, std::greater<double>>

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

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




int main(){
    int A, B;
    cin >> A >> B;
    if(A <= 5){
        cout << 0 << endl;
    }
    else if(A <= 12){
        cout << B / 2 << endl;
    }
    else{
        cout << B << endl;
    }
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#define MAX 0x3f3f3f3f
struct yama
{
    int x, y, z;
}a[10005];
int n, m, k[105];
void Shortest()
{
    memset(k, MAX, sizeof(k));
    k[0] = 0;
    for(int i = 1; i < n; i++)
        for(int j = 1; j <= m; j++)
            if(k[a[j].y] > k[a[j].x] + a[j].z)
                k[a[j].y] = k[a[j].x] + a[j].z;
}
int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int x, j;
        scanf("%d%d", &x, &j);
        while(j--){
            a[++m].x = x;
            scanf("%d%d", &a[m].y, &a[m].z);
        }
    }
    Shortest();
    for(int i = 0; i < n; i++)
        printf("%d %d\n", i, k[i]);
    return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


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

typedef long long ll;

using namespace std;

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

   string ans;
   if(n%10 == 7 || (n/10)%10 == 7 || (n/100)%10 == 7) {
      ans = "Yes";
   } else {
      ans = "No";
   }


   cout << ans << endl;
}
   


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
using namespace std;
#define MOD 1000000007

void add(long long &x, long long y){
    x = (x + y) % MOD;
}

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

    vector<bool> broken(N+2, false);
    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        broken[a] = true;
    }
    vector<long long> dp(N+2, 0);
    dp[0] = 1;
    for(int i=0; i<N; i++){
        if(!broken[i+1]) add(dp[i+1], dp[i]);
        if(!broken[i+2]) add(dp[i+2], dp[i]);
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
arr = [int(s) for s in input().split(" ")]


def calculate(n,arr):

    for ar in arr:
        if ar % 2 == 0:
            s1 = ar % 3
            s2 = ar % 5
            if (s1 == 0) or (s2 == 0):
                pass
            else:
                print("DENIED")
                return

    print("APPROVED")

calculate(n,arr)



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

class ITP1
{
    static void Main()
    {
        var str = Console.ReadLine();
        int a = int.Parse(str.Split(' ')[0]);
        int b = int.Parse(str.Split(' ')[1]);

        int[,] x = new int[a, b];
        int[] y = new int[b];
        int c = 0;
        for (int i = 0; i < a; i++)
        {
            str = Console.ReadLine();
            for (int j = 0; j < b; j++)
            {
                x[i, j] = int.Parse(str.Split(' ')[j]);
            }

        }
        for (int j = 0; j < b; j++)
        {
            str = Console.ReadLine();
            y[j] = int.Parse(str.Split(' ')[0]);
        }

        for (int i = 0; i < a; i++)
        {
            c = 0;
            for (int j = 0; j < b; j++)
            {
                c += x[i,j] * y[j];
            }
            Console.WriteLine("{0}", c);

        }
    }
}

Measured memory_bytes: 5856
from itertools import combinations
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = []
for i in b:
  for x in range(3):
    for y in range(3):
      if i == a[x][y]:
        ans.append(3*x+y)
if len(ans) <= 2:
  print("No")
  exit()
ans.sort()
for i,j,k in combinations(ans,3):
  if (i,j,k) in ((0,1,2),(0,4,8),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(2,4,6)):
    print("Yes")
    break
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);i++)
#define rep1(i,n) for(int i=1; i<(n); i++)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    rep(i, n)rep(j, n) ans = max(ans, abs(a[i]-a[j]));
    cout << ans << endl;
}

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;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  
  int count = 0;
  
  rep(i,n){
    if(p[i]!=i+1) count++;
  }
  if(count<=2){
    puts("YES");
  }else{
    puts("NO");
  }
}

Measured memory_bytes: 256