akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    char s[20];scanf("%s",s);
    if(strlen(s)==1){
        printf("No\n");
        return 0;
    }
    if(strlen(s)%2){
        printf("No\n");
        return 0;
    }
    for(int i=0;i+1<strlen(s);i+=2){
        if(!(s[i]=='h'&&s[i+1]=='i')){
            printf("No\n");
            return 0;
        }
    }
    
    printf("Yes\n");
}


Measured memory_bytes: 128
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

pub fn gcd(a : i32, b : i32) -> i32 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}

fn main() {
    
    let n = read_t_in_line::<i32>()[0];
    let a = read_t_in_line::<i32>();
    let mut front = vec![0 ; n as usize];
    let mut back = vec![0 ; n as usize];
    front[0] = a[0];
    back[n as usize - 1] = a[(n-1) as usize];
    for i in 1..(n as usize) {
        let t1 = front[i-1];
        let t2 = a[i];
        front[i] = gcd(t1, t2);
    }
    for i in (0..(n-1) as usize).rev() {
        let t1 = back[i+1];
        let t2 = a[i];
        back[i] = gcd(t1, t2);
    }
    
    let mut ans = max(front[(n-2) as usize], back[1]);
    for i in 1..(n as usize -1) {
        ans = max(ans, gcd(front[i-1], back[i + 1]));
    }
    println!("{}", ans);
}



Measured memory_bytes: 10740
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
using ll = long long;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repp(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)


int main() {
  string s;  cin >> s;
  if (s == "RSR") {
    cout << 1 << endl;
    return 0;
  }

  int ans = 0;
  rep (i, 3) {
    if (s[i] == 'R') ++ans;
  }
  
  cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int x[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  int ans = INT_MAX, foo;
  for (int i = 0; i < N - K + 1; i++) {
    if (x[i] >= 0) {
      foo = x[i + K - 1];
    }
    else if (x[i + K - 1] < 0) {
      foo = -x[i];
    }
    else {
      foo = x[i + K - 1] - x[i] + min(x[i + K - 1], -x[i]);
    }
    if (foo < ans) {
      ans = foo;
    }
  }
  cout << ans;
  return 0;
}

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

lst.sort(key = lambda x: x[0])
ans = 0

for i in range(len(lst)):
    if lst[i][1] >= m:
        ans += lst[i][0] * m
        break
    else:
        ans += lst[i][0] * lst[i][1]
        m -= lst[i][1]
print(ans)

Measured memory_bytes: 29024
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main()
{
  string s;
  string t;

  cin >> s;
  cin >> t;

  bool isOk = true;

  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] != t[i])
    {
      isOk = false;
    }
  }

  if (isOk)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 3036
#include <stdio.h>
int main() {
	int n,l,r,sum = 0;
	scanf("%d",&n);
	for(int i = 0;i < n;i++) {
		scanf("%d %d",&l,&r);
		sum += r - l + 1;
	}
	printf("%d",sum);
	return 0;
}	

Measured memory_bytes: 128
import Data.List
main = do
  str<-getLine
  let [x,y]=poyo$map read $ words str
  if (x==0 && y==0)
    then return ()
    else do
      putStrLn $ (show x)++" "++(show y)
      main
poyo::[Int]->[Int]
poyo [x,y]
  | x<y = [x,y]
  |otherwise = [y,x]

Measured memory_bytes: 3960
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

void d(std::istream& in)
{
    unsigned long long A, B, N;
    in >> A >> B >> N;

    const unsigned long long min = std::min(B - 1, N);
    const double x_B = static_cast<double>(min) / B;
    const unsigned long long max = static_cast<unsigned long long>(static_cast<double>(A) * x_B) - A * static_cast<unsigned long long>(x_B);

    std::cout << max;
}

int main(int, char* [])
{
    d(std::cin);
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""
 

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
   	int n;
   	cin >> n;
   	int k;
   	cin >> k;
   	int ans = 0;
   	for (int i = 0; i < n; i++) {
   	 	int x;
   	 	cin >> x;
   	 	if (x >= k)++ans;
   	}
   	cout << ans;
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n;
    cin >> n;
    Vi b(n-1, 0);
    REP(i, n-1) {
        cin >> b[i];
    }
    ll cnt = b[0] + b.back();
    REP2(i, 1, n-1) {
        cnt += min(b[i-1], b[i]);
    }
    std::cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int athNum, winUser, exRate;
	while (cin >> athNum >> winUser >> exRate, athNum) {
		int winBet;
		int betSum = 0;
		for (int i = 1; i <= athNum; i++) {
			int bet;
			cin >> bet;
			betSum += bet;
			if (i == winUser) {
				winBet = bet;
			}
		}
		
		if (!winBet) {
			cout << 0 << endl;
		}else {
			double exRate_d = (double)exRate / 100;
			betSum *= 100;
			int price = (int)((betSum - betSum * exRate_d) / winBet);
			cout << price << endl;
		}
	}

	return 0;
}

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

