akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int [] a = new int[n];
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            set.add(a[i]);
        }
        if (set.size() > 2) {
            out.println("No");
        } else if (set.size() == 1) {
            out.println((a[0] == n - 1 || a[0] <= n / 2) ? "Yes" : "No");
        } else {
            int [] b = new int[2]; int j = 0;
            for (Integer i: set) b[j++] = i;
            Arrays.sort(b);
            if (b[0] + 1 != b[1]) {
                out.println("No");
            } else {
                int distinct = 0;
                for (int i = 0; i < n; i++) if (a[i] == b[0]) distinct++;
                int lo = distinct + 1; int hi = distinct + (n - distinct) / 2;
                if (b[1] >= lo && b[1] <= hi) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            }
        }
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 50404
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
char a[100], b[100];
int main()
{
    int n;
 
    scanf("%d%s%s", &n, a, b);
    long long ans = 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (a[i] == b[i]) {
                ans = 3;
            } else {
                ans = 6;
                i++;
            }
            continue;
        }
        if (a[i] == b[i]) {
            if (a[i - 1] == b[i - 1]) {
                ans *= 2;
            }
        } else {
            if (a[i - 1] == b[i - 1]) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            i++;
        }
        ans %= mod;
    }
    printf("%lld\n", ans);
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,X,Y;
string S;

int main()
{
	cin >> S;
	N = S.size();
	cin >> X >> Y;

	vector<int> a,b;
	{
		int i = 0;
		while(i < N){
			if(S [i] == 'T'){
				i++;
				break;
			}
			X--;
			i++;
		}
		while(i < N){
			int cnt = 0;
			while(i < N){
				if(S [i] == 'T'){
					i++;
					break;
				}
				cnt++;
				i++;
			}
			if(cnt) a.push_back(cnt);
			cnt = 0;
			while(i < N){
				if(S [i] == 'T'){
					i++;
					break;
				}
				cnt++;
				i++;
			}
			if(cnt) b.push_back(cnt);
		}
	}

	unordered_set<int> dpX,dpY;
	dpX.insert(0);
	dpY.insert(0);
	FOR(i,0,a.size()){
		unordered_set<int> _dpY;
		for(const auto& it : dpY){
			_dpY.insert(it - a [i]);
			_dpY.insert(it + a [i]);
		}
		dpY.swap(_dpY);
	}
	FOR(i,0,b.size()){
		unordered_set<int> _dpX;
		for(const auto& it : dpX){
			_dpX.insert(it - b [i]);
			_dpX.insert(it + b [i]);
		}
		dpX.swap(_dpX);
	}

	if(dpX.count(X) && dpY.count(Y)){
		puts("Yes");
	}
	else{
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;
#define ms(arr) memset(arr,0,sizeof(arr))
int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v;
    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        v.push_back(make_pair(i, x));
    }
    sort(v.begin(), v.end(), [](pair<ll, ll> &a, pair<ll, ll> &b) { return a.second < b.second; });
    ll max = v[n - 1].second;
    ll max1 = v[n - 2].second;
    sort(v.begin(), v.end(), [](pair<ll, ll> &a, pair<ll, ll> &b) { return a.first < b.first; });
    for (ll i = 0; i < n; ++i) {
        if (v[i].second == max) {
            cout << max1 << endl;
        } else {
            cout << max << endl;
        }
    }
}

Measured memory_bytes: 6512
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main() {
    int N, a;
    cin >> N;
    map<int, int> ma;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (ma.find(a) != ma.end()) ma[a]++;    //高々O(lg(1e5))
        else ma[a] = 1;
    }
    int max = 0;
    for (auto i : ma) {
        int left = ma.find(i.first-1) != ma.end() ? ma[i.first-1] : 0;
        int right = ma.find(i.first+1) != ma.end() ? ma[i.first+1] : 0;
        int tmp = i.second + left + right;
        if (tmp > max) max = tmp;
    }
    cout << max << endl;
}

Measured memory_bytes: 3200
import Control.Monad
import Control.Applicative
import Data.List


-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'
--
-- slst <- replicateM h getLine

-- getBysplit = map read . words <$> getLine

