akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    int input;
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}


void solve(){
    int n,ans=0;bool flag;
    cin>>n;
    map<int,int>mp;
    int* arr = new int[n];
    fo{
        cin>>arr[i];
        mp[arr[i]]++;
        
    }
    if(mp[1]>1){
        cout<<0<<endl;
        return;
    }else if(mp[1]==1){
        cout<<1<<endl;
        return;
    }
    
        fo{
            flag=false;
       // cout<<"For "<<arr[i]<<endl;
            if(mp[arr[i]]>1)
                continue;
            else{
                for(int j=2;j<=sqrt(arr[i]);j++){
                //cout<<"\t"<<arr[i]%j<<" and "<<arr[i]/j<<" with status "<<mp[arr[i]/j]<<endl;
                    if(arr[i]%j==0 && ((mp[arr[i]/j]!=0) || (mp[j]!=0))){
                        flag=true;
                        break;
                    }
                }
                if(!flag){
                //cout<<" "<<arr[i];
                ans++;
                }
            }
        }
        cout<<ans<<endl;
    

}


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

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 33288
use std::io::{self, Read};

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).unwrap();
    let v = buf.trim().parse::<i64>().unwrap();
    let h = v/3600;
    let m = (v - h*3600)/60; 
    let s = v%60; 
    println!("{}:{}:{}", h, m, s);
}


Measured memory_bytes: 5036
#include<bits/stdc++.h>
#define int long long
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int32_t main()
{
    FastIO;
    int n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else 
    cout<<"No";

}

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

class Main{
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] Args) throws IOException{
        final dice d = new dice();
        for(int i = 0; i<6; i++)
            d.face[i] = Integer.parseInt(sc.next());
        final String dir = sc.next();
        for(int i = 0; i<dir.length(); i++){
            d.rotate(dir.charAt(i));
        }
        System.out.println(d.face[0]);
    }
}

class dice{
    public int face[] = new int[6];
    public void rotate(char dir){
        int temp;
        switch(dir){
        case 'N':
            temp = face[0];
            face[0] = face[1];
            face[1] = face[5];
            face[5] = face[4];
            face[4] = temp;
            break;
        case 'E':
            temp = face[0];
            face[0] = face[3];
            face[3] = face[5];
            face[5] = face[2];
            face[2] = temp;
            break;
        case 'W':
            temp = face[0];
            face[0] = face[2];
            face[2] = face[5];
            face[5] = face[3];
            face[3] = temp;
            break;
        case 'S':
            temp = face[0];
            face[0] = face[4];
            face[4] = face[5];
            face[5] = face[1];
            face[1] = temp;
            break;
        }
    }
};

Measured memory_bytes: 26260
#include<bits/stdc++.h>
using namespace std;
char a[51][51],b[51][51];
int main(){
	int n,m,i;
	cin>>n>>m;
	getchar();
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	
	for(i=0;i+m-1<n;i++){
		for(int j=0;j+m-1<n;j++){
			bool flag=true;
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l]){
						flag=false;
					}
				}
			}
			if(flag){
				cout<<"Yes";
				return 0;
			}
			flag=true;
		}
	}
	cout<<"No";
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  
  ll total = 0;
  rep(i, m) total += b[i];
  
  int j = m;
  int ans = 0;
  rep(i, n+1) {
    while(j > 0 && total > k) {
      --j;
      total -= b[j];
    }
    if(total > k) break;
    ans = max(ans, i+j);
    if(i == n) break;
    total += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4792
#include <iostream>
using namespace std;
int s,t,a;
int main(){
        for(int i = 0; i < 4; i++){
                cin >> a;
                s += a;
        }   
        for(int i = 0; i < 4; i++){
                cin >> a;
                t += a;
        }   
        cout << max(s,t) << endl;
}

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

int a, b, c;

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

	cin >> a >> b >> c;
	cout << max(0, c - (a - b))  << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);  \
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}
 
ll binpow(ll a, ll b) {ll res = 1;while (b > 0) {if (b & 1) res = res * a;a = a * a;b >>= 1;}return res;}
 
 
 
