akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=100005;
ll dp[3003][3004]={};
void solve()
{
    int n,k=1,m=0,i=1,j,x,y,l,r,p,q,z,a[3000];
    ll ans=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        ans+=s[i]-'0';
        ans%=9;
    }
    if(ans==0)
    cout<<"Yes";
    else cout<<"No";
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif 
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

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

using namespace std;

int main(void) {
  int n, x;
  cin >> n >> x;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());

  long long hoge = 0;
  for(int i = 0; i < n; i++) {
    hoge += a[i];
    if(hoge == x) {
      cout << i + 1 << endl;
      return 0;
    }
    else if(hoge > x) {
      cout << i << endl;
      return 0;
    }
  }

  cout << n - 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
    int m=sc.nextInt();
  int po[][]=new int[n][n];
  int p[][]=new int[m][m];
  for(int i=0;i<n;i++){
  String a=sc.next();
    String []s=a.split("",0);
    for(int j=0;j<n;j++){
      po[i][j]=(s[j].equals("#"))?1:0;
    }
  }
  for(int i=0;i<m;i++){
  String a=sc.next();
    String []s=a.split("",0);
    for(int j=0;j<m;j++){
      p[i][j]=(s[j].equals("#"))?1:0;
    }
  }
  boolean b=false,b2=true;
  for(int i=0;i<n-m+1;i++){
  for(int j=0;j<n-m+1;j++){
      b2=true;
      for(int k=0;k<m;k++){
          for(int l=0;l<m;l++){
              if(po[i+k][j+l]!=p[k][l])b2=false;
          }
      }if(b2){b=true;break;}
  }   if(b2)break;
  }
  System.out.println(b?"Yes":"No");
}

}


Measured memory_bytes: 24276
eater::Int->Int->[Int]->Int
eater now high [] = now
eater now high (x:xs) = if x < high then eater now high xs else eater (now+1) x xs

main::IO()
main=do
  _<-getLine
  dat<-return.map read.words=<<getLine
  print (eater 0 0 dat)


Measured memory_bytes: 508
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int MOD = 1000000007;

    

    public static class Mas {
        int x;
        int y;
        int step;

        Mas(int x, int y, int step) {
            this.x = x;
            this.y = y;
            this.step = step;
        }
    }

    private static final int[] vX = { 1, 0, 0, -1 };
    private static final int[] vY = { 0, 1, -1, 0 };


    public static void main(String[] args) {

        FastScanner fs = new FastScanner();
        int r=fs.nextInt();
        System.out.println(r * 2 * 3.14);
       
    }

}