main :: IO()
main = do
  s <- getLine
  let n = length s
  let lst1 = map (\x -> if x `mod` 2 == 0 then '1' else '0') [1..n]
  let lst2 = map (\x -> if x `mod` 2 == 0 then '0' else '1') [1..n]
  print $ check s lst1 lst2 (0, 0)

check :: String -> String -> String -> (Int, Int) -> Int
check [] [] [] (a, b) = min a b
check (x:xs) (y:ys) (z:zs) (a, b) = check xs ys zs (ay, bz)
    where
      ay = if x == y then a else a+1
      bz = if x == z then b else b+1


Measured memory_bytes: 7164
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
	lint x;
	cin >> x;
	lint ure=0;
	ure += (x/500)*1000;
	ure += ((x%500)/5)*5;
	cout << ure << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,d,x,a;
    cin>>n>>d>>x;

    int count=0;

    for(int i=0;i<n;i++){
        cin>>a;
        count+=(d-1)/a+1;
    }

    cout<<count+x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

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

    vector<ll> ord(n);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](ll l, ll r){
        return a[l] > a[r];
    });

    vector<vector<ll>> dp(n+1, vector<ll>(n+1));
    REP(i, n) {
        REP(l, i+1) {
            ll r = i-l;
            chmax(dp[l+1][r], dp[l][r]+a[ord[i]]*abs(ord[i]-l));
            chmax(dp[l][r+1], dp[l][r]+a[ord[i]]*abs(ord[i]-(n-1-r)));
        }
    }

    ll ans = 0;
    REP(i, n+1) chmax(ans, dp[i][n-i]);
    cout << ans << endl;

    return 0;
}


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

