akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const double EPS = 1e-9;
int val[1000];
int main()
{
    memset(val,-1,sizeof val);
    int n,m;
    cin>>n>>m;
    int pos,num;
    bool invalid=0;
    forr(i,0,m)
    {
        cin>>pos>>num;
        pos=n-pos;
        if (val[pos]!=-1)
        {
            if (num!=val[pos])
                invalid=1;
        }
        val[pos]=num;
    }
    if (n==1 && m==0)
    {
        cout<<0<<endl;
        return 0;
    }
    if (val[n-1]==0&& n!=1)
        invalid=1;
    if (val[n-1]==-1)
        val[n-1]=1;
    if (invalid)
        cout<<"-1";
    else
    {

        for(int i=n-1;i>=0;i--)
        {
            if (val[i]==-1)
                cout<<0;
            else
                cout<<val[i];
        }
    }

}
// PLUS ULTRA!

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += vec.at(i);
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) * (4 * M) >= sum)
    count++;
  }
  if (count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
	int n, h, ans = 0, max = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> h;
		if (max <= h) {
			max = h;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"

void solve() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    set<int, greater<int>> st;
    for(int i = 0; i < n; i ++) {
        if(s[i] == 'R') st.emplace(i);
    }
    for(int i = 0; i < n; i ++) {
        st.erase(i);
        if(s[i] == 'R') continue;
        if(st.size() == 0) {
            break;
        }
        auto v = *st.begin();
        swap(s[i], s[v]);
        ans ++;
        st.erase(st.begin());
    }
    cout << ans << endl;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

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

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //-----------------------------------------
    int N, R;
    cin >> N >> R;
    
    if(10<=N)
    {
        cout << R << endl;
    }
    else
    {
        cout << 100*(10-N)+R << endl;
    }

    return 0;
}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())
cnt = 0
if K - A < 0:
  print(K)
  exit()
cnt += A
K -= A
if K - B < 0:
  print(cnt)
  exit()
K -= B
if K - C < 0:
  print(cnt - K)
  exit()
cnt -= C
print(cnt)

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 


const int MAX_N = 100000;

int bit[MAX_N + 1], n;

int sum(int i){
	int s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
 
void add(int i, int x){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}
}

int main(){
	int q;
	cin>>n>>q;
	int c,x,y;
	rep(i,q){
		cin>>c>>x>>y;
		if(c==0) add(x,y);
		else cout << sum(y) - sum(x -1)<<endl;
	}
}

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

int main()
{
    int N, M, X,count1=0, count2=0;
    cin >> N >> M>>X;
    vector<int> n(N+1);
    vector<int> m(M);
    for (int i = 0; i < M;i++){
        cin >> m.at(i);
    }
    for (int i = 0; i < M;i++){
        n.at(m.at(i)) = 1;
    }
    for (int i = X; i <= N;i++){
        if(n.at(i)==1){
            count1++;
        }
    }
    for (int i = X; i >= 0;i--){
        if(n.at(i)==1){
            count2++;
        }
    }
    cout << min(count1, count2) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
    int x,y,c,ans;
}card;

int main(void){
    int a,b,m;
    scanf("%d %d %d",&a,&b,&m);
    int aar[a];
    int bar[b];
    card car[m];
    for(int i = 0;i < a;i++)scanf("%d",&aar[i]);
    for(int i = 0;i < b;i++)scanf("%d",&bar[i]);
    for(int i = 0;i < m;i++)scanf("%d %d %d",&car[i].x,&car[i].y,&car[i].c);
    for(int i = 0;i < m;i++)car[i].ans = aar[car[i].x-1] + bar[car[i].y-1] - car[i].c;
    int min = 10000000;
    int amin= 10000000,bmin = 10000000;
    for(int i = 0;i < m;i++)if(min > car[i].ans)min = car[i].ans;
    for(int i = 0;i < a;i++)if(amin > aar[i])amin = aar[i];
    for(int i = 0;i < b;i++)if(bmin > bar[i])bmin = bar[i];
    if(min > amin+bmin)min = amin+bmin;
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin >> b;
  if(b=="A"){
    cout << "T" << endl;
  } else if (b=="T"){
    cout << "A" << endl;
  } else if(b=="G"){
    cout << "C" << endl;
  } else {
    cout << "G" << endl;
  }
}


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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  for (int i(0);i<1000000;i++){
    if ((A*i-C)%B==0&&(A*i-C)>=0){
      cout << "YES"<<endl;
      return 0;
    }
  }
  cout << "NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int n, m;
vvi a;
int ans = 0;
vi flag;


