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

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  unordered_set<int> st;
  for (int i = 1, a; i <= n; ++i) {
    cin >> a;
    st.insert(a);
  }
  if ((int)st.size() == n) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 8520
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
  int b[100],c=0;
  string a;
  cin>>a;
  for(int i=0;i<a.size();i++){
    for(int j=0;j<a.size();j++){
      if(j==i)continue;
      if(a[i]==a[j]){
        c++;
      }
    }
  }
  if(c==0)printf("yes");
  else printf("no");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
using namespace std;
map<int,int> result;
int test(int i, int n){
  i = i%n;
  if(result.find(i)!=result.end()) return result[i];
  cout<<i<<endl;
  string s;
  cin>>s;
  switch(s[0]){
    case 'V':
        exit(0);
    case 'M':
        result[i] = 1;
        return 1;
    case 'F':
        result[i] = 2;
        return 2;
  }
}
void solve(int x, int y, int n){
   int a = test(x,n);
   int m = (x+y)/2;
   int b = test(m,n);
  if((m-x)%2){
    if(a==b) solve(x,m,n);
    else solve(m,y,n);
  }else{
    if(a==b) solve(m,y,n);
    else solve(x,m,n);
  }
}
int main(){
  int n;
  cin>>n;
  solve(0,n,n);
  return 0;
}

Measured memory_bytes: 852
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

static constexpr intmax_t MOD = 1e9+7;

struct matrix {
  size_t n;
  std::vector<std::vector<intmax_t>> body;

  matrix(size_t n): n(n), body(n, std::vector<intmax_t>(n)) {}

  matrix operator *(const matrix& other) const {
    matrix a(n);
    for (size_t i = 0; i < n; ++i)
      for (size_t j = 0; j < n; ++j)
        for (size_t k = 0; k < n; ++k)
          (a[i][j] += body[i][k] * other[k][j]) %= MOD;

    return a;
  }

  matrix& operator *=(const matrix& other) {
    return (*this = *this * other);
  }

  const std::vector<intmax_t>& operator [](size_t i) const {
    return body[i];
  }

  std::vector<intmax_t>& operator [](size_t i) {
    return body[i];
  }
};

matrix fpow(const matrix& mat, intmax_t iexp) {
  size_t n = mat.n;
  matrix res(n);
  for (size_t i = 0; i < n; ++i) res[i][i] = 1;
  for (matrix dbl = mat; iexp; iexp >>= 1) {
    if (iexp & 1) res *= dbl;
    dbl *= dbl;
  }
  return res;
}

int main() {
  size_t N;
  intmax_t K;
  scanf("%zu %jd", &N, &K);

  matrix a(N);
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j)
      scanf("%jd", &a[i][j]);

  matrix b = fpow(a, K);
  intmax_t res = 0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j)
      (res += b[i][j]) %= MOD;
       
  printf("%jd\n", res);
}


Measured memory_bytes: 384
n = int(input())

t = 0
h = 0

for i in range(n) :
    T, H = map(str, input().split())
    
    if T > H :
        t += 3
    elif T < H :
        h += 3
    else :
        t += 1
        h += 1
        
print(t, h)


Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 20000

typedef struct Data{
  int area;
  int pos;
} Data;

int n;
int i;
int T;
int U;
int A;
int ans;
int u[MAX];
Data t[MAX];
Data B,X;

char str[MAX+1];

void D_push(Data data){
  t[T++] = data;
}

Data D_pop(){
  return t[--T];
}

void push(int x){
  u[U++] = x;
}

int pop(){
  return u[--U];
}

void init(){
  ans = T = U = 0;
}

Data makeData(int x, int y){
  Data res;
  res.area = x;
  res.pos = y;
  return res;
}

int main(){
  init();
  scanf("%s", str);
  n = strlen(str);

  for(i=0; i<n; i++){

    if(str[i] == '/'){

      if(U == 0) continue;
      
      A = pop();
      X = makeData(i-A, A);
      ans += i - A;
      
      while(T > 0){
        B = D_pop();
        if(B.pos < A){
          D_push(B);
          break;
        }
        X.area = X.area + B.area;
        if(B.pos<X.pos) X.pos = B.pos;
      }
      D_push(X);
    }else if(str[i] == '\\'){
      push(i);
    }
  }

  printf("%d\n%d", ans, T);
  for(i=0; i<T; i++){
    printf(" %d", t[i].area);
  }
  printf("\n");

  return 0;
}



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

const int MOD = 1e9+7;
const int MAXN = 101010;

