akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
using namespace atcoder;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 998244353

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

typedef long long ll;
typedef pair<ll, ll> p;

using mint = modint998244353;
struct S{
  mint x, w;
  S(mint x=0, mint w=1): x(x), w(w){}
};

S op(S a, S b){
  return S(a.x*b.w + b.x, a.w*b.w);
}

S e() {return S();}

S mapping(int f, S a){
  if(f == 0) return a;
  return S((a.w-1)/9 * f, a.w);
}

int comp(int f, int g){
  if(f == 0) return g;
  return f;
}

int id(){ return 0;}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, q;
  cin >> n >> q;

  lazy_segtree<S, op, e, int, mapping, comp, id> t(n);

  rep(i, n) t.set(i, S(1, 10));
  while(q--){
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    t.apply(l, r, d);
    // S ans = t.prod(0, n);
    // cout << ans.x.val() << endl;
    cout << t.all_prod().x.val() << endl;
  }
}


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

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

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    multiset<int, greater<int>> ms;
    for (int a : A)
        ms.insert(a);

    // make pair
    int npair = 0;
    while (!ms.empty())
    {
        auto it_a = ms.begin();
        int a = *it_a;
        ms.erase(it_a);

        int power_of_two = pow(2, (int)floor(log2(a)) + 1);
        int b = power_of_two - a;
        auto it_b = ms.find(b);
        if (it_b == ms.end())
            continue;
        ms.erase(it_b);
        npair++;
    }

    cout << npair << endl;
}

Measured memory_bytes: 10368
#include <iostream>

int main()
{
	int a,b;
	std::cin >> a;
	std::cin >> b;
	
	while(a && b)
	{
		if(a>b) a = a%b;
		else b = b%a;
	}
	
	std::cout << a+b << std::endl;
	return 0;
}

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

i = n - 1
while i >= 0:
    print(a[i], end=' ')
    i -= 2

if n % 2 == 1:
    i = 1
else:
    i = 0

while i <= n - 1:
    print(a[i], end=' ')
    i += 2

print()


Measured memory_bytes: 22008
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,n=0,w=0;
  std::cin >> x>>y;
  if(x>9){
    std::cout << y << '\n';
  }else{
    std::cout << y+100*(10-x) << '\n';
  }
}


Measured memory_bytes: 256
import sys
#import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
li=[rl() for _ in range(n)]
li.sort(key=lambda x: x[1])
sum_=0
for i in range(n):
    sum_+=li[i][0]
    if sum_>li[i][1]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 113964
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int A, B;

int main(){
  cin >> A >> B;

  cout << max(max(A + B, A * 2 - 1), B * 2 - 1) << endl;

  return 0;
}


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

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

Measured memory_bytes: 1160
/* ex4_3 KitamoriFumiya */
#include <stdio.h>

// 積雪の高さを計算して出力する関数
void snow(int west, int east){
	int difference, snow_height; // difference(西の塔の高さと東の塔の高さの差), snow_height(積雪の高さ)をint型の整数として宣言
	difference = east - west; // differenceを計算
	snow_height = 0; // 積雪の高さは初めは0としておく
	// まず、西の塔の高さを求める
	int level = 1; // 塔の高さは西から1,(1+2),(1+2+3)となっていくので初めのlevel(高さの増加分)は1とする
	// levelがdifferenceより小さい時、積雪の高さをを増加させる
	// ここで求めた積雪の高さは上の方が見えている西の塔の高さ
	while (level < difference){
		snow_height = snow_height + level; // levelの分だけ高さを増加
		level++; // 高さの増加分を1増やす
	}
	snow_height = snow_height - west; // 求めた西の塔の高さから見えている部分を引いて積雪の高さを求める
	printf("%d\n", snow_height); // 積雪の高さを出力
}