void dfs(int v, int cnt){
  for(auto i : a[v]){
    if(flag[i] > 0) continue;
    flag[i] = 1;
    if(cnt+1 == n-1) ans++;
    else dfs(i, cnt+1);
    flag[i] = 0;
  }
  return;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a = vvi(n);
  rep(i, m){
    int x, y;
    cin >> x >> y;
    x--;y--;
    a[x].pb(y);
    a[y].pb(x);
  }
  flag = vi(n+10);
  flag[0] = 1;
  dfs(0, 0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n;
    char egara[4];
    int suuji;
    int S[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int H[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int C[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int D[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%s %d",egara,&suuji);
        switch(egara[0]){
            case 'S':
            S[suuji-1]=0;
            break;
            
            case 'H':
            H[suuji-1]=0;
            break;
            
            case 'C':
            C[suuji-1]=0;
            break;
            
            case 'D':
            D[suuji-1]=0;
            break;
        }
    }
         for(int j=0;j<13;j++){
                if(S[j]>0){
                    printf("S %d\n",S[j]);
                }
            }
            for(int j=0;j<13;j++){
                if(H[j]>0){
                    printf("H %d\n",H[j]);
                }
            }
            for(int j=0;j<13;j++){
                if(C[j]>0){
                    printf("C %d\n",C[j]);
                }
            }
            for(int j=0;j<13;j++){
                if(D[j]>0){
                    printf("D %d\n",D[j]);
                }
            }
    return 0;
}


Measured memory_bytes: 2660
S = input()

k = 'keyence'


if S.find(k) == 0 or S.find(k) == len(S) - 7:
    print('YES')
    exit()

for i in range(1, len(k)):
    if S.find(k[:i]) == 0 and S[::-1].find(k[i:][::-1]) == 0:
        print('YES')
        exit()

print('NO')



Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]): Unit = {
    solve2
  }

  def solve2(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    //ryota さんのコードを見てなるほどなと
    val sorted = a.sorted
    val max = sorted(n - 1)
    val secondMax = sorted(n - 2)
    val pw = new java.io.PrintWriter(System.out)
    for (i <- 0 until n) {
      if (a(i) == max) pw.println(secondMax)
      else pw.println(max)
    }
    pw.flush()
  }


  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    //感想
    //何回もコレクション内を巡回しすぎ。。。
    val first = a.max
    val second = if (a.count(_ != first) == 0) first else a.filter(_ != first).max
    val multiMaxFlg = a.count(_ == first) > 1
    val pw = new java.io.PrintWriter(System.out)
    for (i <- 0 until n) {
      if (a(i) == first) {
        if (multiMaxFlg) {
          pw.println(first)
        } else {
          pw.println(second)
        }
      } else {
        pw.println(first)
      }
    }
    pw.flush()
  }
}


Measured memory_bytes: 73428
public class Main {