int main()
{
    long long int a, b, c, k;
    cin >> a >> b >> c >> k;
    long long int ans = 0;
    ans += min(a, k);
    k -= a;
    k -= b;
    if (k > 0)
        ans -= min(k, c);
    cout<<ans;
}


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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<uint64_t> A;
    for (int i = 0; i < N; i++) {
        uint64_t tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    
    sort(A.begin(), A.end());

    uint64_t prev = A[0];
    for (int i = 1; i < N; i++){
        if (prev == A[i]) {
            cout << "NO";
            return 0;
        }
        prev = A[i];
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 2420
class Fixnum
  alias old_div /
  def/(b)
    if (self>0 and b<0) or (self<0 and b>0)  then
      return self.fdiv(b).to_i
    else
      return self.old_div(b)
    end
  end
end

n= gets.chomp.to_i
0.upto(n-1){|i|
  s = gets.chomp.gsub(/=/,"")
  puts eval(s)
}

Measured memory_bytes: 8700
using System.Collections.Generic;
using System;

public class Hello
{
    static int MOD = 2019;
    public static void Main()
    {
        var s = Console.ReadLine().Trim().ToCharArray();
        Array.Reverse(s);
        var n = s.Length;
        var a = new int[s.Length];
        var k = 1;
        for (int i = 0; i < n; i++)
        {
            a[i] = (k * (s[i] - '0')) % MOD;
            k *= 10;
            k %= MOD;
        }
        var b = new int[n + 1];
        for (int i = 1; i < n + 1; i++)
            b[i] = (b[i - 1] + a[i - 1]) % MOD;
        getAns(b);
    }
    static void getAns(int[] a)
    {
        var d = new Dictionary<int, int>();
        for (int i = 0; i < a.Length; i++)
        {
            if (d.ContainsKey(a[i])) d[a[i]]++;
            else d[a[i]] = 1;
        }
        var ans = 0L;
        foreach (var x in d)
            if (x.Value >= 2) ans += x.Value * (x.Value - 1) / 2L;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 19996
#include <stdio.h>
int n,i,res;
int A[20];
int main(){
  int q,ans;
  int m[200];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    ans=solve(0,m[i]);
    if(ans==1){
      printf("yes\n");
    }
    if(ans==0){
      printf("no\n");
    }
  }
  return 0;
}
int solve(int i,int m){
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  res=solve(i+1,m)|| solve(i+1,m-A[i]);
}

Measured memory_bytes: 580
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

char m[1000][1001];
int d[1000][1000];
int s[1000000][2];
int main(void){
	int h=nextint();
	int w=nextint();
	int ch=nextint()-1;
	int cw=nextint()-1;
	int dh=nextint()-1;
	int dw=nextint()-1;
	for(int i=0; i<h; i++){
		nextstr(m[i]);
	}
	int k=0;
	int sl=0, sr=0;
	d[ch][cw]=1;
	s[sl][0]=ch, s[sl][1]=cw, sr++;
	while(1){
		k++;
		if(sl==sr) break;
		int tl=sl;
		while(sl<sr){
			int x=s[sl][0], y=s[sl][1]; sl++;
			{int i=x-1, j=y; if(0<=i&&i<h&&0<=j&&j<w && m[i][j]=='.' && d[i][j]==0){ d[i][j]=k; s[sr][0]=i, s[sr][1]=j, sr++;}}
			{int i=x+1, j=y; if(0<=i&&i<h&&0<=j&&j<w && m[i][j]=='.' && d[i][j]==0){ d[i][j]=k; s[sr][0]=i, s[sr][1]=j, sr++;}}
			{int i=x, j=y-1; if(0<=i&&i<h&&0<=j&&j<w && m[i][j]=='.' && d[i][j]==0){ d[i][j]=k; s[sr][0]=i, s[sr][1]=j, sr++;}}
			{int i=x, j=y+1; if(0<=i&&i<h&&0<=j&&j<w && m[i][j]=='.' && d[i][j]==0){ d[i][j]=k; s[sr][0]=i, s[sr][1]=j, sr++;}}
		}
		if(d[dh][dw]!=0){
			printf("%d\n", k-1);
			return 0;
		}
		int tr=sr;
		while(tl<tr){
			int x=s[tl][0], y=s[tl][1]; tl++;
			if(d[x][y]==k){
				for(int i=x-2; i<=x+2; i++){
					for(int j=y-2; j<=y+2; j++){
						if(0<=i&&i<h&&0<=j&&j<w && m[i][j]=='.' && d[i][j]==0){
							d[i][j]=k+1;
							s[sr][0]=i, s[sr][1]=j, sr++;
						}
					}
				}
			}
		}
	}
	printf("%d\n", -1);
}


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

using namespace std;

typedef long long int int64;

int main() {
	int64 n, m;
	cin >> n >> m;
	if(n == 1 || m == 1) {
		cout << "1\n";
		return 0;
	}
	cout << ((n*m+1)/2) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;

int main(){

  int n;
  vector<string> vec;
  cin >> n;
  string str;
  rep(i, 3) {
    cin >> str;
    vec.push_back(str);
  }

  int chars[28];

  int res = 0;
  for (int i = 0; i < n; i++) {
    rep(j, 28) chars[j] = 0;
    for (string s : vec) {
      chars[int(s[i]) - 97]++;
    }

    char max = 0;
    int max_char = -1;
    for (int j = 0; j < 28; j++)  { if(chars[j] > max_char) {max_char = chars[j]; max = j;} }

    for (string s : vec) {
      if (s[i] != (max + 97))
        res++;
    }
  }

  cout << res << endl;

  return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
const int maxn = 105;
int a[maxn];

int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		#if __cplusplus >= 201103L
		auto start = steady_clock::now();
		#endif
	#endif
	int n = read();
	int s = 0;
	rep(i, 1, n) {
		a[i]= read();
		s += a[i];
	}
	int ans = INT_MAX;
	int s1 = 0;
	for (int i = 1; i <= n; ++i) {
		s1 += a[i];
		int dif = abs(s1 - (s - s1));
		if (dif < ans) ans = dif;
	}
	cout << ans << endl;
	#ifdef LOCAL
		#if __cplusplus >= 201103L
		auto end = steady_clock::now();
		duration<double> time_span = duration_cast<duration<double>>(end - start);;
		printf("Total time: %.6fs\n", time_span.count());
		#endif
	#endif
	return 0;
}	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
inline void print(int x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) print(x/10);
	putchar(x%10+48);
}
int n;
int a[200010];
long long ans;
long long sum[200010];
const int mod=1e9+7;
int main(){
	n=read();for(int i=1;i<=n;++i) a[i]=read();
	for(int i=n;i>=1;--i) sum[i]=(sum[i+1]+a[i])%mod;
	for(int i=1;i<=n;++i){
		ans=(ans+1ll*sum[i+1]*a[i]%mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6088
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll a,b,q;
  cin>>a>>b>>q;

  vector<ll> s(100001,INF);
  vector<ll> t(100001,2LL*INF);
  vector<ll> qq(q);


  rep(i,a){
    cin>>s[i];
  }
  rep(i,b){
    cin>>t[i];
  }
  rep(i,q){
    cin>>qq[i];

    auto s_k=distance(s.begin(),upper_bound(all(s),qq[i]));
    auto t_k=distance(t.begin(),upper_bound(all(t),qq[i]));
    //cout << s_k << "," << t_k << ":";
    //cout << s[s_k] << "," << t[t_k] << endl;

    ll before_s,before_t,after_s,after_t;

    if(s_k == 0) before_s=-INF;
    else before_s=s[s_k-1];
    if(t_k == 0) before_t=-2LL*INF;
    else before_t=t[t_k-1];



    after_s=s[s_k];
    after_t=t[t_k];

    //cout << before_s << "," << before_t << "," << after_s << "," << after_t << endl;

    cout << min( { abs(before_s-before_t)+min(abs(before_s-qq[i]),abs(before_t-qq[i])) , abs(after_s-after_t)+min(abs(after_s-qq[i]),abs(after_t-qq[i])) , abs(before_s-after_t)+min(abs(before_s-qq[i]),abs(after_t-qq[i])) , abs(before_t-after_s)+min(abs(before_t-qq[i]),abs(after_s-qq[i])) } ) << endl;

  }



  return 0;

}


Measured memory_bytes: 3712
#include<iostream>

long long dp[100][21];

int main(){
	int n;
	std::cin>>n;
	int data[100];
	for(int i=0;i<n;i++){
		std::cin>>data[i];
	}
	dp[0][data[0]]=1;
	for(int i=1;i<n-1;i++){
		for(int j=0;j<=20;j++){
			if(j+data[i]<=20)dp[i][j]+=dp[i-1][j+data[i]];
			if(j-data[i]>=0)dp[i][j]+=dp[i-1][j-data[i]];
		}
	}
	std::cout<<dp[n-2][data[n-1]]<<std::endl;
	return 0;
}

Measured memory_bytes: 1172
def c_get_ac(N, Q, S, I):
    dp = [0] * N
    count = 0
    for k, c in enumerate(S):
        if c == 'C':
            if k != 0 and S[k - 1] == 'A':
                count += 1
                dp[k] += count
    for i in range(1, N):
        dp[i] = max(dp[i], dp[i - 1])

    ans_tmp = []
    for l, r in I:
        ans_tmp.append(dp[r - 1] - dp[l - 1])
    ans = '\n'.join(map(str, ans_tmp))
    return ans

N, Q = [int(i) for i in input().split()]
S = input()
I = [[int(i) for i in input().split()] for j in range(Q)]
print(c_get_ac(N, Q, S, I))

Measured memory_bytes: 34464
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

const ll MAX = 1e6+9;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0]  = fac[1]  = 1;
    finv[0] = finv[1] = 1;
    inv[1]  = 1;

    for(ll i = 2; i < MAX; ++i){
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;

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

int main(){
    ll x, y;
    cin >> x >> y;

    if((x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }

    ll n = (2*y - x)/3;
    ll m = (2*x - y)/3;

    COMinit();

    cout << COM(n+m, min(n, m)) << endl;
}

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

using namespace std;

int main(){
  long long N; cin >> N;
  long long i,j;
  long long k=-1;
  for(i=3500;;i--){
    if(4*i-N<=0) break;
    for(j=3500;;j--){
      if(4*i*j-N*j-N*i<=0) break;
      if((N*i*j)%(4*i*j-N*j-N*i)==0){
        k=(N*i*j)/(4*i*j-N*j-N*i);
        goto LABEL;
      }
    }
  }
  LABEL:
  cout << i << " " << j << " " << k << 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;
typedef pair<int,int>P;

int x[10],y[10];
int main(){
	int n;cin>>n;
	rep(i,n)cin>>x[i]>>y[i];
	vector<int>v(n);
	rep(i,n)v[i]=i;
	double sum=0;
	int cnt=0;
	do{
		double dist=0;
		rep(i,n-1){
			int X=v[i],Y=v[i+1];
			dist+=sqrt(pow(x[X]-x[Y],2)+pow(y[X]-y[Y],2));
		}
		sum+=dist;
		cnt++;
	}while(next_permutation(v.begin(),v.end()));
	printf("%.12lf\n",sum/cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	void solve()
	{
		ll int h,w,i,j;
		cin>>h>>w;
		char ch[h][w];
		rep(i,h)
		rep(j,w)
		cin>>ch[i][j];
		ll int dp[h][w];
		memset(dp,0,sizeof dp);
		dp[h-1][w-1]=1;
		// rep(i,h){rep(j,w)cout<<dp[i][j]<<" ";
		// cout<<endl;}
		for(i=w-2;i>=0;i--)
		{
			if (ch[h-1][i]=='#')
				dp[h-1][i]=0;
			else
			{
				dp[h-1][i]=add(dp[h-1][i+1],dp[h-1][i]);
			}
		}
		// rep(i,h){rep(j,w)cout<<dp[i][j]<<" ";
		// cout<<endl;}
		for(i=h-2;i>=0;i--)
		{
			if (ch[i][w-1]=='#')
				dp[i][w-1]=0;
			else
			{
				dp[i][w-1]=add(dp[i][w-1],dp[i+1][w-1]);
			}
		}
		for(i=h-2;i>=0;i--)
		{
			for(j=w-2;j>=0;j--)
				{
					if (ch[i][j]=='#')
				dp[i][j]=0;
			else{
					ll int op1=dp[i+1][j];
					ll int op2=dp[i][j+1];
					dp[i][j]=(op1+op2)%mod;}
				}
		}
		// rep(i,h){rep(j,w)cout<<dp[i][j]<<" ";
		// cout<<endl;}
		cout<<dp[0][0]<<endl;


		
	}
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, X, Y;
    cin >> N >> X >> Y;

    // グラフ
    Graph G(N);

    REP(i, N-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X-1].push_back(Y-1);
    G[Y-1].push_back(X-1);

    vector<ll> ans(N, 0);
    REP(i, N){
        // BFS のためのデータ構造
        vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
        queue<int> que;

        // 初期条件 (頂点 0 を初期ノードとする)
        dist[i] = 0;
        que.push(i); // 0 を橙色頂点にする

        // BFS 開始 (キューが空になるまで探索を行う)
        while (!que.empty()) {
            int v = que.front(); // キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int nv : G[v]) {
                if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

                // 新たな白色頂点 nv について距離情報を更新してキューに追加する
                dist[nv] = dist[v] + 1;
                ans[dist[nv]]++;
                que.push(nv);
            }
        }
    }
    for(ll i=1; i<=N-1; i++){
        cout << ans[i]/2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;
int H, W, N, ans[101][101];
int main() {
  scanf("%d %d %d", &H, &W, &N);
  for(int i = 1, a, p; i <= N; ++i) {
    scanf("%d", &a);
    for(int j = 0; j < a; ++j, ++p) {
      ans[p/W][p%W] = i;
    }
  }
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(i%2 == 0) printf("%d", ans[i][j]);
      else printf("%d", ans[i][W-j-1]);
      if(j == W-1) printf("\n");
      else printf(" ");
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int sum=n*(n-1)/2+m*(m-1)/2;
	cout<<sum;
	return 0;
}


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

int main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 ll a,b;
 cin>>a>>b;
 cout<<((a*(a-1))/2)+((b*(b-1))/2);
}

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

int main(void){
    int n, c;
    cin >> n >> c;
    int d[35][35], co[535][535], memo[3][35];
    for(int i=0;i<3;++i){
        for(int j=0;j<35;++j){
            memo[i][j] = 0;
        }
    }
    for(int i=0;i<c;++i){
        for(int j=0;j<c;++j){
            cin >> d[i+1][j+1];
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin >> co[i][j];
            ++memo[(i+j)%3][co[i][j]];
        }
    }
    long long min = 1000000000000;
    for(int i=1;i<=c;++i){
        for(int j=1;j<=c;++j){
            if(i==j) continue;
            for(int k=1;k<=c;++k){
                if(i==k || j==k) continue;
                int tmp = 0;
                for(int p=1;p<=c;++p) tmp += d[p][i]*memo[0][p];
                for(int q=1;q<=c;++q) tmp += d[q][j]*memo[1][q];
                for(int r=1;r<=c;++r) tmp += d[r][k]*memo[2][r];
                if(min > tmp) min = tmp;
            }
        }
    }
    cout << min << endl;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

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

#define inf5 100002
#define inf9 1000000002

int main(){
	int cnt = 0;
	string s, t;
	cin >> s >> t;

	rep(i, 3)
		if (s[i] == t[i]) ++cnt;

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = np.array(read().split(), np.int32)[1:]

def f(A):
    diam = A.max()
    if np.any(2 * A < diam):
        return False
    count = np.bincount(A)
    if diam & 1:
        if count[(diam + 1) // 2] != 2:
            return False
        return np.all(count[(diam + 1) // 2:] >= 2)
    if count[diam // 2] != 1:
        return False
    return np.all(count[diam // 2 + 1:] >= 2)

print('Possible' if f(A) else 'Impossible')

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 110 B / Link: http://abc110.contest.atcoder.jp/tasks/abc110_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

// [L,R]
template<class T>
pair<T, T>common_range(vector<pair<T, T>> seg) {
	T L = seg.front().first;
	T R = seg.front().second;
	for (auto &&it : seg) {
		L = max(L, it.first);
		R = min(R, it.second);
	}
	return pair<T, T>(L, R);
}


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

	LL N, M, Y, X; cin >> N >> M >> X >> Y;
	vector<LL> x(N);
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	vector<LL> y(M);
	for (int i = 0; i < M; ++i) {
		cin >> y[i];
	}

	LL Xmax = *max_element(ALL(x));
	LL Ymin = *min_element(ALL(y));

	vector<PLL>a;
	a.push_back(PLL(X + 1, Y));
	a.push_back(PLL(Xmax + 1, Ymin));
	auto res = common_range(a);
	if (res.first <= res.second) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def equation(a,b,c,d,e,f,x):
    buff = a*e-b*d
    buff_a = a

    a = e/buff
    b = -b/buff
    d = -d/buff
    e = buff_a/buff

    x.append((a*c)+(b*f))
    x.append((d*c)+(e*f))

count = 0
a = []
b = []
c = []
d = []
e = []
f = []

while True:
    try:
        buff = input().split()
        a.append(float(buff[0]))
        b.append(float(buff[1]))
        c.append(float(buff[2]))  
        d.append(float(buff[3]))
        e.append(float(buff[4]))
        f.append(float(buff[5]))
        count += 1
    except:
        break

for i in range(count):
    ans = []

    equation(a[i],b[i],c[i],d[i],e[i],f[i],ans)
    print('{:.3f}'.format(ans[0]),'{:.3f}'.format(ans[1]))


Measured memory_bytes: 5600
// #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL
const int maxn = 1e6 + 7;
int read(){
    int x = 0; int zf = 1; char ch = ' ';
    while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}

int main(int argc, char * argv[]) 
{
	double a, b, x;
	cin >> a >> b >> x;
	double v_tri = a * a * b / 2;
	double t;
	double ans;
	if (x <= v_tri){
	//	printf("1\n");
		t = x * 2 / (b * a);
		ans = atan(b / t);
	}
	else{
	//	printf("2\n");
		t = (a * a * b - x) * 2 / (a * a);
		ans = atan(t / a);
	}
	ans = ans / M_PI * 180;
	printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
N,M = gets.split(' ').map(&:to_i)
@xy = M.times.map{ gets.split(' ').map(&:to_i) }

#@xy.sort_by!{|x| x[0]}

@parent = Array.new(N+1,&:itself)
@rank = Array.new(N+1,0)
#puts @parent

def anc(x)
  #puts "x=#{x}"
  #puts "parent[2]=#{@parent[2]}"
  if @parent[x]==x
    return x
  else
    #puts "x=#{x}"
    x=anc(@parent[x])
  end
  return x
end


M.times do |i|
  x=@xy[i][0]
  y=@xy[i][1]
  x_can = anc(x)
  y_can = anc(y)
  #puts "x_can=#{x_can},y_can=#{y_can}"
=begin
  if x_can<y_can
    senzo=x_can
  else
    senzo=y_can
  end
=end
  if @rank[x_can]>=@rank[y_can]
    @parent[y_can]=x_can
    @rank[x_can]+=1 if @rank[x_can]==@rank[y_can]
  else
    @parent[x_can]=@parent[y_can]
  end
  #@parent[x]=senzo
  #@parent[y]=senzo
  #puts @parent
  #puts "aaa"
end
ans = 0
for i in 0..N-1
  cnt = N-i
  senzo = anc(cnt)
  @parent[senzo] = senzo
  if senzo==cnt
    ans+=1
  end
end
puts ans

#puts @parent


Measured memory_bytes: 11132
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt( in.nextLine() );
        String[] params = in.nextLine().split(" ");
        int[] ps = new int[n];
        for( int i = 0 ; i < n ; i++ ){
            ps[i] = Integer.parseInt( params[i] );
        }

        int ans = 0;
        int min = ps[0];
        for( int i = 0 ; i < n ; i++ ){
            if( ps[i] <= min ){
                ans++;
                min = ps[i];
            }
        }

        System.out.println( ans );

    }

}


Measured memory_bytes: 57164
#include <iostream>
#include <stack>
#include <sstream>  
#include <string>

bool IsOp(char c)
{
    return c == '+' || c == '-' || c == '*' || c == '/';
}
int main()
{
    std::stack<int> Stack;
    // while(std::cin.eof() == false){
    // while(std::cin){
    while(true){
        std::string in;
        std::cin >> in;
        if(std::cin.eof()){
            break;
        }
        if(IsOp(in[0]) == false){
            int Num;
            std::stringstream ss;
            ss << in;
            ss >> Num;
            Stack.push(Num);
            continue;
        }
        int a = Stack.top();
        Stack.pop();
        int b = Stack.top();
        Stack.pop();

        switch(in[0]){
        case '+': Stack.push(b + a); break;
        case '-': Stack.push(b - a); break;
        case '*': Stack.push(b * a); break;
        }
    }
    std::cout << Stack.top() << std::endl;
    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
using namespace std;
//using ll = unsigned long long;
ll md=MD;
 
 
ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}


int main()
{
	IOS;
	ll n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;++i) cin>>a[i];
	bool chk[n+1];
	int cnt[n+1]={0};
	memset(chk,false,sizeof(chk));
	int x=1,t=0,c1=0;
	cnt[0]=-1;
	while(!chk[x] && k>0)
	{
		chk[x]=true;
		cnt[x]=cnt[t]+1;
		++c1;
		--k;
		t=x;
		x=a[x];
	}
	
	
	if(k==0)
	{
		cout<<x<<"\n";
		return 0;
	}
//	else --c1;
	
	
	int srt=x;
	vector<int> v;
	v.pb(x);
	v.pb(a[x]);
	x=a[x];
	while(x!=srt)
	{
		v.pb(a[x]);
		x=a[x];
	}
//	cout<<c1<<" "<<cnt[srt]<<"\n";
	int cyc=c1-cnt[x];
	//cout<<x<<" "<<c1<<"\n";
//	k-=cnt[x]
	//int cyc=;
	k=k%cyc;
//	cout<<srt<<" "<<cyc<<" "<<k<<"\n";
	cout<<v[k]<<"\n";
//	for(int i=0;i<v.size();++i)cout<<v[i]<<" ";
	return 0;
}

Measured memory_bytes: 5548
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a <= c && c <= b ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n+1];
      for(int i = 1; i <= n; i++)
        arr[sc.nextInt()] = i;
      TreeSet<Integer> idxTree = new TreeSet<>();
      long sum = 0L;
      for(int i = 1; i <= n; i++) { // value
        int idx = arr[i];
        Integer left = idxTree.lower(idx);
        Integer right = idxTree.higher(idx);
        if(left == null)
          left = 0;
        if(right == null)
          right = n + 1;
        idxTree.add(idx);
        sum += (long)(idx - left) * (long)(right - idx) * i;
      }
      System.out.println(sum);
  }
}

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

void reverse(string &s) {
	int l = 0, r = s.length() - 1;
	while (l < r) {
		swap(s[l], s[r]);
		l++; r--;
	}
}

int mod = 998244353;
string s; int K;
vector<int> a;
vector<int> ra;
int dp[310][310][310];	//dp[index][bsum][cost] = 何通り？

int main() {
	int i;
	
	cin >> s >> K;
	reverse(s);
	K = min(K, 301);
	
	int len = 0;
	rep(i, s.length()) {
		if (s[i] == '0') {
			a.push_back(len);
			len = 0;
		}
		else {
			len++;
		}
	}
	a.push_back(len);
	
	ra.resize(a.size() + 1);
	ra[0] = 0;
	rep(i, a.size()) {
		ra[i + 1] = ra[i] + a[i];
	}

	dp[0][0][0] = 1;
	rep(i, a.size()) {
		for (int bsum = 0; bsum <= ra[i]; bsum++) {
			for (int cst = 0; cst <= ra[i]; cst++) {
				if (dp[i][bsum][cst] == 0) continue;
				for (int b = 0; bsum + b <= ra[i + 1]; b++) {
					int plus = a[i] - b;
					if (plus < 0) plus = 0;
					dp[i + 1][bsum + b][cst + plus] += dp[i][bsum][cst];
					if (dp[i + 1][bsum + b][cst + plus] >= mod) {
						dp[i + 1][bsum + b][cst + plus] -= mod;
					}
				}
			}
		}
	}
	
	//dp[a.size()][*][≦K]
	int ans = 0;
	for (int bsum = ra[a.size()]; bsum <= ra[a.size()]; bsum++) {
		for (int cst = 0; cst <= K; cst++) {
			//cout << "dp[" << a.size() << ", " << bsum << ", " << cst << "] = " << dp[a.size()][bsum][cst] << endl;
			ans += dp[a.size()][bsum][cst];
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30912
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,t;cin>>a>>b>>t;
    cout<<t/a*b<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;cin>>N;
  if(N == 1)
  {
    cout<<0<<endl;
    return;
  }
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  vector<int> vec2 (N,0);
  for (int i = 0; i < N; i++)
  {
    vec2[vec[i]-1] = i;
  }
  // DEBUG(vec2);
  int ANS = 0;
  vec2.push_back(-1);
  for (int i = 0; i < N - 1; i++)
  {
    int str = i;
    while(vec2[i+1] > vec2[i])i++;
    chmax(ANS,i - str + 1);
  }
  // DEBUG(ANS);
  cout<<N - ANS<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

int main() {
  uint N, X = 0;
  std::cin >> N >> X;

  uint sum = 0, min = 1001;
  for (size_t i = 0; i < N; i++) {
    uint m_i = 0;
    std::cin >> m_i;

    sum += m_i;
    if (m_i < min) min = m_i;
  }

  // std::vector<uint> m(N);
  // for(auto &&m_n:m) std::cin >> m_n;

  std::cout << N + (X - sum) / min << std::endl;

  return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << "\n";
    return 0;
}

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

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int res = 0;
        for (int i = 1; i <= a[0]; i++)
        {
            int sum = 0;
            foreach (var digit in i.ToString())
            {
                sum += digit - '0';
            }
            if (a[1] <= sum && sum <= a[2]) res += i;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N;
    cin>>N;
    VI a(N);
    REP(i,N)cin>>a[i];
    V<ll> ans(N,0);
    ll sum=0;
    REP(i,N){
        if(i%2==0)sum+=a[i];
        else sum-=a[i];
    }
    ans[0]=sum;
    ans[N-1]=a[N-1]*2-ans[0];
    REPR(i,N-2)ans[i]=a[i]*2-ans[i+1];
    REP(i,N)cout<<ans[i]<<endl;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  vector<int> B(N,-1),C(N,-1);
  B[0]=C[N-1]=0;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int I=Q.front();
    Q.pop();
    for(int i:A[I])
      if(B[i]==-1){
        B[i]=B[I]+1;
        Q.push(i);
      }
  }
  Q.push(N-1);
  while(!Q.empty()){
    int I=Q.front();
    Q.pop();
    for(int i:A[I])
      if(C[i]==-1){
        C[i]=C[I]+1;
        Q.push(i);
      }
  }
  int a=0,b=0;
  for(int i=0;i<N;i++){
    if(B[i]<=C[i])a++;
    else b++;
  }
  puts(a>b?"Fennec":"Snuke");
}

Measured memory_bytes: 10972