akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-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 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 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)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N;
    cin >> N;

    cout << (N+1) / 2 << endl;
}

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

int main(){
	string s,t;
	cin>>s>>t;
	int n=s.length(),m=t.length();
	int dp[n][m];
	char direc[n][m];
	memset(dp,0,sizeof(dp));
	direc[0][0]='.';
	if(s[0]==t[0]) dp[0][0]=1;
	for(int i=1; i<n; i++){
		dp[i][0]=dp[i-1][0];
		direc[i][0]='^';
		if(s[i]==t[0]){dp[i][0]=1;direc[i][0]='.';}
	}
	for(int j=0; j<m; j++){
		dp[0][j]=dp[0][j-1];
		direc[0][j]='<';
		if(s[0]==t[j]){dp[0][j]=1;direc[0][j]='.';}
	}
	
	for(int i=1; i<n; i++){
		for(int j=1; j<m; j++){
			if(s[i]==t[j]){ dp[i][j] = dp[i-1][j-1] + 1; direc[i][j]='.';}
			if(dp[i][j-1] >= dp[i][j]){
				dp[i][j]=dp[i][j-1]; direc[i][j]='<';
			}
			if(dp[i-1][j] >= dp[i][j]){
				dp[i][j]=dp[i-1][j]; direc[i][j]='^';
			}
		}
	}
	
	int mx=0; pair<int,int> mxpos = make_pair(-1,-1);
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(dp[i][j] > mx){ mx=dp[i][j]; mxpos=make_pair(i,j);}
		}
	}
	int a=mxpos.first,b=mxpos.second;
	string ans="";
	while(a>=0&&b>=0){
		//cout<<a<<' '<<b<<' '<<direc[a][b]<<endl;
		if(a==0||b==0){
			if(s[a]==t[b]){ ans.push_back(s[a]); break;}
			if(direc[a][b]=='.') break;
		}
		int u,v;
		if(direc[a][b]=='^'){
			u=a-1;v=b;
		}
		if(direc[a][b]=='<'){
			u=a;v=b-1;
		}
		if(direc[a][b]=='.'){
			u=a-1;v=b-1;
		}
		
		if(dp[u][v] < dp[a][b]) ans.push_back(s[a]);
		a=u; b=v;
	}
	for(int i=ans.length()-1; i>=0; i--) cout<<ans[i];
}