  private static void solve() {
    int n = ni();
    long x = nl();
    long[] a = nal(n);
    long[][] min = new long[n][n];
    for (int i = 0; i < n; i ++) {
      min[i][0] = a[i];
      for (int j = 1; j < n; j ++) {
        min[i][j] = Math.min(min[i][j - 1], a[(i-j+n)%n]);
      }
    }

    long ret = Long.MAX_VALUE;
    for (int y = 0; y < n; y++) {
      long now = y * x;
      for (int i = 0; i < n; i++) {
        now += min[i][y];
      }
      ret = Math.min(ret, now);
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main() {
   int h, w, n;
   cin >> h >> w >> n;

   int sum = 0;
   if (h >= w) {
      int i = 0;
      while (h * i < n && i < w) {
         i++;
      }
      cout << i << endl;
   } else {
      int i = 0;
      while (w * i < n && i < h) {
         i++;
      }
      cout << i << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;

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

struct Edge {
    ll from;
    ll to;
    ll cost;
    Edge(ll from, ll to, ll cost) : from(from), to(to), cost(cost) {}
};

vector<ll> union_find, rnk;

ll group_of(ll idx) {
    if (union_find[idx] == idx) {
        return idx;
    } else {
        return (union_find[idx] = group_of(union_find[idx]));
    }
}


void unite(ll from, ll to) {
    if (rnk[from] < rnk[to]) {
        union_find[from] = to;
    } else {
        union_find[to] = from;
        if (rnk[from] == rnk[to]) {
            rnk[from]++;
        }
    }
}

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

    ll N;
    cin >> N;
    vector<ll> xidx(N), yidx(N);
    union_find = vector<ll>(N);
    rnk = vector<ll>(N, 0);
    for (ll i = 0; i < N; i++) {
        xidx[i] = i;
        yidx[i] = i;
        union_find[i] = i;
    }

    vector<p> town(N);
    for (ll i = 0; i < N; i++) {
        cin >> town[i].first >> town[i].second;
    }
    
    sort(xidx.begin(), xidx.end(), [&town](ll left, ll right) {
        p l = town[left];
        p r = town[right];
        return l.first < r.first;
    });

    sort(yidx.begin(), yidx.end(), [&town](ll left, ll right) {
        p l = town[left];
        p r = town[right];
        return l.second < r.second;
    });

    vector<Edge> E;
    for (ll i = 0; i < N - 1; i++) {
        ll d = town[xidx[i + 1]].first - town[xidx[i]].first;
        E.push_back(Edge(xidx[i], xidx[i + 1], d));
    }

    for (ll i = 0; i < N - 1; i++) {
        ll d = town[yidx[i + 1]].second - town[yidx[i]].second;
        E.push_back(Edge(yidx[i], yidx[i + 1], d));
    }

    sort(E.begin(), E.end(), [](Edge l, Edge r) {
        return l.cost < r.cost;
    });

    ll ans = 0;
    for (auto&& e : E) {
        ll from_group = group_of(e.from);
        ll to_group = group_of(e.to);
        if (from_group == to_group) {
            continue;
        }

        // cout << "add" << endl;

        ans += e.cost;
        unite(from_group, to_group);
        /*
        for (auto&& u : union_find) {
            cout << u << " ";
        }
        cout << endl;
        */
    }

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



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

int main(void) {
    int n;
    int a;
    int count = 0;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        bool check = true;
        cin >> a;
        for(int j = 2; j <= sqrt(a); ++j) {
            if(a % j == 0) {
                check = false;
            }
        }
        if(check)   ++count;
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3072
while True:
    (H, W) = [int(i) for i in input().split()]
    if H == W == 0:
        break
    for a in range(H):
        for b in range(W):
            if (a + b) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  vector<int> D;
  int d;

  cin >> N;
  REP(i, N) {
    cin >> d;
    if (find(D.begin(), D.end(), d) == D.end()) D.push_back(d);
  }

  cout << D.size() << endl;
}

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

int n, k, q;
int a[2020];
int ans = 1e9;

void f(int idx) {
	vector<int> v;
	vector<int> num;
	for(int i = 0; i <= n; ++i) {
		if(a[i] < a[idx]) {
			int vn = v.size();
			if(vn >= k) {
				sort(v.begin(), v.end());
				for(int j = 0; j <= vn - k; ++j) {
					num.push_back(v[j]);
				}
			}
			v.clear();
		} else {
			v.push_back(a[i]);
		}
	}
	if(num.size() < q) return;
	sort(num.begin(), num.end());
	ans = min(ans, num[q - 1] - num[0]);
}

int main() {
	cin >> n >> k >> q;
	for(int i = 0; i < n; ++i) cin >> a[i];
	a[n] = -1;
	for(int i = 0; i < n; ++i) {
		f(i);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N=int(input())
A=[int(i) for i in input().split(" ")]
c=Counter(A)
c=dict(c)
base=0
for key in c:
    base+=c[key]*(c[key]-1)//2


for a in A:
    _base=base
    ca=c[a]
    if ca>1:
        _base-=ca*(ca-1)//2
        _base+=(ca-1)*(ca-2)//2
    print(_base)


Measured memory_bytes: 26780
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int H = Arr[0];
            int W = Arr[1];
            int tmp;
            string st;
            List<string> list = new List<string>();
            for (int i = 0; i < H; i++) 
            {
                list.Add(Console.ReadLine());
            }
            for (int i = 0; i < H; i++) 
            {
                st = "";
                for (int j = 0; j < W; j++)
                {
                    tmp = 0;

                    for (int k = -1; k < 2; k++) 
                    {
                        for (int l = -1; l < 2; l++)
                        {
                            if (0 <= i + k && i + k < H && 0 <= j + l && j + l < W) 
                            {
                                if (list[i + k][j + l] == '#') tmp++;
                            }
                        }
                    }

                    if (list[i][j] == '#')
                    {
                        st = st + "#";
                    }
                    else 
                    {
                        st = st + tmp.ToString();
                    }

                }
                list[i] = st;
            }

            foreach (string s in list)
            {
                Console.WriteLine(s);
            }

        }

    }
}


Measured memory_bytes: 28452
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/01/12.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
int main(int argc, const char * argv[]) {

	char s;
	cin >> s;

	s++;

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	ll count = 0;
	if (n * 2 <= m) {
		m -= n * 2;
		count += n;
	}
	else {
		
		count += m / 2;;
		m -= m / 2 * 2;;
	}
	count += max(m / 4,(ll)0);
	cout << count << endl;
}


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

    private:
        ll V;
        vector<vector<ll>> E;
        vector<vector<ll>> inv_E;
        ll *number;
        bool *used_dfs;
        ll to_write_num = 0;

        void dfs(ll now){
            used_dfs[now] = 1;
            for(ll next : E[now]){
                if(used_dfs[next]){
                    continue;
                }
                dfs(next);
            }
            number[now] = to_write_num++;
        }

        void dfs(ll now, bool *used, vector<ll> &ret){
            used[now] = 1;
            ret.push_back(now);
            for(ll next : inv_E[now]){
                if(used[next]){
                    continue;
                }
                dfs(next, used, ret);
            }
        }

        void write_num(){
            for(ll i = 0; i < V; i++){
                if(!used_dfs[i]){
                    dfs(i);
                }
            }
        }

    public:
        StrongDisassembly(const vector<vector<ll>> &e){
            V = e.size();
            E = e;
            inv_E = vector<vector<ll>>(V);
            number = new ll[V];
            used_dfs = new bool[V];
            for(ll i = 0; i < V; i++){
                used_dfs[i] = 0;
                inv_E.push_back(vector<ll>(0));
            }
            for(ll i = 0; i < V; i++){
                for(ll next : e[i]){
                    inv_E[next].push_back(i);
                }
            }
            write_num();
        }

        map<ll, vector<ll>> disassembly(){
            map<ll, vector<ll>> ret;
            vector<ll> vec;
            bool used[V] = {};
            for(ll i = 0; i < V; i++){
                vec.push_back(i);
            }
            sort(vec.begin(), vec.end(), [&](ll a, ll b){
                    return number[a] > number[b];
                    }
                );
            for(ll vertex : vec){
                if(used[vertex]){
                    continue;
                }
                vector<ll> to_insert;
                dfs(vertex, used, to_insert);
                ret[ret.size() - 1] = to_insert;
            }
            return ret;
        }
};
int main(){
    ll V, E;
    cin >> V >> E;
    vector<vector<ll>> v(V);
    for(ll i = 0; i < E; i++){
        ll s, t;
        cin >> s >> t;
        v[s].push_back(t);
    }
    StrongDisassembly S(v);
    auto ret = S.disassembly();
    map<ll, ll> group;
    for(auto ite = ret.begin(); ite != ret.end(); ite++){
        for(ll u : ite->second) group[u] = ite->first;
    }
    ll Q;
    cin >> Q;
    for(ll i = 0; i < Q; i++){
        ll u, v;
        cin >> u >> v;
        cout << (group[u] == group[v] ? 1 : 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
cin>>s>>t>>a>>b>>u;
if(s==u)
  cout<<a-1<<" "<<b<<endl;
  else
  {
    cout<<a<<" "<<b-1<<endl;
  }
  
  return(0);
}

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

using namespace std;

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

#define mp make_pair
#define F first
#define S second

const ll N = 2e5;
const ll M = 20;
const ll SQ = 320;
const ll INF = 1e16;
const ll MOD = 1e9+7;

int n,m;
vector<int> v[N];
int a[N];
int f[N],f1[N];

/*void dfs(int x)
{
	f[x] = 1;
	for (int i = 0; i<v[x].size(); i++)
		if (!f[v[x][i]])
			dfs(v[x][i]);
}*/

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

	cin >> n >> m;
	f[0] = 1;
	for (int i = 0; i<m; i++)
	{
		int x,y;
		cin >> x >> y;
		x--; y--;
		a[x]--; a[y]++;
		if (f[x]) f[y] = 1;
		if (f[x] && a[x]==-1) { f[x] = 0; }
	}
	int ans = 0;
	for (int i = 0; i<n; i++)
		if (f[i])
			ans++;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
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> c(h);
  for(int i=0;i<h;i++){
    cin>>c[i];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]=='#'){
        bool flag=true;
        for(int k=0;k<4;k++){
          int x=i+dx[k],y=j+dy[k];
          if(x<0||x>=h||y<0||y>=w) continue;
          if(c[x][y]=='#') flag=false;
        }
        if(flag) {
          cout<<"No";
          return 0;
        }
      }
    }
  }
  cout<<"Yes";
} 

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
 
int main()
{
  int ball = 10;	//ボールの数
	int n,k;	//n:セットの数 k:メモ
	cin >> n;	
	queue<int> a;	//開口部Ａ

 
	for (int i=0; i < n; i++){			//1セットのループ
		int b = 0 , c = 0;	//筒Ｂ、筒Ｃ
		for (int j=0; j < ball; j++){
			cin >> k;
			a.push( k );
		}
		b = a.front();
		a.pop();	//最初の一個
		
		for (int j=0; j < (ball-1); j++){		//ボールのループ
			if (a.front() > b && a.front() > c){	//どっちも乗せられる
				if (a.front() - b > a.front() - c){
					c = a.front();
				}else{
					b = a.front();	//差の小さい方に乗せる
				}
			}else if(a.front() > b){
				b = a.front();
			
			}else if(a.front() > c){
				c = a.front();
			
			}else {	
				cout << "NO" << endl;
				while(1){
					if(a.empty()){
						break;
					}else{
						a.pop();
					}				//中身を空に
				}
				break;	//終了
			}
 
			a.pop();	//乗せた
			if (a.empty()){		//最後まで乗せた
				cout << "YES" << endl;
				while(1){
					if(a.empty()){
						break;
					}else{
						a.pop();
					}
				}
			}
		}
	}

	return 0;
 
}

Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int main(){
  int answer[4]={0},responce[4]={0};

  while(1){
    int hit=0,blow=0;
    int A,R;

    cin>>A>>R;

    if(A==0 && R==0)
      break;

    answer[0]=A/1000;
    answer[1]=(A/100)%10;
    answer[2]=(A/10)%10;
    answer[3]=A%10;

    responce[0]=R/1000;
    responce[1]=(R/100)%10;
    responce[2]=(R/10)%10;
    responce[3]=R%10;
    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(answer[i]==responce[j]){
          if(i==j)
            hit++;
          if(i!=j)
            blow++;
        }
      }
    }

