akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

ll n;
ll W, w[110], v[110];

ll dp[110][100100];

/*
ll rec(ll i, ll j) {
	if (dp[i][j] >= 0) return dp[i][j];

	ll res = INF;
	if (i == n) res = 0;
	else if (j - v[i] >= 0) res = min(res, rec(i + 1, j - v[i]) + w[i]);
	else res = rec(i + 1, j);

	return dp[i][j] = res;
}
*/

ll rec(ll i, ll j) {

	if (j == 0) return 0;
	if (i == -1) return INF;
	if (dp[i][j] >= 0) return dp[i][j];

	ll res = INF;
	if (j < v[i]) res = rec(i - 1, j);
	else res = min(rec(i - 1, j), rec(i - 1, j - v[i]) + w[i]);

	return dp[i][j] = res;
}

int main(void){
	cin>>n>>W;
	for (int i = 0; i < n; i++) cin>>w[i]>>v[i];

	memset(dp, -1, sizeof(dp));

	ll ans = 0;
	for (ll i = 0; i < 100100; i++) {
		if (rec(n - 1, i) <= W) ans = max(ans, i);
	}

	printf("%lld\n", ans);
	//printf("%lld\n", rec(0, V));
	
	return 0;
}

Measured memory_bytes: 86400
import sys
import math
import fractions
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# Nの素因数分解を辞書で返す
def prime_fact(n):
    if n == 1:
        return {1: 1}

    prime_dict = {}
    for i in range(2, int(n**0.5)+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
        if n == 1:
            break
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()

    if max(A) == 1:
        print("pairwise coprime")
        exit()

    g = A[0]
    for a in A:
        g = math.gcd(g, a)
    if g > 1:
        print("not coprime")
        exit()

    SA = set(A)
    if len(SA) >= 90000:
        print("setwise coprime")
        exit()

    p_cnt = defaultdict(int)
    PD_list = defaultdict(dict)
    cnt = 0
    for a in A:
        if a == 1:
            continue

        if PD_list[a]:
            AP = PD_list[a]
        else:
            AP = prime_fact(a)
            PD_list[a] = AP
        for apk in AP.keys():
            p_cnt[apk] += 1

    max_p = max(p_cnt.values())
    if max_p == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")


if __name__ == "__main__":
    main()


Measured memory_bytes: 240064
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	re int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
enum{N=200024};
map <int,int> M;
int sum[N];
int main(){
	int n=ci(), m=ci();
	M[0]++;
	ll ans= 0;
	rep(i,1,n){
		if( i>=m ){
			M[sum[i-m]]--;
		}
		sum[i]= (sum[i-1]+ci()-1)%m;
//		printf("%d ",sum[i]);
		ans+= M[sum[i]];
		M[sum[i]]++;
	}
	ptll(ans),pt('\n');
	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <unordered_set>

 int main(void) {
 int N, M, a, b;
 std::cin >> N >> M;
  std::unordered_set<int> to_N;
  std::unordered_set<int> from_1;
 for (int i=0; i<M;i++) {
  std::cin >> a >> b;
  if(a==1) from_1.insert(b);
 if(b==N) to_N.insert(a);
}
 for(std::unordered_set<int>::iterator it = from_1.begin();
  it != from_1.end(); it++) {
    int next = *it;
  if(to_N.find(next) != to_N.end()){
      std::cout << "POSSIBLE";
return 0;}
  }
  std::cout << "IMPOSSIBLE";
 return 0;
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int h,w;
int MAP[100][100];

int bfs(int y,int x){
  rep(i,8){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(nx>=0&&ny>=0&&nx<w&&ny<h&&MAP[ny][nx]==1){
      MAP[ny][nx]=0;
      bfs(ny,nx);
    }
  }
  return 1;
}

signed main(){
  while(cin>>w>>h,w){
    rep(i,h)rep(j,w)cin>>MAP[i][j];
    int ans=0;
    rep(i,h)rep(j,w){
      if(MAP[i][j]==1)ans+=bfs(i,j);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  ll previousMin = P[0];
  ll ans = 1;
  for (ll i = 1; i < N; i++) {
    if (P[i] < previousMin) {
      previousMin = P[i];
      ans++;
    }
  }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 2e6+100;
const int mod = 1e9+7;
ll fact[upperlimit];
ll invfact[upperlimit];
ll ncr(int n,int r){
	ll ans=fact[n];
	ans*=invfact[r];ans%=mod;
	ans*=invfact[n-r];ans%=mod;
	return ans;
}
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	fact[0]=1;invfact[0]=1;
	for(int i = 1; i < upperlimit; i++){
		fact[i]=fact[i-1];fact[i]*=i;fact[i]%=mod;
		invfact[i]=powmod(fact[i],mod-2,mod);
	}
	int n;
	string s;
	cin >> n >> s;
	int k=s.size();
	ll ans=0;
	for(int i = k; i <= n+k; i++){
		ll calc=ncr(i-1,k-1);
		calc*=powmod(25,i-k,mod);calc%=mod;
		calc*=powmod(26,n+k-i,mod);calc%=mod;
		ans+=calc;ans%=mod;
	}
	plld(ans);
	return 0;
}

Measured memory_bytes: 36512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int k = scan.nextInt();
		int max = 0;

		if (k <= a) {
			max = k;
		} else if (k <= (a + b)) {
			max = a;
		} else {
			max = a - (k - a - b);
		}

			System.out.print(max);

	}
}

Measured memory_bytes: 35708
def main()->None:
    # 回答見た
    n = int(input())
    a = list(map(int, input().split()))
    range_N = range(n)
    acounter = 0
    bcounter = 0
    num = 0
    for i in range_N:
        num += a[i]
        if i % 2 == 0:
            if num <= 0:
                acounter += abs(num) + 1
                num = 1

        else:
            if num >= 0:
                acounter += num + 1
                num = -1


    num = 0
    for i in range_N:
        num += a[i]
        if i % 2 != 0:
            if num <= 0:
                bcounter += abs(num) + 1
                num = 1

        else:
            if num >= 0:
                bcounter += num + 1
                num = -1

    print(min(acounter, bcounter))


if __name__ == "__main__":
    main()

Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
 ll n ;cin>>n;
string s;cin>>s;
ll x=s.length();
 if(x<=n)
    cout<<s<<nn;
 else
 {
     for(ll i=0;i<n;i++)
        cout<<s[i];
     cout<<"..."<<nn;
 }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string.h>
using namespace std;

const int MAXN = 1e6+10;
char s[MAXN];
int a[MAXN],N,M;
struct node {
    int to,next;
}E[MAXN * 10];

int head[MAXN],sumE,sum;
bool vis[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
#define read(x) scanf("%d",&x)
void Init() {
    scanf("%s",s + 1);
    N = strlen(s + 1);
    s[0] = 'a';s[N + 1] = 'a';
    for(int i = 1 ; i <= N + 1; ++i) a[i] = (s[i] - s[i - 1] + 26) % 26;
    read(M);
    int L,R;
    for(int i = 1 ; i <= M ; ++i) {
    read(L);read(R);
    add(L,R + 1);add(R + 1,L);
    }
    for(int i = 1 ; i <= N + 1 ; ++i) {
    add(i,N + 2 - i),add(N+2-i,i);
    }
}
void dfs(int u) {
    vis[u] = 1;
    sum = (sum + a[u]) % 26;
    for(int i = head[u] ; i ; i = E[i].next) {
    int v = E[i].to;
    if(!vis[v]) {
        dfs(v);
    }
    }
}
void Solve() {
    bool flag = 1;
    for(int i = 1 ; i <= N + 1 ; ++i) {
    if(!vis[i]) {
        sum = 0;
        dfs(i);
        if(sum != 0) {flag = 0;break;} 
    }
    }
    if(flag) puts("YES");
    else puts("NO");
}
int main() {
    Init();
    Solve();
    return 0;
}


Measured memory_bytes: 7808
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N = IN();
	vll A(N + 2);
	A[0] = 0;
	for(int i = 1; i <= N; ++i) {
		cin >> A[i];
	}
	A.back() = 0;
	vll F(N - 1 + 2);
	for (int i = 0; i <= N; ++i) {
		F[i] = abs(A[i] - A[i + 1]);
	}
	ll sum = accumulate(ALL(F), 0);

	for (int i = 0; i < N; ++i) {
		int nF = abs(A[i] - A[i + 2]);
		OUT(sum - F[i] - F[i + 1] + nF);
	}

	return 0;
}

Measured memory_bytes: 2816
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut count = 0isize;

        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        let buf = buf.split_whitespace().collect::<Vec<_>>();

        let n = buf.get(0).unwrap().parse::<isize>().unwrap();
        let x = buf.get(1).unwrap().parse::<isize>().unwrap();

        if n == 0 && x == 0 {
            break;
        }

        for i in 1..(n - 1) {
            for j in (i + 1)..x {
                let k = x - i - j;
                if k > j && k <= n {
                    count += 1;
                }
            }
        }

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


Measured memory_bytes: 5032
from math import degrees, atan

a, b, x = map(int, input().split())
y = x/a
t = a*b/2
ans = 0
if y > t:
    ans = atan(2/a**2*(a*b-y))
else:
    ans = atan(b**2/2/y)

print(degrees(ans))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;


int main()
{
    // 整数の入力
    ll N;
    vector<ll> lines;
    cin >> N;
    for(int i = 0;i<N;i++){
        ll a;
        cin >> a;
        lines.push_back(a);
    }
    lines.push_back(10000);

    sort(lines.begin(),lines.end());
    ll total = 0;
    for(int i = 0;i<N;i++){
        for(int j = i+1;j<N;j++){
            ll sum_ab = lines[i] + lines[j];
            ll min_ba = lines[j] - lines[i];
            auto from = upper_bound(lines.begin() + j + 1,lines.end(),min_ba);
            auto to = lower_bound(lines.begin() + j + 1,lines.end(),sum_ab);
            // cout << "a:" << lines[i] << "b:" << lines[j] << "from:" << *from << " to:" << *to << endl;
            // cout << to - from << endl;
            if (to - from > 0){
                total += to - from;
            }
            // if (a < N){
            //     total += N - a;
            //     if (lines[a] <= lines[i]){
            //         total--;
            //     }

            //     if (lines[a] <= lines[j]){
            //         total--;
            //     }
            // }
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define nfree -1
#define free 1

int Board[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
void p();
void Queen(int);

int main(){
  int n;
  int i,j;
  int x,y;
     
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      Board[i][j] = 0;
    }
  }
     
  for(j=0; j<N; j++){
    row[j]=0;
    col[j]=0;
  }
  for(j=0; j<2*N-1; j++){
    dpos[j]=0;
    dneg[j]=0;
  }
     
  scanf("%d",&n);
     
  for(i=0; i<n; i++){
    scanf("%d %d",&x,&y);
    Board[x][y] = 1;
  }
     
  Queen(0);
  return 0;
}

void p(){
  int i,j; 
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(Board[i][j]){
    if(row[i]!=j) return;
      }
    }
  }
 
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void Queen(int i){
  int j;
  if(i==N){
    p();
    return;
  }
     
  for(j=0; j<N; j++){
    if(nfree==col[j]||nfree==dpos[i+j]||nfree==dneg[i-j+N-1]) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = nfree;
    Queen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair

const int N = 102;
typedef pair<int, int> info;
int n;
int a[N];
bool b[N];
vector<int> ans;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = false;
    }
    int cnt = n;
    while (cnt > 0) {
        bool found = false;
        for (int i = n; i >= 1; i--) if (b[i] == false) {
            int pop = 0;
            int idx = i;
            for (int j = 1; j < i; j++) {
                pop += b[j] == true;
            }
            if (idx - pop == a[i]) {
                b[i] = true;
                ans.emplace_back(a[i]);
                found = true;
                break;
            }
//            cout << i << " " << pop << " " << cnt << "\n";
        }
        if (!found) {
            cout << -1;
            return 0;
        }
        cnt--;
    }
    reverse(ans.begin(), ans.end());
    for (auto x: ans) {
        cout << x << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
even = [2]*N
odd = [1]*M
a = even+odd
ans = 0
for i in range(N+M):
    for j in range(i+1, N+M):
        if (a[i]+a[j]) % 2 == 0:
            ans += 1
print(ans)


Measured memory_bytes: 38768
# 再帰関数で実装してみる
numbers = list(input())
# print(numbers)


def rec(s, n):
    if n == 3:
        if eval(s) == 7:
            print(s+"=7")
            exit()
        return
    rec(s+"+"+numbers[n+1], n+1)
    rec(s+"-"+numbers[n+1], n+1)


rec(numbers[0], 0)


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  int most = 0, least = INF;
  int a = -1;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    least = min(least, a);
    most = max(most, a);
  }
  int ans = most - least;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    
    cin >> n;
    for(int i=1; i<=n; i++){
        int a=i/10,b=a/10,c=b/10;
        if(i%3==0){
            cout << " " << i;
        
        }
        else if(i%10==3 || a%10==3 || b%10==3 || c%10==3){
            cout << " " << i;
        }
    }cout << endl;
    
}


Measured memory_bytes: 3080
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

//int ara[];
int main()
{
    ios_base::sync_with_stdio(0);

       int a,b,x,c=0,sum=0,n,m;
       string s,ss;
       cin>>a>>b>>x;

       cout<<x<<" "<<a<<" "<<b<<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;

int main(){
  int A,B,C,X;
  int S;
  int cnt = 0;
  cin >> A >> B >> C >> X;
  for(int i = 0;i<A+1;i++){
    for(int j = 0;j<B+1;j++){
      for(int k = 0;k<C+1;k++){
        S = 500*i + 100*j + 50*k;
        if(S == X) cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d[200001];
ll mod = 1e9 + 7;
ll go(ll x, ll y) {
	if (y == 0)return 1;
	if (y & 1) {
		return (x * go(x, y - 1)) % mod;
	}
	else {
		ll tmp = go(x, y / 2);
		return tmp * tmp % mod;
	}
}
int main() {
	// 코틀린 ,문자열 알고리즘 보기, 앳코더, (시간되면 코드포스까지)
	ios_base::sync_with_stdio(false); cin.tie(NULL); //9 90 900 
	ll h, w, a, b; cin >> h >> w >> a >> b;
	d[0] = 1;

	for (int i = 1; i <= 200000; i++) {
		d[i] = d[i - 1] * i;
		d[i] %= mod;
	}

	int x = h - a;
	int y = 1 + b;
	ll ans = 0;
	while (x > 0 && y <= w) {
		ll cnt = (d[x + y - 2] * (go((d[x - 1] * d[y - 1]) % mod, mod - 2))) % mod;
		cnt = (cnt * ((d[h - x + w - y] * go((d[h - x] * d[w - y]) % mod, mod - 2)) % mod)) % mod;

		ans += cnt;
		ans %= mod;
		x -= 1; y += 1;
	}
	cout << ans << '\n';



}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <map>
using namespace std;
#define REP(n) for(int i=0;i<n;i++)

#define INF_32 0x7fffffff;



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

	double ans = T / X;
	
	

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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=1; i<=N; i++)
    ans+=i;
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int i = 0;
  int inp = 0;
  
  cin >> inp;
  
  while (!(inp == 0))
  {
    cout << "Case " << i + 1 << ": " << inp << endl;
    cin >> inp;
    i++;
  }
}


Measured memory_bytes: 3000
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;
template<typename T> void caut(T a, T b, T c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T> void caut(T a, T b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}

struct tup {
  int x,y,c;
  bool operator<(const tup tt) const {
    if (y != tt.y) return y < tt.y;
    else if (x != tt.x) return x < tt.x;
    else return c < tt.c;
  }
  bool operator>(const tup tt) const {
    if (c != tt.x) return c > tt.c;
    else if (x != tt.y) return x > tt.x;
    else return y > tt.y;
  }
};

template <typename T>
struct seg_pL {
  // 一点更新、区間取得 1~N
  using F = function<T(T,T)>;
  // f: [](int x, int y){return min(x,y);}
  // g: [](int x, int y){return y;} // 下にある値をそのまま上へ

  int n0, n1; const F f, g; const T first_t; vector<T> seg;
  // f: 子の計算 g: 親と子(f)の計算

  seg_pL(int n, const F _f, const F _g, const T& _t) : f(_f), g(_g), first_t(_t) {
    n0 = n, n1 = 1; while(n0 > n1) n1<<=1; seg.assign(2*n1, first_t);
  }

  void set(int k, const T& _t) {seg[k+n1]=_t;} // 1~Nのk番目に値を入れる
  void build() { for(int k=n1-1; k>=0; k--) seg[k] = f(seg[2*k], seg[2*k+1]);}

  void update(int k, const T& t) {
    k += n1; seg[k] = g(seg[k], t); k /= 2;
    while(k > 0) {seg[k] = g(seg[k], f(seg[2*k], seg[2*k+1])); k /= 2;}
    //cout << seg << endl;
  }

  T query(int a, int b, int k, int l, int r) { // (0, 4+1)
    if (r<=a || l>=b) return first_t;
    if (a<=l && r<=b) return seg[k];
    else {
      T q1 = query(a, b, 2*k, l, (l+r)/2);
      T q2 = query(a, b, 2*k+1, (l+r)/2, r);
      //cout << q1 << " " << q2 << endl;
      return f(q1, q2);
    }
  }

  T query(int a, int b) {
    return query(a, b, 1, 0, n1);
  }
};

int main(){
  int n,m; cin>>n>>m;
  tup t[m];
  for(int i=0;i<m;i++) {
    cin>>t[i].x>>t[i].y>>t[i].c; t[i].x--; t[i].y--;
  }
  sort(t,t+m);

  seg_pL<ll> sg(n, [](ll x,ll y){return min(x,y);}, [](ll x,ll y){return y;}, LINF);
  sg.update(0,0);
  for(int i=0;i<m;i++) {
    ll val = sg.query(t[i].x, t[i].y+1) + t[i].c;
    if (sg.seg[t[i].y+sg.n1] > val) sg.update(t[i].y,val);
  }
  if (sg.seg[n-1+sg.n1] != LINF) cout<<sg.seg[n-1+sg.n1]<<endl;
  else cout<<-1<<endl;
}

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

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){
    cout<<(b-a)/2<<endl;
    return 0;
  }
  ll c=a+b,d=n-b+n-a+2;
  cout<<min(c/2,d/2)<<endl;
  return 0;
}




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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[MAXN];
ll val[2];

vi ans;

void solve(){
	int n, maxi = 0;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &v[i]);
		if (v[i] >= 0) {
			val[i & 1] += v[i];
		}
		if (v[i] > v[maxi]) {
			maxi = i;
		}
	}
	
	if (v[maxi] <= 0) {
		printf("%d\n%d\n", v[maxi], n - 1);
		for(int i = n - 1; i > maxi; i--) {
			printf("%d\n", i + 1);
		}
		REP(i, 0, maxi) {
			printf("1\n");
		}
		return;
	}
	
	int ind = 1;
	if (val[0] > val[1]) {
		ind = 0;
	}
	
	int l = n, r = -1;
	for(int i = ind; i < n; i += 2) {
		if (v[i] >= 0) {
			l = min(l, i);
			r = max(r, i);
		}
	}
	for(int i = n - 1; i > r; i--) {
		ans.pb(i);
	}
	
	for(int i = r - 2; i >= l; i -= 2) {
		if (v[i] >= 0) {
			ans.pb(i + 1);
		} else {
			ans.pb(i);
		}
	}
	
	REP(i, 0, l) {
		ans.pb(0);
	}
	
	printf("%lld\n%d\n", val[ind], SZ(ans));
	REP(i, 0, SZ(ans)) {
		printf("%d\n", ans[i] + 1);
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d",$N,$M);
for ($i=1;$i<=$M;$i++){
	fscanf(STDIN, "%d %d %d",$a[$i],$b[$i],$c[$i]);
}

//頂点間の距離を無限で初期化
for ($i=1;$i<=$N;$i++){
	for ($j=1;$j<=$N;$j++){
		if ($i==$j){
			$dist[$i][$j] = 0;
		}else {
			$dist[$i][$j] = INF;
		}
	}
}

//既知の経路
for ($i=1;$i<=$M;$i++){
	$dist[$a[$i]][$b[$i]] = $c[$i];
    $dist[$b[$i]][$a[$i]] = $c[$i];
}

//最短経路判定
for ($k=1;$k<=$N;$k++){
	for ($i=1;$i<=$N;$i++){
		for ($j=1;$j<=$N;$j++){
			//$iから$jに向かう場合$kを経由した方が早いかの判定
			if ($dist[$i][$k]+$dist[$k][$j]<$dist[$i][$j]){
				$dist[$i][$j] = $dist[$i][$k]+$dist[$k][$j];
                $dist[$j][$i] = $dist[$i][$k]+$dist[$k][$j];
			}
		}
	}
}

//最短経路に含まれない道をカウント
$ans = 0;
for ($i=1;$i<=$M;$i++){
	if ($dist[$a[$i]][$b[$i]] < $c[$i]){
		$ans++;
	}
}
echo $ans;
//print_r($dist);

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

int main() {
  int n;
  string det = "No";
  cin >> n;
  for(int i = 1;i <= 9; i++){
    if(n/i < 10 && n%i == 0){
      det = "Yes";
    }
  }
  cout << det << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(a,v) memset(a,v,sizeof(a))
#define all(v) (v.begin(), v.end())
#define sar(a,n) ll a[n];for(i=0; i<n; i++)cin>>a[i] //*declare* and scan array
#define pars(a,n) for(ll i=0; i<n; i++)cout<<a[i]<<" " //prints array with spaces between the elements
#define parl(a,n) for(ll i=0; i<n; i++)cout<<a[i]<<"\n" //prints array with new line between the elements
#define debug(x) cout << '>' << #x << ':' << x << endl
#define debuga() cout<<"AAAAA\n"
#define debugb() cout<<"BBB\n"
#define rep(n) for (ll i=0; i<n; i++)
#define elif else if
#define eb emplace_back
#define pb push_back
#define bitcount __builtin_popcount
using namespace std;
using ll = long long;

ll fastpow(ll a, ll p, ll mod){ll ans=1; a%=mod; for(; p; p>>=1){ if(p&1) ans=ans*a%mod; a=a*a%mod;} return ans;}

void solve() {
    int n;
    cin >> n;
    map<string, int>cnt;
    int m = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        ++cnt[s];
        m = max(cnt[s], m);
    }
    vector<string>ans;
    for (auto x: cnt) {
        if (x.second == m) {
            cout << x.first << "\n";
        }
    }
     
}

int main() {
    
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "rt", stdin);
    //     freopen("output.txt", "wt", stdout);
    // #endif
    
    fastIO;
    int T;
    T=1;
    // cin>>T;
    for (int tt = 1; tt <= T; tt++){
        // cout << "Case #" << tt << ": ";
        solve();
    }
	// your code goes here
	return 0;
}


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

const int INF = 1e8;
vector<vector<int>> dp(401,vector<int> (401,INF));

int main(){
    int n,ma,mb; cin >> n >> ma >> mb;
    vector<vector<int>> vec(n,vector<int> (3));
    rep(i,n) cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
    dp[0][0] = 0;
    rep(i,n){
        int a = vec[i][0], b = vec[i][1], c = vec[i][2];
        for(int x = 400; x >= a;--x){
            for(int y = 400; y >= b;--y){
                dp[x][y] = min(dp[x][y],dp[x-a][y-b]+c);
            }
        }
    }
    int ans = INF;
    for(int i = 1;i <= min(400/ma,400/mb);++i){
        ans = min(ans,dp[i*ma][i*mb]);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 4280
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)


def factorize(n: int):
    d = Counter()
    m = 2

    while m * m <= n:
        while n % m == 0:
            n //= m
            d[m] += 1

        m += 1

    if n > 1:
        d[n] += 1

    return d

from collections import Counter

a, b = li()

g = gcd(a, b)
f = factorize(g)

print(len(f) + 1)

Measured memory_bytes: 3444
n = int(input())
l = input().split()
lst = list(map(int,l))
x = []

for i in range(n):
    x.append(0)
    x[i] = lst[i] - (i+1)

#print(x)
x.sort()
#print(x)

b = x[n//2]

#print(b)

sad = 0

#print(lst)

for i in range(n):
    sad += abs(lst[i]-b-i-1)

print(sad)

Measured memory_bytes: 33860
def main():
    length = int(input())
    numbers = list(map(int, input().split()))
    answer = [0] * length
    if length % 2:
        answer[:length // 2 + 1] = numbers[::-2]
        answer[length // 2 + 1:] = numbers[1::2]
    else:
        answer[:length // 2] = numbers[::-2]
        answer[length // 2:] = numbers[::2]
    print(" ".join(list(map(str, answer))))


if __name__ == '__main__':
    main()



Measured memory_bytes: 29764
#include<bits/stdc++.h>
#define ll long long 
#define MAXN 200010
using namespace std;

int n,m;
int X[2010];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&X[i]);
	}
	sort(X+1,X+1+n);
	
	ll ans=0;
	for(int i=1;i<=n-2;i++){
		for(int j=i+1;j<=n-1;j++){
			int x=lower_bound(X+j+1,X+n+1,X[i]+X[j])-X;
		//	if(x>n)continue;
			ans+=x-1-j;
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3844
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  int n,m;
  cin >> n >> m;
  vector<set<int>> a(m);
  rep(i,m){
    int p;
    cin >> p;
    rep(j,p) {
      int q;
      cin >> q;
      a[i].insert(q);
    }
  }
  vi s(m);
  rep(i,m) cin >> s[i];
  
  int cnt= 0;
  for(int tmp=0;tmp < (1<<n);tmp++){
    vi hikaku(m,0);
    bitset<10> an(tmp);
    for(int i=0;i<n;i++){
      if(an.test(i)){
        //if(tmp==5) cout << i << endl;
       	rep(j,m){
        	if(a[j].count(i+1)) hikaku[j]++;
        }
      }
    }
    //if(tmp==5)rep(j,m) cout << tmp << " " << hikaku[j] << endl;
    bool ok = true;
    rep(j,m){
      if(hikaku[j]%2!=s[j]) {
        ok =false;
        //cout << "a" << tmp << " " << j << " " << hikaku[j] << " " << s[j] << endl;
      }
    }
    if(ok){
      cnt++;
      //cout << tmp << endl;
    }
  }
  cout << cnt << endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define in(a, n) for(int i=0;i<n;i++)
#define w while(t--)
#define tc int t; cin>>t;
int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
bool sortbysec(const pair<string,long long> &a,
              const pair<string,long long> &b)
{
    return (a.second < b.second);
}
long long b[1000009];
long long z[1000009];
int lcm(int a, int b)
 {
    return (a*b)/__gcd(a, b);
 }
int main()
{
    string s;
    int m=INT_MAX;
    cin>>s;
    in(s,s.length()-2)
    {
        int q=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        q=abs(q-753);
        if(q<m)
            m=q;

    }
    cout<<m;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int res=0,cnt=0;
int main()
{
	int a;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		if(i%2==0)cnt++;
		if(i%2!=0)res++;
	}
	cout<<res*cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
def main():
    N, M = map(int, input().split())

    D = dd(list)

    for m in range(M):
        a, b = map(int, input().split())
        D[a-1].append(b-1)

    for d in D[0]:
        if N-1 in D[d]:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')
        

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Measured memory_bytes: 48104
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    set<int> st[26];
    string S,T;
    cin>>S>>T;
    rep(i,0,S.size()){
        st[S[i]-'a'].insert(i);
    }
    ll a=0,b=0;
    rep(i,0,T.size()){
        if(st[T[i]-'a'].empty()){
            cout<<-1<<endl;
            return 0;
        }
        if(st[T[i]-'a'].lower_bound(b)==st[T[i]-'a'].end()){
            a++,b=0;
        }
        b=*st[T[i]-'a'].lower_bound(b);
        b++;
    }
    cout<<a*S.size()+b<<endl;
    return 0;
}




Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

vector<vector<ll>> dp(500005);
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	for(int i=0;i<N-1;i++){
		ll m = i;
		if(C*(N-1-m)-D*m <= B-A && B-A <= -C*m +(N-1-m)*D){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a[100010],stat=0;
  lp(z,4){
    if(z==0){
      a[0]=0;
      a[1]=0;
    }
    if(z==1){
      a[0]=0;
      a[1]=1;
    }
    if(z==2){
      a[0]=1;
      a[1]=0;
    }
    if(z==3){
      a[0]=1;
      a[1]=1;
    }
    int target;
    lp(i,n+1){
      if(i==0) {
        if(a[i]==0){
          if(s[i]=='o'){
            target=a[i+1];
          }
          else{
            target=abs(a[i+1]-1);
          }
        }
        else{
          if(s[i]=='x'){
            target=a[i+1];
          }
          else{
            target=abs(a[i+1]-1);
          }
        }
      }
      else{
        if(a[i]==0){
          if(s[i]=='o'){
            a[i+1]=a[i-1];
          }
          else{
            a[i+1]=abs(a[i-1]-1);
          }
        }
        else{
          if(s[i]=='x'){
            a[i+1]=a[i-1];
          }
          else{
            a[i+1]=abs(a[i-1]-1);
          }
        }
      }
    }
    if(a[n-1]==target&&a[n]==a[0]){
      stat=1;
      break;
    }
  }
  if(stat==0) cout<<-1<<endl;
  else{
    lp(i,n){
      if(a[i]==0) cout<<"S";
      else cout<<"W";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

pair<ll, ll> solve(vector<vector<ll>> g, ll N, ll x, ll y) {
	vector<ll> col(N + 1,-1);
	col[x] = 1;
	col[y] = 1;
	queue<ll> q;
	q.push(x);
	q.push(y);

	ll ret1 = 1;

	while (!q.empty()) {
		ll v = q.front();
		q.pop();

		for (ll w : g[v]) {
			if (col[w] != -1) { continue; }
			col[w] = col[v] + 1;
			q.push(w);

			ret1 = max(ret1, col[w]);
		}
	}

	vector<ll> out(ret1 + 1,0);
	repn(v, N) {
		ll i = 0;
		for (ll w : g[v]) {
			if (col[w] > col[v]) { i++; }
		}

		out[col[v]] = max(out[col[v]], i);
	}

	ll ret2 = 1;
	if (x != y) { ret2 = 2; }
	repn(i, ret1 - 1) { ret2 *= out[i]; }
	
	return{ ret1,ret2 };
}



int main() {
	ll N;
	cin >> N;

	vector<vector<ll>> g;
	g.resize(N + 1);
	repn(i, N - 1) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	pair<ll, ll> ans = { INF,INF };

	repn(v, N) {
		ans = min(ans, solve(g, N, v, v));

		for (ll w : g[v]) {
			ans = min(ans, solve(g, N, v, w));
		}
	}

	cout << ans.first << " " << ans.second << endl;
	
	
	system("PAUSE");
}


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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << a.at(0) << b.at(0) << c.at(0) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
        "sort"
)

func main() {
        var s string
        var k int
        fmt.Scanln(&s)
        fmt.Scan(&k)

        ss := make([]string, 0, 5)
        lm := len(s)
        if k < lm {
                lm = k
        }
        for l := 1; l <= lm; l++ {
                for i := 0; i < len(s)-l+1; i++ {
                        ss = append(ss, s[i:i+l])
                }
        }
        sort.Strings(ss)

        cnt := 0
        for i := range ss {
                if i >= 1 && ss[i] == ss[i-1] {
                        continue
                }
                cnt++
                if cnt == k {
                        fmt.Println(ss[i])
                        return
                }
        }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll long long
#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 all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  char s[50][50];
  int h,w;
  cin >> h >> w;
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='.')goto a;
      else if(s[i-1][j]!='#'&&s[i][j-1]!='#'&&s[i+1][j]!='#'&&s[i][j+1]!='#')goto b;
      a:;
    }
  }
  printf("Yes");
  goto c;
  b:;
  printf("No");
  c:;
}

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

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

    int n,k;
    cin >> n >> k;
    int h[n];
    rep(i,n) cin >> h[i];
    
    int dp[n];
    rep(i,n) dp[i] = INF;
    dp[0] = 0;
    
    rep(i,n){
        for(int j=1; j<=k; j++){
            if(j>n) break;
            
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    
    cout << dp[n-1] << endl;

    return 0;
}

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

int main() {
    int N; cin >> N;
    map<string, int> mp;
    for (int i=0; i<N; i++) {
        string s; cin >> s;
        mp[s]++;
    }
    int max_v = 0;
    for (auto x: mp) {
        max_v = max(int(x.second), max_v);
    }
    for (auto x: mp) {
        if ((x.second) == max_v) cout << x.first << endl;
    }
}

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

int max(int a,int b){
  int max;
  if(a>b){
    return a;    
  }
  else{
    return b;    
  }
}
int main() {

  int  a,b,sum=0;
  cin >> a >> b;

  sum+=max(a,b);
  if(a!=b) sum+=sum-1;
  else sum+=sum;
  cout << sum << endl;    

}


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

int main() {
  int a, b, i, ans;
  cin >> a >> b;
  i = a;
  ans = 0;
  
  while (i <= b) {
    if (i % 10 == (i/10000) % 10000 && (i/10) % 10 == (i/1000) % 10)
      ans += 1;
    i++;
  }
  
  cout << ans << endl;
}


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

int main() {
    int n;
    while (cin >> n, n) {
        vector<vector<int>> v(n, vector<int>(n, 0));
        int y = n/2 + 1;
        int x = n/2;
        int cnt = 1;
        while (cnt <= n * n) {
            if (v[y][x] == 0) {
                v[y][x] = cnt;
                cnt ++;
                y = (y + 1) % n;
                x = (x + 1) % n;
            } else {
                y = (y + 1) % n;
                x = (x + n - 1) % n;
            }
        }
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cout << setw(4) << v[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,shu1,shu2,point[1000005],dp[1000005];
int ans,num[1000005];
int moc(int x)
{
	if(x>=mod) return x-mod;
	if(x<0) return x+mod;
	return x;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&shu1,&shu2);
		shu1--,shu2--;
		point[shu1]|=1<<shu2;
	}
	int maxa=(1<<n)-1;
	dp[0]=1;
	for(int i=0;i<=maxa;i++)
	{
		int now=0;
		for(int j=0;j<n;j++)
		if(i>>j&1) now++;
		num[i]=1<<now;
	}
	for(int s=1;s<=maxa;s++)
	if((s&1)==(s>>1&1))
	{
		for(int ss=s;ss;ss=(ss-1)&s)
		if((ss&1)==(ss>>1&1))
		{
			int t=s^ss,now=1;
			for(int i=0;i<n;i++)
			if(ss>>i&1)
			now=1ll*now*num[point[i]&t]%mod;
			else if(t>>i&1)now=1ll*now*(num[point[i]&ss]-1)%mod;
			dp[s]=moc(dp[s]+1ll*now*dp[t]%mod);
		}
	}
	ans=1;
	for(int i=1;i<=m;i++)
	ans=moc(ans<<1);
	ans=moc(ans-dp[maxa]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4480