akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
ll i ,j;
while(q--)
{
    ll n,m,k,l,r,a,b,c=0,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n >> m;
    ll sum  = 0;
    vector<ll> V(n);
    for(i=0;i<n;i++) {cin >> V[i]; sum+=V[i];}
    sort(allr(V));
    if(V[m-1]>=(sum/(4*m) + ( (sum%(4*m)!=0) ?1:0))) cout << "Yes";
    else cout << "No";

}
    return 0;
}

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

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%tmod;}
    else{return (b*((temp*temp)%tmod))%tmod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 256
use std::cmp::min;
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    let n: usize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let info: Vec<usize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp
    };
    let mut ps: Vec<usize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp
    };
    ps.sort();
    let one = ps.iter().filter(|a| a <= &&info[0]).count();
    let two = ps.iter().filter(|a| &&info[0] < a && a <= &&info[1]).count();
    let three = ps.iter().filter(|a| &&info[1] < a).count();
    println!("{}", min(min(one, two), three));
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
      	int rate = scanner.nextInt();
      
      	if(rate >= 1800) {
        	System.out.println("1");
        } else if(rate >= 1600) {
        	System.out.println("2");
        } else if(rate >= 1400) {
        	System.out.println("3");        
        } else if(rate >= 1200) {
        	System.out.println("4");        
        } else if(rate >= 1000) {
        	System.out.println("5");        
        } else if(rate >= 800) {
        	System.out.println("6");
        } else if(rate >= 600) {
        	System.out.println("7");
        } else {
        	System.out.println("8");
        }
    
    }
}

Measured memory_bytes: 35660
#include <cstdio>
#include <cstring>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int S_MAX = 100000;

char s[S_MAX + 1];

void solve() {
  if (s[0] == s[1]) {
    puts("1 2");
    return;
  }
  FOR(i, 2, strlen(s) - 1) {
    if (s[i - 1] == s[i]) {
      printf("%d %d\n", i, i + 1);
      return;
    }
    if (s[i - 2] == s[i]) {
      printf("%d %d\n", i - 1, i + 1);
      return;
    }
  }
  puts("-1 -1");
}