    cout<<hit<<" "<<blow<<endl;
  }
  
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    ll x,y;
    cin >> x >> y;
    ll b = 2;
    ll ans = 0;
    while (x <= y)
    {
        x *= b;
        ans ++;
    }
    cout << ans << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
//
//  main.cpp
//  173A
//
//  Created by Parsa Alimohammadi on 4/25/1399 AP.
//  Copyright © 1399 Parsa Alimohammadi. All rights reserved.
//

#include <iostream>

using namespace std;

int main()
{
    int n,i=1000;
    cin >> n;
    
    for (; i<n; i+= 1000)
    {}
    
    cout << i-n;

    return 0;
}


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

ll N, X, a[51], p[51]; // a: all num, p: only p num

ll f(ll n, ll x) {
    if (x == 0){
        return 0;
    } else if (n == 0) {
        return 1;
    } else if (x <= a[n-1] + 1) {     // B level(n-1)
        return f(n-1, x-1);
    } else if (x == a[n-1] + 2) {     // B level(n-1) P
        return p[n-1] + 1;
    } else if (x <= 2*a[n-1] + 2) {   // B level(n-1) P level(n-1)
        return p[n-1] + 1 + f(n-1, x - a[n-1] - 2);
    } else {                          // B level(n-1) P level(n-1) B
        return p[n];
    }
}