typedef struct def{
	int a,b,c;

	def(){}
	def(int a2, int b2, int c2){
		a = a2; b = b2; c = c2;
	}
	bool operator < (def comp) const{
		if(a!=comp.a) return a < comp.a;
		else return b < comp.b;
	}
} generico;

typedef pair<int,int> pii;
typedef long long int ll;

#define INF 0x3f3f3f3f
#define pb push_back
#define mp make_pair

int v,e;
int memo[MAXN];
vector<int> g [MAXN];

int dfs (int x){
	if(memo[x] != -1) return memo[x];
	
	int ans = 0;
	
	for(int i = 0 ; i < g[x].size() ; i ++){
		int y = g[x][i];
		ans = max(ans , dfs(y) + 1);
	}
	
	return memo[x] = ans;
}

int main(){
	
	memset(memo,-1,sizeof memo);
	
	scanf("%d %d",&v,&e);
	
	int a,b;
	for(int i=0;i<e;i++){
		scanf("%d %d",&a,&b);
		g[a].pb(b);
	}
	
	int ans=0;
	
	for(int i = 1 ; i <= v ; i ++)
		ans = max(ans , dfs(i));
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 8192
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    char s[17];
    char E[]="END_OF_TEXT";
    int ans=0;
    char a[17];
    cin>>a;
    for(int i=0;i<strlen(a);i++)if(a[i]>='A'&&a[i]<='Z')a[i]=a[i]-'A'+'a';
    while (cin>>s&&strcmp(s,E)) {
       for(int j=0;j<strlen(a);j++)
           if(s[j]>='A'&&s[j]<='Z')s[j]=s[j]-'A'+'a';
        if(!strcmp(s,a))ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <bitset>
#include <chrono>
#include <iomanip>
using namespace std;

/////------------------------TYPEDEF--------------------------/////
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
#define prq priority_queue<ll>;

/////------------------------CONSTANTS--------------------------/////
ll MOD=1000000007;
#define PI 3.1415926535897932384626433832795

/////------------------------GENERAL--------------------------/////
#define forx(i,j,n) for(int i=j;i<n;i++)
#define fory(i,j,n) for(int i=j;i>=n;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false)
#define testcase int t; cin>>t
#define MEM(xx,yy) memset(xx,yy,sizeof(xx))
#define vbs(xx,x) binary_search(all(xx),x)
#define vlb(xx,x) lower_bound(all(xx),x)
#define vub(xx,x) upper_bound(all(xx),x)

/////------------------------IO--------------------------/////
#define inpi(xx) scanf("%d",&xx)
#define inpl(xx) scanf("%lld",&xx)
#define inpc(xx) scanf("%c",&xx)
#define inps(xx) scanf("%s",&xx)
#define pri(xx) printf("%d",xx)
#define prl(xx) printf("%lld",xx)
#define prls(xx) printf("%lld ",xx)
#define prle(xx) printf("%lld\n",xx)
#define prc(xx) printf("%c",xx)
#define prs printf(" ");
#define pre printf("\n")
ll n,k;
ll h[100005];
ll ans[100005];

ll fun(ll n){
    if(n==1) return 0;
    if(n==2) return abs(h[2]-h[1]);
    if(ans[n]!=-1) return ans[n];
        ans[n]=INT_MAX;
    forx(i,1,k+1){
        if(n-i<=0) break;
        ans[n]=min(fun(n-i)+abs(h[n]-h[n-i]),ans[n]);
    }
    return ans[n];
}

int main() {
	int t=1;
	while(t--){
	    cin>>n>>k;
	    forx(i,0,n) cin>>h[i+1];
	    MEM(ans,-1);
	    cout<<fun(n);
	}
	return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
            Scanner scn=new Scanner(System.in);
            int n=scn.nextInt();
            long []arr =new long[n];
            long a =1;
            long val1=(long)Math.pow(10, 18);
             long max =1;
             boolean flag=false;
             for(int i=0;i<arr.length;i++){
            	 arr[i]=scn.nextLong();
            	 if(arr[i]==0){
            		 flag=true;
            	 }
             }
             if(flag){
            	 System.out.println(0);
            	 return;
             }
            
            for(int i=0;i<arr.length;i++){
            	long val =arr[i];
            	//System.out.println(val+"a");
            
            	a*=val;
//            	System.out.println(max+"^"+a);
            	if(a<max||a>val1){
            		System.out.println(-1);
            		return;
            	}else{
            		max=a;
            	}
            }
            System.out.println(a);
	}

}

Measured memory_bytes: 61200
#include <iostream>

using namespace std;

const int NMAX = 100000 + 5;

int cnt[NMAX];
bool red[NMAX];

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

    int N, M;
    cin >> N >> M;

    for (int i = 1; i <= N; ++ i)
        cnt[i] = 1;
    red[1] = true;

    while (M --) {
        int a, b;
        cin >> a >> b;

        if (red[a]) {
            if (cnt[a] == 1) {
                red[a] = false;
                red[b] |= true;
            }
            else
                red[b] |= true;
        }

        ++ cnt[b];
        -- cnt[a];
    }

    int ans = 0;
    for (int i = 1; i <= N; ++ i)
        ans += red[i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    int ans = 0;
    
    for (int i = 1; i <= N; ++i) 
    {
        ans = ans+i;
    }

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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    set<ll> st={-1,n};
    map<ll,ll> mp;
    ll ans = 0,l=0,r=n-1;
    for(int i = 0;i < n;i ++){
        ll a0;
        cin >> a0;
        a[i] = a0;
        mp[a0] = i;
    }
    for(int i = 1;i <= n;i ++){
        ll j = mp[i];
        auto itr = st.upper_bound(j);
        r = *itr-1;
        itr --;
        l = *itr+1;
        ans += (r-j+1)*(j-l+1)*i;
        st.insert(j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23680
using System;

namespace Tax_Counting
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] array = input.Split(' ');

            int lowerTax = int.Parse(array[0]);
            int higherTax = int.Parse(array[1]);

            if(lowerTax > higherTax)
            {
                Console.WriteLine("A is higher than B");
                return;
            }

            if (lowerTax < 1)
            {
                Console.WriteLine("A needs to be higher than 0");
                return;
            }

            if (higherTax > 100)
            {
                Console.WriteLine("B needs to be lower than 101");
                return;
            }

            int minLowerTax = int.Parse(Math.Ceiling(lowerTax / 0.08).ToString());
            int minHigherTax = int.Parse(Math.Ceiling(higherTax / 0.1).ToString()); 

            int maxLowerTax = Convert.ToInt32(Math.Ceiling(((lowerTax + 1) / 0.08)));
            int maxHigherTax = Convert.ToInt32(Math.Ceiling(((higherTax + 1) / 0.1)));

            int taxCompare = Convert.ToInt32(Math.Max(minLowerTax,minHigherTax));   

            if (minLowerTax <= (maxHigherTax - 1) && minHigherTax <= (maxLowerTax - 1))
            {
                Console.WriteLine(taxCompare);
            }
            else
            {
                Console.WriteLine("-1");
            }                      
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

void tumble(int *a,int *b,int *c,int *d){
  int e;
  e=*a; *a=*b; *b=*c; *c=*d; *d=e;
}

int main(){
  int i,m,n;
  int top,bottom,left,right,front,back;
  char cmd[6];
  while(scanf("%d",&n)){
    if(n==0)break;
    top=1; bottom=6; left=4; right=3; front=2; back=5;
    for(i=0,m=top;i<n;i++){
      scanf("%s",cmd);
      if(cmd[0]=='N') tumble(&top,&front,&bottom,&back);
      if(cmd[0]=='E') tumble(&top,&left,&bottom,&right);
      if(cmd[0]=='W') tumble(&top,&right,&bottom,&left);
      if(cmd[0]=='S') tumble(&top,&back,&bottom,&front);
      if(cmd[0]=='R') tumble(&front,&right,&back,&left);
      if(cmd[0]=='L') tumble(&front,&left,&back,&right);
      m+=top;
    }
    printf("%d\n",m);
  }
  return 0;
}

Measured memory_bytes: 604
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

l = 0
r = 10 ** 18

while r - l > 1:
  m = (r + l) // 2
  li = [h - b * m for h in H]
  cnt = sum([(i - 1) // (a - b) + 1 if i > 0 else 0 for i in li])
  if cnt <= m:
    r = m
  else:
    l = m
print(r)

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


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

    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    int c=0;
    sort (a,a+n);
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            for (int k=j+1;k<n;k++){
                if (a[i]!=a[j] && a[j]!=a[k] && a[i]+a[j]>a[k]){
                    c++;
                }
            }
        }
    }
    cout << c;

    return 0;
}


Measured memory_bytes: 3668
fn main() {
    let _:i32 = read();
    let an: Vec<i32> = read_vec();

    let mut ans = true;
    for a in an.iter() {
        if a % 2 == 0 {
            if a  % 3 != 0 && a % 5 != 0 {
                ans = false;
                break;
            }
        }
    }
    if ans {
        println!("APPROVED");
    } else {
        println!("DENIED");
    }
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <cmath>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pb push_back
#define mp make_pair
using namespace std;

int f(int a){
  return (a+1)%2 + (a-1)%2 + a%2;
}

int main(void){
  int n;
  cin>>n;
  vi a = vi(n);
  rep(i,n){
    cin>>a[i];
  }
  int ret = 1;
  rep(i,n){
    // cout<<a[i]<<' ';
    // cout<<f(a[i])<<endl;
    ret *= f(a[i]);
  }
  cout<<pow(3,n) - ret<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
  int n;
  std::string s, t;
  std::cin >> n;
  std::cin >> s >> t;
  
  for (int i = 0; i < n; ++i) {
    std::cout << s.at(i) << t.at(i);
  }
  std::cout << std::endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int flag=0;
    while(n){
        if(n%10==7) flag=1;
        n/=10;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



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

void bye() { std::cout << -1 << std::endl; exit(0); }
const int MAXN = 100010;
typedef long long LL;
std::map<LL, LL> idx, sub, fa, dep;
int n;
LL D[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> D[i], idx[D[i]] = i, sub[D[i]] = 1;
	std::sort(D + 1, D + 1 + n);
	for (int i = n; i > 1; --i) {
		LL td = D[i] - n + sub[D[i]] * 2;
		if (td >= D[i] || !idx.count(td)) bye();
		sub[td] += sub[D[i]];
		fa[D[i]] = td;
	}
	for (int i = 2; i <= n; ++i) {
		dep[D[i]] = dep[fa[D[i]]] + 1;
		D[1] -= dep[D[i]];
	}
	if (D[1]) bye();
	for (int i = 2; i <= n; ++i)
		std::cout << idx[fa[D[i]]] << ' ' << idx[D[i]] << '\n';
	return 0;
}


Measured memory_bytes: 29184
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define drep(i,cc,n) for(int i=cc;i>n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

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

ll choose2(ll n){
    return n*(n-1)/2;
}

int main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);

    rep(i,0,m) {
        int a,b;
        cin>>a>>b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> dist(n,-1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()) {
        int v = que.front();
        que.pop();

        for(int nv : g[v]){
            if(dist[nv] != -1) continue;

            dist[nv] = v + 1;
            que.push(nv); 
        }
    }

    rep(i,1,n-1){
        if(dist[i] == -1){
            cout<<"No"<<endl;
            break;
        }
    }

    cout<<"Yes"<<endl;

    rep(i,1,n) cout<<dist[i]<<endl;

    return 0;
}

Measured memory_bytes: 10236
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 1e5+7;

ll n,dp[nax][2]={{0}};
bool vis[nax]={0};
vector<ll> edge[nax];

void DFS(ll s,ll par = -1){
	vis[s]=true;
	
	bool value=false;
	
	for (auto it: edge[s]){
		if (it!= par) {
			DFS(it,s);
			
			dp[s][0]=dp[s][0]*(dp[it][0]+dp[it][1])%mod;
			dp[s][1]=dp[s][1]*dp[it][0]%mod;
		}
	}
}

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n;
	
	for (ll i=0;i<=n;++i) dp[i][0]=dp[i][1]=1;
	
	for (ll i=0;i<n-1;++i){
		ll a,b;
		cin>>a>>b;
		
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	
	DFS(1);
	
	cout<<(dp[1][0]+dp[1][1])%mod<<"\n";
	
}

Measured memory_bytes: 17680
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <functional>

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

int main(){
  string s; cin>>s; int n=s.size();
  int k; cin>>k;
  set<string> v;
  for(int i=0;i<n;i++) {
    for(int j=1;j<=k;j++) {
      if (i+j<=n) {
        v.insert(s.substr(i,j));
      }
    }
  }
  /*
  while(!v.empty()) {
    cout<<*(v.begin())<<endl; v.erase(v.begin());
  }*/
  
  for(int i=0;i<k-1;i++) v.erase(v.begin());
  cout<<*(v.begin())<<endl;
}

Measured memory_bytes: 1664
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]

i = 0
j = 0
direction = 'r'
ans = []
route = []
is_selected = False
cnt = 0
while True:
    if cnt >= h * w:
        break
    next_i = i
    next_j = j
    if j == 0 and direction == 'l':
        next_i = i + 1
        direction = 'r'
    elif j == w-1 and direction == 'r':
        next_i = i + 1
        direction = 'l'
    else:
        if direction == 'r':
            next_j += 1
        else:
            next_j -= 1

    if a[i][j] % 2 == 1:
        if is_selected:
            ans.extend(route)
            route = []
            is_selected = False
        else:
            route.append([i+1, j+1, next_i+1, next_j+1])
            is_selected = True
    else:
        if is_selected:
            route.append([i+1, j+1, next_i+1, next_j+1])
    i = next_i
    j = next_j
    cnt += 1


print(len(ans))
for i in range(len(ans)):
    print(" ".join(list(map(str, ans[i]))))


Measured memory_bytes: 69596
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;

    for ( int i = 0; i < n; i++) cin >> R[i] ;

    int maxv = -1000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
    
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= n; ++i)
#define fore(i, l, r) for (int i = l; i <= r; ++i)
 
using namespace std;
 
int main(){
	int N; cin >> N;
	vector<int> sides(N);
	forn(i, N){
		cin >> sides[i];
	}
	sort(sides.begin(), sides.end());
	int sum = 0;
	forn(i, N - 1){
		sum += sides[i];
	}
	if (sum > sides[N - 1]){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
ans = -1
for i in range(10**n):
    i = str(i)
    flag = 1
    for j in range(m):
        try:
            if not i[sc[j][0]-1] == str(sc[j][1]):
                flag = 0
                break
        except:
            flag = 0
            break
    if flag == 1:
        if len(i) == n:
            ans = int(i)
            break

print(ans)


Measured memory_bytes: 3064
import sys
N = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    sys.exit()

b=1
for i in range(0,N):
    b *= a[i]
    if b > 1000000000000000000:
        print(-1)
        sys.exit()

print(b)

Measured memory_bytes: 21648
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
int main(){
 
    vector<int> V;
 
    int num_query;
    scanf("%d",&num_query);
 
    int command,tmp;
 
    for(int loop = 0; loop < num_query; loop++){
        scanf("%d",&command);
 
        switch(command){
        case 0:
            scanf("%d",&tmp);
            V.push_back(tmp);
            break;
        case 1:
            scanf("%d",&tmp);
            printf("%d\n",V[tmp]);
            break;
        case 2:
            V.pop_back();
            break;
        }
    }
 
    return 0;
}


Measured memory_bytes: 3852
#include<stdio.h>
int main(void)
{
	int a[5];
	int n,x,i,i2;
	x=0;
	for(i=0;i<5;i++)	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<5;i++)	{
		if(a[i]<40)	{
			a[i]=40;
		}
		//printf("%d\n",a[i]);
		x=x+a[i];
	}
	n=x/5;
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 2756
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=998244353
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  n=len(s)
  t=S()
  n2=len(t)

  d={}
  for i,x in enumerate(s):
    if x in d:
      y=d[x]
      y.append(i)
      d[x]=y
    else:
      d[x]=[i]

  # print(d)
  i=0
  j=0
  ans=1
  while j<n2:
    check=t[j]
    if check not in d:
      return -1
    l=d[check]
    if i<l[0]:
      ans+=l[0]-i+1
      i=l[0]+1
      j+=1
    elif l[-1]<i:
      ans+=n-(i+1)+l[0]+2
      i=l[0]+1
      j+=1
    else:
      if i==l[0]:
        ans+=1
        i+=1
        j+=1
      elif i==l[-1]:
        ans+=1
        i+=1
        j+=1
      else:
        left=0
        right=len(l)
        while right-left>1:
          m=(right+left)//2
          if l[m]>=i:
            right=m
          else:
            left=m
          # print(right,left,m,i)
        ans+=l[right]-i+1
        i=l[right]+1
        j+=1

    # print(i,ans)

    i%=n

  return ans-1

# main()
print(main())


Measured memory_bytes: 15132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

const int N = 1e5+5;
int cnt[N];

void Suhaib_Sawalha (){

    int n , q;
    cin >> n;
    int a[n];
    ll sum = 0;
    for (int i = 0 ; i < n ; ++i){
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    cin >> q;
    int bf , af;
    while (q--){
        cin >> bf >> af;
        sum -= bf * 1ll * cnt[bf];
        sum += af * 1ll * cnt[bf];
        cnt[af] += cnt[bf];
        cnt[bf] = 0;
        cout << sum << endl;
    }

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if(s[0]=='S'){ 
  	cout << "Cloudy" << endl;
  }
  else if(s[0]=='C'){
  	cout << "Rainy" << endl;
  }
  else{
  	cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
long int a,b,c,j;
scanf("%ld %ld %ld",&a,&b,&c);
int d[11];
  d[0]=c;
  for(j=1;j<11;++j)
  {d[j]=d[j-1]*a-b;
  printf("%ld\n",d[j]);
  }
return 0;
}

Measured memory_bytes: 128
use proconio::input;
// use num::*;

fn main() {
    input! {
        x: [i128; 5],
    };
    let mut ans = 0;
    for (i, &val) in x.iter().enumerate() {
        if val == 0 {
            ans = i + 1
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2148
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.IntMap.Strict as IntMap
import Control.Monad

type Weight = Int
type Tree = IntMap.IntMap [(Int,Weight)]

insert' :: Int -> a -> IntMap.IntMap [a] -> IntMap.IntMap [a]
insert' !k v = IntMap.alter (\m -> Just (v : fromMaybe [] m)) k

main = do
  n <- readLn
  edges <- U.replicateM (n-1) $ do
    [u,v,w] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (u-1, v-1, w)
  let tree :: Tree
      tree = U.foldl' (\m (u,v,w) -> insert' u (v,w) $ insert' v (u,w) m) IntMap.empty edges
  let result = U.create $ do
        vec <- UM.replicate n (-1)
        -- white: 0, black: 1
        let dfs !i !color = do
              x <- UM.read vec i
              when (x == -1) $ do
                UM.write vec i color
                let Just t = IntMap.lookup i tree
                forM_ t $ \(j,w) -> do
                  dfs j ((color + w) `rem` 2)
        dfs 0 0
        return vec
  U.mapM_ print result


Measured memory_bytes: 54780
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;


unsigned long long gcd(unsigned long long a, unsigned long long b)
{
	if (b == 0)
	{
		return a;
	}

	return gcd(b, a % b);
}


int main()
{
	long long A, B, C, D;
	cin >> A >> B >> C >> D;

	auto l = (long long)(C / gcd(C, D) * D);
	auto sub = B / C - (A - 1) / C;
	sub += B / D - (A - 1) / D;
	sub += - B / l + (A - 1) / l;

	cout << B - A + 1 - sub << endl;

	return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        _n: usize,
        s: String
    };
    let c = s.as_bytes();
    let r = c.iter().filter(|&&x| x == b'R' ).count();
    let mut res = 0;
    for i in 0..r {
        if c[i] == b'W' { res += 1 }
    }
    println!("{}", res);
}


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

int main() {
	int n,i,j,c[4];
	string a[4],b;

	a[0]="AC";
	a[1]="WA";
	a[2]="TLE";
	a[3]="RE";

	cin >> n;
	for(i=0;i<4;i++)
		c[i]=0;
	for(i=0;i<n;i++){
		cin >> b;
		for(j=0;j<4;j++){
			if(b==a[j]){
				c[j]++;
				break;
			}
		}
	}
	for(i=0;i<4;i++){
		cout << a[i] << " x " << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, TD):
    TD.sort(key=lambda x: x[1], reverse=True)

    c = Counter()
    base = 0
    rc = []
    for i in range(K):
        t, k = TD[i]
        c[t] += 1
        base += k
        if c[t] > 1:
            rc.append((t, k))

    mi = i
    ans = [base + len(c)**2]
    while True:
        if len(rc) == 0:
            break
        rt, rk = rc.pop()
        for i in range(mi+1, len(TD)):
            if TD[i][0] not in c:
                c[TD[i][0]] += 1
                c[rt] -= 1
                base -= rk
                base += TD[i][1]
                mi = i
                ans.append(base + len(c)**2)
                break

        else:
            break
    return max(ans)


def main():
    # N = read_int()
    N, K = read_int_n()
    TD = [read_int_n() for _ in range(N)]
    print(slv(N, K, TD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 35372
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		InputReader in = new InputReader();
		int l = in.nextInt();
		int r = in.nextInt();
		int n = r-l+1;
		if (n > 2020) {
			System.out.println(0);
			return;
		}
		int[] arr = new int[n];
		for (int i=l; i<=r; i++)
			arr[i-l] = i;
		long res = Long.MAX_VALUE;
		for (int i=l; i<r; i++) {
			for (int j=i+1; j<=r; j++) {
				res = Math.min(res, ((long)i*j)%2019);
			}
		}
		System.out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

const int MAX=510000;

int main()
{
    int n,d;
    cin>>n>>d;
    int p[n][d];
    int count=0;
    rep(i,n)rep(j,d)
    {
        cin>>p[i][j];
    }
    rep(i,n-1)
    {
        for(int j=i+1;j<n;j++)
        {
            double length=0;
            rep(k,d)
            {
                length+=pow(p[i][k]-p[j][k],2.0);
            }
            int a=sqrt(length);
            if(sqrt(length)-a==0)
            {
                count++;
            }
        }
        
    }
    cout<<count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n;cin>>n;
    int a[n+5];
    for(int i=1;i<=n;i++)    cin>>a[i];
    int flag=1;
    int dp[n+10]={0};
    int count=0;
    vector<int>ans;
    for(int i=n;i>=2;i--){
        if(dp[i]!=a[i])
         {
                count++,dp[i]++,dp[i]%=2,ans.push_back(i);
                for(int j=1;j<=sqrt(i);j++){
                if(i%j==0){
                    dp[j]++;
                    dp[j]%=2;
                    if(j*j!=i && i%(i/j)==0){
                        dp[i/j]++;
                        dp[i/j]%=2;
                    }
                }
            }   
         }
    }
    if(dp[1]!=a[1])
            dp[1]++,dp[1]%=2,count++,ans.push_back(1);
    cout<<count<<"\n";
    for(auto x:ans)
        cout<<x<<" ";
}

Measured memory_bytes: 4980
#!/usr/bin/env python
import math
def main():
    N = int(input())
    ans = len(str(N))
    for i in range(1, math.ceil(math.sqrt(N))+1):
        if N % i == 0:
            tmp = max(len(str(i)), len(str(N // i)))
            if ans > tmp:
                ans = tmp
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 39152
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_D
  * Structured Program I - Structured Programming
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    //Memory Limit Exceeded
    //    val result = (1 to n).filter(i => i % 3 == 0 || i.toString.contains('3'))
    //      .foldLeft("") { (str, i) => str + s" $i" }
    val result = " " + (1 to n).filter(i => i % 3 == 0 || i.toString.contains('3')).mkString(" ")
    println(result)
  }
}

Measured memory_bytes: 47280
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vi a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a.at(K-1) << endl;
}

Measured memory_bytes: 256
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

const INF: usize = 1e15 as usize;

fn solve1(xy: &Vec<(usize, usize)>) -> usize {
    let max = xy.iter().map(|&(x, y)| cmp::max(x, y)).max().unwrap();
    let min = xy.iter().map(|&(x, y)| cmp::min(x, y)).min().unwrap();
    let max_minimum = xy.iter().map(|&(x, y)| cmp::min(x, y)).max().unwrap();
    let min_maximum = xy.iter().map(|&(x, y)| cmp::max(x, y)).min().unwrap();
    (max - min_maximum) * (max_minimum - min)
}

fn solve2(xy: &Vec<(usize, usize)>) -> usize {
    let n = xy.len();
    let mut pairs = vec![];
    for &(x, y) in xy.iter() {
        pairs.push((cmp::min(x, y), cmp::max(x, y)));
    }
    pairs.sort();

    let (whole_minimum, _) = pairs[0];
    let whole_maximum = pairs.iter().map(|&(_, b)| b).max().unwrap();
    let (mut cur_max, _) = pairs[n - 1];
    let mut right_min = INF;

    let mut ans = (cur_max - pairs[0].0) * (whole_maximum - whole_minimum);
    for i in 0..(n - 1) {
        let (_, cur_right) = pairs[i];
        let (next_left, _) = pairs[i + 1];
        right_min = cmp::min(right_min, cur_right);
        let cur_min = cmp::min(right_min, next_left);
        cur_max = cmp::max(cur_max, cur_right);
        ans = cmp::min(ans, (whole_maximum - whole_minimum) * (cur_max - cur_min));
    }
    ans
}

fn main() {
    input!(n: usize, xy: [(usize, usize); n]);
    println!("{}", cmp::min(solve1(&xy), solve2(&xy)));
}


Measured memory_bytes: 17652
#include <bits/stdc++.h>
using namespace std;
double calcAngle(double h, double m)
{
    // validate the input

    if (h == 12)
        h = 0;
    if (m == 60)
        m = 0;

    // Calculate the angles moved
    // by hour and minute hands
    // with reference to 12:00
    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;

    // Find the difference between two angles
    double angle = abs(hour_angle - minute_angle);

    // Return the smaller angle of two possible angles
    angle = min(360 - angle, angle);

    return angle;
}

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle = calcAngle(h, m);
    double pi = 3.1415926535897932384626433832795028841;
    //cout << angle << endl;
    cout
        << std::fixed << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(angle * pi / 180));
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s.at(5) == '1') cout << "TBD" << endl;
  else if (s.at(6) <= '4') cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}


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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vi L(M), R(M);
    rep(i, M) {
        cin >> L[i] >> R[i];
        // L[i]--; R[i]--;
    }
    vi A(Q), B(Q);
    rep(i, Q) {
        cin >> A[i] >> B[i];
        // A[i]--; B[i]--;
    }

    vector<vector<int>> G(N + 1, vector<int>(N + 1));
    rep(i, M) {
        G[L[i]][R[i]]++;
    }

    // 2次元累積和
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            G[i][j] += G[i][j - 1];
            G[i][j] += G[i - 1][j];
            G[i][j] -= G[i - 1][j - 1];
        }
    }

    rep(i, Q) {
        int p = A[i];
        int q = B[i];
        int res = G[q][q] - G[q][p - 1] - G[p - 1][q] + G[p - 1][p - 1];
        cout << res << endl;
    }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  int N;
  cin >> N;
  
  cout << 800 * N - N / 15 * 200 << endl;

}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
#S = input()
#N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

A.sort(reverse = True)
h = [-A[0]]

answer = 0
for a in A[1:]:
    answer -= heappop(h)
    heappush(h, -a)
    heappush(h, -a)

print(answer)

Measured memory_bytes: 102416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//Declare
		int cnt = 0;

		// Recieve StdIn
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		for (int i=0; i<N; i++) {
			int an = sc.nextInt();

			while (an%2 == 0) {
				an /= 2;
				cnt++;
			}
		}

		// Display
		System.out.println(cnt);
	}

}


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    int count = 0;
    rep(i, N) {
        if (P[i] != i+1) {
            count += 1;
        }
        if (count >= 3) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

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

	A -= B * 2;

	if (A < 0) {
		A = 0;
	}

	cout << A << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100001]={},arr[100001]={};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    dp[1]=0,dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++){
        int ans=1e9;
        for(int j=1;j<=k;j++){
            if(i-j<=0){
                continue;
            }else{
                ans=min(ans,dp[i-j]+abs(arr[i]-arr[i-j]));
            }

        }
        dp[i]=ans;
        //cout<<dp[i]<<' ';
    }
    //cout<<'\n';
    cout<<dp[n]<<'\n';

return 0;

}

//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *   ****      *  ****

//     ****  *   *  *   *   ***   *   *  *****  *   *
//    *     *   *  *   *  *   *  *   *  *      *   *
//    ***  *****  *   *  *****  * * *  ****   *   *
//      *   *    *   *  *   *  * * *  *      *   *
//  ****   *     ***   *   *   * *   *****   ***


Measured memory_bytes: 4412
fun main() {
    val (n, k) = readLine()?.split(" ")?.map(String::toLong) ?: return
    val a = readLine()?.split(" ")?.map(String::toInt) ?: return
    val arrival = Array(n.toInt() + 1) { false }
    val loopRoutes = mutableListOf<Int>()

    var c = a[0]
    arrival[1] = true
    loopRoutes.add(1)
    loopRoutes.add(c)
    while (true) {
        val t = a[c - 1]
        if (arrival[t]) {
            val r = k - loopRoutes.size
            if (r < 0) {
                println(loopRoutes[(k).toInt()].toString())
                return
            } else if (r == 0L) {
                println(t.toString())
                return
            }
            val loop = loopRoutes.drop(loopRoutes.indexOf(t))
            if (loop.size == 1) {
                println(loop.first().toString())
                return
            }
            val p = r % loop.size
            println((loop[p.toInt()]).toString())
            return
        } else {
            arrival[t] = true
            loopRoutes.add(t)
            c = t
        }
    }
}



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

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  int sum=0;
  int mi=1e8;
  for(int i=0;i<N;i++){
    cin >> s.at(i);
    sum+=s.at(i);
    if(s.at(i)%10!=0){
      if(mi>s.at(i)){
        mi=s.at(i);
      }
    }
  }
  if(sum%10!=0){
    cout << sum << endl;
    return 0;
  }
  if(mi==1e8){
    cout << 0 << endl;
    return 0;
  }
  cout << sum-mi << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int p[110][110];

int main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int c = 0;
    rep(i,h){
        rep(j,w){
            if(i%2==0){
                p[i][j] = c+1;
                a[c]--;
                if(a[c]==0)c++;
            }else{
                p[i][w-1-j] =c+1 ;
                a[c]--;
                if(a[c]==0)c++;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << p[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384