#define fi(a,b) for(int i=a;i<b;++i)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
////////////////////

int const N = 1e5 + 41;

int n;
char s[N];
int ans, p[N];

int can(int m){
	int l = n-1-m;
	int r = m;
	if(l >= r) return 1;
	int s = p[r-1] - p[l];
	int k = r-l-1;
	if(s == 0 || s == k) return 1;
	return 0;
}

void solve(){
	n = strlen(s);
	fi(0, n){
		p[i] += s[i] - '0';
		p[i+1] += p[i];
	}
	if(string(s).find('0') == string::npos || string(s).find('1') == string::npos){
		ans = n;
		return;
	}
	fdi(n, 1){
		if(can(i)){
			ans = i;
			break;
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%s",s);

	solve();

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/
int const maxi = 200000;
pair<int, pair<int,int> > dp[3003][3003];
int main(){
    //freopen(".txt", "w", stdout
    //IO;
    string a,b;
    cin>>a>>b;
    int n = 3003;
    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j < b.size(); j++){
            if(a[i] == b[j]){
                if(dp[i][j].first + 1 >= dp[i+1][j+1].first){
                    dp[i+1][j+1].first = dp[i][j].first + 1;
                    dp[i+1][j+1].second = {i,j};
                }
 
            }
            if(dp[i][j].first > dp[i+1][j].first){
                    dp[i+1][j].first = dp[i][j].first;
                    dp[i+1][j].second = {i,j};
            }
            if(dp[i][j].first > dp[i][j+1].first){
                    dp[i][j+1].first = dp[i][j].first;
                    dp[i][j+1].second = {i,j};
            }
        }
    }
    pair<int,int> answer;
    int sum = 0;
    for(int i = 0; i < 3003; i++){
        for(int j = 0; j < 3003; j++){
            if(sum < dp[i][j].first){
                sum = dp[i][j].first;
                answer = dp[i][j].second;
            }
        }
    }
    //cout<<answer.first<<" "<<answer.second<<"\n";
    if(sum == 0){
        cout<<"";
        return 0;
    }
    //cout<<sum<<"\n";
    string ans="";
    ans += a[answer.first];
    while(answer.first != 0 && answer.second != 0){
        pair<int,int>prev = answer;
        answer = dp[answer.first][answer.second].second;
        if(answer.first + 1 == prev.first && answer.second + 1 == prev.second){
            ans += a[answer.first];
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 105856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int d, n; cin >> d >> n;
  int ans = 1;
  for(int i=0; i<d; i++) ans *= 100;
  if(n != 100) ans *= n;
  else ans *= (n+1);
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<set>
using namespace std;

int main(void)
{
	set<int> s;
	for(int i=0; i<3; i++)
	{
		int a;
		cin >> a;

		s.insert(a);
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int[] p = new int[N];
		final int[] q = new int[N];
		for(int i=0;i<N;i++) {
			q[i] = p[i] = sc.nextInt();
		}
		Arrays.sort(q);
		int diff = 0;
		for(int i=0;i<N;i++) {
			if(p[i]!=q[i]) {
				diff++;
			}
		}
		if(diff <= 2) {
			out.println("YES");
		}else {
			out.println("NO");
		}
	}
}


Measured memory_bytes: 22996
s=input()
t=input()
ans=len(t)
for i in range(len(s)):
  if i+len(t)>len(s):break
  anss=0
  for j in range(len(t)):
    if t[j]!=s[i+j]:anss+=1
  ans=min(ans,anss)
print(ans)


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

int main(){
	int n,ans;
	while(cin>>n){
		ans=0;
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int c=0;c<10;c++){
					for(int d=0;d<10;d++){
						if(a+b+c+d==n)ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	bool isYes = 1;

	while (1) {
		c -= b;
		if (c <= 0)
			break;
		a -= d;
		if (a <= 0) {
			isYes = 0;
			break;
		}
	}

	cout << (isYes ? "Yes" : "No") << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll              long long int
#define int             int64_t
#define ff              first
#define ss              second
#define pb              push_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define en              cout<<endl
using namespace std;
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}
void system_output(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
}
void solve(){
    int n,k,s;
    cin>>n>>k;int snuk[n+1];
    memset(snuk,0,sizeof (snuk));
    for(int  i =1;i<=k;i++)
    {
         int d;
         cin>>d;
         for(int  j =0;j<d;j++)
         {
             cin>>s;
             snuk[s]++;    
         } 
    }
    int count = 0;
    for(int i =1;i<=n;i++)
        if(snuk[i]==0)
            count++;
      cout<<count<<endl;  
}
signed main(void)
{
      fast();
      //w(t)
      solve();

}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll b1 = (int) b;
    ll b2 = (int)(b * 10) % 10;
    ll b3 = (int)(b * 100) % 10;

    ll c = a * b2 % 10;
    ll d = a * b3 % 100;

    double b4 = c * 0.1;
    double b5 = d * 0.01;

    ll add = (int)(b4 + b5);


    ll ans = a * b1 + (a * b2 / 10) + (a * b3 / 100);
    ans += add;
    cout << ans << endl;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  double n;
  cin>>n;
  double ans=0.0;
  double cnt=0;
  for(int i=1;i<=n;++i){
    if(i&1)cnt++;
  }
  ans=cnt/n;
  cout<<(ans)<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int H,W;
	cin>>H>>W;
	char b[100][100];
	rep(i,H)rep(j,W)cin>>b[i][j];
	
	int r[100]={};
	int c[100]={};
	rep(i,H){
		int flag=0;
		rep(j,W){
			if(b[i][j]!='.')flag=1;
		}
		r[i]=flag;
	}
	rep(j,W){
		int flag=0;
		rep(i,H){
			if(b[i][j]!='.')flag=1;
		}
		c[j]=flag;
	}
	rep(i,H){
      	if(r[i]==0) continue;
		rep(j,W){
			if(c[j])cout<<b[i][j];
		}
		cout<<endl;
	}
}


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

// PI
const double PI = acos(-1);

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double th = double(h * 60 + m) / 720 * 2 * PI;
  double tm = double(m) / 60 * 2 * PI;
  double xh = a * cos(th), yh = a * sin(th);
  double xm = b * cos(tm), ym = b * sin(tm);
  double dx = xh - xm, dy = yh - ym;
  double ans = sqrt(dx * dx + dy * dy);

  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 4124
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

ll a(ll n, ll x) {
	ll r = pow(10, x);
	n = (n % r);
	n /= pow(10, x - 1);
	return n;
}

int main() {
	ll k; cin >> k;
	vector<ll> cue;
	for (int i = 1; i <= 9; i++)cue.push_back(i);
	while (1) {
		if (k <= cue.size()) {
			cout << cue[k - 1] << endl;
			return 0;
		}

		k -= cue.size();
		vector<ll> old;
		swap(old, cue);
		for (ll x : old) {
			for(int i = -1; i <= 1  ; i++){
				int d = x % 10 + i;
				if (d < 0 || d > 9)continue;
				ll nx = x * 10 + d;
				cue.push_back(nx);
			}
		}
	}
}

Measured memory_bytes: 1712
#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime> 
#include <stack>
#include <iostream>
#include <fstream>

#define mp make_pair
#define pb push_back

using ll = long long;
using ld = long double;

using namespace std;

const int MAXN = 805;		
const int INF = MAXN * MAXN;
bool g[MAXN][MAXN];

int mx[] = { 0, 1, 0, -1 };
int my[] = { 1, 0, -1, 0 };

pair <int, int> q[MAXN * MAXN];
int qe = 0;
int d[MAXN][MAXN];

void setd(int x, int y, int dd) {
	d[x][y] = dd;
	q[qe++] = mp(x, y);
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cout.setf(ios::fixed); cout.precision(20);
	for (int i = 0; i < MAXN; i++)
		for (int j = 0; j < MAXN; j++)
			d[i][j] = INF;
	int n, m, k;
	cin >> n >> m >> k;
	memset(g, 0, sizeof(g));
	for (int i = 0; i < MAXN; i++) g[i][0] = g[0][i] = g[n + 1][i] = g[i][m + 1] = true;
	int sx, sy;
	for (int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < s.length(); j++) {
			if (s[j] == '#') g[i][j + 1] = true;
			if (s[j] == 'S') sx = i, sy = j + 1;
		}
	}
	setd(sx, sy, 0);
	for (int qb = 0; qb < qe; qb++) {
		int x = q[qb].first, y = q[qb].second;
		for (int j = 0; j < 4; j++) {
			int nx = x + mx[j], ny = y + my[j];
			if ((!g[nx][ny]) && (d[nx][ny] == INF)) setd(nx, ny, d[x][y] + 1);
		}
	}
	int ans = INF;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (d[i][j] <= k) {
				ans = min(ans, i - 1);
				ans = min(ans, j - 1);
				ans = min(ans, n - i);
				ans = min(ans, m - j);
			}
		}
	}
	ans = (ans + k - 1) / k;
	cout << ans + 1 << endl;
	return 0;
}

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

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;

int n;
int s[400], l[400], p[400];
int m;
int dp[400];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	rep(i, n) {
		cin >> s[i] >> l[i] >> p[i];
		rep(j, 400) {
			for (int k = s[i]; k <= l[i]; k++) {
				if(j - k >= 0)dp[j] = max(dp[j], dp[j - k] + p[i]);
			}
		}
	}
	cin >> m;
	vector<int>ans;
	rep(i, m) {
		int w; cin >> w;
		if (dp[w] == 0) {
			cout << -1 << endl; return 0;
		}
		ans.push_back(dp[w]);
	}
	rep(i, m) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string X;
    cin >> X;
    stack<char> s;
    int length, ans = 0;
    length = X.length();

    //文字列を先頭から見ていく
    for(int i=0;i<length;i++){
        if(s.empty()){
            s.push(X[i]);
        }else if(X[i]=='S'){
            s.push('S');
        }else if(X[i]=='T' && s.top()=='T'){
            s.push('T');
        }else{
            s.pop();
        }
    }
    
    while(!s.empty()){
        //cout << s.top();
        ans++;
        s.pop();
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=100005;
void solve()
{
    int n,k=0,val=0,m=0,i=0,j=0,l=-1,x,y,z;
    ll ans=0;
    int a[105]{};
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])
                {
                    m++;
                }
            }
        }
    }
    cout<<m;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MAXN 2999