int main(){
	adiii
	ll n,tw;
	cin>>n>>tw;
	vector <ll> w(n+1),v(n+1);
	vector <ll> dp(tw+1,0);
	rep(i,1,n+1) cin>>w[i]>>v[i];
	
	rep(i,1,n+1){
		rrep(j,tw-w[i],0){
			 dp[j+w[i]] = max(dp[j+w[i]],dp[j] + v[i]); 
		}
	}
	ll ans=0;
	rep(i,1,tw+1){
		ans = max(ans,dp[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

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

	int A, B, C;
	cin >> A >> B >> C;

	int cap = A - B;
	int use = min(C, cap);
	
	cout << C - use << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static long gcd(long m, long n) {
		if(n > m) {
			long tmp = m;
			m = n;
			n = tmp;
		}
		if(m % n == 0)
			return n;
		else {
			m = (m % n);
			return gcd(n, m);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long div = gcd(a, b);
		long ans = 1;
		boolean flag = false;
		while(div % 2 == 0) {
			flag = true;
			div /= 2;
		}
		if(flag)
			ans++;
		for(long i = 3; i < Math.sqrt(div) + 1; i += 2) {
			flag = false;
			while(div % i == 0) {
				flag = true;
				div /= i;
			}
			if(flag)
				ans++;
		}
		if(div > 1)
			ans++;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22612
toYN :: Bool -> String
toYN False = "No"
toYN True = "Yes"

x -: f = f x

getInts = ((fmap ((fmap read) . words)) getLine) :: IO [Int]
getInt = (fmap read) getLine :: IO Int
main = do
  [a,b,c] <- getInts
  k <- getInt
  putStrLn $ (magics k [(a,b,c)]) -: (filter (\(a,b,c)-> b > a && c > b)) -: null -: not -: toYN

magic :: (Int,Int,Int) -> [(Int,Int,Int)]
magic (a,b,c) = [(2*a,b,c),(a,2*b,c),(a,b,2*c)]

magics :: Int -> [(Int,Int,Int)]->[(Int,Int,Int)]
magics k l = (iterate (\l-> l>>=magic) l)!!k


Measured memory_bytes: 3980
import { isRegExp } from "util";

class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder();
  let [n,m]=o.nn(2)
  let ar=[],g=0
  for(let i=0;i<n;i++){
    let t=o.n();
    g+=t;
    ar.push(t);
  }
  let bo = g/(4*m)
  o.asc(ar);
  for(let i=0;i<m;i++){
    if(Number(ar.pop()) < bo){
      o.No()
      return
    };
  }
  o.Yes()
}
m();

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

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> arr(n);
    int val = 1;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        if( arr[i] == val )
            val++;
    }
    if( val == 1 )
        cout << -1 << endl;
    else
    cout << n - val + 1 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, std::vector<long long> A) {
    int pos = 0;
    A.push_back(-1e9);

    long long v = 1000;
    while (pos + 1 < A.size()) {
        while (pos + 1 < A.size() && A[pos] >= A[pos + 1]) {
            pos++;
        }
        int mi = A[pos];
        while (pos + 1 < A.size() && A[pos] <= A[pos + 1]) {
            pos++;
        }
        int mx = A[pos];
        v = v % mi + v / mi * mx;
    }
    cout << v << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main() {
    int s;
    cin >> s;
    int count = 1;
    while(true){
    if(s == 4 || s == 2 || s == 1){
      break;
    }
    if(s % 2 == 0){
        s = s / 2;
    } else {
        s = 3 * s + 1;
    }
    if(s == 4){
        count++;
        break;
    }
    count++;
    }
    cout << count + 3 << endl;
}


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

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}
template <class T>
inline void tense(T &a, const T &b)
{
	if (b < a)
		a = b;
}

const int MaxN = 100000;
const int INF = 100000000;

int n, m;
int vl[MaxN + 1], vr[MaxN + 1];

struct halfEdge
{
	int v;
	halfEdge *next;
};
halfEdge adj_pool[MaxN * 2], *adj_tail = adj_pool;
halfEdge *adj[MaxN + 1];

inline void addEdge(const int &u, const int &v)
{
	adj_tail->v = v, adj_tail->next = adj[u];
	adj[u] = adj_tail++;
}

void dfs(const int &u, const int &fa)
{
	for (halfEdge *e = adj[u]; e; e = e->next)
		if (e->v != fa)
		{
			dfs(e->v, u);

			int l = vl[e->v];
			int r = vr[e->v];
			if (l > r || ++r < vl[u] || --l > vr[u])
			{
				vl[u] = 1, vr[u] = 0;
				break;
			}

			relax(vl[u], l);
			tense(vr[u], r);
		}
}

bool valid = true;

void construct(const int &u, const int &fa, const int &cur)
{
	if (vl[u] > vr[u])
		valid = false;

	vl[u] = cur;

	for (halfEdge *e = adj[u]; e; e = e->next)
		if (e->v != fa)
		{
			int l = vl[e->v], r = vr[e->v];
			int next = cur - 1;
			if (l > next || next > r)
				next = cur + 1;
			if (l > next || next > r)
				valid = false;

			construct(e->v, u, next);
		}
}

int main()
{
	cin >> n;
	for (int i = 1; i < n; ++i)
	{
		int u = getint(), v = getint();
		addEdge(u, v);
		addEdge(v, u);
	}

	cin >> m;
	for (int u = 1; u <= n; ++u)
		vl[u] = -INF, vr[u] = INF;
	for (int i = 0; i < m; ++i)
	{
		int u = getint(), v = getint();
		vl[u] = vr[u] = v;
	}

	dfs(1, 0);

	construct(1, 0, vl[1]);

	if (valid)
	{
		puts("Yes");
		for (int u = 1; u <= n; ++u)
			printf("%d\n", vl[u]);
	}
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	cout << a[n-1]-a[0] << endl;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
lis = [0] * k
def win(string):
    if string == "r":
        return p
    if string == "s":
        return r
    if string == "p":
        return s
def upper(n):
    return (n+1)//2
ans = 0
for i in range(n):
    now = i % k
    lis[now] += 1
    if i+k >= n or t[i] != t[i+k]:
        ans += win(t[i])*upper((lis[now]))
        lis[now] = 0
print(ans)

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main(void){
  int a[2*100000+10],b[2*100000+10],n;
  cin >> n;
  for (int i=1;i<n+1;i++) cin >> a[i];
  int s = n / 2;
  int d = n % 2;
  if(d==0){
    for(int i=1;i<s+1;i++){
      b[s+i] = a[2*i-1];
    }
    for(int i=s;i>0;i--){
      b[i] = a[n-2*i+2];
    }
  }
  else{
    for(int i=1;i<s+1;i++){
      b[s+1+i] = a[2*i];
    }
    for(int i=s+1;i>0;i--){
      b[i] = a[n-2*i+2];
    }
  }
  for (int i=1;i<n+1;i++) cout << b[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int ll;
int main(){
  ll n,h,w;
  cin >> n>>h>>w;
  ll cnt=0;
  ll a[n],b[n];
  for(ll i=0;i<n;i++) {
    cin >>a[i]>>b[i];
    if(a[i]>=h&&b[i]>=w){
         cnt++;
      }
  }
  cout <<cnt<<endl;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in) ;
		int n, result, flag = 0, zero = 0 ;
		n = sc.nextInt() ;
		BigInteger val = BigInteger.valueOf(1), check = new BigInteger("1000000000000000000"), x ;
		for (int i = 0; i < n; i++) {
			x = sc.nextBigInteger() ;
			if (x.compareTo(BigInteger.valueOf(0)) == 0) {
				zero = 1 ;
				break ;
			}
			if (flag == 0) {
				val = val.multiply(x) ;
				result = val.compareTo(check) ;
				if (result == 1) {
					flag = 1 ;
				}
			}
		}
		if (zero == 1)	System.out.print(0) ;
		else {
			if (flag == 1)	System.out.println(-1) ;
			else	System.out.println(val) ;
		}
		System.gc(); 
	}
}


Measured memory_bytes: 61060
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  ll a;
  cin >> a;
  cout << a + a * a +  a * a* a << endl;
  return 0;
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(){
    int n, m;
    cin >> n >> m;
    vint edge[n];
    vint from(n, -1);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    queue<int> q;
    q.push(0);
    from[0] = 0;
    while(!q.empty()){
        int pos = q.front(); q.pop();
        for(int to : edge[pos]){
            if(from[to] == -1){
                from[to] = pos;
                q.push(to);
            }
        }
    }
    int flag=1;
    rep(i,n) if(from[n] == -1) flag=0;
    if(flag){
        cout << "Yes" << endl;
        for(int i=1; i<n; i++) cout << from[i]+1 << endl;
    }
}



Measured memory_bytes: 10232
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,K;
char s[N];
int cnt[N];
int L[N],R[N];
void solve(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='L')L[i]=i-1;
		else R[i]=i+1;
	}
	for(int i=1;i<=n;i++)
		if(L[i]&&L[i-1])L[i]=L[i-1];
	for(int i=n;i>=1;i--)
		if(R[i]&&R[i+1])R[i]=R[i+1];
	for(int i=1;i<=n;i++){
		int k;
		if(L[i]){
			k=L[i];
			if((i-k)%2!=0)k++;
		}else{
			k=R[i];
			if((k-i)%2!=0)k--;
		}
		cnt[k]++;
	}
	for(int i=1;i<=n;i++)printf("%d ",cnt[i]);puts("");
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 5");
            WillReturn.Add("4 9");
            WillReturn.Add("2 4");
            //12
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 30");
            WillReturn.Add("6 18");
            WillReturn.Add("2 5");
            WillReturn.Add("3 10");
            WillReturn.Add("7 9");
            //130
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1 100000");
            WillReturn.Add("1000000000 100000");
            //100000000000000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int M = wkArr[1];

        var ABList = new List<int[]>();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            ABList.Add(wkArr);
        }

        long Answer = 0;
        long BoughtCnt = 0;
        foreach (int[] EachAB in ABList.OrderBy(X => X[0])) {
            for (int I = 1; I <= EachAB[1]; I++) {
                Answer += EachAB[0];
                if (++BoughtCnt == M) {
                    Console.WriteLine(Answer);
                    return;
                }
            }
        }
    }
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, D;
    cin >> N >> D;
    int i = 0;
    int ans = 0;
    while(i < N)
    {
        i+=D;
        ans++;
        i+=D+1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll i,j,k,l,m,n,o,p;
    cin>>k;
    i=1;
    m=7;
    while(i<=k&&m%k!=0)
    {
        i++;
        m=(m*10+7)%k;
    }
     
    if(i>k)
    cout<<"-1\n";
    else 
    cout<<i<<endl;
    return 0;

}

Measured memory_bytes: 3636
n = int(input())
h_list = [int(i) for i in input().split()]

count = 1
for i in range(1, n):
  flag = True
  for j in range(i):
    if h_list[j] > h_list[i]:
      flag = False
      break
  if flag:
    count +=1

print(count)

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  bool found[26];

  for(int i=0;i<26;i++){
  	found[i] = false;
  }
  string S;
  cin >> S;
  int l = S.size();

  for(int i=0;i<l;i++){
  	int check = S[i] - 'a';
  	found[check] = true;
  }

  for(int i=0;i<26;i++){
  	if(!found[i]){
  		char ans ='a'+i;
  		cout << ans <<endl;
  		return 0; 
  	}
  }
  cout << "None" <<endl;
   

  return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    A,B= map(int, input().split())
    P = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    c0=c1=c2=0
    for p in P:
        if p<=A:
            c0+=1
        elif p<=B:
            c1+=1
        else:
            c2+=1
    print(min(c1,c2,c0))




if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b&& b == c) {
		cout << 1 << endl;
		return 0;
	}else if (a == b || b == c || a == c) {
		cout << 2 << endl;
		return 0;
	}else {
		cout << 3 << endl;
		return 0;
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	n, k := nextInt(), nextInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		a, b := nextInt(), nextInt()
		if v, ok := m[a]; ok {
			m[a] = v + b
		} else {
			m[a] = b
		}
	}
	a := make([][]int, 0, len(m))
	for k, v := range m {
		a = append(a, []int{k, v})
	}
	sort.Sort(kvs(a))
	t := 0
	for _, v := range a {
		t += v[1]
		if k <= t {
			out(v[0])
			return
		}
	}
}