void input() {
  scanf("%s", s);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main() {
    int n;
    cin >> n;

    set<string> s;
    string w;
    char c;
    cin >> w;
    s.insert(w);
    c = w.at(w.size() - 1);
    for (int i = 1; i < n; i++) {
        string x;
        cin >> x;
        if (s.find(x) == s.end() && x.at(0) == c) {
            s.insert(x);
            c = x.at(x.size() - 1);
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>>	A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    cin >> A.at(i).at(0) >> A.at(i).at(1) >> A.at(i).at(2);
  }
  
  int n;	cin >> n;
  for(int i=0;i<n;i++){
    int b;	cin >> b;
    for(int x=0;x<3;x++){
      for(int y=0;y<3;y++){
        if(A.at(x).at(y)==b)	A.at(x).at(y)=0;
      }
    }
  }
  
  for(int x=0;x<3;x++){
    if(A.at(x).at(0)==0&&A.at(x).at(1)==0&&A.at(x).at(2)==0){
      cout << "Yes";
      return 0;
    }
  }
  
  for(int x=0;x<3;x++){
    if(A.at(0).at(x)==0&&A.at(1).at(x)==0&&A.at(2).at(x)==0){
      cout << "Yes";
      return 0;
    }
  }
  
  if(A.at(0).at(0)==0&&A.at(1).at(1)==0&&A.at(2).at(2)==0){
    cout << "Yes";
    return 0;
  }
  if (A.at(0).at(2)==0&&A.at(1).at(1)==0&&A.at(2).at(0)==0){
    cout << "Yes";
    return 0;
  }else{
  	cout << "No";
}
  
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
//#define MXN 300000
#define N 100005
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>0&&b>0)printf("Positive\n");
    if(a<0&&b<0){
        int tot=(b-a+1)&1;
        if(tot)printf("Negative\n");
        else printf("Positive\n");
    }
    if(a<=0&&b>=0)printf("Zero\n");

}

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

int main() {
    int N;
    cin >> N;
    map<long long, long long> A;
    long long sum = 0;
    ++A[sum];
    for(int i=0; i<N; ++i) {
        long long a;
        cin >> a;
        sum += a;
        ++A[sum];
    }

    long long res = 0;
    for(auto itr = A.begin(); itr != A.end(); ++itr) {
        res += (itr->second) * (itr->second - 1LL) / 2LL;
    }
    cout << res << endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 10*9+7

int main(){
  int s,w;
  cin >> s >> w;
  if(s<=w) cout<< "unsafe" <<endl;
  else cout<< "safe" <<endl;
}


Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    left = min(A[i], B[i])
    ans += left
    A[i] -= left
    B[i] -= left
    right = min(A[i+1], B[i])
    ans += right
    A[i+1] -= right
    B[i] -= right
print(ans)
    

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string o, e;
    cin >> o >> e;

    string res = "";
    rep(i, o.size()+e.size()) {
        if(i%2==0) {
            res += o[i/2];
        } else {
            res += e[i/2];
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int inf = 1 << 30;
const int maxn = 100000 + 5;

int n, k, ans[maxn], col[maxn];
vector<PII> edge[maxn];

void dfs(int u, int f) {
  int c = 0;
  for (auto& x: edge[u]) {
    int v = x.first, id = x.second;
    if (v == f) continue;
    c++; if (c == col[u]) c++;
    col[v] = c; ans[id] = c;
    dfs(v, u);
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 2, u, v; i <= n; i++) {
    scanf("%d%d", &u, &v);
    edge[u].emplace_back(v, i);
    edge[v].emplace_back(u, i);
  }
  for (int i = 1; i <= n; i++) {
    k = max(k, (int)edge[i].size());
  }
  dfs(1, 0);
  printf("%d\n", k);
  for (int i = 2; i <= n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 8576
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

const int N = 80;
const int M = 12800 + 10;
bitset<M * 2> dp[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  // n = m = 80;
  vector<vector<int>> a(n, vector<int>(m));
  vector<vector<int>> b(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
      // a[i][j] = rnd(81);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &b[i][j]);
      // b[i][j] = rnd(81);
    }
  }
  int x = a[0][0] - b[0][0];
  dp[0][0][M + x] = dp[0][0][M - x] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i + j == 0) continue;
      int x = a[i][j] - b[i][j];
      if (i - 1 >= 0) {
        for (int k = -M; k < M; ++k) {
          if (dp[i - 1][j][M + k]) {
            dp[i][j][M + k + x] = dp[i][j][M + k - x] = 1;
          }
        }
      }
      if (j - 1 >= 0) {
        for (int k = -M; k < M; ++k) {
          if (dp[i][j - 1][M + k]) {
            dp[i][j][M + k + x] = dp[i][j][M + k - x] = 1;
          }
        }
      }
      // trace(i, j, dp[i][j].size());
    }
  }
  int best = INF;
  for (int k = -M; k < M; ++k) {
    if (dp[n - 1][m - 1][M + k]) {
      best = min(best, abs(k));
    }
  }
  printf("%d\n", best);
  return 0;
}


Measured memory_bytes: 20352
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long N = scan.nextLong();
			
			/*int []M =new int[N];
			long goukei = 0;
			M[0] = 1;
			goukei+=M[0];
			for(int i = 1;i<N;i++) {
				M[i] = (i+1)%i;
				goukei+=M[i];
				System.out.println(M[i]);
			}*/
			
			System.out.println((N*(N-1))/2);
			
		}	
	}
}


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

int main() {
  int a,b,k; cin >>a >>b >>k;
  for (int i=a; i<b+1; i++){
    if (i<=a+k-1 || b-k+1<=i){
      cout <<i <<endl;
    }
  }
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n, d;

signed main()
{
    cin >> n >> d;

    cout << ceil((double)n / (2 * d + 1)) << endl;

    return 0;
}


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

struct UnionFind{
  vector<int> r;
  
  UnionFind(int N){
    r=vector<int>(N,-1);
  }
  
  int root(int x){
    if(r[x]<0){
      return x;
    }
    return r[x]=root(r[x]);
  }
  
  bool unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y){
      return false;
    }
    if(r[x]>r[y]){
      swap(x,y);
    }
    r[x]+=r[y];
    r[y]=x;
    return true;
  }
  
  int size(int x){
    return -r[root(x)];
  }  
};