double p[MAXN];
double q[MAXN];
long double dp[MAXN][MAXN];
int n;


int main() {
  int i, j;
  long double respuesta;
  scanf("%d",&n);
  for (i=0; i<n; i++) {
    scanf("%lf",&p[i]);
    q[i]=1.0-p[i];
  }
  dp[0][0]=1.0;
  for (j=1; j<=n; j++) {
    dp[0][j]=0.0;
  }
  for (i=1; i<=n; i++) {
    for (j=0; j<=i; j++) {
      dp[i][j]=dp[i-1][j]*q[i-1];
      if (j) {
        dp[i][j]+=dp[i-1][j-1]*p[i-1];
      }
    }
  }
  for (respuesta=0.0,i=(n+1)>>1; i<=n; i++) {
    respuesta+=dp[n][i];
  }
  printf("%.14Lf\n",respuesta);
  

  return 0;
}

Measured memory_bytes: 85312
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll d[100001][101];
int main(){
	int n;cin>>n;
	ll w;cin>>w;
	ll a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(ll i=1;i<=w;i++){
		for(int j=1;j<=n;j++){
			if(i-a[j]>=0){
				d[i][j]=max(d[i-a[j]][j-1]+b[j],d[i][j-1]);
			}
			else d[i][j]=d[i][j-1];
		}
	}
	
//	for(int i=1;i<=w;i++){
//		for(int j=1;j<=n;j++){
//			cout<<d[i][j]<<' ';
//		}
//		cout<<endl;
//	}
	
	cout<<d[w][n];
}


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

