akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    string S;
    ll Q;
    cin >> N >> S >> Q;
    vector<ll> k(N);
    REP(i,Q)cin >> k[i];
    vector<ll> cmr(0);
    vector<ll> dm(0);
    vector<ll> c(0);
    vector<ll> d(0);
    ll nowm = 0;
    REP(i,N){
        if(S[i] == 'M'){
            nowm++;
        }else if(S[i] == 'D'){
            d.pb(i);
            dm.pb(nowm);
        }else if(S[i] == 'C'){
            c.pb(i);
            if(c.size() != 1){
                cmr.pb(cmr[cmr.size()-1] + nowm);
            }else{
                cmr.pb(nowm);
            }
        }
    }
    REP(i,Q){
        ll answer = 0;
        if(c.size() == 0 || d.size() == 0){
            cout << 0 << "\n";
            continue;
        }
        REP(l,d.size()){
            ll idxin = distance(c.begin(), lower_bound(ALL(c),d[l]));
            ll idxax = distance(c.begin(), lower_bound(ALL(c),d[l]+k[i]));
            if(idxax != 0 && idxin != c.size()){
                answer += cmr[idxax-1]-(idxin == 0 ? 0 : cmr[idxin-1]) - (idxax - idxin)*dm[l];
            }
            // cout << (idxax == 0 ? 0 : cmr[idxax-1]) <<" "<< (idxin == 0 ? 0 : cmr[idxin-1]) <<" "<< idxax <<" "<< idxin <<" "<< dm[l] <<" "<<cmr[idxax-1]-(idxin == 0 ? 0 : cmr[idxin-1]) - (idxax - idxin)*dm[l]<< "\n";
        }
        cout << answer << "\n";
    }
}

Measured memory_bytes: 27788
#include <stdio.h>
 
int main(void)
{
    int i, n;
     
    while (scanf("%d", &n) != EOF){
        for (i = 1; i <= 512; i *= 2){
            if (n % (i * 2) != 0){
                printf("%d", i);
                n -= i;
                 
                if (n != 0){
                    printf(" ");
                }
            }
             
            if (n == 0){
                puts("");
                break;
            }
        }
    }
     
    return (0);
}


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

int main() {
  std::string S;
  std::cin >> S;

  // 字符串 S 必须满足如下三个条件:
  //  1. 第一个字符必须是 'A'
  //  2. 在 S 中只出现一次 'C', 且他必须是在第三个与倒数第二个字符之间
  //  3. 所有除了 'A' 和 'C' 之外的字符必须都是小写.
  //  e. 如果满足所有条件, 打印 "AC"; 否则, 打印 "WA"

  // -------- Test1 --------
  if (S[0] != 'A') {
    puts("WA");
    return 0;
  }

  // -------- Test2 --------
  if (S[1] == 'C' || S.back() == 'C') {
    puts("WA");
    return 0;
  }
  int count_c = 0;
  for (int i = 2; i < S.length() - 1; i++)
    if (S[i] == 'C') count_c++;
  if (count_c != 1) {
    puts("WA");
    return 0;
  }

  // -------- Test3 --------
  S = S.substr(1);  // Exclude Test1
  for (char c : S) {
    if (c == 'C') continue;  // Exclude Test2
    if (isupper(c)) {
      puts("WA");
      return 0;
    }
  }

  // Pass all test
  puts("AC");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

long long int MOD = 1e9+7;

int main(){
  
  long long int N, M, tmp;
  scanf("%lld%lld", &N, &M);
  std::vector<long long int> S, T;
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    S.push_back(tmp);
  }
  for(long long int i = 0; i < M; i++){
    scanf("%lld", &tmp);
    T.push_back(tmp);
  }
  
  /*std::cerr << "S:" << std::endl;
  for(long long int i = 0; i < N; i++){
    std::cerr << S[i] << " ";
  }std::cerr << std::endl;
  
  std::cerr << "T:" << std::endl;
  for(long long int i = 0; i < M; i++){
    std::cerr << T[i] << " ";
  }std::cerr << std::endl;*/
  
  // solve problem
  std::vector<std::vector<long long int> > dp(N+1);
  for(long long int i = 0; i <= N; i++){
    for(long long int j = 0; j <= M; j++){
      dp[i].push_back(0);
    }
  }
  dp[0][0] = 1;
  for(long long int i = 1; i <= N; i++)dp[i][0] = 1;
  for(long long int j = 1; j <= M; j++)dp[0][j] = 1;
  
  for(long long int i = 1; i <= N; i++){
    for(long long int j = 1; j <= M; j++){
      if(S[i-1] == T[j-1]){
        //std::cerr << "S[i-1] == T[i-1]" << std::endl;
        dp[i][j] = dp[i-1][j] + dp[i][j-1];
      }
      else{
        //std::cerr << "else" << std::endl;
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
      }
      dp[i][j] = (dp[i][j] + MOD)%MOD;
    }
  }
  
  /*std::cerr << "dp:" << std::endl;
  for(long long int i = 0; i <=N; i++){
    for(long long int j = 0; j <= M; j++){
      std::cerr << dp[i][j] << " ";
    }std::cerr << std::endl;
  }*/
  
  std::cerr << "Answer:" << std::endl;
  std::cout << dp[N][M] << std::endl;
  
  return 0;
  
}