int main(){
  int a,b;
  cin >>a>>b;
  
  UnionFind UF(a);
  
  for(int i=0;i<b;i++){
    int c,d;
    cin >>c>>d;
    c--;
    d--;
    UF.unite(c,d);
  }
  
  vector<int> ans1(a,1);
  int ans=0;
  for(int i=0;i<a;i++){
    if(ans1[UF.root(i)]){
    ans+=UF.size(i)-1;
    ans1[UF.root(i)]=0;
    }  
  }
  
  cout << a-ans-1 <<endl;
}
  
  
  


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/

char c[305][305];
int n;
char c2[305][305];
bool check(int a,int b){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			c2[i][j]=c[(i+a)%n][(j+b)%n];
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(c2[i][j]!=c2[j][i]){
				return false;
			}
		}
	}
	return true;
}
int main(int argc,char* argv[]){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s",c[i]);
	}
	
	int ans=0;
	for(int i=0;i<n;i++){
		bool aa=check(0,i);
		int x=0,y=i;
		while(x<n && y<n){
			ans+=aa;
			x++;y++;
		}
		
	}
	
	for(int i=1;i<n;i++){
		bool aa=check(i,0);
		int x=i,y=0;
		while(x<n && y<n){
			ans+=aa;
			x++;y++;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(a+b>=a-b&&a+b>=a*b)cout<<a+b<<endl;
  else if(a+b<a-b&&a*b<=a-b)cout<<a-b<<endl;
  else cout<<a*b<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0){
      break;
    }
    vector<int> mx(M, 0);
    for (int i = 0; i < N; i++){
      int d, v;
      cin >> d >> v;
      d--;
      mx[d] = max(mx[d], v);
    }
    int ans = 0;
    for (int i = 0; i < M; i++){
      ans += mx[i];
    }
    cout << ans << endl;
  }
}


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

bool check(int a,int b,int c){
	if(a*a==(b*b+c*c)) return true;
	else return false;
}