int main() {
    cin >> N >> X;
    a[0] = p[0] = 1;
    
    rep(i, N) {
        a[i+1] = a[i] * 2 + 3;
        p[i+1] = p[i] * 2 + 1;
    }
    cout << f(N, X) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
    int N; cin >> N;
    string S, T;
    unordered_map<string, bool> Map;
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            cin >> T;
            Map[T] = true;
        }
        else {
            S = T; cin >> T;
            if (S[S.length() - 1] != T[0]) {
                printf("%s\n", "No"); return 0;
            }
            if (Map[T] == true) {
                printf("%s\n", "No"); return 0;
            }
            else Map[T] = true;
        }
    }
    printf("%s\n", "Yes");
    return 0;
}


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

ll a,b,c,n,m;
ll ans=100000000000;

string s;

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  string t;
  cin>>s;
  cin>>t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      cout<<"No";
      return 0;
    }
  }
  if(s.size()+1==t.size())cout<<"Yes";
  else cout<<"No";

  return 0;
}



Measured memory_bytes: 3636
n, m = map(int, input().split())
mat = [input() for _ in range(n)]
i = 0
j = 0

while i != n-1 or j != m-1:
    down = '.'
    right = '.'
    downleft = '.'
    rightup = '.'
    if i != n-1:
        down = mat[i+1][j]
        if j != 0:
            downleft = mat[i+1][j-1]
    if j != m-1:
        right = mat[i][j+1]
        if i != 0:
            rightup = mat[i-1][j+1]
    
    if down == right:
        print('Impossible')
        exit()
    elif down == '#': 
        if downleft == down:
            print('Impossible')
            exit()
        i+=1
    else: 
        if rightup == right:
            print('Impossible')
            exit()
        j+=1