Measured memory_bytes: 25452
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,q,a[100010],sum[100010],sum2[100010],b[100010];
bool check(int x,int p){
    int range=a[p-1]-x;
    if(range<0)return false;
    int foo=x-range;
    int it=upper_bound(b,b+n,-foo)-b-1;
    if(it<2*p-2)return false;
    return true;
}
signed main(){
    cin>>n>>q;
    rep(i,n)cin>>a[i];
    reverse(a,a+n);
    rep(i,n)b[i]=-a[i];
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
        sum2[i+1]=sum2[i]+(i%2==0?a[i]:0ll);
    }
    while(q--){
        int x;
        cin>>x;
        if(n%2){
            if(abs(a[n/2])-x>=abs(x-a[n-1])){
                cout<<sum[n/2+1]<<endl;
                continue;
            }
        }
        int ok=1,ng=n/2+1;
        while(ng-ok>1){
            int mid=(ok+ng)/2;
            if(check(x,mid))ok=mid;
            else ng=mid;
        }
        cout<<sum[ok]+sum2[n]-sum2[ok+ok]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4864
import bisect
A,B,Q = map(int, input().split())
S,T,X = [],[],[]
for i in range(A):
  S.append(int(input()))
for i in range(B):
  T.append(int(input()))
for i in range(Q):
  X.append(int(input()))

for i in range(Q):
  ans = []
  sin = bisect.bisect_left(S, X[i])
  if sin == 0:
    s1,s2 = S[sin], -(10**12)
  elif sin == A:
    s1,s2 = (10**12),S[sin-1]
  else:
    s1,s2 = S[sin],S[sin-1]
  tin = bisect.bisect_left(T, X[i])
  if tin == 0:
    t1,t2 = T[tin], -(10**12)
  elif tin == B:
    t1,t2 = (10**12),T[tin-1]
  else:
    t1,t2 = T[tin],T[tin-1]
  for j in [s1,s2]:
    for k in [t1,t2]:
      for l in [0,1]:
        if l ==0:
          ans.append(abs(j-X[i])+abs(k-j))
        else:
          ans.append(abs(k-X[i])+abs(j-k)) 
          
  print(min(ans))


Measured memory_bytes: 16152
#include<stdio.h>
#define RM 10
#define FR 3
#define BL 4
 
int main(){
 int bfrv[BL][FR][RM]={};
 int n,i,j,k,b,f,r,v;
 scanf("%d",&n);
 for(i=0; i<n; i++){
  scanf("%d %d %d %d", &b, &f, &r, &v);
  bfrv[b-1][f-1][r-1] = bfrv[b-1][f-1][r-1] + v;
 }
 for(i=0; i<BL;i++){
  for(j=0; j<FR; j++){
   for(k=0; k<RM; k++){
    printf(" %d",bfrv[i][j][k]);
   }
   printf("\n");
  }
  if(i==3){}
  else{printf("####################\n");}
 }
 return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  int d[n];
  for(int i = 0; i < n; i++){
    cin>>a[i];
    d[i] = 1;
  }
  sort(a,a+n);
  int j = 0;

  for(int i = 0; i<n;i++){
    if(a[i] == a[i+1]){
      d[j]++;
    }
    else{
      j++;
    }
  }
  for(int i = j; i < n; i++){
    d[i] = 0;
  }
  sort(d,d+n);
  
  int sum = 0;
  for(int i = 0; i< n-k; i++){
    sum+=d[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
 long long n;
 cin>>n;
 long long maxp;
 for(maxp=1;maxp*maxp<=n;maxp++)
  ;
 maxp--;
 for(long long i=maxp;i;i--)
  if(n%i==0)
  {
   cout<<(i-1)+(n/i-1)<<endl;
   return 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[502][502];
int main()
{
	int n,m,p,i,j,x,y,ans;
	scanf("%d%d%d",&n,&m,&p);
	for(i=1;i<=m;i++)
	{
	   scanf("%d%d",&x,&y);
	   for(j=y;j<=n;j++)f[x][j]++;
	}
	for(i=1;i<=p;i++)
	{
		ans=0;
		scanf("%d%d",&x,&y);
		for(j=x;j<=y;j++)
		 ans+=f[j][y];
		printf("%d\n",ans);
	}
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long

#define sc(n) scanf("%lld",&n)
#define scc(n1,n2) scanf("%lld %lld",&n1,&n2)
#define sccc(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define debug(x) cerr<<#x<<": "<<x<<endl;

signed main() {
    int n, c=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=2; s[i]; i++){
        if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') c++;
    }
    cout<<c;
}



Measured memory_bytes: 3604
s = input('')
n = len(s)
s1 = s[0:(n-1)//2]
s2 = s[(n+3)//2-1:]

if (s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]):
	print("Yes")
else:
  	print("No")
    


Measured memory_bytes: 2940
a,b,c,x=4.times.map{gets.to_i}
res=0
(0..a).each do|i|
  (0..b).each do |j|
    (0..c).each do |k|
      res+=1 if 500*i+100*j+50*k === x
    end
  end
end
puts res

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

string s;

set<int> parse(int l, int r)
{
	set<int> res;
	string t = s.substr(l, r - l);
	bool f = true;
	REP(i, t.size())
	{
		if (!isdigit(t[i])) f = false;
	}
	if (f)
	{
		res.insert(stoi(t));
		return res;
	}
	
	if (t[0] == '('&&t.back() == ')')
	{
		bool f = true;
		int cnt = 0;
		REP(i, t.size()-1)
		{
			if (t[i] == '(') cnt++;
			else if (t[i] == ')') cnt--;
			if (cnt == 0) f = false;
		}
		if (f) return parse(l + 1, r - 1);
	}
	int cnt = 0;
	FOR(i, l, r)
	{
		if (s[i] == '(') cnt++;
		else if (s[i] == ')') cnt--;
		else if (!isdigit(s[i]) && cnt == 0)
		{
			set<int> lhs = parse(l, i);
			set<int> rhs = parse(i + 1, r);
			for (auto j : lhs)for (auto k : rhs)
			{
				if (s[i] == '+') res.insert(j + k);
				if (s[i] == '-') res.insert(j - k);
				if (s[i] == '*') res.insert(j * k);
				if (k != 0 && s[i] == '/') res.insert(j / k);
			}

		}
	}
	return res;
}

int main()
{
	while (cin >> s, s != "#")
	{
		cout << parse(0, s.size()).size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, readline().split())

A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))

n = len(A)
score = np.zeros(n, np.int32)
m = map(int, read().split())
for a, b, c, d in zip(m, m, m, m):
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond

print(score.max())

Measured memory_bytes: 46700
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double sum;
  int SUM=0;
  int y;
  cin>>N;
  vector<int> x(N);

  for(int i=0; i<N; i++){
    cin>>x.at(i);
  }

  for(int i=0; i<N; i++){
    sum+=x.at(i)*2;
  }
  y=sum/2/N;

  if(double(y)+0.5<=sum/2/N){
    y++;
  }

  for(int i=0; i<N; i++){
    SUM+=((x.at(i)-y)*(x.at(i)-y));
  }

  //cout<<sum/2/N<<endl<<double(y)+0.5<<endl;
  cout<<SUM<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  char s[50];
  scanf("%s",&s);
  
  int i;
  int sum=0;
  int max=0;
    
  for(i=0;i<10;i++){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
      sum++;
    }
    else{
      sum=0;
    }																																																			
      if(max<sum){
        max=sum;
        
      
    }
  }
  
  printf("%d",max);
  
  return 0;
}


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

int main() {
  string s;
  ll k;
  cin >> s;
  cin >> k;
  int num;
  for(int i=0;i<k;i++){
    if((s.at(i))!='1'){
      cout << s.at(i) << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}




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

using ll = long long;

#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 pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

template <class T>
bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T>
bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

long
getLIS(const vector<int> &a)
{
	vector<int> dp(a.size(), INF_INT);
	for (int i=0; i<a.size(); ++i) {
		*lower_bound(all(dp), a[i]) = a[i];
	}
	return lower_bound(all(dp), INF_INT) - dp.begin();
}

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll N; cin >> N;
	vector<int> a(N);
	vector<int> q(N);
	REP(i, N) {
		cin >> a[i];
		q[a[i]-1] = i;
	}

	int ans = 1, cnt = 0;
	int num = -1;
	FOR(i, 0, N) {
		if (num >= q[i]) {
			chmax(ans, cnt);
			cnt = 0;
			num = -1;
			i--;
		} else {
			cnt++;
			num = q[i];
		}
	}
	chmax(ans, cnt);
	
	cout << N - ans << endl;

	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    int sumA = 0; 
    int sumB = 0;

    sort(A.rbegin(), A.rend());
    for(int i = 0; i < N; i++){
        if(i%2 == 0) sumA += A[i];
        else sumB += A[i];
    }

    cout << sumA - sumB << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s;
  cin >> s;
  
  if(s == "Sunny") cout << "Cloudy";
  else if(s == "Cloudy") cout << "Rainy";
  else cout << "Sunny";
  
  return 0;
}

Measured memory_bytes: 256
/* # */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

void sol() {
	int n, m;
	cin >> n >> m;

	int s1=0, s2=n/2;
	for(int i=1; i<=m;i++){
		if(i%2){
			cout << s1+1 << " " << (n - s1) << '\n';
			s1++;
		}	
		else{
			cout << s2 << " " << s2 + i << '\n';
			s2--;
		}
	}
}         

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
	sol();
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    int n;  cin>>n;
    int a[n], b[n], c[n];   forI(i, 0, n-1) cin>>a[i]>>b[i]>>c[i];

    int dp[n+1][3];
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];

    forI(i, 1, n-1){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;

}

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 8196
N, K = map(int, input().split())
R, S, P = map(int, input().split())
winner = {'r': 'p',
          's': 'r',
          'p': 's'}

point = {'r': P,
         's': R,
         'p': S}

T = input()

result = 0
for i in range(K):
    before = ''

    for t in T[i:N:K]:
        if t != before:
            result += point[t]
            before = t
        else:
            before = ' '

print(result)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), cnt = 0, p = 100;
	while(p < n) p *= 1.01, cnt++;
	cout<<cnt<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static int h;
    public static int w;
    public static int x;
    public static int y;
    public static int res;
    public static boolean[][] b;
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            w = sc.nextInt();
            h = sc.nextInt();
            
            if (w == 0 && h == 0) break;
            
            x = 0;
            y = 0;
            res = 0;
            b = new boolean[h][w];

            for (int i = 0; i < h; i++) {
                String s = sc.next();
                for (int j = 0; j < w; j++) {
                    if (s.charAt(j)=='#') {
                        b[i][j] = true;
                    } else if (s.charAt(j)=='@') {
                        x = i;
                        y = j;
                    }
                }
            }
            
            solve(x, y);
            
            System.out.println(res);
        }
    }
    
    public static void solve(int x, int y) {
        b[x][y] = true;
        res++;
        int[] d = {-1,0,1,0,0,-1,0,1};
        for (int i = 0; i < 4; i++) {
            int nx = x + d[i*2];
            int ny = y + d[i*2+1];
            if ( 0 <= nx && nx < h && 0 <= ny && ny < w && b[nx][ny] == false) {
                solve(nx, ny);
            }
        }
    }
}

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