int main(void){
	int a,b,c;
	int N;
	int i;

	cin >> N;

	for(i=0;i<N;i++){
		cin >> a >> b >> c;
		if(check(a,b,c)||check(b,a,c)||check(c,a,b)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		System.out.println((N==M)?"Yes":"No");
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
 
using namespace std;
int main()
 
{
int r,b,g;
cin>>r>>g>>b;
 
if((r * 100 + g * 10 + b) % 4 == 0)
  cout<< "YES" <<endl;
else
  cout<< "NO" <<endl;
    
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int x, i = 0;
		while(true) {
			x = sc.nextInt();
			if(x == 0) break;
			System.out.println("Case " + (++i) + ": " + x);
		}
	}
}


Measured memory_bytes: 42864
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
cnt_i = defaultdict(lambda :0)
cnt_j = defaultdict(lambda :0)
for i in range(n):
    temp_i = a[i] + i + 1
    temp_j = i + 1 - a[i]
    cnt_i[temp_i] += 1
    cnt_j[temp_j] += 1

ans = sum(v * cnt_j[i] for i,v in cnt_i.items())
print(ans)

Measured memory_bytes: 73756
function Main(input) {
  input = input.split("\n");
  var r = input[0];
  var ans = Math.pow(r,2)*3;

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int n; cin >> n;
    long long ans = 1;
    int mod = 1000000007;
    for(int i = 1; i <= n; i ++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

// AAAAA
// BBBBB

int main()
{
    int n; in >> n;
    string a, b; in >> a >> b;

    REP(i, n)
    {
        if(a.substr(i, n-i) == b.substr(0, n-i))
        {
            //out << a << b.substr(n-i, i) << "\n";
            out << a.size() + i << "\n";
            return 0;
        }
    }
    // out << a << b << "\n";
    out << a.size()+b.size() << "\n";

    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()
#define fst first
#define sec	second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<long,long> P;

const int mod = 1e9 + 7;


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

	int m, d;
	cin >> m >> d;


	int ans = 0;
	rept(i, 1, m+1){
		rept(j, 1, d+1){
			int d1 = j / 10;
			int d2 = j % 10;
			int D = d1 * d2;
			if(i == D && d1 >= 2 && d2 >= 2){
				ans ++;
			}
		}
	}

	cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
	

int map[10][10];


void Drop_1(int x,int y){

	if(x >= 1)
		map[y][x-1]++;
	if(x < 9)
		map[y][x+1]++;
	if(y >= 1)
		map[y-1][x]++;
	if(y < 9)
		map[y+1][x]++;

}
void Drop_2(int x,int y){

	if(x >= 1){
		map[y][x-1]++;

		if(y >= 1)
			map[y-1][x-1]++;
		if(y < 9)
			map[y+1][x-1]++;

	}
	if(y >= 1)
		map[y-1][x]++;
	if(y < 9)
		map[y+1][x]++;

	if(x < 9){
		map[y][x+1]++;

		if(y >= 1)
			map[y-1][x+1]++;
		if(y < 9)
			map[y+1][x+1]++;

	}


}
void Drop_3(int x,int y){

	Drop_2(x,y);

	if(x >= 2)
		map[y][x-2]++;
	if(x < 8)
		map[y][x+2]++;
	if(y >= 2)
		map[y-2][x]++;
	if(y < 8)
		map[y+2][x]++;


}

void Drop(int x, int y, int size){

	map[y][x] ++;

	switch(size){

	case 1:
		Drop_1(x,y);
		break;

	case 2:
		Drop_2(x,y);
		break;

	case 3:
		Drop_3(x,y);
		break;
	}

}


int main(void){

	int x,y,size;

	int i,j;
	int white=0,max=0;

	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			map[i][j] = 0;

	while(scanf("%d,%d,%d",&x,&y,&size) != EOF){

		Drop(x,y,size);

	}

	for(i=0;i<10;i++){
		for(j=0;j<10;j++){

			if(map[i][j] == 0)
				white++;
			else if(map[i][j] > max)
				max = map[i][j];
		}
	}

	printf("%d\n%d\n",white,max);

	return 0;
}

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

int main() {
    ll N; cin >> N;
    double A = sqrt(N);
    ll a = A;

    ll I = 1;
    ll J = N;
    for (ll i = a; i >= 2; i--){
        if (N%i == 0){
            I = i;
            J = N / i;
            break;
        }
    }

    cout << I+J - 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll mod = 1e9+7;
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    REP(i, N) cin >> S[i];
    REP(i, M) cin >> T[i];

    vector<vector<ll>> dp(N+1, vector<ll>(M+1, 1));

    FOR(i, 1, N)
        FOR(j, 1, M) {
            if(S[i-1] == T[j-1])
                dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod;
            else
                dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + mod) % mod;
        }    

    // cerr << "debug" << endl;
    // FOR(i, 0, N) {
    //     FOR(j, 0, M) {
    //         cerr << dp[i][j] << " ";
    //     }
    //     cerr << endl;
    // }

    cout << dp[N][M] << endl;

    return 0;
}

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

int main(){
  long long n,T,t[200010],ans=0;
  cin>>n>>T;
  for(int i=0;i<n;++i){
    cin>>t[i];
    if(i==0)ans+=T;
    else if(t[i]-t[i-1]>=T)ans+=T;
    else ans+=t[i]-t[i-1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
n, m = [int(x) for x in input().split()]
min_num = 0
max_num = n

for x in range(m):
    tmp_min, tmp_max = map(int, input().split())
    min_num = max(min_num, tmp_min)
    max_num = min(max_num, tmp_max)

if max_num - min_num + 1 > 0:
    print(max_num - min_num + 1)
else:
    print(0)

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vi a(n);
    ll f1=0;
    rep(i,n){
        cin>>a[i];
        if(a[i] == 1) f1++;
    }
    if(f1==0) {
        cout<<-1<<endl;
        exit(0);
    }

    ll ans=0;
    ll nxt=1;
    rep(i,n){
        if(a[i] == nxt){
            nxt++;
        } else {
            ans++;
        }
    }
    cout<<ans<<endl;




    timer();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#ifndef DBG
#define dbg(...)
#else
#define dbg(...) {cerr << "\033[1;96m"; ostream& cout = cerr; \
(void)(cout); __VA_ARGS__; cerr << "\033[0m";} 
#endif
#define bgn(...) begin(__VA_ARGS__)
#define rsz(...) resize(__VA_ARGS__)
#define emp(...) emplace_back(__VA_ARGS__)
#define psh(...) push_back(__VA_ARGS__)
#define ddmp(...) dbg(dmp(__VA_ARGS__))
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__)
#define all(...) bgn(__VA_ARGS__), end(__VA_ARGS__)
#define siz(...) static_cast< int >((__VA_ARGS__).size())
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
template< typename... t > using outit = ostream_iterator< t... >;
template< typename t > void print(ostream& os, const t& a)
{os << a <<  '\n';} template< typename t, typename... v >
void print(ostream& os, const t& a, v&&... b){os << a << ' '; print(os, b...);}

constexpr int mod = 998244353;

int n, a, b;
ll k;
V< int > sil;

inline int fpow(int v, int w)
{
    int r = 1;
    while (w > 0)
    {
        if (w & 1)
            r = ((ll)r * v) % mod;
        w >>= 1; v = ((ll)v * v) % mod;
    }
    return r;
}

inline int binom(int n, int k)
{
    int m = ((ll)sil[k] * sil[n - k]) % mod;
    return ((ll)sil[n] * fpow(m, mod - 2)) % mod;
}

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

    cin >> n >> a >> b >> k;

    sil.rsz(n + 1);

    sil[0] = 1;

    for (int i = 1; i <= n; ++i)
        sil[i] = ((ll)sil[i - 1] * i) % mod;

    int res = 0;
    for (int i = 0; i <= n; ++i)
    {
        if ((ll)i * a > k)
            break;

        ll v = k - (ll)i * a;
        
        if (v % b)
            continue;

        ll j = v / b;

        if (j > n)
            continue;

        res = ((ll)res + (ll)binom(n, i) * binom(n, j)) % mod;
    }

    prt(res);
}

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

int main(){

    string s;
    cin >> s;
    if((s[0] == s[1] && s[1]== s[2]) || (s[1] == s[2]  && s[2]== s[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1242>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

double getx(int a,int b,int vy,vector<int>& x,vector<int>& y){
    if(y[a] < y[b]) swap(a,b);
    double A = y[a] - vy, B = vy - y[b];
    return (B*x[a]+A*x[b])/(A+B);
}
ll N;
ll solve(){
    ll res = 0;
    vector<int> x(N),y(N); for(int i = 0; i < N;i++) cin >> x[i] >> y[i];
    int l = *min_element(y.begin(), y.end()), r = *max_element(y.begin(), y.end());
    for(int i = l; i < r; i++){
        vector<pair<double,double>> xs;
        for(int j = 0; j < N;j++){
            int nextj = (j+1)%N;
            if(y[j] == y[nextj]) continue;
            if(i < min(y[j],y[nextj])) continue;
            if(i+1 > max(y[j],y[nextj])) continue;
            double x1 = getx(j,nextj,i,x,y),x2 = getx(j,nextj,i+1,x,y);
            if(x1 > x2) swap(x1,x2);
            xs.push_back(make_pair(x1,x2));
        }
        sort(xs.begin(),xs.end());
        int Xr = -INF;
        for(int j = 0; j < xs.size()-1; j+=2){
            int l = max(int(floor(xs[j].first)),Xr),r = ceil(xs[j+1].second);
            res += r - l;
            Xr = r;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N,N){
        cout << solve() << endl;
    }
    return 0;
}



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

int main(){
  int N ; 
  cin >> N ; 
  int D , X ; 
  cin >> D >> X ; 
  vector<int> A(N) ; 
  int cnt = 0 ; 
  for( int i = 0 ; i < N ; i++){
    cin >> A.at(i) ; 
    cnt += (D-1)/A.at(i) + 1  ; 
  }
  
  cout << cnt + X << endl ;
  
  
}

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

int main() {
	int x,fx=0;
	cin >> x;
	string str = to_string(x);

	for (int i = 0; i < str.size(); i++) {
		fx += str[i] - 48;
	}

	if (x%fx == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int
main
()
{
  std::size_t k;
  std::cin >> k;

  const std::size_t num_even{ k / 2 };
  const std::size_t num_odd{ num_even + k % 2 };
  const std::size_t num_pairs{ num_even * num_odd };

  std::cout << num_pairs << std::endl;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n,q;cin>>n>>q;
    string s;cin>>s;
    V memo(n+1);
    for(int now=1;now<n;now++){
        memo[now+1]=memo[now];
        if(s[now-1]=='A'&&s[now]=='C'){
            memo[now+1]++;
        }
        
    }
    rep(i,q){
        int a,b;cin>>a>>b;
        int cnt=memo[b]-memo[a];
        cout<<cnt<<endl;
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int tot = 1, cnt = 1;
  rep(i, n) {
    if (a[i] % 2 == 0) cnt *= 2;
    tot *= 3;
  }
  cout << tot - cnt << endl;
  return 0;
}

Measured memory_bytes: 3616
/**
 *    author:  FromDihPout
 *    created: 2020-08-16
**/

#include <bits/stdc++.h>
using namespace std;


void dfs(int u, set<int> &comp, vector<vector<int>> &adj) {
    comp.insert(u);
    for (int v : adj[u]) {
        if (comp.count(v)) continue;
        dfs(v, comp, adj);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> p(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    vector<vector<int>> adj(n+1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    
    vector<bool> seen(n+1);
    set<int> comp;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (seen[i]) continue;
        comp.clear();
        dfs(i, comp, adj);
        for (int x : comp) {
            if (comp.count(p[x])) ans++;
            seen[x] = true;
        }
    }
    
    for (int i = 1; i <= n; i++) {
        if (!seen[i] && p[i] == i) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 17644
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)



int main(){
	long long int x, k, d;
	scanf("%lld%lld%lld", &x, &k, &d);

	long long int syo=0, ans=x;
	if(x < 0){
		x = x*(-1);
	}
	syo = x/d;

	if(syo >= k){
		ans = x - d*k;
	}
	else{
		k = k - syo;
		x = x - d*syo;

		if(k%2 == 0){
			ans = x;
		}
		else{
			ans = d - x;
		}
	}

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



Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
    int x;
    cin >> x;
    if (x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

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

int main()
{
    string s;
    cin>>s;
    deque<char>dq;
    for(int i=0;i<s.size();i++)dq.push_back(s[i]);

    int m;
    cin>>m;
    int counter=0;
    while(m--)
    {
        int k;
        cin>>k;
        if(k==1)
        {
            counter++;
        }
        else
        {
            int l;
            char p;
            cin>>l>>p;
            if(counter%2==0)
            {
                if(l==1)
                {
                    dq.push_front(p);
                }
                else
                {
                    dq.push_back(p);
                }
            }
            else if(counter%2==1)
            {
                if(l==1)
                {
                  dq.push_back(p);
                }
                else
                {
                     dq.push_front(p);
                }
            }
        }
    }
    if(counter%2==1)reverse(dq.begin(),dq.end());
    for(deque<char>::iterator it=dq.begin();it!=dq.end();it++)
    {
        cout<<*it;
    }
    cout<<"\n";

}


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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    const ll p = 1000000007,
             max_n = 5'000 + 1;
    array<ll, max_n> pp;
    pp[0] = 1;
    for(int i = 1; i < max_n; i++)
        pp[i] = pp[i - 1] * p;
    ll n;
    cin >> n;
    string S;
    cin >> S;

    vector<ll> A(n + 1, 0);
    for(int i = 0; i < n; i++)
        A[i + 1] = A[i] + S[i] * pp[i];

    int a = 0, b = n + 1, c;
    while(a < b) {
        c = (a + b + 1) / 2;
        bool found = false;
        for(int i = 0; i < n - 2 * c + 1; i++)
            for(int j = i + c; j < n - c + 1; j++)
                if((A[i + c] - A[i]) * pp[j - i] == A[j + c] - A[j]) {
                    found = true;
                    break;
                }
        if(found)
            a = c;
        else
            b = c - 1;
    }

    cout << a << "\n";
    
    return 0;
}


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

int main() {
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    int xx;
    cin >> xx;
    x[i] = xx - a;
  }
  map<int, ll> num1, num2, num3;
  int n1 = n / 3, n2 = (n + 1) / 3, n3 = (n + 2) / 3;

  for (int i = 0; i < (1 << n1); i++) {
    ll sum_x = 0;
    for (int j = 0; j < n1; j++) {
      if (i & (1 << j)) {
        sum_x += x[j];
      }
    }
    num1[sum_x]++;
  }

  for (int i = 0; i < (1 << n2); i++) {
    ll sum_x = 0;
    for (int j = 0; j < n2; j++) {
      if (i & (1 << j)) {
        sum_x += x[n1 + j];
      }
    }
    num2[sum_x]++;
  }

  for (int i = 0; i < (1 << n3); i++) {
    ll sum_x = 0;
    for (int j = 0; j < n3; j++) {
      if (i & (1 << j)) {
        sum_x += x[n1 + n2 + j];
      }
    }

    num3[sum_x]++;
  }

  ll ans = 0;
  for (auto p1: num1) {
    for (auto p2: num2) {
      ans += p1.second * p2.second * num3[-(p1.first + p2.first)];
    }
  }
  cout << ans - 1 << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int

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

string s;
cin>>s;
for(int i=0;i<s.length();i++)
{
	if(s[i]=='7')
	{
		cout<<"Yes";
		return 0;
	}
}
cout<<"No\n";
    
    
    return 0;
}

Measured memory_bytes: 3616
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    bool vis[n] = {false};
    forn(i,n)   cin>>a[i];
    int alice=0, bob=0, dir=0;
    int visited = n;
    
    while(visited){
        int maxi = INT_MIN;
        int idx =0 ;
        forn(i,n){
            if(maxi < a[i] && !vis[i]){
                maxi = a[i];
                idx = i;
            }
        }
        vis[idx] = true;
        if(dir==0)  alice += maxi, dir=1;
        else if(dir==1)  bob += maxi, dir=0;
        visited--;
    }
    cout<<alice-bob<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
long long INF = 1e18;
int main(){
  int N, K;
  scanf("%d %d", &N, &K);
  long long a[N];
  for(int i = 0; i < N; i++) scanf("%lld", &a[i]);
  long long ans = INF;
  for(int i = 0; i < N; i++){
      if(i + K - 1 >= N) break;
      long long b = a[i], c = a[i + K - 1];
      if(b < 0 && c >= 0) ans = min(ans, llabs(c) + llabs(b) + min(llabs(c), llabs(b)));
      else ans = min(ans, max(llabs(b), llabs(c)));
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  ll X, Y;
  cin >> X >> Y;
  ll start = X;
  int count = 0;
  while (start <= Y) {
    start = 2 * start;
    count++;
  }

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

Measured memory_bytes: 256
#include <stdio.h>


int main(void) {

	// 1_5-D Structured Programming

	int n;
	int i,j,x;
	scanf("%d",&n);
	
	for(i=1; i<=n; i++){
		if(i%3==0){
			printf(" %d",i);
		}else{
			x = i;
			while(0<x){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				x = x/10;
			}
		}
	}
	printf("\n");
        return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
int a,b,c;
ll k;
int main(){
  scan(a);scan(b);scan(c);scan(k);
  if(k%2==0){
    prin(a-b);
  }
  else{
    prin(b-a);
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scan(&N)
	fmt.Scan(&K)
	var S string
	fmt.Scan(&S)

	count := 0
	for i := 0; i < N - 1; i++ {
		if S[i] != S[i + 1] {
			count++
		}
	}

	if K * 2 <= count {
		fmt.Println(N + 2*K - count - 1)
	} else {
		fmt.Println(N - 1)
	}
}


Measured memory_bytes: 1280
#include<stdio.h>

int num[10000];
int main( void ) 
{
 
    int n;
    scanf( "%d", &n );
    
    int i, j;

    int cnt = n;
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num[i] );
    }
    for( i=0; i<n; i++ ) {    
        if( 2 == *(num+i) ) { continue; }
        
        if( 0 == *(num+i)%2 ) {
            cnt--;
            continue;
        }
        
        for( j=3; j*j<=*(num+i); j+=2 ) {
            if( 0 == *(num+i)%j ) {
                cnt--;
                break;
            }
        }
    }
     
    printf( "%d\n", cnt );
    
    return 0;
}

Measured memory_bytes: 628
import math

a = input()
b = input()
c = input()
d = input()
e = input()

a_1 = 9 if int(a[-1]) == 0 else int(a[-1])
b_1 = 9 if int(b[-1]) == 0 else int(b[-1])
c_1 = 9 if int(c[-1]) == 0 else int(c[-1])
d_1 = 9 if int(d[-1]) == 0 else int(d[-1])
e_1 = 9 if int(e[-1]) == 0 else int(e[-1])

m = min(a_1, b_1, c_1, d_1, e_1)
ans = 0

if a_1 == m:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(a)
elif b_1 == m:
    ans = math.ceil(int(a) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(b)
elif c_1 == m:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(a) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(c)
elif d_1 == m:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(a) / 10) * 10 + math.ceil(int(e) / 10) * 10 + int(d)
else:
    ans = math.ceil(int(b) / 10) * 10 + math.ceil(int(c) / 10) * 10 + math.ceil(int(d) / 10) * 10 + math.ceil(int(a) / 10) * 10 + int(e)

print(ans)


Measured memory_bytes: 3188
import sys
from collections import defaultdict as dd
from collections import deque as dq
input = sys.stdin.readline
N = int(input())
e = dd(list)
if N == 1:
  print(0)
  print(1)
  exit(0)
for _ in range(N - 1):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
res = [0] * (N + 1)
x = list(map(int, input().split()))
x.sort()
print(sum(x[: -1]))
p = 0
dimp = 0
for i in range(N + 1):
  if len(e[i]) > dimp:
    p = i
    dimp = len(e[i])
Q = dq([])
Q.append(p)
vis = set()
while len(Q):
  q = Q.popleft()
  y = x.pop()
  vis.add(q)
  res[q] = y
  for n in e[q]:
    if n in vis: continue
    Q.append(n)

print(" ".join(list(map(str, res[1: ]))))

Measured memory_bytes: 46704
#include <iostream>
using namespace std;
int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {
    cin >> a >> b;
    
    if( a<1 && b<1 )
    break;
    
    if(a > b)
    {
    temp = a;
    a = b ;
    b = temp;
    
    }

 

    cout << a << " " << b << endl;
}
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
   string s;
   cin>>s;
   int x=0;
   for(auto i:s)
    x+=i-'0';
if(x%9==0)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3784
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  long long r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    cout << 1ll * r * x - d << " ";
    x = 1ll * r * x - d;
  }
  cout << endl;
  return 0;
}


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

#define A first
#define B second

const int MAXN = 1e5+5;

int n, m;
vector<int> g[MAXN];
int vis[MAXN];
ll ans = 0;
int col[MAXN];
int ct;
int y;
int cta;

void dfs(int v) {
	vis[v] = 1;
	ct++;
	for (int u : g[v])
		if (!vis[u])
			dfs(u);
}

void b(int v, int c) {
	col[v] = c;
	if (c == 1)
		cta++;
	for (int u : g[v]) {
		if (col[u] == 0)
			b(u, 3-c);
		if (col[u] + col[v] != 3)
			y = 0;
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i = 0; i < n; ++i) {
		if (!vis[i]) {
			ct = 0;
			dfs(i);
			y = 1;
			cta = 0;
			b(i, 1);
			if (y == 0)
				ans += 1LL*ct*(ct-1)/2;
			else
				ans += 1LL*cta*(ct-cta);
		}
	}

	cout << ans-m << endl;
}


Measured memory_bytes: 7296
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> 
using namespace std;
const int N=1e5+5;
map <int ,int > ma;
int a[N],b[N];
int main (){
    int n;scanf ("%d",&n);
    for (int i=1;i<=n;i++) scanf ("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+n+1);for (int i=1;i<=n;i++) ma[b[i]]=i;
    int k=0;
    for (int i=1;i<=n;i++)
        if ((i-ma[a[i]])&1) k++;
    printf ("%d",(k>>1));
    return 0;
}

Measured memory_bytes: 5760
n, k = gets.split.map(&:to_i)
ans = 0
if k == 0
  ans += n ** 2
else
  (1..n).each do |i|
    ans += (n / i) * [i - k, 0].max + [n % i + 1 - k, 0].max
  end
end
p ans

Measured memory_bytes: 1788