int main(){
	int west, east; // west(西の塔の見えている部分の高さ), east(東の塔の見えている部分の高さ)をint型の整数として宣言
	scanf("%d %d", &west, &east); // westとeastを入力
	
	snow(west, east); // 積雪の高さを計算して出力する関数を実行
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        long count = 0;
        HashMap<String, Integer> hash = new HashMap<>();

        for(int i = 0; i < n; i++){
            char[] charArray = sc.next().toCharArray();
            Arrays.sort(charArray);
            String str = String.valueOf(charArray);
            if(hash.containsKey(str)){
                hash.put(str, hash.get(str) + 1);
                count += hash.get(str);
            } else {
                hash.put(str, 0);
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 54524
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;

int main()
{

    ll a, b, c;

    cin >> a >> b >> c;
    ll d=c-a-b;
    cout << solve(4 * a * b < d*d and d>0) << endl;
}


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

int main()
{
	string s;
	cin>>s;
	int ans = 0;
	for(int i=0; i<s.length(); i++)
	{
		ans += (s[i]-'0');
	}
	(ans%9)? cout<<"No"<<endl : cout<<"Yes"<<endl;
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

#define POS(i, j, k) (((i) * (n + 1) + (j)) * (n + 1) + (k))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  double *dp = ALLOC ((n + 1) * (n + 1) * (n + 1), double);
  const double p = (double) 1 / n;
  for (i32 i = 0; i <= n; ++i) {
    for (i32 j = 0; j <= n - i; ++j) {
      for (i32 k = (i == 0 && j == 0 ? 1 : 0); k <= n - i - j; ++k) {
        double e = 1;
        if (i > 0) e += i * p * dp[POS(i - 1, j + 1, k)];
        if (j > 0) e += j * p * dp[POS(i, j - 1, k + 1)];
        if (k > 0) e += k * p * dp[POS(i, j, k - 1)];
        dp[POS(i, j, k)] = e / ((i + j + k) * p);
      }
    }
  }
  i32 *cnt = ALLOC (3 + 1, i32);
  for (i32 i = 0; i < n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    cnt[a]++;
  }
  double ans = dp[POS(cnt[3], cnt[2], cnt[1])];
  printf ("%.10f\n", ans);
}

int main (void) {
  run();
  return 0;
}


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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=3e5+50;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;
vector<ll> adj[maxn];

ll gt[maxn];
ll dp[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //freopen("FRAC.INP", "r", stdin);
    // freopen("WALKING.OUT", "w", stdout);
   ll k ,a ,b ;
   cin>>k>>a>>b;
   ll t= b/k-(a-1)/k;
   if (t>0)
   {
       cout <<"OK";

   }
   else
   {
       cout <<"NG";

   }

}


Measured memory_bytes: 10728
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new B().doIt();
    }
    class B{
    	int DP(int map[][],int n,int m,int C[],int D[]){
    		int length = m - n + 1;
    		for(int i = 0;i < length;i++)map[0][i] = C[i] * D[0];
    		for(int i = 1;i < n;i++){
    			for(int j = i;j < i + length;j++){
    				for(int k = j;k < i + length;k++){
    					map[i][k] = Math.min(map[i][k],D[i] * C[k] + map[i-1][j-1]);
    				}
    			}
    		}
    		int result = Integer.MAX_VALUE;
    		for(int i = 0;i < m;i++)result = Math.min(map[n-1][i], result);
    		return result;
    	}
        void doIt(){
        	int n = sc.nextInt();
        	int m = sc.nextInt();
        	int D[] = new int[n];
        	int C[] = new int[m];
        	int map[][] = new int [n][m];
        	for(int i = 0;i < n;i++)Arrays.fill(map[i], Integer.MAX_VALUE);
        	for(int i = 0;i < n;i++)D[i] = Integer.parseInt(sc.next());
        	for(int i = 0;i < m;i++)C[i] = Integer.parseInt(sc.next());
        	System.out.println(DP(map,n,m,C,D));
//        	for(int i = 0;i < n;i++){
//        		for(int j = 0;j < m;j++){
//        			System.out.print(map[i][j]+" ");
//        		}
//        		System.out.println();
//        	}
        }
    }
}

Measured memory_bytes: 38920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y, z;
  int ans;
  
  cin >> x >> y >> z;
  
  ans = x / (y + z);
  
  if(x % (y + z) < z) ans--;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val ab = inputs.head.split(" ").map(_.toInt)
  val a = ab(0)
  val b = ab(1)

  println(solve(a, b))

  private def solve(a: Int, b: Int): Int = {
    (a + b) % 24
  }
}

Measured memory_bytes: 54936
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