print('Possible')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
    long long a[100005],b[100005],c[100005],n,nowa,nowc;
    long long ans=0;
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%lld",&a[i]);
    for (int i=0;i<n;i++) scanf("%lld",&b[i]);
    for (int i=0;i<n;i++) scanf("%lld",&c[i]);
    sort(a,a+n);sort(b,b+n);sort(c,c+n);
    nowa=0;nowc=0;
    for (int i=0;i<n;i++)
    {
        while ((a[nowa]<b[i])&&(nowa<n)) nowa++;
        while ((c[nowc]<=b[i])&&(nowc<n)) nowc++;
        ans=ans+nowa*(n-nowc);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2688
#![allow(unused_imports)]
use petgraph::unionfind::UnionFind;
use proconio::*;
use std::cmp::*;
use std::fs;
use std::io::*;

const INF: i64 = 1e18 as i64;
const MAX_N: usize = 200005;

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [i64; n]
   }
   let k = (n % 2) + 1;
   let mut dp = [[-INF; 4]; MAX_N+1];
   dp[0][0] = 0;
   for i in 0..n {
      for j in 0..(k+1) {
         dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]);
         dp[i+1][j] = max(dp[i+1][j], dp[i][j]+if (i+j)%2==0{a[i]}else{0});
      }
   }
   println!("{}", dp[n][k]);
}


Measured memory_bytes: 12056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  while(true) {
  int N,M;
  cin >> N;
  if(N == 0) break;
  cin >> M;
  vector<string> A(N);
  for(int i=0; i<N; i++) cin >> A.at(i);
  
  unordered_set<string> res;
  
  for(int i=0; i<N; i++){
    string a = A.at(i);
    
    for(int j=0; j<N; j++){
      if( i == j ) continue;
      string b = a + A.at(j);
      if( M==2 ) res.insert(b);
      
      for(int k=0; k<N; k++){
        if( i == k || j == k ) continue;
        string c = b + A.at(k);
        if( M==3 ) res.insert(c);
        
         for(int l=0; l<N; l++){
           if( i == l || j == l || k == l ) continue;
           string d = c + A.at(l);
           if( M==4 ) res.insert(d);
         }
       }
    }
  }
  
  cout << res.size() << endl;
  }
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    map<string,int> m;
    string s;
    for(int i=0; i<n; i++){
        cin>>s;
        m[s]++;
    }
    int mac=0;
    for(auto i:m){
        int c=0;
        c=i.second;
        mac=max(mac,c);
    }
    for(auto i:m){
        if(i.second==mac){
            cout<<i.first<<endl;
        }
    }
}

Measured memory_bytes: 25216
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
bool rev[MAXN];
vector<int> pos,neg;
vector<P> ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    if(a[1]>=0) 
    {
        neg.push_back(a[1]);
        for(int i=2;i<=n;i++) pos.push_back(a[i]);
    }
    else if(a[n]<=0)
    {
        pos.push_back(a[n]);
        for(int i=1;i<=n-1;i++) neg.push_back(a[i]);
    }
    else
    {
        for(int i=1;i<=n;i++) if(a[i]<=0) neg.push_back(a[i]); else pos.push_back(a[i]);
    }
    while(neg.size()>1)
    {
        int x=pos.back(),y=neg.back();
        ans.push_back(P(x,y));
        pos.pop_back(); neg.pop_back();
        pos.push_back(x-y);
    }
    while(pos.size()>1)
    {
        int x=pos.back(),y=neg.back();
        ans.push_back(P(y,x));
        pos.pop_back(); neg.pop_back();
        neg.push_back(y-x);
    }
    printf("%d\n",pos.back()-neg.back());
    ans.push_back(P(pos.back(),neg.back()));
    for(auto p:ans) printf("%d %d\n",p.F,p.S);
    return 0;
}



Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,a,b,cnta,cntb;
char ss[100005];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("Qualification Simulator.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,a,b);
	scanf("%s",ss+1);
	for(int i=1;i<=n;i++)
	{
		if(ss[i]=='c' || cnta+cntb>=a+b)
		{
			printf("No\n");
			continue ;
		}
		if(ss[i]=='b')
		{
			if(cntb>=b) printf("No\n");
			else cntb++, printf("Yes\n");
		}
		if(ss[i]=='a') cnta++, printf("Yes\n");
	}
	//fclose(stdin); fclose(stdout);
	return 0;
}

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