type kvs [][]int

func (a kvs) Len() int           { return len(a) }
func (a kvs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a kvs) Less(i, j int) bool { return a[i][0] < a[j][0] }


Measured memory_bytes: 8576
#!/usr/bin/env python
from itertools import permutations

def dist(P, Q):
    return ((P[0] - Q[0]) ** 2 + (P[1] - Q[1]) ** 2) ** 0.5

def main():
    N = int(input())
    points = tuple(tuple(map(int, input().split())) for _ in range(N))
    paths = list(permutations(list(range(N))))

    ans = 0
    for path in paths:
        for i in range(N-1):
            ans += dist(points[path[i]], points[path[i+1]])

    ans /= len(paths)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 47728
#include <stdio.h>
#include <memory.h>
#include <math.h>

int main(void) {
	int size, b, f, r, v;
	int i, j, k;
	int count[4][3][10];
	
	memset((char*)count, 0x00, sizeof(count));
	scanf("%d\n", &size);
	for(i=0;i<size;i++) {
		scanf("%d %d %d %d\n", &b, &f, &r, &v);
		count[b-1][f-1][r-1] += v;
	}
	
	for(i=0;i<4;i++) {
		for(j=0;j<3;j++) {
			for(k=0;k<10;k++) {
				printf(" %d", count[i][j][k]);
			}
			printf("\n");
		}
		if(i<3) {
			printf("####################\n");
		}
	}
/*	printf("\n");*/
	
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  string s;
  cin>>s;
  int n=s.size();
  stack<char>k;
  for(int i=0;i<n;i++){
    if(k.empty()){k.push(s[i]);}
    else if(s[i]=='T'&&k.top()=='S'){k.pop();}
    else{k.push(s[i]);}
  }
  cout<<k.size()<<endl;
  return 0;
}