//1 -> 2 -> 4
 //|
 //V
//3


//1-2 3

//2-4 5

//1-3 5
const int mxN = 1e5 + 7;
vector<pair<int,int>> adj[mxN];
bool visited[mxN], ans[mxN];

void dfs(int i, ll summ){
	if(!visited[i]){
		visited[i] = 1;
		if(summ&1) ans[i] = 1;
		for(auto neigh : adj[i]) dfs(neigh.first, summ + neigh.second);
	}
}

void solve(){
	int n; cin >> n;
	FOR(n-1){
		int u,v,w; cin >> u >> v >> w;
		--u,--v;
		adj[u].pb({v,w});
		adj[v].pb({u,w});
	}
	dfs(0,0);
	FOR(n) cout << ans[i] << '\n';
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 10564
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector dp(n+1, 0LL);
    ll sum = a[0];
    dp[0] = dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        if(i % 2 == 0){
            dp[i] = max(dp[i-2] + a[i-1], sum);
            if(i < n)sum += a[i];
        }
        else {
            dp[i] = max(dp[i-2] + a[i-1], dp[i-1]);
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 6356
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long []a = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextLong();
		}
		scan.close();
		if(N >= 2) {
			long ans = 0;
			for(int i = 0; i < N; i++) {
				ans += a[i];
			}
			ans -= N;
			System.out.println(ans);
			System.exit(0);
		}
		long c =  lcm(a[0], a[1]);
		if(N == 2) {
			long ans = (c - 1) % a[0] + (c - 1) % a[1];
			System.out.println(ans);
			System.exit(0);
		}
		for(int i = 2; i < N; i++) {
			c = lcm(c, a[i]);
		}
		long ans1 = 0;
		for(int i = 0; i < N; i++) {
			ans1 += (c - 1) % a[i];
		}

		long ans2 = 0;
		for(int i = 0; i < N; i++) {
			ans2 += (c + 1) % a[i];
		}

		long k = Math.max(ans1, ans2);
		System.out.println(k);


	}
	static long gcd(long a, long b) {
		long v0 = a, v1 = b, v2 = a % b;
		  while (v2 != 0) {
		    v0 = v1;
		    v1 = v2;
		    v2 = v0 % v1;
		  };
		  return v1;
		}

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

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

int main() {
  int h,w;
  cin>>h>>w;
for(int i=0;i<h;i++) for(int j=0;j<w;j++){
  string s;
  cin>>s;
  if(s=="snuke"){
    cout<<char('A'+j)<<i+1<<endl;
  }
}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=105;
const ll INF=1LL<<50;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int M;cin>>M;
        map<string,vector<bool>> MA;
        for(int i=0;i<M;i++){
            string S;
            int a,b;cin>>S>>a>>b;
            vector<bool> A(256);
            for(int j=a;j<=b;j++) A[j]=1;
            
            MA[S]=A;
        }
        
        int N;cin>>N;
        bool ans=true;
        stack<vector<bool>> ST;
        
        for(int i=0;i<N;i++){
            string S;cin>>S;
            if(S=="+"||S=="-"||S=="*"||S=="/"){
                vector<bool> ne(256),A,B;
                B=ST.top();
                ST.pop();
                A=ST.top();
                ST.pop();
                
                for(int j=0;j<256;j++){
                    for(int k=0;k<256;k++){
                        if(A[j]&&B[k]){
                            if(k==0&&S=="/"){
                                ans=false;
                                continue;
                            }
                            
                            if(S=="+"){
                                ne[(j+k)%256]=1;
                            }else if(S=="-"){
                                ne[(256+j-k)%256]=1;
                            }else if(S=="*"){
                                ne[j*k%256]=1;
                            }else{
                                ne[j/k]=1;
                            }
                        }
                    }
                }
                
                ST.push(ne);
            }else if('0'<=S[0]&&S[0]<='9'){
                int a=stoi(S);
                vector<bool> ne(256);
                ne[a]=1;
                ST.push(ne);
            }else{
                vector<bool> ne=MA[S];
                ST.push(ne);
            }
        }
        
        if(ans) cout<<"correct"<<endl;
        else cout<<"error"<<endl;
        
        break;
    }
}





