akhauriyash/Code-Regression huggingface dataset:
while true
	break if gets.to_i == 0
	a=gets.split(" ").map{|e|e.to_i}
	start = a[0]
	before = a[0]
	count = 0
	puts a[0] if a.length == 1
	a[1..a.length-1].each_with_index{|e,i|
		i+=1
		if before == e-1
			if i == a.length-1
				print " " if count != 0
				print "#{start}-#{e}"
				count+=1
				before = e
				start = e
			else
				before = e
			end
		else
			if before == start
				print " " if count != 0 
				print before
				start = e
				before = e
				count+=1
			else
				print " " if count != 0
				print "#{start}-#{a[i-1]}"
				count+=1
				start = e
				before = e
			end
			if i == a.length-1
				a.length-1 
				print " " if count != 0  
				print e 
				before = e 
				start = e 
				count+=1 
			end
		end
	}
		puts "" if count != 0
end

Measured memory_bytes: 6124
using static System.Console;
using System;
 
namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
			string line = ReadLine();
          	string[] l = line.Split(' ');
            long N = long.Parse(l[0]);
          	long A = long.Parse(l[1]);
            long B = long.Parse(l[2]);
          	long tmp1 = N / (A + B);
            long tmp2 = N % (A + B);
			WriteLine(tmp1 * A + Math.Min(tmp2, A ));
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N,M; cin >> N >> M;
    vector<vector<int>> AB(100010);
    rep(i,N){
        int A,B;
        cin >> A >> B;
        AB[A].push_back(B);
    }
    priority_queue<int> q;
    int ans = 0;
    for(int i = M-1; i >= 0; i--){
        for(int j : AB[M-i]){
            q.push(j);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>

using namespace std;

int A[8];
int B[4];

int main(int argc, char** argv)
{
	int a, c;
	double b;
	double d;
	
	while( 1 )
	{
		cin >> d;
		if(d < 0.0) break;
		
		a = (int)d;
		b = d - a;
		
		for(int i=7; i>=0; i--)
		{
			A[i] = a%2;
			a /= 2;
		}
		
		for(int i=0; i<4; i++)
		{
			b *= 2.0;
			if(b>=1.0) B[i] = 1, b-=1.0;
			else B[i] = 0;
		}
		
		if(a==0 && b==0.0)
		{
			for(int i=0; i<8; i++) cout << A[i];
			cout << ".";
			for(int i=0; i<4; i++) cout << B[i];
			cout << endl;
		}
		else cout << "NA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include <math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const ll INF =1LL << 62;
using namespace std;

int main(){
	while(1){
		int n; cin >>n;
		if(n==0)  break;
		vector<int> a(n);
		cinf(n,a);
		sort(a.begin(),a.end());
		int ans=1e9;
		for(int i=0;i<n-1;i++){
			ans=min(ans,a[i+1]-a[i]);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[100000];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[100000];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(abs(h[i-2]-h[i])+dp[i-2],abs(h[i-1]-h[i])+dp[i-1]);
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
from collections import deque
r, c = map(int, raw_input().split())
n = input()
P = [map(int, raw_input().split()) for i in xrange(n)]

d = {}
P.sort()
for i in xrange(1, n):
    r1, c1, a1 = P[i-1]
    r2, c2, a2 = P[i]
    if r1 == r2:
        d.setdefault((r1, c1), []).append(((r2, c2), a2-a1))
        d.setdefault((r2, c2), []).append(((r1, c1), a1-a2))
P.sort(key=lambda (r,c,a): (c,r))
for i in xrange(1, n):
    r1, c1, a1 = P[i-1]
    r2, c2, a2 = P[i]
    if c1 == c2:
        d.setdefault((r1, c1), []).append(((r2, c2), a2-a1))
        d.setdefault((r2, c2), []).append(((r1, c1), a1-a2))
m = {}
for i, (r0, c0, a0) in enumerate(P):
    m[r0, c0] = (a0, i)
used = [0]*n
for i in xrange(n):
    if not used[i]:
        r0, c0, base = P[i]

        used[i] = 1
        deq = deque()
        deq.append((r0, c0, base))
        rs = {r0: 0}
        cs = {c0: 0}

        while deq:
            r0, c0, now = deq.popleft()

            for (r1, c1), diff in d.get((r0, c0), []):
                a1, j = m[r1, c1]
                if r0 == r1:
                    if not used[j]:
                        cs[c1] = cs[c0] + diff
                        used[j] = 1
                        deq.append((r1, c1, now + diff))
                    else:
                        if cs[c0] + diff != cs[c1]:
                            print "No"
                            exit(0)
                else:
                    if not used[j]:
                        rs[r1] = rs[r0] + diff
                        used[j] = 1
                        deq.append((r1, c1, now + diff))
                    else:
                        if rs[r0] + diff != rs[r1]:
                            print "No"
                            exit(0)
        rmin = min(rs.values())
        cmin = min(cs.values())
        if rmin + cmin + base < 0:
            print "No"
            exit(0)
print "Yes"

Measured memory_bytes: 126896
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
using namespace std;

const int mod = 998244353;
typedef long long li;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Inv(int x) {
  return Pow(x, mod - 2);
}

// ----------------------------------------

const int maxn = 400;

int n, A[maxn], B[maxn], SA, SB;
int f[maxn + 1][maxn + 1], f2[maxn + 1][maxn + 1];
int fact[maxn + 1], ifact[maxn + 1], pow[maxn + 1];

void InitFact(int n) {
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = Mul(fact[i - 1], i);
  ifact[n] = Inv(fact[n]);
  for (int i = n; i >= 1; --i) ifact[i - 1] = Mul(ifact[i], i);
}

void InitPow(int x, int n) {
  pow[0] = 1;
  for (int i = 1; i <= n; ++i) pow[i] = Mul(pow[i - 1], x);
}

int main(void) {
  scanf("%d", &n);
  SA = SB = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", A + i, B + i);
    --B[i];
    Add(SA, A[i]);
    Add(SB, B[i]);
  }
  FILL(f, SB + 1, 0);
  f[0][0] = Sub(-1);

  InitFact(SB);

  for (int id = 0; id < n; ++id) {
    FILL(f2, SB + 1, 0);
    int Ai = A[id], Bi = B[id];
    InitPow(Ai, Bi);

    for (int m = 0; m <= SB; ++m) {
      for (int sa = 0; sa <= SA; ++sa) {
        int val = f[m][sa];
        if (val == 0) continue;

        // don't choose id
        Add(f2[m][sa], val);

        // choose with x^i
        for (int i = 0; i <= Bi; ++i) {
          int coeff = Mul(pow[i], ifact[i]);
          Add(f2[m + i][sa + Ai], Mul(val, Sub(-coeff)));
        }
      }
    }

    COPY(f2, SB + 1, f);
  }

  int ans = 0;

  for (int m = 0; m <= SB; ++m) {
    for (int sa = 0; sa <= SA; ++sa) {
      int val = f[m][sa];
      if (val == 0) continue;
      Add(ans, Mul(val, fact[m], Inv(Pow(sa, m + 1))));
    }
  }
  ans = Mul(ans, SA);
  printf("%d\n", ans);
  return 0;
}


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

// 最大公約数
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  else return gcd(b, a % b);
}

// 素因数分解でユニークな個数を数える
ll prime_fact_num(ll a) {
  int cnt = 0;
  ll sa = sqrt(a)+1;
  for (ll i=2;i<=sa;++i ) {
    if (a%i==0) cnt++;
    while (a%i==0) {
      a /= i;
//      cout << i << " " << a << endl;
    }
  }
  if (a != 1) cnt++;
  return cnt;
}


int main() {
  ll A,B;
  cin >> A >> B;

  ll g = gcd(A,B);
//  cout << g << endl;
  int cnt = prime_fact_num(g);
  cout << cnt+1 << endl;
}


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

int main(){
  long long int N,M;
  cin>>N>>M;
  if(N==1&&M==1){
    cout<<1<<endl;
  }else if(N==1){
    cout<<M-2<<endl;
  }else if(M==1){
    cout<<N-2<<endl;
  }else{
    cout<<(M-2)*(N-2)<<endl;
  }
  
}

Measured memory_bytes: 256
n = int(input())
flag = False
for i in range(1,3501):
	for j in range(i,3501):
		if (4*i*j-i*n-j*n)>0 and (n*i*j)%(4*i*j-i*n-j*n)==0:
			a,b,c,flag = i,j,(n*i*j)//(4*i*j-i*n-j*n),True
			break
	if flag: break
print(a,b,c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int sum[n];
    for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum[i]=INT_MAX;
        }
    for(int i=1;i<=k&&i<n;i++)
        sum[i]=abs(a[i]-a[0]);
    for(int i=k+1;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        sum[i]=min(sum[i],sum[i-j]+abs(a[i]-a[i-j]));
    }
    cout<<sum[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
  int n; cin>>n;
  cout<<n/3<<endl;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    long long int sum=0;
    for(int i=1; i<=N; i++)
    {
        if(i%3!=0 && i%5!=0)
            sum=sum+i;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  vector<string> st = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;
  rep(i, st.size()){
    if(st.at(i) == s){
      cout << 7 - i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define max 1000000

int prime[1000005];

int main(void)
{
  int i, j, n;

  for (i = 2; i < max; i++) {
    prime[i] = 1;
  }

  for (i = 2; i < max; i++) {
    if (prime[i] == 1){
      for (j = 2; j <= max; j++) {
        if (i * j <= max) prime[i * j] = 0;
        else break;
      }
    }
  }

  for (i = 1; i < max + 1; i++) {
    prime[i] = prime[i] + prime[i - 1];
  }

  while (scanf("%d", &n) != EOF) {
    printf("%d\n", prime[n]);
  }

  return (0);
}

Measured memory_bytes: 4500
n = int(input())
A = list(map(int, input().split()))
color = []
other = 0
for a in A:
    if a < 400: color.append(1)
    elif a < 800: color.append(2)
    elif a < 1200: color.append(3)
    elif a < 1600: color.append(4)
    elif a < 2000: color.append(5)
    elif a < 2400: color.append(6)
    elif a < 2800: color.append(7)
    elif a < 3200: color.append(8)
    else: other += 1
c = len(set(color))
if color: print(c, c+other)
else: print(1, other)

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

int main()
{
	int n;
	cin >> n;
	vector<int> ss(n, 0);
	for (int i = 1; i < n; i++)
	{
		int j;
		cin >> j;
		ss[--j]++;
	}
	for (auto&& e : ss)
	{
		cout << e << endl;
	}
}

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

int main(){

    int D, N;
    cin >> D >> N;

    int S = 1; for(int i = 0; i < D; i++) S *= 100;
	if(N <= 99){
		cout << S * N << endl;
	}else{
		cout << S * 101 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)

def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    #print(inv, q, gcd_val)
    return inv % m

def m(n,r):
    d=1
    e=1
    f=1
    for i in range(r):
        d=(n-i)
        e=(i+1)
        d%=(10**9+7)
        f = f*d*modinv(e,(10**9+7))%(10**9+7)
        
    return(f)

n=[int(i) for i in input().split()]
a=sum(n)
if a%3 != 0:print(0)

else:
    b=int(a/3)
    if b==1:
        print(1)
    else:
        c=n[0]-b
        d=n[1]-b
        if c<0 or d<0: print(0)

        else:
            if c==d:
                c=int(b/2)
            #d=m(b,min(c,d))
            print(m(b,min(c,d)))

Measured memory_bytes: 3064
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n ; cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    vector<map<char, int>> mp(n);

    int zero_a = 'a';

    map<char, int> tmp;
    rep(i, 26) {
        tmp[char(zero_a+i)] = 0;
    }

    rep(i, n) {
        mp[i] = tmp;
        int len = s[i].size();
        rep(j, len) {
            mp[i][s[i][j]] ++;
        }
    }

    map<char, int> ansmap;
    rep(i, 26) {
        ansmap[char(zero_a+i)] = 50;
    }

    rep(i, n) {
        rep(j, 26) {
            ansmap[char(zero_a+j)] = min(ansmap[char(zero_a+j)], mp[i][char(zero_a +j)]);
        }
    }

    string ans = "";
    rep(i, 26) {
        int num = ansmap[char(zero_a+i)];
        rep(j,num) {
            ans += char(zero_a+i);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		for(int i=1;i<10;i++) {
			if(n%i==0 && n/i<10) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
		
	}

}


Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
    int a,b;
    cin >> a >> b;

    int ab = a+b;
    int a2 = 2*a-1;
    int b2 = 2*b-1;

    const auto res = max({ab, a2, b2});

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def dfs(bu, bv, u=0):
        for cu in to[u]:
            if (u, cu) == (bu, bv) or (u, cu) == (bv, bu): continue
            if fin[cu]: continue
            fin[cu] = True
            dfs(bu, bv, cu)

    to = defaultdict(list)
    ee = []
    n, m = MI()
    for _ in range(m):
        a, b = map(int1, input().split())
        to[a].append(b)
        to[b].append(a)
        ee.append([a, b])
    ans = 0
    for u, v in ee:
        fin = [False] * n
        fin[0] = True
        dfs(u, v)
        if sum(fin) < n: ans += 1
    print(ans)

main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
char s[210];
int main()
{
	
	
	scanf("%s", s);
	int x = strlen(s);
	for (int i = (x - 1) / 2 - 1; i >= 0; i--) {
		if (!strncmp(s, s + i + 1, i + 1)) {
			printf("%d\n", 2 * (i + 1));
			break;
		}
	}
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
        int n = in.readInt();
        boolean bool = false; 
        for(int i = 0; i<=n/4; i++) {
        	for(int j=0; j<=n/7; j++) {
        		if(4*i + 7*j == n) bool = true; 
        	}
        }
        if(bool) System.out.println("Yes"); 
        else System.out.println("No");
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr double pi = acos(-1);

int main()
{
    double a, b;
    cin >> a >> b;
    double ans = a * b / (a + b);
    cout << fixed << setprecision(10);
    cout << ans << endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n;
string s;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    s = to_string(n);
    int m = 0;
    rep(i, s.size()) {
        m += s[i] - '0';
    }
    if (n % m == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

int main()
{
    int x, y;
    cin >> x >> y;

    rep(i, x) {
        int tatol = i;
        int toki = x - i;

        if ((tatol * 4) + (toki * 2) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i, x) {
        int toki = i;
        int tatol = x - i;

        if ((tatol * 4) + (toki * 2) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

// 最大公約数
template <typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

// nを素因数分解
inline vector<pair<long long, long long>> factorize(const long long n) {
    vector<pair<long long, long long>> factors;
    long long i = 2;
    long long j = n;
    while (i * i <= n && j != 1) {
        long long cnt = 0;
        while (j % i == 0) {
            ++cnt;
            j /= i;
        }
        if (cnt > 0)
            factors.push_back(make_pair(i, cnt));
        ++i;
    }

    if (j > 1)
        factors.push_back(make_pair(j, 1));

    return factors;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << factorize(gcd(a, b)).size() + 1 << endl;
    return 0;
}

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

int main() 
{
    string t,s;
    cin>>s>>t;
    
    ll i,j;
    ll n=s.length();
    ll m=t.length();
    
    ll mn=LLONG_MAX;
    for(i=0;i<n-m+1;i++)
    {
        ll cnt=0;
        for(j=0;j<m;j++)
        {
            if(s[i+j]!=t[j])cnt++;
        }
        mn=min(mn,cnt);
    }
    cout<<mn;
    
}

Measured memory_bytes: 3624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::f32;

fn main() {
    input! {
        k: i32,
        s: i32,
    }

    let mut cnt = 0;

    for i in 0..k + 1 {
        for j in 0..k + 1 {
            let remain = s - i - j;
            if remain >= 0 && remain <= k {
                cnt += 1;
            }
        }
    }

    println!("{}", cnt)
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

template<class Monoid> struct SegmentTree { // {{{
    using Func = function<Monoid(Monoid, Monoid)>;
    const int sz;
    const Func merge;
    const Monoid unity;
    vector<Monoid> dat;

    SegmentTree(int n, const Monoid &u, Func f)
        : sz(1 << (__lg(n+5) + 1)), merge(f), unity(u), dat(sz*2, unity) {}

    void set(int k, const Monoid &v) { dat[k + sz] = v; }

    Monoid& operator[] (int k) { return dat[k + sz]; }
    const Monoid& operator[] (int k) const { return dat[k + sz]; }

    void build() { for (int k = sz-1; k > 0; --k) dat[k] = merge(dat[2*k], dat[2*k+1]); }

    void update(int k, const Monoid &v) {
        dat[ k += sz ] = v;
        while(k >>= 1) dat[k] = merge(dat[2*k], dat[2*k+1]);
    }

    Monoid query(int a, int b) const {
        Monoid L = unity,  R = unity;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = merge(L, dat[a++]);
            if (b & 1) R = merge(dat[--b], R);
        }
        return merge(L, R);
    }
}; // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    vector<int> h(N);
    vector<i64> a(N);
    rep(i, N) read(h[i]);
    rep(i, N) read(a[i]);

    // dp[h_i]
    SegmentTree<i64> dp(N+5, 0, [](i64 a, i64 b) { return max(a, b); });

    i64 ans = 0;
    rep(i, N) {
        const i64 best = dp.query(0, h[i]);
        dp.update(h[i], best + a[i]);
        chmax(ans, best + a[i]);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 6656
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int* x = new int[N];
	for (size_t i = 0; i < N; i++)
		cin >> x[i];

	int* ways = new int[N];
	
	for (size_t j = 0; j < N; j++)
		ways[j] = 0;
		
	ways[0] = 2;

	long long start = 0;
	for (size_t i = 2; i < N; i++)
	{
		int canleft = (x[i - 1] + 1) / 2;
		if (i - start > canleft)
			start++;
		ways[start]++;
	}

	for (size_t i = 1; i < N; i++)
		ways[i] += ways[i-1];

	long long result = ways[0];
	for (int j = 1; j < N; j++)
		result = (result * (ways[j] - j)) % 1000000007;

	cout << result;

	return 0;
}

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

long long calc(vector<long long>& List, int K) {
	int N = List.size();
	vector<long long> LSum(N);
	LSum[0] = List[0];
	for (int i = 1; i < N; i++) LSum[i] = LSum[i - 1] + List[i];

	int NK = K;
	if (K > N) K = N;

	long long MAX = -pow(10ll, 10);
	for (int i = 0; i < K; i++) MAX = max(MAX, LSum[i] + max(0ll, LSum[N - 1] * ((NK - (i + 1)) / K)));
	for (int i = 1; i < N; i++) {
		for (int j = i; j < i + K; j++) {
			int nj = j % N;
			if (i <= nj) MAX = max(MAX, LSum[nj] - LSum[i - 1] + max(0ll, LSum[N - 1] * ((NK - (j - i + 1)) / K)));
			else MAX = max(MAX, LSum[N - 1] - LSum[i - 1] + LSum[nj] + max(0ll, LSum[N - 1] * ((NK - (j - i + 1)) / K)));
		}
	}
	return MAX;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> P(N);
	vector<long long>C(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		P[i]--;
	}
	for (int i = 0; i < N; i++) cin >> C[i];
	vector<int> Used(N, 0);
	long long ans = -pow(10ll, 10);
	for (int st = 0; st < N;) {
		Used[st] = 1;
		vector<long long> List;
		List.push_back(C[st]);
		int now = P[st];
		while (now != st) {
			List.push_back(C[now]);
			Used[now] = 1;
			now = P[now];
		}
		ans = max(calc(List, K), ans);
		while (st < N && Used[st]) st++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3816
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

const double EPS = 1e-15;

struct Point {
	double x, y;

	bool operator < ( const Point & other ) const {
		if ( x != other.x ) return x < other.x;
		return y < other.y;
	}

	Point operator - ( const Point & other) {
		Point res;
		res.x = x - other.x;
		res.y = y - other.y;
		return res;
	}

	double norm() {
		return x * x + y * y;
	}
};


typedef vector<Point> Polygon;
typedef Point Vector;

double cross( Vector a, Vector b ) {
	return a.x * b.y - a.y * b.x;
}

double dot( Vector a, Vector b ) {
	return a.x * b.x + a.y * b.y;
}

bool comp( Point a, Point b ) {
	if ( a.y != b.y ) return a.y < b.y;
	return a.x < b. x;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw( Point p0, Point p1, Point p2) {
	Vector a = p1 - p0;
	Vector b = p2 - p0;
	if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
	if ( cross(a, b) < -EPS ) return CLOCKWISE;
	if ( dot(a, b) < -EPS ) return ONLINE_BACK;
	if ( a.norm() < b.norm() ) return ONLINE_FRONT;

	return ON_SEGMENT;
}

Polygon andrewScan( Polygon s ) {
	Polygon u, l;
	if ( s.size() < 3 ) return s;
	sort(s.begin(), s.end()); // 以x,y為基準升序排序

	// 將x值最小的2個點添加至u
	u.push_back(s[0]);
	u.push_back(s[1]);
	// 將x值最大的2個點添加至l
	l.push_back(s[s.size() - 1]);
	l.push_back(s[s.size() - 2]);

	// 構建凸包上部
	for ( int i = 2; i < s.size(); i++ ) {
		for (int n=u.size();n >= 2 && ccw(u[n-2], u[n-1], s[i]) >= 0; n--) {
			u.pop_back();
		}
		u.push_back(s[i]);
	}

	// 構建凸包下部
	for ( int i = s.size() - 3; i >= 0; i-- ) {
		for( int n=l.size();n >= 2 && ccw(l[n-2], l[n-1], s[i]) >= 0; n--) {
			l.pop_back();
		}
		l.push_back(s[i]);
	}

	// 按逆時針方向生成凸包的點的序列
	reverse(l.begin(), l.end());
	for ( int i = u.size() - 2; i >= 1; i-- ) l.push_back(u[i]);

	return l;
}

int main() {
	int n;
	Polygon s;
	
	scanf("%d", &n);
	for ( int i = 1;i<=n;i++)
	{
		Point x;
		scanf("%lf %lf", &x.x, &x.y);
		s.push_back(x);
	}
	s = andrewScan( s );

	printf("%d\n", s.size());

	int pos = -1;
	Point k;
	for ( int i = 0; i < s.size(); i++ ) {
		if( pos == -1 || comp(s[i], k) ) {
			pos = i;
			k = s[i];
		}
	}
	for ( int i = pos; i < s.size(); i++ ) {
		printf("%.0lf %.0lf\n", s[i].x, s[i].y);
	}
	for ( int i = 0; i < pos; i++) {
		printf("%.0lf %.0lf\n", s[i].x, s[i].y);
	}

	return 0;
}



Measured memory_bytes: 10472
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	int g = 0, p = 0;
	for (int i = 0; i < (int)(s.length()); i++) {

		if (s[i] == 'g') g++;
		else p++;
	}

	int ch = s.length() / 2;

	cout << abs(p - ch); //思考はif(g>ch) ch - p else g - (p - (ch - g))

	return 0;
}

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

int main(){
	int n,x[3],p[100] = {},ans = 0;
	cin >> n;
	for(int i = 0;i < 3;i++){
		cin >> x[i];
		for(int j = 0;j < x[i];j++){
			int t;
			cin >> t; t--;
			p[t] += 1;
		}
		if(i != 2) for(int j = 0;j < n;j++) p[j] *= 2;
	}
	for(int i = 0;i < n;i++){
		if(p[i] == 7 || p[i] == 3 || p[i] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
# print(visited)
path = [0]
at = 0
loop = 0
visited[0]=True

for i in range(N):
    at = A[at]-1
    # print(at)
    if visited[at]:
        loop = i+1-path.index(at)
        break
    else:
        visited[at]=True
        path.append(at)
if K < len(path):
    print(path[K]+1)
else:
    print(path[(K-path.index(at))%loop+path.index(at)]+1)

Measured memory_bytes: 32356
#include <iostream>
#include <vector>
using namespace std;
class Position {
  public:
    int x;
    int y;
    Position() {
      x = 10;
      y = 10;
    }
    bool isEqual(Position pos) {
      return ((pos.x == x) && (pos.y == y));
    }
    bool operator == (Position pos) {
      return (x == pos.x) && (y == pos.y);
    }
    void erase() {
      x = -1;
      y = -1;
    }
    bool isDeleted() {
      return (x == -1) && (y == -1);
    }
};
void deletePosition(vector<Position>&, Position&);

int main() {
  while(true) {
    vector<Position> dests;
    int n;
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; ++i) {
      Position dest;
      int x, y;
      cin >> x >> y;
      dest.x = x;
      dest.y = y;
      dests.push_back(dest);
    }
    Position currentPosition;
    cin >> n;
    for(int i = 0; i < n; ++i) {
      char direction;
      int steps;
      cin >> direction >> steps;
      int lastX = currentPosition.x;
      int lastY = currentPosition.y;
      for(int i = 0; i < steps; ++i) {
        switch(direction) {
          case 'N':
            ++currentPosition.y;
            break;
          case 'E':
            ++currentPosition.x;
            break;
          case 'S':
            --currentPosition.y;
            break;
          case 'W':
            --currentPosition.x;
            break;
        }
        deletePosition(dests, currentPosition);
      }
      //if(direction == 'N') for(++currentPosition.y; currentPosition.y <= lastY + steps; ++currentPosition.y) {deletePosition(dests, currentPosition); cout << currentPosition.x << ":" << currentPosition.y << endl; }
      //if(direction == 'E') for(++currentPosition.x; currentPosition.x <= lastX + steps; ++currentPosition.x) {deletePosition(dests, currentPosition); cout << currentPosition.x << ":" << currentPosition.y << endl; }
      //if(direction == 'S') for(--currentPosition.y; currentPosition.y >= lastY - steps; --currentPosition.y) deletePosition(dests, currentPosition);
      //if(direction == 'W') for(--currentPosition.x; currentPosition.x >= lastX - steps; --currentPosition.y) deletePosition(dests, currentPosition);
      //cout << currentPosition.x << ":" << currentPosition.y << endl;
    }
    bool flag = true;
    for(int i = 0; i < dests.size(); ++i) {
      if(!dests[i].isDeleted()) {
        flag = false;
      }
    }
    cout << ((flag) ? ("Yes") : ("No")) << endl;
  }
  return 0;
}

void deletePosition(vector<Position> &poses, Position &pos) {
  for(int i = 0; i < poses.size(); ++i) {
    if(pos == poses[i]) {
      poses[i].erase();
    }
  }
}

Measured memory_bytes: 1192
n,a,b = gets.strip.split.map(&:to_i)

def digit_sum n
  sum = 0
  while n > 0 do
    sum += n % 10
    n /= 10
  end
  sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a<= d[1] && d[1] <=b } 
        .inject(0) { |sum,d| sum + d[0] }
puts ans

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int64 C[2222][2222];
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  const int64 mod=1e9+7;
  int64 res=0;
  for(int i=0;i<2222;++i)C[i][0]=1;
  for(int i=1;i<2222;++i){
    for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
  }
  for(int i=1;i<=n;++i){
    if(3*i<=n){
      (res+=C[n-3*i+i-1][n-3*i])%=mod;
    }
  }
  cout<<res;
  return 0;
}
//2020.09.13 20:00:37


Measured memory_bytes: 30788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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 main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  int ind_of_lower_0;
  rep(i, N) { cin >> x[i]; }

  int ans = INF;
  rep(i, N - K + 1) {
    int l = i;
    int r = i + K - 1;
    if (x[r] <= 0)
      chmin(ans, abs(x[l]));
    else if (x[l] >= 0)
      chmin(ans, x[r]);
    else {
      int l_abs = abs(x[l]);
      int r_abs = x[r];
      chmin(ans, l_abs + r_abs + min(l_abs, r_abs));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, n);
    Cins(ll, 5, a);
    Sort(a);
    Cout((n + a[0]-1) / a[0] + 4);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <cassert>
#include <algorithm>
using namespace std;

int main()
{
    int res;
    int N, X;
    cin >> N >> X;
    vector<int> m;
    for (int temp; cin>>temp;){
       m.push_back(temp);
    }

    int sum = accumulate(m.begin(), m.end(), 0);
    int min = *min_element(m.begin(), m.end());
    X -= sum;
    res = N+X/min;

    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<stdio.h>
int main(){
	for(;;){
		int a,b,i,p,o=1;
		cin>>a>>b;
		if(a==0&&b==0)
		return 0;
		for(i=1;i<=a;i++){
			for(p=1;p<=b;p++){
				if((i%2)==0&&p==1)
				o=2;
				if((o%2)==0)
				cout<<'.';
				else if((o%2)==1)
				cout<<'#';
				o++;
			}
			o=1;
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

				
				

Measured memory_bytes: 3088
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse =  True)

MOD = 10 ** 9 + 7

if N == 1:
    print (2 * C[0] % MOD)
    exit()

start = pow(2, N - 1, MOD)
step = pow(2, N - 2, MOD)
ans = 0
for c in C:
    ans += c * start
    ans %= MOD
    start += step
    start %= MOD

ans *= pow(2, N, MOD)
ans %= MOD

print (ans)

Measured memory_bytes: 26764
n,m=map(int,input().split())
a=[]
b=[]
ans=False
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m]!=b[k]:
                break
            if k==m-1:
                ans=1
    if ans==1:
        break
print('Yes') if ans==1 else print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int countA = 0,countB = 0;
  for(int i = 0;i < S.size();i++){
    if(i % 2 == 0){
      if(S.at(i) != '0')countA++;
      else countB++;
    }
    if(i % 2 == 1){
      if(S.at(i) != '1')countA++;
      else countB++;
    }
  }
  cout << min(countA,countB) << endl;
}
  

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

void Main()
{
    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<long> sell(n);
    vector<vector<long>> buy(n, vector<long>(2));
    sell[0] = 1000;
    buy[0][0] = 1000 % a[0];
    buy[0][1] = 1000 / a[0];
    for (int i = 1; i < n; i++)
    {
        for (int k = 0; k < i; k++)
        {
            long tmps = max(sell[k], buy[k][1] * a[i] + buy[k][0]);
            if (sell[i] < tmps) sell[i] = tmps;

            long tmpb0 = tmps % a[i];
            long tmpb1 = tmps / a[i];
            if (buy[i][1] < tmpb1 
                || (buy[i][1] == tmpb1 && buy[i][0] < tmpb0)) {
                buy[i][0] = tmpb0;
                buy[i][1] = tmpb1;
            }    
        }
    }
    
    cout << sell[n-1] << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long a[10], c = 1, d, e = 0;
	int b = 0;
	while (c <= 1000000000) {
		a[b] = c;
		b++;
		c *= 8;
	}
	while (cin >> d&&d != 0) {
		e = 0;
		int f = 0;
		for (int i = b-1; i >= 0; i--) {
			f = 0;
			if (a[i] <= d) {
				while (a[i] <= d) {
					f++;
					d -= a[i];
				}
				if (f <= 3)
					e += (pow(10, i)*f);
				else if (f == 5)
					e += (pow(10, i)*(f + 2));
				else if (f < 6)
					e += (pow(10, i)*(f + 1));
				else if(f>=6)
					e += (pow(10, i)*(f + 2));
			}
		}
		cout << e << endl;
	}
}

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

int N, S, T, W[10009], minx;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> W[i]; S += W[i];
	}
	minx = S;
	for (int i = 1; i <= N; i++) {
		T += W[i]; minx = min(minx, abs(T - (S - T)));
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 n, k;
    cin >> n >> k;
    int64 r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    int64 dp[n + 1][3];
    memset(dp, 0, sizeof(dp));
    int64 ans = 0;
    for (int j = 0; j < k; ++ j) {
        int64 cur = 0;
        for (int i = j; i < n; i += k) {
            // rock
            dp[i][0] = ((i - k) >= 0 ? max({dp[i - k][1], dp[i - k][2]}) : 0) + (t[i] == 's' ? r : 0);
            // paper
            dp[i][1] = ((i - k) >= 0 ? max({dp[i - k][0], dp[i - k][2]}) : 0) + (t[i] == 'r' ? p : 0);
            // scissor
            dp[i][2] = ((i - k) >= 0 ? max({dp[i - k][0], dp[i - k][1]}) : 0) + (t[i] == 'p' ? s : 0);
            cur = max({dp[i][0], dp[i][1], dp[i][2]});
        }
        ans += cur;
    }
    cout << ans;
    
}

Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,i;
    string s,st,sk;
    cin>>n;
    cin>>k;
    cin>>s;
        if(s[k-1]>=65 && s[k-1]<=90){
            s[k-1]=s[k-1]+32;
        }
    cout<<s;
    return 0;
}


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

using namespace std;

int main()
{
    const uint64_t mod = 1000000007;
    uint64_t N;
    cin >> N;
    vector<uint64_t> zeros(60, 0);
    vector<uint64_t> ones(60, 0);

    for (uint64_t i = 0; i < N; i++)
    {
        uint64_t val;
        cin >> val;
        for (int i = 0; i < 60; i++)
        {
            if ((val >> i) & (uint64_t)1)
            {
                ones[i]++;
            }
            else
            {
                zeros[i]++;
            }
        }
    }
    uint64_t ans = 0;
    for (int i = 59; i >= 0; i--)
    {
        ans = (ans * 2 + (zeros[i] * ones[i]) % mod) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

ll MOD = 1000000007;



int main()
{
	int N;
	cin >> N;
	vec B(N,10000000);

	for (int i = 0; i < N-1; ++i)
	{
		cin >> B[i];
	}

	int ans = B[0];
	for (int i = 1; i < N; ++i)
	{
		ans += min(B[i], B[i - 1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256