using namespace std;

int main(){
	string s; cin >> s;
	string year, month, day;
	year = s.substr(0, 4);
	month = s.substr(5, 2);
	day = s.substr(8, 2);
	
	if(year <= "2019" && month <= "04" && day <= "30"){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
#定義
n, x = input().split()
n = int(n)
x = int(x)
m = []
i_min = 0
gokei = 0
#リストに数値を読み込み
for i in range(n):
  m.append(int(input()))
#一個ずつの合計
for i in range(n):
  gokei = gokei + m[i]
  if m[i_min] > m[i]:
    i_min = i
#残量を出す
x = x - gokei
print(n + int(x/m[i_min]))

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    static int mod = 1_000_000_007;
static long pow(long a,int n) {
    long res=1;
    while (n>0) {
        if ((n-n/2*2)==1) {
            res=res*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

static ArrayList<int[]> factorization (int n) {
    ArrayList<int[]> list = new ArrayList<int[]>();
    int tmp= n ;
    for (int i=2;i<=Math.sqrt(n);i++) {
        if (tmp%i==0) {
            int cnt=0;
            while (tmp%i==0) {
                cnt++;
                tmp/=i;
            }
            int[] x = {i, cnt};
            list.add(x);
        }
    }
    if (tmp!=1) {
        int[] x = {tmp, 1};
        list.add(x);
    }

    if (list.size()==0) {
        int[] x = {n, 1};
        list.add(x);
    }
    return list;
}

static long modinv(long n) {
    return pow(n, mod-2);
}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
            ArrayList<int[]> list = factorization(A[i]);
            for (int[] arr : list) {
                if (!map.containsKey(arr[0])) {
                    map.put(arr[0], arr[1]);
                } else {
                    if (map.get(arr[0])<arr[1]) {
                        map.put(arr[0], arr[1]);
                    }
                }
            }
        }


        ArrayList<Integer> key = new ArrayList<Integer>(map.keySet());
        ArrayList<Integer> val = new ArrayList<Integer>(map.values());
        long lcm = 1L;
        for (int j=0;j<key.size();j++) {
            lcm = lcm*pow(key.get(j), val.get(j))%mod;
        }

        long ans = 0L;
        for (int i=0;i<N;i++) {
            ans = (ans+lcm*modinv(A[i])%mod)%mod;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 33152
import sys

def check(p):
    s = w[0]
    track = 1
    for i in range(1, n):
        if s + w[i] <= p:
            s += w[i]
        else:
            track += 1
            if track > k: return False
            s = w[i]
    return True

n, k = map(int, sys.stdin.readline().strip().split())
w = []
for i in range(n):
    w.append(int(sys.stdin.readline()))

L = max(w)
if check(L):
    print(L)
else:
    R = sum(w)
    assert check(R)

    while L + 1 < R:
        M = (L + R) // 2
        if check(M):
            R = M
        else:
            L = M

    print(R)

Measured memory_bytes: 11144
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int MAX = 100001;
int dp[MAX];
int visited[MAX];
vector<int> adj[MAX];

int dfs(int u)
{
  if (visited[u]) return dp[u];
  visited[u] = 1;
  for (int ch: adj[u]) dp[u] = max(dp[u], 1 + dfs(ch));
  return dp[u];
}

int main()
{
  int n, m; cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dfs(i));
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int N, v[50];
    double ans;
    cin >> N;
    REP(i,N){
        cin >> v[i];
    }

    sort(v, v+N);
    
    ans = v[0];
    REP(i,N-1){
        ans = (ans + v[i+1])/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a, b;
    while (scanf("%d", &a) != EOF) {
        scanf("%d", &b);
        a = a + b;
        b = 1;
        while(a / 10 > 0) {
            a = a / 10;
            b += 1;
        }            
        printf("%d\n", b);
    }
    return 0;
}

Measured memory_bytes: 1028
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

// ----------- VECTOR ------------
template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;

  map<int, int> m;
  for (int i : A) m[i]++;

  LL total = 0;
  for (auto p : m) {
    LL k = p.second;
    total += k*(k-1)/2;
  }

  for (int i : A) {
    LL n = m[i];
    cout << total - (n - 1)<< endl;
  }
}


Measured memory_bytes: 8320
function Main(input){
  var X = parseInt(input);
  var keta = Math.floor(Math.log10(X)) + 1;

  var fX = 0;
  var x = X;
  for(var i = 0; i < keta; i++){
    fX += x % 10;
    x = Math.floor(x / 10);
  }

  if(X % fX === 0){
    console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 18248
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include <numeric>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N, K;
    cin >> N >> K;

    int x[N];
    FOR(i, 0, N){
        cin >> x[i];
    }

    int min_distance = abs(x[N-1]) + (x[N-1] - x[0]);
    FOR(i, 0, N-K+1){
        int left = x[i];
        int right = x[i+K-1];

        int left_to_right = abs(left) + (right - left);
        int right_to_left = abs(right) + (right - left);

        int distance = min(left_to_right, right_to_left);
        if(distance < min_distance){
            min_distance = distance;
        }
    }

    p(min_distance);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N;
    cin >> N;
    vector <int> A(N);
    vector <int> S(N+1);
    int inp;
    REP(i,N){
        cin >> inp;
        A[i] = inp;
    }
    int pos = 0;
    S[0] = abs(A[0]);
    pos = A[0];
    for(int i=1; i<N; i++){
        S[i] = S[i-1] + abs(pos - A[i]);
        pos = A[i];
    }
    S[N] = S[N-1] + abs(A[N-1]);

    int path;
    path = S[N] - S[1] + abs(A[1]);
    cout << path << endl;

    for(int i=1; i<N-1; i++){
        path = S[N] - (S[i+1]-S[i-1]) + abs(A[i+1]-A[i-1]);
       cout << path << endl;
    }

    path = S[N-2] + abs(A[N-2]);
    cout << path << endl;
    return 0;
}


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

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

    int ans = 0;
    rep (i, n)
    {
        int a;
        cin >> a;
        if ((i + 1) % 2 == 1 && a % 2 == 1)
            ans++;
    }

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


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

int main(){
  int n;
  int SN=0;
  cin >> n;
  int a=n;
  for (int i=0; i<10; i++){
    SN += (n%10);
    n = n/10;
  }
  if (a%SN==0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  int i, N, c0, c1, c2, c3;
  c0 = 0;
  c1 = 0;
  c2 = 0;
  c3 = 0;
  string C[100000];
  cin >> N;
  for ( i = 0; i < N; i++)
  {
    cin >> C[i];
    if (C[i].find("AC") == 0)
    {
      c0 += 1;
    }else if (C[i].find("WA") == 0)
    {
      c1 += 1;
    }else if (C[i].find("TLE") == 0)
    {
      c2 += 1;
    }else if (C[i].find("RE") == 0)
    {
      c3 += 1;
    }
  }
  cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
  
}

Measured memory_bytes: 6744
N, K = gets.split.map(&:to_i)
mod = 10 ** 9 + 7

1.upto(K) do |i|
  if i > N - K + 1
    puts 0
    next
  end

  b = (1..i + 1).to_a.repeated_combination(N - K + 1 - i).size
  r = (1..i).to_a.repeated_combination(K - i).size
  puts b * r % mod
end


Measured memory_bytes: 2912
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
vector<set<int>> graph;
vector<int> memo;

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}

  int find(int x) {
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }

  bool unite(int a, int b) {
    a = find(a); b = find(b);
    if (a == b) return false;
    if (d.at(a) > d.at(b)) swap(a, b);
    d.at(a) += d.at(b); d.at(b) = a; 
    return true; 
  }

  bool same(int a, int b) {
    return find(a) == find(b);
  }

  int size(int x) {
    return -d.at(find(x));
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  graph.resize(n, set<int>());
  memo.resize(n, -1);
  UnionFind uf(n);

  rep(i,m) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    uf.unite(x, y);    
  }
  int gcnt = 0;
  rep(i, n) gcnt = max(gcnt, uf.size(i));
  cout << gcnt << endl;
  return 0;
}

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

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

    for (int i = 1; i <= n; i++) {
        int ans = 0;
        for (int x = 1; x * x <= n; x++) {
            for (int y = 1; y * y <= n; y++) {
                int z = (-(x + y) +
                         sqrt(4 * x * y + 4 * i - 3 * (x + y) * (x + y))) /
                        2;
                if (z < 1) continue;
                ll a = x * x + y * y + z * z + x * y + y * z + z * x;
                if (a == i) ans++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;


int main(void) {
    int N;
    cin >> N;
    int64_t ans = 1;
    while(N) {
        ans = (ans*N--) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

n = int(input())
c = r = 0
for _ in range(n):
    a = int(input())
    if a == 0:
        c = 0
        continue
    r += c
    a -= c
    r += a // 2
    c = a % 2
print(r)


Measured memory_bytes: 7964