Measured memory_bytes: 3256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n = 0, a,b,m = 0,counter = 0;
	string in;
	vector<ll>vec;
	cin >> n>>a>>b;
	cout << min(n*a, b) << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void solve(){
   int n;
   cin >> n;

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

   vector<int> b = a;
   sort(a.begin(), a.end());
   //make sure vector is sorted
   ((a).erase(unique((a).begin(), (a).end()), (a).end()));

   for (int i = 0; i < n; ++i)
   {
      int x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
      b[i] = x;     
   }

   int maxx = *max_element(b.begin(), b.end());
   vector<int> fst(maxx+1, -1), lst(maxx+1, -1);

   for (int i = 0; i < n; ++i)
   {
      if(fst[b[i]] == -1)
         fst[b[i]] = i;
      lst[b[i]] = i;
   }

   vector<int> dp(maxx+1);
   int prev = -1;
   for (int i = 0; i <= maxx; ++i)
   {
      if(prev != -1 and lst[prev] < fst[i]){
         dp[i] = dp[prev] + 1;
      }
      else{
         dp[i] = 1;
      }

      prev = i;
   }

   cout<<maxx - *max_element(dp.begin(), dp.end()) + 1;
}

int32_t main(){_
   
   int q = 1;

   // cin >> q;
   
   while(q--){
      solve();         
      cout<<endl;
   }      

   return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];
    
    int ans=1;
    bool up=0,dn=0;
    for(int i=1;i<N;i++)
    {
        if(a[i-1]<a[i]){
            if(dn) ans++,up=dn=0;
            else up=1;
        }
        if(a[i-1]>a[i]){
            if(up) ans++,up=dn=0;
            else dn=1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>

using namespace std;

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	int cnt = 0;

	sort(a, a + 3);
	if (a[0] % 2 != a[1] % 2) {
		a[0]++;
		a[2]++;
		cnt++;
	}

	for (;;) {
		if (a[1] == a[2])
			break;
		a[0]++;
		a[1]++;
		cnt++;
	}
	for (;;) {
		if (a[0] == a[2])
			break;
		a[0] += 2;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m,c;
    cin >> n >> m >> c;
    vi b(m);
    rep(i,m)cin >> b[i];
    int ans=0;
    rep(i,n)
    {
        int num=0;
        rep(j,m)
        {
            int a;
            cin >> a;
            num+=b[j]*a;
        }
        if(num+c>0)++ans;
    } 
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
ll inf = -1;
ll mod = pow(10, 9) + 7;

int main() {
	string s;cin>>s;
	sort(s.begin(),s.end());
	if((s[0]==s[1]&&s[2]==s[3])&&s[1]!=s[2]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main(){
  long long int w, h, v, t, x, y, p, q;
  cin >> w >> h >> v >> t >> x >> y >> p >> q;
  long long int r = v*t;
  long long int ans = 0LL;
  for(int i = 0; i < 2; ++i){
    for(int j = 0; j < 2; ++j){
      long long int m = (-r+x)/2/w - 1;
      long long int k = 2*w*m - (1-2*i)*p;
      int d = (1-2*j);
      while(k < r + x && (k-x)*(k-x) + (d*q-y)*(d*q-y) > r*r && (k-x)*(k-x) + (2*h+d*q-y)*(2*h+d*q-y) > r*r) k += 2*w;
      while((k-x)*(k-x) + (d*q-y)*(d*q-y) <= r*r || (k-x)*(k-x) + (2*h+d*q-y)*(2*h+d*q-y) <= r*r){
	long long int l = sqrt(r*r - (k-x)*(k-x));
	ans += (l+y-d*q)/2/h - (-l+y-d*q)/2/h + 1;
	if((k-x)*(k-x) + (d*q-y)*(d*q-y) > r*r && (k-x)*(k-x) + (2*h+d*q-y)*(2*h+d*q-y) <= r*r) --ans;
	k += 2*w;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
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> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 998244353;

ll dp[4010][4010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;
  ll n = s.size();

  vector<ll> r, b;
  REP(i, n) {
    if(s[i] == '0') { r.push_back(i); r.push_back(i); }
    else if(s[i] == '1') { r.push_back(i); b.push_back(i); }
    else { b.push_back(i); b.push_back(i); }
  }

  dp[0][0] = 1;
  REP(i, r.size()+1) REP(j, b.size()+1) {
    // x回目の操作で取れるのはx人目が持ってるボールまで
    if(i<r.size() && r[i]<=i+j) (dp[i+1][j] += dp[i][j]) %= MOD;
    if(j<b.size() && b[j]<=i+j) (dp[i][j+1] += dp[i][j]) %= MOD;
  }
  cout << dp[r.size()][b.size()] << endl;

  return 0;
}

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

const int MAXN = 2001;

int n, max_diam;
vector<int> nxt[MAXN];
vector<pair<int, int> > edges;

bool vis[MAXN];

int get_tree_size(int v, int depth) {
    vis[v] = 1;
    int ret = 0;
    if(depth < max_diam / 2) {
        for(int w : nxt[v]) {
            if(!vis[w]) {
                ret += get_tree_size(w, depth + 1);
            }
        }
    }
    return ret + 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> max_diam;
    for(int i = 0; i < (n-1); i++) {
        int a, b;
        cin >> a >> b;
        edges.push_back(make_pair(a, b));
        nxt[a].push_back(b);
        nxt[b].push_back(a);
    }
    
    int ans = MAXN;
    
    if(max_diam % 2 == 0) {
        for(int v = 1; v <= n; v++) {
        
            for(int w = 1; w <= n; w++) vis[w] = 0;
            
            int a = get_tree_size(v, 0);
            ans = min(ans, n - a);
        }   
    } else {
        for(int e = 0; e < (n-1); e++) {
        
            for(int w = 1; w <= n; w++) vis[w] = 0;
            
            int v = edges[e].first,
                w = edges[e].second;
                
            vis[v] = vis[w] = 1;
            int av = get_tree_size(v, 0),
                aw = get_tree_size(w, 0);
            ans = min(ans, n - (av + aw));
        }
    }
    
    cout << ans << '\n';
    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

bitset<2000001> bs;

int main() {
	make(n);
	makev(v, n);
	sort(all(v));
	int sum = 0;
	FOR(i,0,n) sum += v[i];
	bs.set(0);
	FOR(i,0,n) {
		bs |= (bs << v[i]);
	}
	int ans = 0;
	int k = 0;
	while (k+k<=sum) {
		if (bs.test(k)) ans = k;
		k++;
	}
	printf("%d\n", sum - ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

set<char> st;
bool fn(string N){
	REP(i,(int)N.length())
		if(st.find(N[i])!=st.end()) return false;
	
	return true;
}

int main(void){
	int N,K;
	char number;
	
	cin>>N>>K;
	REP(i,K){
		cin>>number;
		st.insert(number);
	}

	int i=N;
	while(1){
		if(fn(to_string(i))){
			cout<<i<<endl;
			break;
		}
		i++;
	}
	return 0; 
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        cout<<fixed;
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int a[11234];
int b[11234];
double c[11234];
double d[11234];


namespace _DSU{
    int cnt=0;
    int mem[2][21234];
    int* get(){
        cnt=(cnt+1)%2;
        return mem[cnt];
    }
}
class UnionFind{
private:
    int *par,*rank;
    int find(int x){
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
    }
public:
    UnionFind(int n,int *par,int *rank) :par(par),rank(rank){
	for(int i = 0; i < n; i++)par[i] = i,rank[i] = 0;
    }
        UnionFind(int n):UnionFind(n,_DSU::get(),_DSU::get()){}
    bool unite(int x, int y){
	x = find(x);y = find(y);
	if (x == y)return false;
	if (rank[x] < rank[y]) par[x] = y;
	else{
	    par[y] = x;
	    if (rank[x] == rank[y])rank[x]++;
	}
	return true;
    }
    bool same(int x, int y){
	return find(x) == find(y);
    }
};

typedef pair<double,int> P;
int main(){
    int n,m;
    cin>>n>>m;
    REP(i,m){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<P> E(m);
    double ok=1e11,ng=0;
    auto f=[&](double x){
        UnionFind uf(n);
        REP(i,m)E[i]=P(d[i]-c[i]*x,i);
        sort(ALL(E));
        reverse(ALL(E));
        double ret=0;
        REP(i,m){
            int e=E[i].se;
            if(!uf.unite(a[e],b[e])){
                ret+=E[i].fi;
            }
        }
        return ret<=0;
    };
    REP(i,300){
        const double mid=(ok+ng)/2;
        if(f(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m;
char s1[200000],s2[200000];
while(cin>>s1>>s2){
    i=strlen(s1);
    j=strlen(s2);
    if(i>j) cout<<"GREATER"<<endl;
    else if(i<j) cout<<"LESS"<<endl;
    else{ l=0;
        for(k=0;k<i;k++){
            if(s1[k]>s2[k]){cout<<"GREATER"<<endl;l++; break;  }
            else if(s1[k]<s2[k]) {cout<<"LESS"<<endl;l++; break;  }
        }
        if(l==0) cout<<"EQUAL"<<endl;
    }
} return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[7];
  scanf("%s", s);
  if (strcmp(s, "Sunny") == 0){
    printf("Cloudy");
  }else{
    if (strcmp(s, "Cloudy") == 0){
    printf("Rainy");
    }else{
      printf("Sunny");
    }
  }
      return 0;
      }


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int r = sc.nextInt();
		int c = sc.nextInt();
		int K = sc.nextInt();
		long[][] rcv = new long[r][c];
		for(int i = 0; i < K; i++){
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			rcv[x][y] = sc.nextLong();
		}
		
		// 計算
		long result = 0;
		long[][][] dp = new long[r][c][4];
		if(rcv[0][0] > 0) dp[0][0][1] = rcv[0][0];
		for(int i = 0; i < r; i++){
		    for(int j = 0; j < c; j++){
		        for(int k = 0; k < 4; k++){
		            if(j-1 >= 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
		            if(j-1 >= 0 && k-1 >= 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + rcv[i][j]);
		            if(i-1 >= 0) dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][k]);
		            if(i-1 >= 0) dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][k] + rcv[i][j]);
		        }
		    }
		}
		
		for(int k = 0; k < 4; k++){
		    result = max(result, dp[r-1][c-1][k]);
		}
		//System.out.println(Arrays.deepToString(dp));
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 675356
#include "bits/stdc++.h"
using namespace std;
int main() {
	string s;
	cin >> s;

	int cnt = 0;
	for (int i = 0; i < s.size() / 2; i++) {
		if (s.at(i) != s.at(s.size() - i - 1)) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a[0]%=m
for i in range(n-1):
  a[i+1]=((a[i+1]+a[i]) % m)
dict={}
dict[0]=1;ans=0
for i in range(n):
  try:ans+=dict[a[i]]
  except:dict[a[i]]=0
  dict[a[i]]+=1
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double btc=380000;
    double ans=0;
    REP(i,n){
        double x;
        string s;
        cin>>x>>s;
        if(s=="JPY") ans+=x;
        else ans+= x*btc;
    }
    printf("%.5lf\n",ans);
}

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

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

ll N,K;
  cin>>N>>K;
  
ll ans=min(N%K,K-N%K);
  cout<<ans<<endl;

  
  
}



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

ll sum_lr(string s, ll left, ll right) {
  return stoll(s.substr(left, right - left + 1));
}

int main() {
  string s;
  cin >> s;
  
  ll n = s.size();
  ll ans = 0;
  
  for (int i = 0; i < (1 << n - 1); i++) {
    bitset<10> b(i);
    
    ll cnt = 0;
    ll left = 0;
    for (int j = 0; j < n; j++) {
      if (b.test(j) || j == n - 1) {
        cnt += sum_lr(s, left, j);
        left = j + 1;
      }
    }
    ans += cnt;
  }
  cout << ans << endl;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

   int X;
   cin >> X;

   if(X == 3 || X == 5 || X == 7){
       cout << "YES" << endl;
   }else{
       cout << "NO" << endl;
   }

}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 256
import numpy as np
k=int(input())
t=np.array([49+((k-1)//50+1)]*50)
for i in range(0 if k%50==0 else 50-k%50):
    k=np.argmax(t)
    t+=1
    t[k]-=50+1
print(50)
print(*t)

Measured memory_bytes: 12420
from collections import deque
h,w = map(int,input().split(" "))
s = [input() for _ in range(h)]
 
ans = 0
direcion = [(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            continue
        que = deque([(j,i)])
        dist = [[0]*w for _ in range(h)]
        visited = [[0]*w for _ in range(h)]
        visited[i][j] = 1
        while que:
            j, i = que.popleft()
            for x,y in direcion:
                n_x,n_y = j+x,i+y
                if not 0 <= n_x < w: continue
                if not 0 <= n_y < h: continue
                if visited[n_y][n_x]: continue
                if s[n_y][n_x] == "#": continue
                visited[n_y][n_x] = 1
                dist[n_y][n_x] = dist[i][j] + 1
                que.append((n_x,n_y))
        ans = max(ans,max(max(row) for row in dist))
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<ll> l;
  l.push_back(2);  // l0 = 2
  l.push_back(1);  // l1 = 1
  for (int i = 2; i <= n; i++) {
    l.push_back(l[i - 2] + l[i - 1]);
  }
  cout << l[n] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int alength=200000;

int main() {
	int k;string s;
    cin>>k>>s;
    if(s.length()<=k){
        cout<<s;
    }else{
        fori(k){cout<<s[i];}
        cout<<"...";
    }
}

Measured memory_bytes: 3628
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc164
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc164B();
			Console.Out.Flush();

        }

        public static void solve_abc164B()
        {
            int[] abcd = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = abcd[0];
            int b = abcd[1];
            int c = abcd[2];
            int d = abcd[3];
            if ((c + b - 1) / b <= (d + a - 1)/ d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public static void solve_abc164A()
        {
            int[] sw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            if (sw[1] >= sw[0])
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 28332
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int main() {
	int r, d; long long int x; std::cin >> r >> d >> x;
	for (auto i = 1; i <= 10; ++i) {
		x = r * x - d;
		std::cout << x << '\n';
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int cnt = 0;
	int subcnt = 0;
	for( int i = 0; i < n-1; ++i ){
		if( s[i] == 'R' && s[i+1] == 'L' ) ++cnt;
	}
	if( s[0] == 'L' ) ++subcnt;
	if( s[n-1] == 'R' ) ++subcnt;
	// cout << 2*cnt << ' ' << subcnt << ' ' << 2*min(k, cnt) << ' ' << subcnt << ' ' << k-min(k, cnt) << endl;
	cout << min(n-1, n - ( 2*cnt + subcnt - 2*min(k, cnt) - min(subcnt, k-min(k, cnt)) )) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005
 
ll n,m;
vi adj[N];
bool vis[N];
vi top;
ll dp[N];
void dfs(ll x)
{
    vis[x]=1;
    for(auto u:adj[x])
    {
        if(!vis[u])
        {
            dfs(u);
        }
    }
    top.pb(x);
}
void solve()
{
    cin>>n>>m;
    rep(i,0,m)
    {
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
        // adj[y].pb(x);
    }
    dp[0]=-1;
    rep(i,1,n+1)
    {
        if(!vis[i])
            dfs(i);
    }
    reverse(all(top));
    for(auto i:top)
    {
        for(auto u:adj[i])
        {
            dp[u]=max(dp[u],dp[i]+1);
        }

    }
    ll ans=0;
    rep(i,1,n+1)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	ll res, rem;
	res = rem = 0;
	while (n--) {
		ll a; cin >> a;
		if (a && rem) {
			res++;
			a--;
		}
		res += a / 2;
		rem = a % 2;
	}
	cout << res << '\n';
	return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, b, c;
  std::cin >> a >> b >> c;

  for (int64_t i = 0; i < b; i++) {
    if ((a * i) % b == c) {
      std::cout << "YES" << std::endl;
      return 0;
    }
  }

  std::cout << "NO" << std::endl;
  return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) = {
    import scala.io.StdIn.readLine

    val n = readLine.toInt
    val v = readLine.split(" ").take(n).map(_.toInt)
    val c = readLine.split(" ").take(n).map(_.toInt)

    val deltas = for {
      i <- (0 until n)
      if (v(i) - c(i) > 0)
    } yield v(i) - c(i)

//    println(deltas.foldLeft(0) { (acc, x) => acc + x })
    println(deltas.sum)
  }
}

Measured memory_bytes: 27320