Measured memory_bytes: 32384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int cnt = sc.nextInt();
		int total = 0;
		int[] list = new int[cnt];
		for(int i=0;i<cnt;i++) {
			int num = sc.nextInt();
			list[i] = num;
			total += num;
		}
		sc.close();
		double ave = Math.round((double)total/cnt);
		int cost = 0;
		for(int i=0;i<cnt;i++) {
			int diff = (int)ave - list[i];
			cost += Math.pow(diff, 2);
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> H >> W >> K;
  Vec(G,string,H,"");
  rep(i,0,H)cin >> G[i];
  sum=INF;
  for(int i=0; i < (1<<H-1); i++){
    num=0;
    DV(uni,int,2,H,0);
    Vec(root,int,H,0);
    rep(j,0,H-1){
      if(i&(1<<j))num++;
      root[j+1]=num;
    }
    rep(j,0,W){
      rep(k,0,H)if(G[k][j]=='1')uni[0][root[k]]++;
      flag=1;
      rep(k,0,H){
        if(uni[0][k]>K+K){
          flag=-1;
          break;
        }
        else if(uni[0][k]>K)flag=0;
      }
      if(flag==-1){
        num=INF;
        break;
      }
      else if(!flag){
        rep(k,0,H)uni[0][k]-=uni[1][k];
        num++;
      }
      rep(k,0,H)uni[1][k]=uni[0][k];
    }
    chmin(sum,num);
  }
  Out(sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll INF = 1e10;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	ll min = INF;
	int minus = 0;
	rep(i, n)
	{
		ll tmp;
		cin >> tmp;
		sum += abs(tmp);
		if (abs(tmp) < min)min = abs(tmp);
		if (tmp < 0)minus++;
	}
	ll ans;
	if (minus % 2 == 0) ans = sum;
	else ans = sum -2*min;
	co(ans);
	return 0;
}


Measured memory_bytes: 1024
import java.beans.Introspector;
import java.util.*;
final class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    long n =  s.nextLong();
    long a = s.nextLong();
    long b = s.nextLong();
    
    if((b-a)%2==0)
        System.out.println(((b-a)/2));
    else{
        //long ans = Math.min(n-a, b-1);
        //System.out.println( Math.min(ans, ((b-a)/2)+2));
        //System.out.println( "ans");

        System.out.println( Math.min(a-1,n-b)+1 +((b-a-1)/2));


    }
    
  }
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    bool n[10] = {};
    int N[4] = {};
    for (int i = 0; i < 4; i++){
        cin >> N[i];
        n[N[i]] = true;
    }
    bool ok = true;
    if (n[1] != true) ok = false;
    else if (n[4] != true) ok = false;
    else if (n[7] != true) ok = false;
    else if (n[9] != true) ok = false;

    if (ok){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    



    return 0;
}


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