int main(){

  string word;
  string str;
  int count = 0;

  getline(cin,word);
  while(1){
    cin >> str;
    if(str== "END_OF_TEXT"){
      break;
    }
    for(int i = 0; i < str.size();i++){
      if(str[i] >= 'A' && str[i] <= 'Z'){
        str[i] += 32;
      }
    }
    if(str == word){
      count++;
    }
  }


  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
  cin>>a>>b;
  vector<int> v;
  v.resize(a);
  for(int i = 0 ; i < a ; i++) cin>>v[i];
  sort(v.begin(), v.end());
  int ans=0;
  for(int i = 0 ; i < b ; i++)ans+=v[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
# ABC108 B - GridCompression 
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

Measured memory_bytes: 4468
#include<iostream>
#include<algorithm>

using namespace std;
#define REP(i,n)  for(int i=0; i < n;i++);

int main(){
    int N,a[5000];
    cin >> N;
    for(int i=0; i < N;i++) cin >> a[i];
    sort(a,a+N);
    int res[10];

    for(int i=0; i < N;i++){
        if(a[i] >= 1 && a[i] < 400){
            res[0]++;
        }else if(a[i] >= 400  && a[i] < 800){
            res[1]++;
        }else if(a[i] >= 800  && a[i] < 1200){
            res[2]++;
        }else if(a[i] >= 1200  && a[i] < 1600){
            res[3]++;
        }else if(a[i] >= 1600  && a[i] < 2000){
            res[4]++;
        }else if(a[i] >= 2000  && a[i] < 2400){
            res[5]++;
        }else if(a[i] >= 2400  && a[i] < 2800){
            res[6]++;
        }else if(a[i] >= 2800  && a[i] < 3200){
            res[7]++;
        }else if(a[i] >=3200){
            res[8]++;
        }    
    }

    int totalmin,totalmax;
    for(int i=0; i < 8;i++){
        if(res[i] > 0)totalmin += 1;

    }
  	totalmax = totalmin + res[8];
  
  	if(totalmin <= 0){
        cout  << "1 " << res[8] << endl;
    }else{
    	cout << totalmin << " " << totalmax << endl;

    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n);i<(N);i++)
#define RREP(i,n,N) for(ll i=(N-1);i>=(n);i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a,b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod= 1e9+7;
const ll inf = 1e18;

ll N;
int main(){
    while(cin>>N, N!=0){
        ll cnt=0;
        bool flag=true;

        REP(i, 0, N){
            string str;
            cin>>str;

            if(str=="A") cnt++;
            else cnt--;

            if(cnt<0){
                flag=false;
            }
        }

        if(flag && cnt==0) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

        return 0;
    }

    return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};



int main(){
	int h, w, a[25][25];
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}

	int ans = inf;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int check = 0;
			for(int k = 0; k < h; k++){
				for(int l = 0; l < w; l++){
					check += min(abs(i-k), abs(j-l)) * a[k][l];
				}
			}
			ans = min(ans, check);
		}
	}

	cout << ans << endl;

	return 0;
}



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