Measured memory_bytes: 3724
S=input()
if S == 'SUN':
    print('7')
if S == 'MON':
    print('6')
if S == 'TUE':
    print('5')
if S == 'WED':
    print('4')
if S == 'THU':
    print('3')
if S == 'FRI':
    print('2')
if S == 'SAT':
    print('1')

Measured memory_bytes: 38384
/* 実装例　Atcoder Beginers Contest 174-F Range Set query */
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,q;
    cin >> n >> q;
    int sq=sqrt(n);
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        c[i]--;
    }
    vector<int> l(q),r(q);
    rep(i,q){
        cin >> l[i] >> r[i];
        l[i]--;
    }
    vector<int> qu(q);
    rep(i,q) qu[i]=i;
    sort(ALL(qu),[&](int i,int j){if(l[i]/sq!=l[j]/sq) return l[i]<l[j]; else return r[i]<r[j];});
    
    vector<int> ans(q);
    vector<int> cnt(n,0);
    int nl=0,nr=0;
    int res=0;
    for(int i:qu){
        while(nl>l[i]){
            nl--;
            if(cnt[c[nl]]++==0) res++;
        }
        while(nl< l[i]){
            if(--cnt[c[nl]]==0) res--;
            nl++;
        }
        while(nr< r[i]){
            if(cnt[c[nr]]++==0) res++;
            nr++;
        }
        while(nr> r[i]){
            nr--;
            if(--cnt[c[nr]]==0) res--;
        }
        /* ここから結果 */
        ans[i]=res;
    }
    rep(i,q) cout << ans[i] << "\n";
}