int main(){
  int n,i,j,ans=0;
  cin >> n;
  string a,b,c;
  cin >> a >> b >> c;
  for(i=0; i<n; i++){
    if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i]){
      ans+=2;
    }else if(!(a[i]==b[i] && b[i]==c[i])){
      ans++;
    }
  } 

  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

int main(){
  int N; cin >> N;
  if(N%2==0) cout << (N/2)*(N/2) << endl;
  else cout << (N/2)*((N+1)/2) << endl;

}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}

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

    int n, p;
    cin >> n >> p;

    string s;
    cin >> s;

    ll ans = 0;

    if (p == 2 || p == 5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) {
                ans += i + 1;
            }
        }
    } else {
        map <ll, ll> mp;

        ll cur = 0;
        mp[cur]++;
        for (int i = n - 1; i >= 0; i--) {
            ll tmp = pow_mod(10, n - i - 1, p);
            tmp = tmp * (s[i] - '0') % p;
            cur = (cur + tmp) % p;
            mp[cur]++;
        }

        ans += mp[0] * (mp[0] - 1) / 2;
        for (int i = 1; i < p; i++) {
            ans += mp[i] * (mp[i] - 1) / 2;
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
 
 int main() {
   int y, m, d;
   char slash, slash2;
   cin >> y >> slash >> m >> slash2 >> d;
   
   if(m <= 4 && y <= 2019 && d <= 30){
   cout << "Heisei";
   }
   else{
       cout << "TBD"; 
    }
}

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

int main() {

int n; cin>>n; int x=n;
int a=0;int i=1;
  while(n>0){a=a+n%10;n=n/10;}
  
  
  if(x%a==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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 <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    vecin(vec);
    if(K == 1){
        ll ans = INF;
        rep(i,N)chmin(ans,abs(vec[i]));
        cout << ans << endl;
        return 0;
    }
    ll low = 0,high = 0,ans = INF;
    rep(i,N - K + 1){
        low = vec[i];
        high = vec[i + K - 1];
        ll res = INF;
        chmin(res,abs(low) + abs(high - low));
        chmin(res,abs(high) + abs(low - high));
        chmin(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3976
n = int(input())
v = list(map(int,input().split()))
v_1 = v[::2]
v_2 = v[1::2]
v_1_d = {}
v_2_d = {}
for i in v_1:
  if i in v_1_d:
    v_1_d[i] += 1
  else:
    v_1_d[i] = 1
    
for i in v_2:
  if i in v_2_d:
    v_2_d[i] += 1
  else:
    v_2_d[i] = 1
    
v_1_d = sorted(v_1_d.items(),key = lambda x: -x[1])
v_2_d = sorted(v_2_d.items(),key = lambda x: -x[1])


for i in v_2_d:
  if i[0] != v_1_d[0][0]:
    max_v_2 = v_1_d[0][1]+i[1]
    break
else:
  max_v_2 = v_1_d[0][1]
    
for i in v_1_d:
  if i[0] != v_2_d[0][0]:
    max_v_1 = v_2_d[0][1]+i[1]
    break
else:
  max_v_1 = v_2_d[0][1]
print(n-max(max_v_1,max_v_2))
    
    

Measured memory_bytes: 18676
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
new_A = []
for i in range(N):
  if A[i] >= sum(A)/(4*M):
    new_A.append(A[i])
if len(new_A) >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

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

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

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int k=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }
        int way=Integer.MAX_VALUE;
        int dp[]=new int[n+1];
        dp[2]=Math.abs(h[2]-h[1]);
        for (int i=3;i<dp.length;i++) {
          way=Integer.MAX_VALUE;
          for (int j=Math.max(1,i-k);j<i;j++) {
             way=Math.min(way,dp[j]+Math.abs(h[j]-h[i]));
          }
          dp[i]=way;
        }
        
        out.println(dp[n]);
    out.close();

}
}




Measured memory_bytes: 43520
// uno {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}

int n, k;
void input() {
    RI(n, k);
}

void solve() {
    if(n%k)
        printf("1\n");
    else
        printf("0\n");
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
l, r = map(int, input().split())
if l == 0:
    print(0)
    sys.exit()

div_l, mod_l = divmod(l, 2019)
div_r, mod_r = divmod(r, 2019)
if div_l != div_r:
    print(0)
else:
    num = float('inf')
    for i in range(mod_l, mod_r + 1):
        for j in range(i + 1, mod_r + 1):
            num = min(num, (i * j) % 2019)
    print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
#define ll long long int 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define f first
#define s second

const ll mod = 1000000007;
const ll N = 1e6;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x; cin >> x;
	int year = 0 ;
	ll dep = 100;
	while(x  > dep){
		dep+=dep/100;
		year++;
	}
	cout << year << "\n";
 	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>


int main(){
	int A, B, post = 0;
	char S[20];
	
	scanf("%d %d %s", &A, &B, S);
	
	for(int i = 0; S[i] != '\0'; i++) {
		(S[i] == '-')? post += i + 1 : post += 0;
	}
	post == A+1 ? puts("Yes") : puts("No");
	
	return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string t;
  int sum=0,j=0;
  cin>>t;
  for(int i=0;i<t.size();i++){
    if(t[i]=='?'){
      t[i]='D';
    }
  }
  cout<<t<<"\n";
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const ll maxn = 3005;
int sg[maxn],a[maxn],n;
vector<int> edge[maxn];

void dfs(int u){
	sg[u] = 0;
	for(auto v : edge[u]){
		if(sg[v] == -1){
			dfs(v);
			if(a[u] > a[v] && sg[v] == 0){
				sg[u] = 1;
				break;
			}
		}
	}
}

int main(){
	n = rd();
	Rep(i,1,n) a[i] = rd();
	rep(i,1,n){
		int a = rd(),b = rd();
		edge[a] . push_back(b);
		edge[b] . push_back(a);
	}
    Rep(i,1,n){
		memset(sg,-1,sizeof sg);
		dfs(i);
		if(sg[i])write(i),pc(' ');
    }
	return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  string S;
  int N,i;
  long ans=1;
  ans=1;
  cin>>N;
  cin>>S;
  int a[26]={0};
  for(i=0;i<N;i++){
  if(S[i]=='a'){
  a[0]++;
  }else if(S[i]=='b'){
  a[1]++;
  }else if(S[i]=='c'){
  a[2]++;
  }else if(S[i]=='d'){
  a[3]++;
  }else if(S[i]=='e'){
  a[4]++;
  }else if(S[i]=='f'){
  a[5]++;
  }else if(S[i]=='g'){
  a[6]++;
  }else if(S[i]=='h'){
  a[7]++;
  }else if(S[i]=='i'){
  a[8]++;
  }else if(S[i]=='j'){
  a[9]++;
  }else if(S[i]=='k'){
  a[10]++;
  }else if(S[i]=='l'){
  a[11]++;
  }else if(S[i]=='m'){
  a[12]++;
  }else if(S[i]=='n'){
  a[13]++;
  }else if(S[i]=='o'){
  a[14]++;
  }else if(S[i]=='p'){
  a[15]++;
  }else if(S[i]=='q'){
  a[16]++;
  }else if(S[i]=='r'){
  a[17]++;
  }else if(S[i]=='s'){
  a[18]++;
  }else if(S[i]=='t'){
  a[19]++;
  }else if(S[i]=='u'){
  a[20]++;
  }else if(S[i]=='v'){
  a[21]++;
  }else if(S[i]=='w'){
  a[22]++;
  }else if(S[i]=='x'){
  a[23]++;
  }else if(S[i]=='y'){
  a[24]++;
  }else if(S[i]=='z'){
  a[25]++;
  } 
  }
  for(i=0;i<26;i++){
  ans=ans*(a[i]+1);
  ans=ans%1000000007;
  }
  ans=ans-1;
  cout<<ans%1000000007<<endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
using namespace std;
int main(void){
    int n;
    scanf("%d",&n);
    char s[10001];
    scanf("%s",s);
    
    for(int i=0;i<strlen(s);i++){
        if(s[i] + n > 'Z'){
            s[i] = s[i]+n - 'Z' + 'A'-1;
        } else {
            s[i] += n;
        }
    }
    
    printf("%s\n",s);
    return 0;
}


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

int main() {
    int H, W, A, B; cin >> H >> W >> A >> B;
    REP(i,H){
        REP(j,W){
            if((i<B&&j<A)||(i>=B&&j>=A)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}



Measured memory_bytes: 1280
import math
# import datetime

def s(n):
	sum = 0
	for c in str(n):
		sum += int(c)
	return sum

k = int(input())
found=0

def next_sunuke(n, s_n, s_n_div):

	global found

	if n == 1:
		return

	log_n = int(math.log(n,10))
	m = n - 10 ** int(log_n // 1.25)
	# m = n - 1

	while m >= 1:
		s_m = s(m)
		s_mplus1 = s(m + 1)

		# if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8)) and m > 9:
		if (s_m < s_mplus1) and m > 9:
			m -= 10 ** int(log_n // 1.25)
			continue

		# print("check: " + str(m))

		s_m_div = m / s(m)

		if s_m_div <= s_n_div:
			next_sunuke(m, s_m, s_m_div)
			if found >= k:
				return

			found += 1
			# print("{0:d}".format(m), "{0:+d}".format(n-m), "{0:d}".format(s_m), s_m_div)
			print(m)
			break
		# else:
		# 	log_m = int(math.log(m,10))
		# 	if (m + 1) / (10 ** (log_m - 1)) == 19:

		# 		print ("skip: " + str(m) + " to " + str(10 ** log_m - 1))

		# 		m = 10 ** log_m - 1
		# 		s_mplus1 = s(m+1)
		# 		continue

		m -= 10 ** int(log_n // 1.25)


# 適当な大きいスヌケ数
current_sunuke = 999999999999999
s_current_sunuke = s(current_sunuke)
s_current_sunuke_div = current_sunuke / s_current_sunuke

# start = datetime.datetime.now()
next_sunuke(current_sunuke, s_current_sunuke, s_current_sunuke_div)
if found < k:
	print(current_sunuke)
# end = datetime.datetime.now()
# print(str(end-start))

# sunukes=[]

# n = current_sunuke - 1

# while(n >= 1):
# 	s_n = n / s(n)
# 	if s_n <= current_sunuke_n:
# 		#sunukes.insert(0,n)
# 		sunukes.append(n)
# 		current_sunuke = n
# 		current_sunuke_n = s_n
# 	n -= 1

# for n in sunukes:
# 	print (n)


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

int main()
{
	int n, a, v,maxa,maxv;
	cin >> n;
	maxv = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> v;
		if ((maxv < v) || (a < maxa && v==maxv))
		{
			maxa = a;
			maxv = v;
		}
	}

	cout << maxa << ' ' << maxv << endl;

	return 0;
}

Measured memory_bytes: 1160
import sys
import collections

input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))

l = collections.Counter(a)

points = 0

for i in l.keys():
    cnt = l[i] + l[i-1] + l[i+1]
    if points < cnt: points=cnt

print(points)

Measured memory_bytes: 14500
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A,B,C;
    std::string S[200],T[200];
    bool F=true;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B;
    REP(i,A)cin>>S[i];
    REP(i,B){REP(j,A){
        DEB(S[j][i])
        if(S[j][i]=='#'){
            DEB(i)DEB(j)END
            REP(k,A)T[k]+=S[k][i];
            break;
        }
    }END}
    REP(i,A){
        bool f=false;
        REP(j,T[i].size()){
            if(T[i][j]=='#')f=true;
        }
        if(f)cout<<T[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
using namespace std;

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i,h) cin >> s[i];
  int ans = 0;
  
  REP(sx,h){
    REP(sy,w){
      if(s[sx][sy] == '#') continue;
      vector<vector<int> > dist(h, vector<int>(w, -1)); 
      dist[sx][sy] = 0;
      
      queue<pair<int, int>> que; 
      que.push(make_pair(sx, sy));
        
      /* キューが空になるまで */
      while (!que.empty()) {
        pair<int, int> current_pos = que.front(); // キューの先頭を見る
        int x = current_pos.first;
        int y = current_pos.second;
        que.pop(); // キューから pop を忘れずに

        // 隣接頂点を探索
        for (int direction = 0; direction < 4; ++direction) {
          int next_x = x + dx[direction];
          int next_y = y + dy[direction];
          if (next_x < 0 || next_x >= h || next_y < 0 || next_y >= w) continue;
          if (s[next_x][next_y] == '#') continue;

          // まだ見ていない頂点なら push
          if (dist[next_x][next_y] == -1) {
            que.push(make_pair(next_x, next_y));
            dist[next_x][next_y] = dist[x][y] + 1;
          }
        }
      }
      int maxi = 0;
      REP(i,h) maxi = max(maxi, (int)*max_element(dist[i].begin(), dist[i].end()));
      if(ans < maxi) ans = maxi;
      
      
    }
  }

  cout << ans;
  return 0;
}

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    auto move = [](size_t n, char c) {
        while (n--) cout << c;
    };

    size_t w = tx - sx, h = ty - sy;

    move(w, 'R');
    move(h, 'U');
    move(w, 'L');
    move(h, 'D');

    move(1, 'D');
    move(w + 1, 'R');
    move(h + 1, 'U');
    move(1, 'L');
    move(1, 'U');
    move(w + 1, 'L');
    move(h + 1, 'D');
    move(1, 'R');
}



Measured memory_bytes: 3596
import math

n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors

def factorize(N):
    up = int(math.sqrt(N))+2
    out = {}

    for i in range(2,up):
        if N%i == 0:
            temp = N
            count = 0
            while(True):
                N = N//i
                count += 1
                if N%i != 0:
                    break
            out[i] = count
        else:
            continue
    if N != 1:
        out[N] = 1
    return out

yakusuu = make_divisors(n)[1:]

soinnsuu = factorize(n)
soinnsuu2 = factorize(n-1)

# print(yakusuu)
# print(soinnsuu)
# print(soinnsuu2)

ans = 0
for y in yakusuu:
    hoge = n
    while True:
        if hoge%y == 0:
            hoge = hoge//y
        else:
            break
    if hoge%y == 1:
        ans+=1

ok = {}
for key in soinnsuu2.keys():
    if not key in soinnsuu:
        ok[key] = soinnsuu2[key]
# print(ok)

ex = 1
for key in ok.keys():
    ex *= ok[key]+1

ex-=1

# print(ans)
# print(ex)
print(ans+ex)

# test = []
# for i in range(2,3141):
#     base = 3141
#     while True:
#         if base < i:
#             if base == 1:
#                 test.append(i)
#             break
#         if base%i == 0:
#             base /= i
#         else:
#             base %= i
# print(test)

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

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,K = LI()
    A = LI()

    ans = 1
    ma = max(A)
    if ma <= 0 and K % 2:
        # 最大値が0以下でKが奇数の場合
        x = sorted(A,reverse=True)
        # 大きいほうからK個の積
        for i in range(K):
            ans = (ans * x[i]) % MOD
        print(ans)
        return

    # 絶対値でソート
    x = sorted(A, key=lambda x: abs(x), reverse=True)
    m = 0
    # 絶対値が大きいほうからK個の積
    for i in range(K):
        ans = (ans * x[i]) % MOD
        if x[i] < 0: m += 1

    # K==Nか、マイナスが偶数、答えが0ならそのままリターン
    if K == N or m % 2 == 0 or ans == 0:
        print(ans)
        return
    # K+1個目が0なら、0でリターン
    if x[K] == 0:
        print(0)
        return

    # K個目まですべてマイナスなら
    if m == K:
        # K番目とK+1以降の最大値とを入れ替え
        ans = (ans * pow(x[K-1],MOD-2,MOD) * max(x[K:])) % MOD

    else:
        K1 = -1
        # K+1番目と符号が反対で絶対値が最大の数をK+2番目以降で探す
        for i in range(K+1,N):
            if x[K] * x[i] < 0:
                K1 = i
                break

        f0 = 0.0
        f1 = 0.0
        i0 = -1
        i1 = -1
        # K番目以内でK+1番目と符号が反対で最小の数を探す
        for i in range(K-1,-1,-1):
            if x[i] * x[K] < 0:
                i0 = i
                # 入れ替えた時の減少率
                f0 = x[K] / x[i]
                break

        if K1 >= 0:
            # K1が存在するとき、K番目以内でK1番目と符号が反対で最小の数を探す
            for i in range(K-1,-1,-1):
                if x[i] * x[K1] < 0:
                    i1 = i
                    f1 = x[K1] / x[i]
                    break

        if abs(f0) >= abs(f1):
            ans = (ans * pow(x[i0],MOD-2,MOD) * x[K]) % MOD
        else:
            ans = (ans * pow(x[i1],MOD-2,MOD) * x[K1]) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin>>n;
    ll a[n],b[n],m,ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=n-1;i>=0;i--){
        m=(a[i]+ans)%b[i];
        if(m!=0){
            ans+=b[i]-m;
        }
    }
    cout << ans<<endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
   cin >> a.at(i);}
  int ans=0;
  vector<int> b(n);
  for(int i=0;i<n;i++){
   cin>>b.at(i);
   b.at(i)=b.at(i)*(-1)+a.at(i);
   if(b.at(i)>0){
     ans+=b.at(i);}
  }
  cout<< ans << endl;

}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
ll N;cin>>N;vl A(N);rep(i,N)cin>>A[i];
  map<ll,ll> mp,mq;
  rep(i,N){
    mp[i+A[i]]++;
  }
  rep(i,N){
    mq[i-A[i]]++;
  }
  ll cnt=0;
  for(auto x: mp){
    cnt+=x.second *mq[x.first];
  }
  cout<<cnt<<endl;
}






Measured memory_bytes: 38980
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    string s;
    LL num_r=0;
    LL num_g=0;
    LL num_b=0;
    LL ans=0;
    cin >> n;
    cin >> s;

    for(int i=0; i<n; i++){
        if(s[i]=='R'){
            num_r++;
        }else if(s[i]=='G'){
            num_g++;
        }else{
            num_b++;
        }
    }
    ans = num_r*num_g*num_b;
    int k;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            k=2*j-i;
            if(k>=n){
                break;
            }
            if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]){
                ans--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define N 100010
int n, a[N]; ll S;

int main () {
	cin >> n;
	for (int i = 0; i < n; i ++) cin >> a[i];
	int la = 0;
	for (int i = 0; i < n; i ++) {
		if (la > 0 && a[i] > 0) {
			la --;
			a[i] --;
			S ++;
		}
		S += a[i]/2;
		a[i] %= 2;
		la = a[i];
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

ll get(ll a, ll b) {
	return (a - b) * (a - b);
}

void solve(){
 	int n;
	cin >> n;
	ll sum = 0;
	ll a[n];
	rep(i, n){
		cin >> a[i];
		sum += a[i];
	}
	ll f = sum / n;
	ll s = (sum + n - 1) / n;
	ll x = 0, y = 0;
	rep(i, n){
		x += get(a[i], f);
		y += get(a[i], s);
	}
	cout << min(x, y);
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 1010

int n,x,y;
char s[MXN];

int main(){
	
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		switch(s[i]){
			case 'N':{
				x|=1;
				break;
			}
			case 'S':{
				x|=(1<<1);
				break;
			}
			case 'W':{
				y|=1;
				break;
			}
			case 'E':{
				y|=(1<<1);
				break;
			}
			default:{
				printf("Error!\n");
				while(1);
			}
		}
	if( (x==0 || x==(1<<2)-1) && (y==0 || y==(1<<2)-1) )
		printf("Yes\n");
	else
		printf("No\n");
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string str;
	cin>>str;
	transform(str.begin(),str.end(),str.begin(),[](char c){
			if(c <= 'C')c += 23;
			else c -= 3;
			return c;
			}
		 );
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 1184
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		
		int n=Integer.parseInt(in.next()),q=Integer.parseInt(in.next());
		mypqueue A[]=new mypqueue[n];
		for(int i=0;i<n;i++)A[i]=new mypqueue();
		
		for(int i=0;i<q;i++){
			int query=Integer.parseInt(in.next());
			
			switch(query){
			case 0:
				int t1=Integer.parseInt(in.next()),x=Integer.parseInt(in.next());
				A[t1].pq.add(x);
				break;
				
			case 1:
				int t2=Integer.parseInt(in.next());
				if(!A[t2].pq.isEmpty())out.println(A[t2].pq.peek());
				break;
				
			case 2:
				int t3=Integer.parseInt(in.next());
				if(!A[t3].pq.isEmpty())A[t3].pq.remove();
				break;
			}
		}
		out.flush();
	}

}

class mypqueue{
	Queue<Integer> pq;
	
	mypqueue(){
		pq=new PriorityQueue<>(Comparator.reverseOrder());
	}
}


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

string str;
int pre[100003],q,n;
int main () {
	cin >> n >> q;
	cin >>str;
	for (int i=1;i<n;i++) {
		if (str[i] == 'C' && str[i-1] == 'A') {
			pre[i+1] = pre[i] + 1;
		} else {
			pre[i+1] = pre[i];
		}
	}
	
	
	while (q--) {
		int l,r;
		cin >> l >> r;
		int sum = pre[r] - pre[l-1];
		if (l >= 2 && str[l-1] == 'C' &&str[l-2] == 'A') {
			sum--;
		}
		cout << sum << endl;
	}
}

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

main(){
  int b,r,g,c,s,t;
  while(cin >> b >> r >> g >> c >> s >> t, b || r || g || c || s || t){
    int m,pulas,total;
    int game;
    m=100+s*3+(5*b+3*r)-(3*t);
    pulas=b*15*6+r*15*4+g*7+c*2;
    total=m+pulas;
    cout << total << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iostream>
#include <string> 
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int ans = 0;
  for(int i = A; i <= B; i++){
    if(C % i == 0){
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let mut ans = 0;
    let mut chain = 0;
    for c in s {
        if c == 'R' {
            chain += 1;
        } else {
            chain = 0;
        }
        ans = std::cmp::max(chain, ans);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2132
import copy

N, M = list(map(int, input().split()))

V = []


def dfs(node, seen, V):

    if seen[node] is True:
        return 0

    seen[node] = True
    if not(False in seen):
        return 1

    ret = 0
    for next_node in V[node]:
        ret += dfs(next_node, copy.deepcopy(seen), V)
    return ret


for _ in range(N):
    V.append(set())

for _ in range(M):
    a, b = list(map(int, input().split()))
    V[a-1].add(b-1)
    V[b-1].add(a-1)

print(dfs(0, copy.deepcopy([False] * N), V))

Measured memory_bytes: 3572
#include<stdio.h>
int main(){
    int n,m,b[100],a[100][100],i,k,sum[100];
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            scanf("%d",&a[i][k]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            sum[i] += a[i][k] * b[k];
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",sum[i]);
    }
    return 0;
}


Measured memory_bytes: 2132