int main() {
    long n, temp, cnt = 0, ans;
    bool flag = false;
    cin >> n;
    while(n) {
        if(temp / 10 && temp % 10 != 9) flag = true;
        temp = n;
        n /= 10;
        cnt++;
    }
    ans = temp + 9 * (cnt - 1);
    if(flag) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;

my $str = <STDIN>;
chomp $str;

my %hash;

for(split(//, $str)){
    $hash{$_}++;
}
if ((keys %hash)+0 != 2){
    say "No";
    exit;
}
my $ok = 1;
for(keys %hash){
    if ($hash{$_} != 2){
        $ok = 0;
    }
}
if ($ok){
    say "Yes";
}
else {
    say "No";
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    double R;
    cin >> R;
    put_double(2.0 * R * 3.1415926);
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdint>

using namespace std;

int64_t gcd(int64_t n, int64_t m) {
    if (n > m) {
        return gcd(m, n);
    }

    assert(n <= m);

    if (n == 0) {
        return m;
    }

    return gcd(m % n, n);
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    string s, t;
    cin >> s >> t;

    assert(n == s.size());
    assert(m == t.size());

    int64_t g = gcd(n, m);
    int64_t a = n / g;
    int64_t b = m / g;

    // n = a * g
    // m = b * g
    // nのi*a番目の文字はmのi*b番目の文字と一致していなければならない
    for (int64_t i = 0; i < g; ++i) {
        if (s[i * a] != t[i * b]) {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << a * b * g << endl;

    return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	listA := make([]int, m)
	listB := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&listA[i], &listB[i])
	}
	listC := make([]int, n)
	for i := 0; i < m; i++ {
		listC[listA[i]-1]++
		listC[listB[i]-1]++
	}
	for i := 0; i < n; i++ {

		fmt.Println(listC[i])
	}

}


Measured memory_bytes: 512
import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.string;

void main() {
    string s = readln.strip;

    int w = 0, l = 0;

    foreach (i, h; s) {
        if (i % 2 == 0 && h == 'p') {
            l++;
        } else if (i % 2 == 1 && h == 'g') {
            w++;
        }
    }

    writeln(w - l);
}


Measured memory_bytes: 2556
def solve(n, a):
  if 0 in a:
    return 0
  else:
    p = 1
    x = 10**18
    for i in a:
      if p<=x:
      	p*=i
      else:
        break
    if p>x:
      p = -1
    return p

n = int(input())
a = [int(x) for x in input().split()]
print(solve(n, a))

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

int main(){
    int N,X,T;
    cin >> N >> X >> T;

    int res = 0;
    while(N > 0){
        N -= X;
        res += T;
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define MAXN 10010
#define MAXY 2010
#define INF 0x3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
vector<int> e[100005];
int n,s,t;
int dep[100005],md[100005],fa[100005];
void dfs(int u,int f){
	dep[u]=md[u]=dep[f]+1;
	fa[u]=f;
	for(auto v:e[u])
	if(v!=f){
		dfs(v,u);
		md[u]=max(md[u],md[v]);
	}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>s>>t;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(t,0);
	int ans=0,x=s;
	while(1){
		if(dep[s]-dep[x]>=dep[x]-dep[t])
		break;
		ans=max(ans,md[x]-1);
		x=fa[x];
	}
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

bool isprime[200000];
int prime[100000];

void init() {
  fill(isprime, isprime+200000, true);
  isprime[0] = isprime[1] = false;
  int count = 0;
  for (int i=2; i<200000; i++) {
    if (isprime[i]) {
      prime[count] = i;
      // if (count < 10) // cerr << "prime[" << count << "] = " << prime[count] << endl;
      count++;
      for (int j=2; j<200000; j++) {
	if (i * j >= 200000) break;
	isprime[i*j] = false;
      }
    }
  }
}

int main() {
  init();
  int N, P;
  while (scanf("%d%d", &N, &P) != EOF && N != -1 && P != -1) {
    vector<int> V;
    int idx;
    for (idx=0; prime[idx]<=N; idx++) {
    }
    // cerr << "idx = " << idx << endl;
    // cerr << "prime[idx] = " << prime[idx] << endl;
    // cerr << "prime[0] = " << prime[0] << endl;
    for (int i=0; i<100; i++) {
      for (int j=0; j<=i; j++) {
	V.push_back(prime[idx+i] + prime[idx+j]);
	// // cerr << prime[idx+i] + prime[idx+j] << endl;
      }
    }
    sort(V.begin(), V.end());
    /*for (int p=0; p<100; p++) {
      // cerr << "V[" << p << "] = " << V[p] << endl;
      }*/
    printf("%d\n", V[P-1]);
  }
}

Measured memory_bytes: 1512
S = gets.chomp
L = S.length

s = 0; as = [s]
S.each_char{|c| s += c == '1' ? 1 : -1; as << s}
@bs = Array.new(L + 1)
@bs[-1] = as[-1]
(0 ... L).reverse_each{|i| @bs[i] = [as[i], @bs[i + 1]].max}
z = @bs[0]

def f(m)
  s, ad, ret = 0, 0, 0
  S.each_char.with_index do |c, i|
    if c == '1'
      s += 1
    elsif c == '0'
      s -= 1
      ret = [ret, s].min
    elsif ad + @bs[i + 1] + 2 <= m
      s += 1
      ad += 2
    else
      s -= 1
      ret = [ret, s].min
    end
  end
  ret
end

puts [z - f(z), z + 1 - f(z + 1)].min

Measured memory_bytes: 40052
while True:
  a,b = map(int,input().split())
  if a == 0 and b == 0:
    break
  ans = 0
  for i in range(1,a+1):
    for j in range(i+1,a+1):
      for k in range(j+1,a+1):
        if i + j + k == b: ans += 1
  print(ans)


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

int main(){
    int a,ai1,aa=0;
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        
        ai1=k-a;
        
        if(ai1<a){
            aa+=ai1;
        }else{
            aa+=a;
        }
    }
    cout<<aa*2<<endl;
}    

    


Measured memory_bytes: 3556
#include<stdio.h>
#include<map>
using namespace std;
map<int,int> p;
int main()
{
    int n,i,j,s;
    scanf("%d",&n);
    s=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&j);
        if(p[j]==0)
        {
            p[j]=1;
            s++;
        }
        else
        {
            p[j]=0;
            s--;
        }
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 4864
module Main where

import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char
import qualified Data.Map.Strict as M
import Control.Arrow
-- import Debug.Trace

main :: IO ()
main = do
  [a, b] <- unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  print . succ . length . primeFactor' $ gcd a b

-- http://qiita.com/myuon_myon/items/ad006568bd187223f494#2-4
primes = 2:3:[x|i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x] where
  isPrime n = null [i|i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

-- | returns [(PrimeFactor, Exponent)]
-- >>> primeFactor 9
-- [(2,0),(3,2)]
primeFactor x = go x primes
  where       
    ub = floor . sqrt $ fromIntegral x
    go x (p:ps) 
      | p <= ub = let (x', e) = gogo x p 0 
        in (p, e) : go x' ps
      | x == 1 = []
      | otherwise = [(x, 1)]
      where
        gogo x p e = case quotRem x p of
          (q, 0) -> gogo q p (e + 1)
          (q, _) -> (x, e)

-- | returns [(PrimeFactor, Exponent)]
-- >>> primeFactor' 9
-- [(3,2)]
primeFactor' x = map (head &&& length) . group $ go x divisor []
  where
    go 1 [] acc = acc
    go y [] acc = y:acc
    go y ps'@(p : ps) acc = case quotRem y p of
      (q, 0) -> go q ps' (p : acc)
      (q, _) -> go y ps acc
    ub = floor . sqrt $ fromIntegral x
    divisor = takeWhile (<= ub) primes


Measured memory_bytes: 7932
n, a, b = map(int, input().split())
# 偶奇一致
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    left = a - 1
    right = n - b

    if left > right:
        cnt = right + 1
        left = min(a + cnt, n)
        print((n - left) // 2 + cnt)
    else:
        cnt = left + 1
        right = max(b - cnt, 1)
        print((right - 1) // 2 + cnt)


Measured memory_bytes: 3060
function main(input) {
    const args = input.split(' ');
    const age = parseInt(args[0], 10);
    
    if(age === 7 || age == 5 || age == 3 ) {
        console.log("YES");
    }
    else {
        console.log("NO");
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n,m,c;cin>>n>>m>>c;
  int res=0;
  vector<int> b(m);
  rep(i,m)cin>>b[i];
  rep(i,n){
      int sm=c;
      rep(j,m){
          int a;cin>>a;
          sm+=a*b[j];
      }
      if(sm>0)++res;
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3596
h,w = map(int,input().split())
c = list(map(int,input().split()))
c[0] -= 1
c[1] -= 1
d = list(map(int,input().split()))
d[0] -= 1
d[1] -= 1
p = []
q = [[None for i in range(w)]for i in range(h)]
r = [[] for i in range(10**6)]
for i in range(h):
    s = input()
    s = list(s)
    p.append(s)
from collections import deque
de = deque()
de.append([c[0],c[1]])
q[c[0]][c[1]] = 0
g = 0
while q[d[0]][d[1]] == None and g < 10**6-3:
    while de:
        v = de.popleft()
        r[g].append([v[0],v[1]])
        for i in (-1,1):
            j = 0
            if 0 <= v[0]-i <= h-1:
                if 0 <= v[1]-j <= w-1:
                    if p[v[0]-i][v[1]-j] == '.' and q[v[0]-i][v[1]-j] == None:
                        q[v[0]-i][v[1]-j] = g
                        de.append([v[0]-i,v[1]-j])
        for j in (-1,1):
            i = 0
            if 0 <= v[0]-i <= h-1:
                if 0 <= v[1]-j <= w-1:
                    if p[v[0]-i][v[1]-j] == '.' and q[v[0]-i][v[1]-j] == None:
                        q[v[0]-i][v[1]-j] = g
                        de.append([v[0]-i,v[1]-j])
    g += 1
    while r[g-1]:
        v = r[g-1].pop()
        for i in range(-2,3):
            for j in range(-2,3):
                if (abs(i) == 1 and j == 0) or (abs(j) == 1 and i == 0):
                    continue
                else:
                    if 0 <= v[0]-i <= h-1:
                        if 0 <= v[1]-j <= w-1:
                            if p[v[0]-i][v[1]-j] == '.' and q[v[0]-i][v[1]-j] == None:
                                q[v[0]-i][v[1]-j] = g
                                de.append([v[0]-i,v[1]-j])
if q[d[0]][d[1]] == None:
    print(-1)
else:
    print(q[d[0]][d[1]])

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

int main() {
  int N,Q; string S;
  cin >> N >> Q >> S;
  vector<int> l(Q); vector<int> r(Q);
  for (int i =0; i<Q; i++) {
    cin >> l.at(i); cin >> r.at(i);
  }
  
  vector<int> check(N,0);
  for (int i =1; i<N; i++) {
    check.at(i) = check.at(i-1);
    if (S.at(i-1) == 'A' && S.at(i) == 'C') check.at(i)++;
  }
  for (int i =0; i<Q; i++) {
    cout << check.at(r.at(i)-1) - check.at(l.at(i)-1) << endl;
  }
}

Measured memory_bytes: 4580
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[800][805];

int main(int argc, char* argv[])
{
    int h,w,K;
    scanf("%d%d%d", &h, &w, &K);

    vector<int> vis(h*w);

    int si=-1,sj=-1;
    int i,j;
    for(i=0; i<h; i++) {
        scanf("%s", str[i]);
        for(j=0; j<w; j++) {
            if(str[i][j]=='S') {
                si=i; sj=j;
            }
        }
    }
    assert(si>=0 && sj>=0);

    int dx[4]={1,-1,0,0};
    int dy[4]={0,0,1,-1};
#define P(i,j) ((i)*w+(j))
    queue<pair<int,int> > que0;
    que0.push(make_pair(P(si,sj), 0));

    int min=INF;
    while(!que0.empty()) {
        auto tmp=que0.front();
        int curr=tmp.first;
        int dist=tmp.second;
        que0.pop();
        int i=curr/w;
        int j=curr%w;
        vis[P(i,j)]=1;
        if(i==0 || i==h-1 || j==0 || j==w-1) {
            printf("1\n");
            return 0;
        }
        min=MIN(min,i);
        min=MIN(min,h-1-i);
        min=MIN(min,j);
        min=MIN(min,w-1-j);

        int p;
        for(p=0; p<4; p++) {
            int i2=i+dx[p];
            int j2=j+dy[p];
            int dist2=dist+1;
            if(i2<0 || i2>=h || j2<0 || j2>=w) continue;
            if(dist<K && str[i2][j2]=='.' && !vis[P(i2,j2)]) {
                int dist2=dist+1;
                que0.push(make_pair(P(i2,j2),dist2));
                vis[P(i2,j2)]=1;
            }
        }        
    }
    printf("%d\n", (min-1+K)/K+1);

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void)
{
	int n,i,j,k;
	int a[5000],b[5000],c[5000],d[5000],sum[101],x[101];
	scanf("%d",&n);
	k=n*(n-1)/2;
	for(i=0;i<k;i++){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
	}
	for(i=1;i<=n;i++){
		sum[i]=0;
		x[i]=1;
	}
	for(i=0;i<k;i++){
		if(c[i]>d[i]){
		sum[a[i]]+=3;
		}
		else if(c[i]<d[i]){
		sum[b[i]]+=3;
		}
		else{
		sum[a[i]]++;
		sum[b[i]]++;
		}					
	}
//	for(i=1;i<=n;i++){
//		printf("%d\n",sum[i]);
//	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(sum[i]<sum[j]){
				x[i]++;
			}
		}
		printf("%d\n",x[i]);
	}
	return 0;
}
					

Measured memory_bytes: 1868
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],n,cnt,q,mx,mn,x,y,z;
bool prime(int l){
    if(l<=1) return 0;
    for(int i=2;i<l;++i)
        if(l%i==0) return 0;
    return 1;
}
int main(){
    for(int i=1;i<N;++i){
     A[i]=(prime(i)&&prime((i+1)/2));
     A[i]+=A[i-1];
    }
    //for(int i=0;i<55;++i)
      //  cout<<i<<":"<<A[i]<<endl;
    scanf("%d",&q);
    while(q--){
        scanf("%d %d",&x,&y);
        printf("%d\n",A[y]-A[x-1]);
    }
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define PI 3.14159265358979

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 MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    string lstr;
    cout << 0 << endl;
    cin >> lstr;
    if (lstr == "Vacant") {
        return 0;
    }
    ll l = 0;
    ll r = N;
    while(r - l >= 1){
        ll m = l + (r - l) / 2;
        cout << m << endl;
        string tmp;
        cin >> tmp;
        if (tmp == "Vacant") {
            return 0;
        }
        if ((m-l) % 2 == 0) {
            if (tmp == lstr) {
                l = m;
            } else {
                r = m;
            }
        } else {
            if (tmp != lstr) {
                l = m;
                lstr = tmp;
            } else {
                r = m;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <map>


using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

int main(){
    int  N,count[200000]={}; 
    map<string,int> data;
    string str;

    cin>>N;
    rep(i,N){
        cin>>str;
        data[str]+=1;
    }

    int maxv=0;
    for(const auto& x: data){
        int v=x.second;
        if(v>maxv) maxv=v;
    }
    for(auto it =data.begin();it!=data.end(); it++){
        if(it->second == maxv){
            cout<<it->first<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25216