Measured memory_bytes: 15480
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> x(60, 0);
  ll maxNum = 0;
  rep(i, n){
    cin >> a[i];
    ll now = a[i];
    ll s = 0;
    while(now){
      if (now&1) {x[s]++; x[s] %= 2;}
      now>>=1;
      s++;
      maxNum = max(maxNum, s);
    }
  }
  
  rep(i, n){
    ll ans = 0;
    rep(s, maxNum){
      if (((x[s]+(a[i]&1))%2==1)) ans += (1LL<<s);
      a[i]>>=1;
    }
    if (i == n-1) cout << ans << endl;
    else cout << ans << ' ';
  }
  
  return 0;
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i, n){
    int x;
    cin >> x;
    a[x-1] = i+1;
  }
  ll ans = 0;
  set<int> s;
  set<int, greater<int>> t;
  s.insert(0);
  s.insert(n+1);
  t.insert(0);
  t.insert(n+1);
  REP(i, n){
    set<int>::iterator it1, it2;
    it1 = s.lower_bound(a[i]);
    it2 = t.lower_bound(a[i]);
    ans += (i+1)*((ll)a[i] - *it2)*(*it1 - a[i]);
    s.insert(a[i]);
    t.insert(a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Bottom Up Approach
int frog1(vector<int>h, int n) {
	vector<int>dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		int option1 = abs(h[i] - h[i - 1]) + dp[i - 1];
		int option2 = abs(h[i] - h[i - 2]) + dp[i - 2];
		dp[i] = min(option1, option2);
	}
	return dp[n - 1];
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vector<int>h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	cout << frog1(h, n) << endl;


	return 0;
}


Measured memory_bytes: 4400
#include <stdio.h>

int main () {
  int i,j,num,a,b;
  char str[1001],tem[1001],com[20];

  scanf("%s",str);
  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%s %d %d",com,&a,&b);
    if(com[0]=='p'){
      for(j=a;j<=b;j++) printf("%c",str[j]);
      printf("\n");
    }
    else if(com[2]=='p'){
      scanf("%s",tem);
      for(j=a;j<=b;j++) str[j]=tem[j-a];
    }
    else if(com[2]=='v'){
      for(j=a;j<=b;j++) tem[j]=str[j];
      for(j=a;j<=b;j++) str[j]=tem[b-(j-a)];
    }
  }
  return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
long long int a[200000], b[200000];
long long int sum_a[200001], sum_b[200001];
int max(int a, int b){return a > b ? a : b;}
int min(int a, int b){return a < b ? a : b;}

int main(void){
    sum_a[0] = 0;
    sum_b[0] = 0;
    int n, m;
    long long int k;
    scanf("%d%d%lld", &n, &m, &k);
    
    

    int i, j;
    for(i = 0; i < n; i++){
        scanf("%lld", &a[i]);
        sum_a[i+1] = sum_a[i] + a[i];
    }
    for(i = 0; i < m; i++){
        scanf("%lld", &b[i]);
        sum_b[i+1] = sum_b[i] + b[i];
    }
    int ans = 0;
    for(i = 0; i < n + 1; i++){
        long long int L = k - sum_a[i];//Aのテーブルからi冊読む
        if(L < 0){
            continue;
        }else if(L == 0){
            ans = max(ans, i);
        }else if(sum_b[m] <= L){
            ans = max(ans, i + m);
        }
        int r = m;
        int l = 0;
        while(r - l != 1){
            int mid = (r + l)/2;
            if(sum_b[mid] <= L){
                l = mid;
            }else{
                r = mid;
            }
        }
        ans = max(ans, l + i);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 7964
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = inx(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
	
	string S;
	ll K;
	cin >> S >> K;
	
	ll len = S.size();
	set<string> s;
	rep(i, len){
		string tmp = "";
		rep(j, K){
			if(i + j < len){
				tmp += S[i + j];
				s.insert(tmp);
			}
		}
	}
	
	auto it = s.begin();
	rep(i, K - 1) it++;
	string ans = *it;
	print(ans);

}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
    
	return 0;
	
}





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



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


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int a = Integer.parseInt(tokens[0]);
		int b = Integer.parseInt(tokens[1]);
		int x = a + b;
		int y = a - b;
		int z = a * b;
		int result = Math.max(Math.max(x, y), z);
		System.out.println(result);
		in.close();
	}

}