Measured memory_bytes: 44288
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    string c[a];
    for ( int i = 0 ; i < a ; i++ ) cin >> c[i];
    for ( int i = 0 ; i < b + 2 ; i++ ) cout << '#';
    cout << endl;
    for ( int i = 0 ; i < a ; i++ ) cout << '#' << c[i] << '#' << endl;
    for ( int i = 0 ; i < b + 2 ; i++ ) cout << '#';
}

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> p;
	for (int i = 0; i < N; ++i)
	{
		int A, B;
		cin >> A >> B;
		p.push({B, A});
	}
	
	int time = 0;
	while (!p.empty())
	{
		auto job = p.top();
		p.pop();
		int due = job.first;
		time += job.second;
		if (time > due)
		{
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 2420
/*
    0123456
    ???abcdefg
    012
    fga 
*/


#include<stdio.h>
#include<string.h>
#define SIZE 200

int main(void)
{
  char s[SIZE], p[SIZE];
  int slen, plen;
  int hed, i, j;
  int mach = 0;

  scanf("%s", s);
  scanf("%s", p);  
  slen = strlen(s);
  plen = strlen(p);

  hed = 0;
  do{
    i = hed;
    j = 0;
    while(s[i] == p[j]){
      i = (i + 1) % slen;
      j = j + 1;
      if(plen <= j){
        mach = 1;
      }
    }
    hed = (hed + 1) % slen;
  }while(hed != 0 );

  if(mach){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return(0);
}

Measured memory_bytes: 524
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] d = new int[999];
        for(int i = 0; i < 999; i++) {
            d[i] = i + 1;
        }
        int[] s = new int[999];
        s[0] = d[0];
        for(int i = 1; i < 999; i++) {
            s[i] = s[i-1] + d[i];
        }
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.println(solve(s, a, b));
    }
    public static int solve(int[] s, int a, int b) {
        int diff = b - a;
        int i = 0;
        for(i = 1; i < 999; i++) {
            if (s[i] - s[i-1] == diff) {
                break;
            }
        }
        return s[i] - b;
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
  int n;if(scanf("%d",&n)==1){}
  int b[n-1];int i;
  for(i=0;i<n-1;i++){
    if(scanf("%d",&b[i])==1){}
  }
  int max = b[0]+b[n-2];
  for(i=1;i<n-1;i++){
    if(b[i-1]<b[i]){
      max+=b[i-1];
    }else{
      max+=b[i];
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
int n;
  scanf("%d",&n);
  int dp[n];
  dp[0]=0;
  int xp,x;
  scanf("%d",&xp);
  int ans=0;
  for(int i=1;i<n;i++)
  {
    scanf("%d",&x);
    if(x>xp)
      dp[i]=0;
    else
      dp[i]=dp[i-1]+1;
    ans=max(ans,dp[i]);
    xp=x;
  }
  printf("%d",ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    set<string> st;

    rep(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<(st.size()==3 ? "Three" : "Four")<<endl;
    return 0;
}



Measured memory_bytes: 256
s=input()
dic={}
for i in range(4):
  if s[i] not in dic:
    dic[s[i]]=1
  else:
    dic[s[i]]+=1
val=list(dic.values())
if len(dic)==2 and val[0]==2 and val[1]==2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,ans,dp[100001];
bool fix[100001];
vector<int>v[100001];
int dfs(int x)
{
    fix[x] = true;
    for(int i=0; i<v[x].size(); i++)
        if(fix[v[x][i]]) dp[x] = max(dp[x], dp[v[x][i]] + 1);
        else dp[x] = max(dp[x], dfs(v[x][i]));
    return dp[x] + 1;
}
int main()
{
    cin >> n >> m;
    for(int i=1; i<=m; i++)
        cin >> a >> b, v[a].push_back(b);
    for(int i=1; i<=n; i++)
        if(!fix[i]) dfs(i);
    for(int i=1; i<=n; i++) ans = max(dp[i],ans);
    cout << ans << endl;
}

Measured memory_bytes: 8192
def F(A,B):
    A_len=len(str(A))
    B_len=len(str(B))
    return max(A_len,B_len)

N=int(input())
answer=len(str(N))
for A in range(1,int(N**0.5)+1):
    if( N % A == 0):
        B=N // A
        answer= min(answer,F(A,B))
print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
int main()
{
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int k;
    cin>>k;
    int ans=a[0]+a[1];
    ans+=a[2]<<k;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int N;cin >> N;
    vector<double> v(N);
    rep(i,0,N)cin >> v[i];
    sort(range(v));
    rep(i,0,N-1){
        v[i+1]=(v[i]+v[i+1])/2;
    }
    cout << v[N-1] << endl;
    return 0;
}

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

public class Program{
    public static void Main(){
        int times = int.Parse(Console.ReadLine());
        int[] sticks = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int result = 0;
        
        for (int i = 0; i < sticks.Count() - 2; i++){
            for (int j = i + 1; j < sticks.Count() - 1; j++){
                for (int k = j + 1; k < sticks.Count(); k++){
                    int[] targetSticks = new int[] {sticks[i], sticks[j], sticks[k]};
                    Array.Sort(targetSticks);
                    if (targetSticks[0] != targetSticks[1] && targetSticks[1] != targetSticks[2]){
                        if (targetSticks[0] + targetSticks[1] > targetSticks[2]) result++;
                    }
                }
            }
        }
        
        Console.WriteLine(result);
    }
}


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

int main()
{
    std::string s;
    std::cin>>s;
    int ans;
    if(s == "SAT")ans = 1;
    if(s == "FRI")ans = 2;
    if(s == "THU")ans = 3;
    if(s == "WED")ans = 4;
    if(s == "TUE")ans = 5;
    if(s == "MON")ans = 6;
    if(s == "SUN")ans = 7;
    std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    rep(i,s.size()-1){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;return 0;
        }
        else if(i+2<s.size()&&s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#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;

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

int main(){
    int N; cin >> N;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N) A[i]--;
    
    vector <int> cnt(N);
    rep(i,N) cnt[A[i]]++;
    ll sum=0;
    rep(i,N) sum+=choose2(cnt[i]);
    rep(i,N){
        ll ans=sum;
        ans-=choose2(cnt[A[i]]);
        ans+=choose2(cnt[A[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
n,k=map(int,input().split())
a=list(map(int,input().split()))
ma=max(a)
g=a[0]
for i in a:
  g=gcd(g,i)
if(k%g==0 and k<=ma):print("POSSIBLE")
else:print("IMPOSSIBLE")

Measured memory_bytes: 14224
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,n,f=0,j,k,mn=0,ans;
    cin>>x>>n;
    ll a[n];
    ans=x;
    mll m;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    sort(a,a+n);
    if(m.find(x)==m.end())
        cout<<x;
    else
    {
        j=x,k=x;
        while(1)
        {
           j--;
           if(m.find(j)==m.end())
           {
               f=1;
               ans=j;
               break;
           }
           k++;
           if(m.find(k)==m.end())
           {
               f=1;
               ans=k;
               break;
           }
        }
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
int main(void) {
	int n,i,b,sem,c,ans;
	scanf("%d", &n);
	int a[100];
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	ans = 0;
	b = 1;
	
	while (b <= n) {
		sem = 1;
		while (a[b] == a[b + 1]) {
			sem++;
			b++;
		}
		c = sem % 2;
		ans = ans + (sem - c) / 2;
		b++;
	}
	printf("%d", ans);
	return 0;


	}


Measured memory_bytes: 128
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=100005;

int n,m;
vector<int>G[N];
int in[N],dp[N];
int qh,qt,q[N];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n>>m;
    while (m--) {
        int u,v; cin>>u>>v;
        G[u].pb(v);
        ++in[v];
    }
    for (int i=1;i<=n;++i)
        if (!in[i]) q[qt++]=i;
    while (qh<qt) {
        int u=q[qh++];
        for (int v:G[u]) {
            dp[v]=max(dp[v],dp[u]+1);
            --in[v];
            if (!in[v]) q[qt++]=v;
        }
    }
    cout<<*max_element(dp+1,dp+n+1)<<'\n';
}

Measured memory_bytes: 6912
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC = [list(map(int,input().split())) for _ in range(Q)]
total = sum(A)
dict = {}
for i in range(len(A)):
  if A[i] not in dict:
    dict[A[i]] = 1
  else:
    dict[A[i]] += 1
for i in range(Q):
  if BC[i][0] not in dict:
    dict[BC[i][0]] = 0
  if BC[i][1] not in dict:
    dict[BC[i][1]] = 0
  if dict[BC[i][0]] > 0:
    num = (BC[i][1] - BC[i][0]) * (dict[BC[i][0]])
    total += num
  print(total)
  dict[BC[i][1]] += dict[BC[i][0]]
  dict[BC[i][0]] = 0

Measured memory_bytes: 39608
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        if((C>=A)&&(B>=C)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

}
        
        
    }


Measured memory_bytes: 21844
n, m = gets.chomp.split(" ").map(&:to_i)
edges = Hash.new([])
m.times do
    a, b = gets.chomp.split(" ").map(&:to_i)
    if edges.has_key?(a)
        edges[a] << b
    else
        edges[a] = [b]
        
    end
    if edges.has_key?(b)
        edges[b] << a
    else
        edges[b] = [a]
    end
end


def dfs(v, edges, visited)
    if visited.length == visited.count{|i| i == true}
        return 1
    end

    ret = 0

    edges[v].each do |i|
        next if visited[i-1] == true
        visited[i-1] = true
        ret += dfs(i, edges, visited)
        visited[i-1] = false
    end

    return ret
end

visited = Array.new(n, false)
visited[0] = true
puts dfs(1, edges, visited)

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

int main() {
    ll n, sum = 0; cin >> n;
    vector<ll> a(n),cnt(100010);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    int q; cin >> q;
    vector<int> b(q), c(q);
    for(int i=0; i<q; i++) cin >> b[i] >> c[i];
    for(int i=0; i<q; i++)  {
        ll num = sum + (cnt[b[i]] * (c[i] - b[i]));
        cout << num << endl;
        cnt[c[i]] += cnt[b[i]];
        cnt[b[i]] = 0;
        sum = num;
    }
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, m; std::cin >> n >> m;
  string s; std::cin >> s;
  reverse(rng(s));
  vi ans;
  int x = 0;
  while (x < n) {
    int dx = m;
    while (x+dx > n || s[x+dx] == '1')
      dx--;
    if (dx == 0) {
      std::cout << -1 << "\n";
      return 0;
    }
    ans.pb(dx);
    x += dx;
  }
  int len = ans.size();
  drep(i, len) std::cout << ans[i] << (i > 0 ? " " : "\n");
}


Measured memory_bytes: 1096
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll mod=998244353;

int main() {
    ll n,i;cin>>n;ll h[n];for(i=0;i<n;i++)cin>>h[i];
    ll dp[n+1];dp[0]=0;dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-2]+abs(h[i-1]-h[i-3]),dp[i-1]+abs(h[i-1]-h[i-2]));
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5;  
const double pie = 3.14159265358979323846 ;
// limit for array size 
double dist(double Ax,double X,double Ay, double Y){
  double best = (Ax-Ay)*(Ax-Ay) + (X-Y)*(X-Y) ;
  best = sqrt(best) ;
  return best ;
}
int tests(){ 
  // vector <vector <int>> M(3,vector <int> (3,271)) ;
    ll N,A,B ;
    cin >> N >> A >> B ; 
    ll ans  =  (N/(A+B))*A ; 
    N %= (A+B) ;
    N = min(N,A) ; 
    ans += N ; 
    cout << ans  <<  '\n' ;  
  return 0 ;
}
int main(){
    I__O ;  
    int cases = 1 ;
    // cin >> cases ; 
    while(cases--)
      tests(); 
    return 0 ; 
}

Measured memory_bytes: 256
n=int(input())
ans=0
#it is the power of every prime number
#and as z is always a prime numer we should not bother about
# combiations of prime numer dividing N
for i in range(2,1000010):
	power=0
	j=1
	if(n%i==0):
		while(n%i==0):
			power+=1
			n=(n//i)
		while(power>=j):
			power-=j
			j+=1
			ans+=1
if(n>1):
	ans+=1
print(ans)

Measured memory_bytes: 9188
s = input()
S=len(s)
ans = ''
for i in range(2**(S-1)):
    ans+=s[0]
    for j in range(0,S-1):
        if i>>j&1:
            ans+=""+s[j+1]
        else:
            ans+=" "+s[j+1]
    ans+=" "
 

print(sum(map(int,ans.split())))

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

int main(){
    int n,i,j;
    char a[6],b[6],temp;
    scanf("%s",a);
    scanf("%s",b);
    n=strlen(a);
    for(i=0,j=n-1;i<j;i++,j--){
        temp=a[i];
        a[i]=a[j];
        a[j]=temp;
    }
    if(strcmp(a,b)==0) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<int> V;
typedef vector<V> VV;

constexpr int X = 30001;
int main() {
	VV num(3);
	for (int i : range(1,X)) {
		if (i % 6 == 0);
		else if (i % 3 == 0)num[1].push_back(i);
		if (i % 2 == 0)num[0].push_back(i);
	}
	vector<pair<int, int>> ok(X, {0,0});
	for (int i = 2; i <= num[1].size();i+=2) {
		int j = 2,k=1;
		while (j <= num[0].size()) {
			ok[i + j] = { j,i };
			j += k;
			k = 3 - k;
		}
	}
	int N;
	cin >> N;
	if (N == 3) {
		cout << "2 5 63" << endl;
	}
	else if (N == 4) {
		cout << "2 5 20 63" << endl;
	}
	else {
		for (int i : range(ok[N].first)) {
			cout << num[0][i] << " ";
		}
		for (int i : range(ok[N].second)) {
			cout << num[1][i] << " ";
		}
		cout << endl;

	}
	return 0;
}


Measured memory_bytes: 768
import sys
from collections import Counter

def prime_factorize(n):
    ans = []
    while not n%2:
        ans.append(2)
        n //= 2
    mod = 3
    while mod**2 <= n:
        if n%mod == 0:
            ans.append(mod)
            n //= mod
        else:
            mod += 2
    if n != 1:
        ans.append(n)
    counter = Counter(ans)
    return counter

def main():
    input = sys.stdin.readline
    mod = pow(10,9)+7
    n = int(input())
    a = [int(x) for x in input().split()]
    
    prime_list = dict()
    for i in range(n):
        primes = prime_factorize(a[i])
        for key, value in primes.items():
            if key in prime_list:
                if prime_list[key] < value:
                    prime_list[key] = value
            else:
                prime_list[key] = value
    
    L = 1
    for key, value in prime_list.items():
        L *= pow(key, value, mod)
        L %= mod
        
    ans = 0
    for i in range(n):
        ans += (L*pow(a[i], mod-2, mod))%mod
        ans %= mod
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4844
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int a[100005];
    int s1=0,s2=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]&1)s1++;
    }
    if(s1%2==0)printf("YES\n");
    
    else printf("NO\n");
    return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, x, y;

	cin >> n;

	vector<ll> a;

	REP(i, n + 1) {
		cin >> x;
		a.push_back(x);
	}

	ll ans = 0;

	vector<ll> b;

	REP(i, n) {
		cin >> y;
		b.push_back(y);
	}

	REP(i, n) {
		if (b[i] >= a[i]) {
			b[i] -= a[i];
			ans += a[i];
			a[i] = 0;
			if (b[i] >= a[i + 1]) {
				ans += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				ans += b[i];
				a[i + 1] -= b[i];
			}
		}
		else {
			ans += b[i];
			a[i] -= b[i];
			b[0] = 0;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2548
until (n = gets.to_i).zero?
  h, str = {}, ""
  
  n.times do
    k, v = gets.chomp.split
    h[k] = v
  end
  
  gets.to_i.times do
    tmp = gets.chomp
    h[tmp] ? str += h[tmp] : str += tmp
  end
  
  puts str
end

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



int main(){
    int a,b,c;
    cin >> a >> b >>c;
    int tmp;
    if(a<b){
        tmp = a;
        a = b;
        b  =tmp;
    }
    while(b !=0){
        tmp = a%b;
        a = b;
        b = tmp;
    }
    if(c%a != 0){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k;
string s;
void solve(){
	cin >> n >> k >> s;
	
	vector<int> v;
	if(s[0] == '0') v.push_back(0);
	int cnt = 1;
	for(int i = 1; i < n; i++){
		if(s[i-1] != s[i]){
			v.push_back(cnt);
			cnt = 1;
		}
		else{
			cnt++;
			if(i == n-1) v.push_back(cnt);
		}
	}
	v.push_back(0);
	
	int ans = 1;
	cnt = 0;
	for(int i = 0; i < min((int)v.size(),k*2+1); i++){
		cnt += v[i];
	}
	chmax(ans,cnt);
	for(int i = k*2+1; i < v.size()-1; i+=2){
		cnt -= v[i-(k*2+1)] + v[i-(k*2+1)+1];
		cnt += v[i] + v[i+1];
		chmax(ans, cnt);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1020
'use strict'

const main = (input) => {
    const S = input.split('\n')[0]
    let ans = 1000
    for(let i = 0; i < S.length - 2; i++){
        let s = parseInt(S.slice(i, i + 3))
        let diff = Math.abs(753 - s)
        if(diff < ans){
            ans = diff
        }
    }
    console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


Measured memory_bytes: 9420
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B, C = map(int, input().split())
K = int(input())

while A >= B:
    B *= 2
    K -= 1
while B >= C:
    C *= 2
    K -= 1

print("Yes" if K >= 0 else "No")

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    ll res = 0;
    REP(i, N-1){
    	if(a[i] == a[i+1]){
    		res++;
    		a[i+1] = -1;
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
N = int( input())
A = [ int( input()) for _ in range(N)]
now = 0
ans = 0
if A[0] != 0:
    ans = -1
else:
   for i in range(1,N):
       if A[i] > i:
           ans = -1
           break
       elif now + 1 == A[i]:
           ans += 1
           now += 1
       elif now >= A[i]:
           ans += A[i]
           now = A[i]
       else:
           ans = -1
           break
print(ans)

Measured memory_bytes: 11048
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct strProcess
{
  char name[11];
  int time;
} process;

typedef struct strProcessQueue
{
  process value;
  struct strProcessQueue *next;
} processQueue;

processQueue *current;
processQueue *previous;
int qsize;

void printProcess(process);
void removeProcess();
int runProcess(int, int);

int main(void)
{
  int n, q, i, totalTime = 0;
  scanf("%d %d", &n, &q);
  qsize = n;
  current = (processQueue *) malloc(sizeof(processQueue));
  processQueue *first = current;
  for (i = 0; i < n; i++)
    {
      char name[11];
      int time;
      scanf("%s %d", name, &time);
      strcpy(current->value.name, name);
      current->value.time = time;
      if (i == n-1)
	  current->next = first;
      else
	current->next = (processQueue *) malloc(sizeof(processQueue));
      previous = current;
      current = current->next;
    }
  while (qsize > 0)
    totalTime = runProcess(q, totalTime);
  return 0;
}

void printProcess(process input)
{
  printf("%s %d\n", input.name, input.time);
}

void removeProcess()
{
  previous->next = current->next;
  free(current);
  current = previous->next;
  qsize--;
}

int runProcess(int q, int totalTime)
{
  if (current->value.time <= q)
    {
      totalTime += current->value.time;
      printf("%s %d\n", current->value.name, totalTime);
      removeProcess();
    }
  else
    {
      totalTime += q;
      current->value.time -= q;
      previous = current;
      current = current->next;
    }
  return totalTime;
}



Measured memory_bytes: 3372
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 1;
  if(s[0] == 'W' && s[2*n-1] == 'W'){
    ans = 0;
  }
  int opr[2*n];
  opr[0] = 1; //L = 1,R = 0
  for(int i=1;i<2*n;i++){
    if(s[i] == s[i-1]) opr[i] = 1 - opr[i-1];
    else opr[i] = opr[i-1];
  }
  if(opr[2*n-1] == 1) ans = 0;
  ll count[2*n];
  count[0] = 0;
  for(int i=1;i<2*n;i++){
    count[i] = count[i-1];
    if(opr[i-1] == 1) count[i]++;
  }
  if(count[2*n-1] != n) ans = 0;
  ll r = 0;
  for(int i=0;i<2*n;i++){
    if(opr[i] == 1) continue;
    ans *= (count[i]-r);
    ans %= MOD;
    r++;
  }
  for(int i=1;i<n+1;i++){
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string a;
  cin>>a;
  if(a.at(0)==a.at(1)){
    cout<<"Bad"<<endl;
  }
  else if(a.at(1)==a.at(2)){
    cout<<"Bad"<<endl;
  }
  else if(a.at(2)==a.at(3)){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}

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


int main() {
    int k;
    ll len;
    string s;
    cin >> k >> s;
    len = s.size();
    if(len <= k){
        cout << s <<endl;
    }
    else if(len > k){
        s = s.erase(k,len-k);
        s = s.insert(k,"...");
        cout << s <<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll a, b;
    cin >> a >> b;
    ll ans = 0;

    rep(i, max(a, b))
    {
        ans += min(a, b) * pow(10, i);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

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

	
	
}


Measured memory_bytes: 3624
#include<stdio.h>
void SelectionSort(int *,int);
#define N 100 



main(){
  int i,A[N],n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  SelectionSort(A,n);

  return 0;
}

void SelectionSort(int *a,int num){
  int i,j,temp,minj,con=0;
  for(i=0;i<num;i++){
    minj = i;
    for(j=i;j<num;j++) {
      if(a[j]<a[minj]){ 
	minj = j;

      }
    }
    if(i!=minj)	con++;
    temp=a[i];
    a[i] = a[minj];
      a[minj]=temp;
  }
  
  for(i=0;i<num-1;i++) printf("%d ",a[i]);
  printf("%d",a[num-1]);  
  printf("\n");  
  printf("%d\n",con);
}

Measured memory_bytes: 604
import sys


def main():
    n = int(sys.stdin.readline().strip())
    l = [int(s) for s in sys.stdin.readline().strip().split()]
    # n = 4
    # l = [1, 2, 3, 4]

    l.sort()

    # [lo, hi)
    # Returns -1 if no valid item
    def b_search(lo, hi, limit):
        while lo + 1 < hi:
            mid = (lo + hi) // 2
            if l[mid] < limit:
                lo = mid
            else:
                hi = mid
        if lo >= hi:
            return -1
        if lo + 1 == hi:
            return lo

    ans = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            a_plus_b = l[i] + l[j]
            valid_longest_idx = b_search(j, n, a_plus_b)
            ans += valid_longest_idx - j

    print(ans)


main()


Measured memory_bytes: 42944
object Main {
  val dp = Array.ofDim[Long](10, 1001)
  dp(0)(0) = 1
  for(i <- 0 to 100) {
    for(c <- 8 to 0 by -1) {
      for(j <- 0 to 1000 if i + j <= 1000) {
        dp(c + 1)(i + j) += dp(c)(j)
      }
    }
  }
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var n = sc.nextInt
    var s = sc.nextInt
    while(n != 0 || s != 0) {
      println(dp(n)(s))
      n = sc.nextInt
      s = sc.nextInt
    }
  }
}

Measured memory_bytes: 59696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    if(a != c) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 10000009
#define mod 998244353
ll n,m,i,j,k,t,arr[sz],brr[sz],l;
vector<ll>v[sz];
map<ll,ll>mp;
vector<pair<ll,ll> >v1;
int main()
{
 for(i=1;i<=10000000;i++)
 {
    for(j=1;j*i<=10000000;j++)
        arr[i*j]++;
 }
 for(i=1;i<=10000000;i++)
    arr[i]*=i,brr[i]=brr[i-1]+arr[i];
    scanf("%lld",&n);
    printf("%lld\n",brr[n]);
 return 0;
}


Measured memory_bytes: 394332
#include<stdio.h>

int main()
{
	int a,b,c,d;
	int area1,area2;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	area1 = a*b;
	area2 = c*d;
	if(area1 >= area2)
		printf("%d",area1);
	else 
		printf("%d",area2);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int sum(int number){
    int s = 0;
    while(number){
        s += number%10;
        number/=10;
    }
    return s;
}

int main()
{
    int N,A,B;
    int ans = 0;
    cin>>N>>A>>B;
    for(int i =1;i<=N;i++){
        if(sum(i)>=A && sum(i)<=B)ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp = min(x[i], k - x[i]);
		ans += tmp;
	}
	cout << ans * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }


int N;

signed main()
{
	cin >> N;

	int ans = 0;
	for (int i = 1; i < N; i++)
	{
		int b = (N - 1) / i;
		ans += b;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  double ans=0;
  vector<vector<int>> P(N, vector<int>(2,0));
  for(int i=0; i<N; i++){
    int a, b;
    cin >>a >>b;
    P[i][0]=a;
    P[i][1]=b;
  }
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      ans+=sqrt((P[i][0]-P[j][0])*(P[i][0]-P[j][0])+
        (P[i][1]-P[j][1])*(P[i][1]-P[j][1]));
//       cout<<"i:"<<i<<" j:"<<j<<" ans:"<<ans<<endl;
    }
  }
  int line=0;
  for(int i=1; i<N; i++){
    line+=i;
  }
  ans=ans/line*(N-1);
  cout <<setprecision(10) <<ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define ll long long
map<ll,ll> chk;
ll arr[100001],N,M,mi=2100000000,dis,ans;
int main()
{
	cin >> N >> M;
	
	for(int i=0; i<N; i++)
	{
		cin >> arr[i];
		chk[arr[i]]=i+1;
		
		if(arr[i]-mi>dis)
		dis=arr[i]-mi;
		if(mi>arr[i])
		mi=arr[i];
	}
	for(int i=0; i<N; i++)
	{
		if(chk[arr[i]-dis]<i+1&&chk[arr[i]-dis])
		ans++;
	}
	cout << ans;
	
}

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

int main() {
    int64_t N;
    string S;
    int64_t cnt = 0;
    cin >> N >> S;
    vector<int64_t> R(0);
    vector<int64_t> G(0);
    vector<int64_t> B(0);

    for(int64_t i = 0;i < N; i++){
        if(S.at(i) == 'R'){
            R.push_back(i);
        }else if(S.at(i) == 'G'){
            G.push_back(i);
        }else if(S.at(i) == 'B'){
            B.push_back(i);
        }
    }

    for(int64_t x: R){
        for(int64_t y: G){
            cnt += B.size();
            if(binary_search(B.begin(), B.end(), 2*y-x)){
                cnt -= 1;
                //cout << x << y << 2*y-x << endl;
            }
            if(binary_search(B.begin(), B.end(), 2*x-y)){
                cnt -= 1;
                //cout << 2*x-y << x << y << endl;
            }
            if((x+y)%2 == 0 && binary_search(B.begin(), B.end(), (x+y)/2)){
                cnt -= 1;
                //cout << x << (x+y)/2 << y << endl;
            }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3628
from bisect import *
n,k = map(int,input().split())
A = list(map(int,input().split()))

s = 0
sl = {0:[0]}
for i in range(n):
    s += A[i] - 1
    s %= k
    if s not in sl.keys():
        sl[s] = []
    sl[s].append(i+1)
ans = 0
for ls in sl.values():
    for i,l in enumerate(ls):
        x = bisect_right(ls, l + k - 1)
        ans += x - i - 1
print(ans)


Measured memory_bytes: 59912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(),(v).end()

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> T(N);
	int a, b;
	for (int i = 0;i < M;i++) {
		cin >> a >> b;
		T[b - a].push_back(a);
	}
	for (int i = 0;i < N;i++) {
		sort(all(T[i]));
	}
	int ans;
	for (int i = 0;i < Q;i++) {
		ans = 0;
		cin >> a >> b;
		//始まりの数がb-jならよい
		for (int j = 0;j <= b - a;j++) {
			ans += distance(lower_bound(all(T[j]), a), upper_bound(all(T[j]), b - j));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int a, b; cin >> a >> b;
    cout << max(0, a - 2 * b) << "\n";
}


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

#define db(x) cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;

template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

#define MAXN 100005

int N, M;
int freq[MAXN];
vi adj[MAXN];
int vis[MAXN], dp[MAXN];

int solve(int idx)
{
	if (vis[idx])
	{
		return dp[idx];
	}
	vis[idx] = 1;
	
	int res = 0;
	for (int i : adj[idx])
	{
		res = max(res, solve(i) + 1);
	}
	
	dp[idx] = res;
	return res;
}

int main() 
{
	scanf("%d%d", &N, &M);
	
	int u, v;
	for (int i = 0; i < M; i++)
	{
		scanf("%d%d", &u, &v);
		freq[v]++;
		adj[u].pb(v);
	}
	
	int res = 0;
	for (int i = 0; i <= N; i++)
	{
		if (freq[i] == 0)
		{
			res = max(res, solve(i));
		}
	}
	
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <math.h>
//#include <bitset/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//キモは、必ずV問選ばなければいけないことにありそう
int main()
{
    ll N,M,V,P,res;
    cin >> N >> M >> V >> P;
    vector <ll> a(N);
    REP(i, N)cin >> a[i];
    sort(a.rbegin(),a.rend());

    //まず、降順にならべる
    //自分よりすでに下の部分の数を知りたい

    //自分よりめちゃくちゃ票を持っている人にいくら票が入ろうが問題ない
    //-> 現時点で何位か
    //-> P位以内に入るには、何票はいるか
    //まず、+MでP位以内に入るか
    //入るなら、Vを上位と下位に割り振ってがどこまで削れるか
    //残り(例:V = 3)をいい感じに割り振って、P位以内に入るか
    //P,iの区間が3以下なら無理
    //

    int point = a[P-1];

    ll wa = a[P-1];
    res = P;
    //0-indexd
    for(int i = P; i < N; ++i)
    {
        //おわり
        if(a[i] + M < point)break;
        //上位下位
        if(V <= P-1 + N-i)
        {
            ++res;
        }
        else
        {
            ll zan = V - (P-1) - (N-i);
            ll ke = M + a[i];
            //cout << zan << endl;
            //cout << (i+1-P)<< endl;
            //cout <<  ke << endl;
            //cout <<  wa << endl;
            //
            if(zan * M <= (i+1-P) * ke - wa)++res;
        }
        //最後にwa
        wa += a[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 1024
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    const w = Number.parseInt(lengthList[0]);
    const h = Number.parseInt(lengthList[1]);
    const x = Number.parseInt(lengthList[2]);
    const y = Number.parseInt(lengthList[3]);
    const r = Number.parseInt(lengthList[4]);

    if(x-r>=0 && x+r<=w && y+r<=h && y-r>=0){
      console.log("Yes");
    }else{
      console.log("No");
    }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 15352