int main(){
    int N,Q,*l,*r,i,*check;
    string S;
    cin >> N >> Q;
    check = new int[N];
    for(i=0;i<N;i++){
        check[i] = 0;
    }
    cin >> S;
    for(i=0;i<N-1;i++){
        if(S[i]!='A'){
            continue;
        }else{
            if(S[i+1]!='C'){
                continue;
            }else{
                check[i] = 1;
                i++;
            }
        }
    }
    for(i=1;i<N;i++){
        check[i] += check[i-1];
    }
    l = new int[Q];
    r = new int[Q];
    for(i=0;i<Q;i++){
        cin >> l[i] >> r[i];
        if(l[i]!=1){
            cout << check[r[i]-2] - check[l[i]-2] << endl;
        }else{
            cout << check[r[i]-2]<< endl;
        }
        
    }
    return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int MOD = 1e9+7;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int S; cin >> S;
	vi dp (S+1);
	dp[0] = 1;
	for (int j = 0; j <= S; ++j) {
		for (int i = 3; i <= S; ++i) {
			if (j + i <= S) dp[j+i] = (dp[j+i] + dp[j]) % MOD;
		}
	}
	print(dp[S]);
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gosagu(ll A,ll B)
{
	if(A<B) swap(A,B);
	if(A%B==0) return B;
	else return gosagu(B,A%B);
}
int main()
{
	ll A,B;cin>>A>>B;
	ll gcd = gosagu(A,B);
	ll ans = (A*B)/(gcd);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  const int64_t mod = 1e9 + 7;
  int64_t answer = 1;
  rep(i, N) { answer = (answer * 10) % mod; }
  int64_t minus = 1;
  int64_t minus09 = 1;
  rep(i, N) {
    minus = (minus * 9) % mod;
    minus09 = (minus09 * 8) % mod;
  }
  answer = (answer - minus + mod) % mod;
  answer = (answer - minus + mod) % mod;
  answer = (answer + minus09) % mod;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3604
N=int(input())
S=list(map(int,input().split()))
ans=1
for i in range(N):
    if S[i]==0:
        print(0)
        exit()
for i in range(N):
    ans*=S[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d[i];
  
  int ans = 0;
  rep(j,n) {
    rep(i,j) {
      ans += d[i]*d[j];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())
    if A >= 2*C and B >= 2*C:
        ans = max(X, Y) * 2 * C
        print(ans)
        return
    if A>= 2*C:
        num_c = X * 2
        ans = num_c * C
        if Y * 2 > num_c:
            ans += (Y - num_c//2) * B
        print(ans)
        return
    if B >= 2*C:
        num_c = Y * 2
        ans = num_c * C
        if X * 2 > num_c:
            ans += (X - num_c//2) * A
        print(ans)
        return
    if A + B >= 2*C:
        num_c = min(X, Y) * 2
        ans = num_c * C
        ans += (X - num_c//2) * A
        ans += (Y - num_c//2) * B
        print(ans)
        return
    ans = X * A + Y * B
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)


n = int(input())
a = tuple(map(int, input().split()))

gl = []
g = 0
for aa in a:
    g = gcd(g, aa)
    gl.append(g)
gl = tuple(gl)

gr = []
g = 0
for aa in reversed(a):
    g = gcd(g, aa)
    gr.append(g)
gr = tuple(reversed(gr))

ans = 0
for rm in range(n):
    if rm - 1 < 0:
        ans = max(ans, gr[rm + 1])
    elif rm + 1 >= len(gr):
        ans = max(ans, gl[rm - 1])
    else:
        ans = max(ans, gcd(gl[rm - 1], gr[rm + 1]))
print(ans)


Measured memory_bytes: 14556
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0,high=0;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){high++;ans=max(ans,high);}
        else{high=0;}
    }
    cout<<ans;
}


Measured memory_bytes: 640
S = input()
i = len(S)
while i > 0:
  if S[i-5:i] in ["dream", "erase"]:
    i -= 5
  elif S[i-6:i] == "eraser":
    i -= 6
  elif S[i-7:i] == "dreamer":
    i -= 7
  else:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int main(){
    speed;
    ll X,Y;
    cin>>X>>Y;
    ll a=2*X-Y/2;
    ll b=(Y-2*X)/2;
    if(a>=0&&b>=0&&Y%2==0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int gcd(int a, int b){
  int tmp,r;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  
  return b;
}


int main(){
  int k;
  cin>>k;
  ll ans=0;
  rep(i,k){
    rep(j,k){
      rep(l,k){
        ans+=gcd(i+1,gcd(j+1,l+1));
      }
    }
  }
  
  cout<<ans<<endl;
}

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

int main(){
	
	int n;
	int a;
	int *row,line;

	while(scanf("%d",&n)){
		if(n==0){break;}
		
		row=(int*)malloc(sizeof(int)*(n+1));
		for(int i=0;i<(n+1);i++){
			row[i]=0;
		}

		for(int i=0;i<n;i++){
			line=0;
			for(int j=0;j<n;j++){
				scanf("%d",&a);
				line+=a;
				row[j]+=a;
				printf("%5d",a);
			}
			printf("%5d\n",line);
			row[n]+=line;
		}

		for(int i=0;i<(n+1);i++){
			printf("%5d",row[i]);
		}printf("\n");

		free(row);
	}

	return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int a[] = new int[n];
		final int MOD = 1000000007;
		long tmp = 0;
		for(int i = 0 ; i < n ; i++){
			a[i] = Integer.parseInt(sc.next());
			tmp += a[i];
			tmp %= MOD;
		}
		sc.close();
		long sum = 0;
		for(int i = 0 ; i < n; i++){
			tmp -= a[i];
			if(tmp < 0){
				tmp += MOD;
			}
			sum += (a[i] * tmp);
			sum %= MOD;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 60500
#include <stdio.h>
//#include <stdlib.h>

#define min(a,b)((a)<(b)?(a):(b))

int main(void)
{
	int i,n,w[100],sum=0,s1=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
		sum += w[i];
	}
	
	int ans = sum;
	for(i=0;i<n;i++){
		s1 += w[i];
		ans = min(ans,abs(sum-2*s1));
	}
	printf("%d\n",ans);
	
	return 0;
}


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

#define ll       long long

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("in.txt", "w", stdout);
    //ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n;



      cin>>n;
        vector<int> a;
        for(int i = 0;i<n;i++)
        {
            int x;
            cin>>x;
            a.push_back(x);
        }
        sort(a.begin(), a.end());
        ll cnt = 0LL;
        for(int i = 0;i<n;i++) for(int j = i+1;j<n-1;j++)
        {
            int ind = upper_bound(a.begin(), a.end(), a[i]+a[j]-1) - a.begin()-1;
            cnt+= ind - j;
        }
        cout<<cnt<<endl;
        a.clear();

}


Measured memory_bytes: 256
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                flag = 0
                break
        if (flag == 1):
            print("%s %s %s" % (cx, cy, H))
            sys.exit(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    for(int i=1;i<=50000;i++){
        double x;
        x = i * 1.08;
        if(N<=x&&x<N+1){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int64_t get_int(void) {
  int64_t num;
  scanf("%lld", &num);
  return num;
}

int main(void) {
    int64_t num = get_int();
    int64_t cnt = num/11;
    cnt *= 2;
    if(num%11 > 6) {
        cnt += 2;
    } else if(num%11>0) {
        cnt++;
    }
    printf("%lld\n", cnt);
    return 0;
}

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

int main() {
  ll n; cin>>n;
  vector<ll> v(n);
  rep(i,n){
      cin>>v.at(i);}
  ll ans=1;
  ll m=pow(10,18);
  if(count(v.begin(),v.end(),0)>0)ans=0;
  else{
    rep(i,n){
      if(m/ans<v.at(i)){ans=-1;break;}
      ans*=v.at(i);
      if(ans>m){ans=-1;break;}
    }
  }
  
  cout<<ans;
}
      



Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  char a;
  cin >> a;
  if(a == 'T') cout << "A" << endl;
  else if(a == 'A') cout << "T" << endl;
  else if(a == 'G') cout << "C" << endl;
  else cout << "G" << endl;
  
}

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

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

Measured memory_bytes: 256
//12
#include<iostream>
#include<complex>
#include<cmath>
#include<algorithm>

using namespace std;

typedef complex<double> P;

int cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

int dt(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

int main(){
  for(;;){
    int x,y;
    P t[3],c;
    int r;
    for(int i=0;i<3;i++){
      cin>>x>>y;
      if((i|x|y)==0)return 0;
      t[i]=P(x,y);
    }
    cin>>x>>y;
    c=P(x,y);
    cin>>r;
    if(abs(t[0]-c)<=r&&abs(t[1]-c)<=r&&abs(t[2]-c)<=r){
      cout<<'b'<<endl;
    }else{
      double d[3];
      bool f[2]={};
      for(int i=0;i<3;i++){
	P l=t[(i+1)%3]-t[i];
	if(dt(l,c-t[i])>0&&dt(-l,c-t[(i+1)%3])>0){
	  d[i]=fabs(cr(l,c-t[i])/abs(l));
	}else{
	  d[i]=min(abs(c-t[i]),abs(c-t[(i+1)%3]));
	}
	f[cr(l,c-t[i])<0]=true;
      }
      if(f[0]^f[1]&&d[0]>=r&&d[1]>=r&&d[2]>=r){
	cout<<'a'<<endl;
      }else if(d[0]<=r||d[1]<=r||d[2]<=r){
	cout<<'c'<<endl;
      }else{
	cout<<'d'<<endl;
      }
    }
  }
  return 0;
}

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

#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;
int main() {

	int n;
	cin >> n;

	vector<ll> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}


	int ans = 0;


	for (int i = 0; i < n; i++)
	{
		while (a[i] % 2 == 0) {
			a[i] = a[i] / 2;
			ans++;
		}

	}

	cout << ans << endl;



}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	AB := sc.nextInts()
	A := AB[0]
	B := AB[1]

	ans := lcm(A, B)
	fmt.Println(ans)
}

func lcm(X int, Y int) int {
	target := X * Y
	r := X % Y
	for {
		if r == 0 {
			break
		}
		X = Y
		Y = r
		r = X % Y
	}
	return target / Y
}

/* template functions */
var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
vector<int > g[100001];
vector<int > dis(100001,0),in(100001,0);
void bfs()
{
    
    queue<int > q;
   
    for(int i=1;i<in.size();i++)
    if(in[i]==0)
    {
    q.push(i);
    dis[i]=0;
    
    }
    while(!q.empty())
    {
        int p=q.front();
        q.pop();
        for(int j=0;j<g[p].size();j++)
        {
            in[g[p][j]]--;
            if(in[g[p][j]]==0)
            {
               
                dis[g[p][j]]=dis[p]+1;
                
                q.push(g[p][j]);
                
            }
        }
    }
}
int main()
{  ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

    int n,m;
    cin>>n>>m;
    int i;
    for(i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        in[y]++;
        
        
    }
    int z=0;
 
       
        bfs();
        
        sort(dis.rbegin(),dis.rend());
       
       
        z=dis[0];
        
  
   cout<<z<<endl;
    
    return 0;
    
}

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

vector<vector<ll>> c;

ll comb(ll n, ll m, ll mod){
    if(m > n-m) m = n - m;
    if(c[n][m] != -1) return c[n][m];
    if(n==m || m==0){
        c[n][m] = 1;
    }else{
        c[n][m] = (comb(n-1,m-1, mod) + comb(n-1,m, mod))%mod;
    }
    return c[n][m];
}


int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> a;
    for(int i=2; i*i<=M; i++){
        ll cnt = 0;
        while(M%i==0){
            M/=i;
            cnt++;
        }
        if(cnt!=0) a.push_back(cnt);
    }
    if(M!=1) a.push_back(1);

    int alen = a.size();
    ll aMax = 0;
    for(int i=0; i<alen; i++){
        aMax = max(aMax, a[i]);
    }
    c = vector<vector<ll>>(N+aMax+1, vector<ll>(aMax+1, -1));
    ll ans = 1;
    int mod = 1e9+7;
    for(int i=0; i<alen; i++){
        ans = (ans*comb(a[i]+N-1, a[i], mod))%mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 33792
def main():
    H, W, K = map(int, input().split())
    c = [input() for _ in range(H)]
    ans = 0

    # 選ばない:0  選ぶ:1

    for row in range(2 ** H):
        for column in range(2 ** W):
            cnt = 0
            for i in range(H):
                for j in range(W):
                    if row >> i & 1:
                        continue
                    if column >> j & 1:
                        continue
                    if c[i][j] == "#":
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9140
N, M = map(int, input().split())

d = {i+1: []  for i in range(N)}
for _ in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

for i in range(N):
    print(len(d[i+1]))

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
mod = 10**9 + 7

n = int(input())
s = input().rstrip()

from collections import Counter

c = Counter(s)

n_ = len(c.keys())

ans = 1

for i in c.keys():
    ans *= (c[i] + 1)
    ans %= mod

ans -= 1

print(ans)

Measured memory_bytes: 39280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        int[][] counts = new int[14][14];
        while ((line = reader.readLine()) != null && !line.isEmpty()) {
            String[] values = line.split(",");
            int x = Integer.parseInt(values[0]);
            int y = Integer.parseInt(values[1]);
            int size = Integer.parseInt(values[2]);
            int i = x + 2;
            int j = y + 2;
            counts[i][j]++;
            counts[i][j - 1]++;
            counts[i + 1][j]++;
            counts[i][j + 1]++;
            counts[i - 1][j]++;
            if (size >= 2) {
                counts[i + 1][j - 1]++;
                counts[i + 1][j + 1]++;
                counts[i - 1][j + 1]++;
                counts[i - 1][j - 1]++;
                if (size >= 3) {
                    counts[i][j - 2]++;
                    counts[i + 2][j]++;
                    counts[i][j + 2]++;
                    counts[i - 2][j]++;
                }
            }
        }
        int emptyCount = 0;
        int maxCount = 0;
        for (int i = 2; i < 12; i++) {
            for (int j = 2; j < 12; j++) {
                int count = counts[i][j];
                if (count == 0) {
                    emptyCount++;
                } else if (count > maxCount) {
                    maxCount++;
                }
            }
        }
        out.println(emptyCount);
        out.println(maxCount);
    }
}

Measured memory_bytes: 9352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, A, B = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

ans = 0
for i in range(N - 1):
    ans += min(B, A * (X[i + 1] - X[i]))

print (ans)

Measured memory_bytes: 14172