Measured memory_bytes: 23636
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;

in main()
{
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
cin>>n;
cout<<a[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String ans = "No";

    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
        if(i * j == n){
          ans = "Yes";
          break;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22100
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

r,d,x = inpl()
a = [0] * 11
a[0] = x
for i in range(10):
    a[i+1] = a[i] * r - d
print(*a[1:])

Measured memory_bytes: 38636
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

long long solve(const int n, const int k) {
  vector<long long> v(k);
  for (int i = 1; i <= n; ++i) ++v[i % k];
  long long cnt{};
  for (int a = 0; a < k; ++a) {
    int b = (k - a) % k;
    int c = (k - a) % k;
    if ((b + c) % k != 0) continue;
    cnt += v[a] * v[b] * v[c];
  }
  return cnt;
}

int main() {
  int n, k;
  cin >> n >> k;
  cout << solve(n, k) << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    int n;
    cin >> n;
    vector<int> v(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> v[i];
    }
    int neck = *min_element(v.begin(), v.end());
    int result = (n - 1) / neck + 5;
    cout << result << "\n";
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    string s;
    cin>>n>>s;
    int t=s.size();
    string ans="";
    for(int i=0;i<t;i++){
        int x=s[i]-'A';
        //cout<<x<<endl;
        x+=n;
        x%=26;
        ans+='A'+x;

    }
    cout<<ans<<endl;

    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n)
    {
        int i;

        rep(i, 0, 1)
        {
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }

        rep(i, 2, n)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

int main(void)
{
    int N;
    vector<P> v;
    int p, q;
    int i, j;
    bool flag_p, flag_q;
    int pp = 0, qp = 0;

    cin >> N;

    factorial f(N);

    v.resize(N);

    rep(i, 0, N - 1)
    {
        v[i].first = i + 1;
        v[i].second = i + 1;
    }

    rep(i, 0, N - 1)
    {
        cin >> p;
        pp += f.fac[N - 1 - i] * (v[p - 1].second - 1);
        rep(j, p, N - 1)
        {
            v[j].second--;
        }
    }

    rep(i, 0, N - 1)
    {
        v[i].first = i + 1;
        v[i].second = i + 1;
    }

    rep(i, 0, N - 1)
    {
        cin >> q;
        qp += f.fac[N - 1 - i] * (v[q - 1].second - 1);
        rep(j, q, N - 1)
        {
            v[j].second--;
        }
    }
    cout << abs(pp - qp) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double yenSum = 0;
        double btcSum = 0;

        for(int i = 0; i < n; i++) {
            double value = sc.nextDouble();
            if ("JPY".equals(sc.next())) {
                yenSum += value;
            } else {
                btcSum += value;
            }
        }

        // 出力
        System.out.println(yenSum + btcSum * 380000);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 9;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 1200500; //       e5
const int SZ = 11;

int a[MX];

int main()
{
    //vector<int> a;lower_bound(a.begin(), a.end());
    //brute(); return 0;
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans += a[i];
    }
    sort(a, a + n);
    if(ans % 10 == 0){
        int pos = 0;
        while(pos < n && a[pos] % 10 == 0) pos++;
        if(pos == n) ans = 0; else ans -= a[pos];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

while K != 0:
    K -= 1
    if A % 2:
        A -= 1
    B += A / 2
    A /= 2
    if not K:
        break

    K -= 1
    if B % 2:
        B -= 1
    A += B / 2
    B /= 2

print(int(A), int(B))


Measured memory_bytes: 3060
import sys


if __name__ == '__main__':
    L, R = map(int, input().split())

    answer = sys.maxsize
    if R - L >= 2019 * 2:
        answer = 0
    else:
        for i in range(L, R):
            for j in range(i+1, R+1):
                # print(str(i) + ', ' + str(j))
                i_mod2019 = i % 2019
                j_mod2019 = j % 2019
                answer = min(answer, (i_mod2019 * j_mod2019) % 2019)
    print(answer)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int h[n]={};
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int ans=0;
  for(int i=n-1;i>0;i--){
    if(h[i]-h[i-1]>=0){
    }
    else if(h[i]-h[i-1]==-1){
      h[i-1]--;
    }
    else{
      ans=1;
      break;
    }
  }
  if(ans==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
      

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		int a[100000];
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==i)
			{
				int t=a[i];a[i]=a[i+1];a[i+1]=t;
				sum++;
			}
		}
		cout<<sum<<"\n";
	}
}

Measured memory_bytes: 640