akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define ALL(c) (c).begin(),(c).end()
typedef pair<char,int> P;
vector<P> a,b,c,ans;
void init(vector<P>& vc){
	while(true){
		char ch;
		int l;
		cin >> ch;
		if(ch=='$') break;
		cin >> l;
		vc.push_back(P(ch,l));
	}
}
int main(){
	init(a);
	init(b);
	init(c);
//	assert(a.size()-b.size()<=a.size());
	if(b.size()>a.size()){
		rep(j,a.size()) cout << a[j].first << " " << a[j].second << " ";
		cout << "$" << endl;
		return 0;
	}
	rep(i,(int)(a.size())-b.size()+1){
//		assert(i<a.size());
//		assert(b.size()>0);		//true
		bool able=true;
		rep(j,b.size()){
			if(b[j].first!=a[i+j].first){
				able=false;
				break;
			}
		}
		if(!able) continue;
		if(b[0].second>a[i].second) continue;
		able=true;
		for(int j=1;j<b.size()-1;j++){
			if(b[j].second!=a[i+j].second){
				able=false;
				break;
			}
		}
		if(!able) continue;
		if(b[b.size()-1].second>a[i+b.size()-1].second) continue;
		rep(j,i){
//			assert(j<a.size());			//false
			ans.push_back(a[j]);
//			assert(a[j].second>=0);		//a[j]==0???????????????
		}
		if(b.size()>1 && a[i].second!=b[0].second){
			ans.push_back(P(a[i].first,a[i].second-b[0].second));
//			assert(a[i].second-b[0].second>0);
		}
		rep(j,c.size()){
			ans.push_back(c[j]);
//			assert(c[j].second>0);
		}
		if(a[i+b.size()-1].second!=b[b.size()-1].second){
			ans.push_back(P(a[i+b.size()-1].first,a[i+b.size()-1].second-b[b.size()-1].second));
//			assert(a[i+b.size()-1].second-b[b.size()-1].second>0);
		}
		for(int j=i+b.size();j<a.size();j++) ans.push_back(a[j]);
		rep(j,ans.size()-1){
			if(ans[j].first==ans[j+1].first){
				ans[j].second+=ans[j+1].second;
				ans.erase(ans.begin()+(j+1));
				j--;
			}
		}
		rep(j,ans.size()) cout << ans[j].first << " " << ans[j].second << " ";
		cout << "$" << endl;
		return 0;
	}
	rep(i,a.size()){
//		assert(a[i].second!=0);
		cout << a[i].first << " " << a[i].second << " ";
	}
	cout << "$" << endl;
	return 0;
}

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

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

	if (x == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	int max = 1;
	for (size_t i = 2; i <= x; i++)
	{
		int s = i*i;
		while (s <= x)
		{
			if (s > max)
			{
				max = s;
			}
			s *= i;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main()
{
	int a,b,c,d,e;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	int m,n;
	if (a<b)
		if (a>c) m = c;
		else     m = a;
	else
		if (b>c) m = c;
		else	 m = b;
	if (d<e) n = d;
	else	 n = e;
	int S;
	S = m + n - 50;
	printf("%d\n",S);
}

Measured memory_bytes: 1020
// Author: Mohammad Faisal
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if(s[0]=='2' && s[1]=='0' && s[2]=='1' && s[3]=='7')
  {
	s[3]='8';
  }
  cout<<s<<endl;
  return 0;
}

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


int main()
{
    int N;
    cin >> N;
    vector<int> a(3*N);
    for (int i=0; i<3*N; i++) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<int>());

    int64_t sum = 0;    
    for (int i=0; i<2*N; i++) {

        if (i % 2 == 1) {
            sum += a.at(i);
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d;
    string s1;
    cin>>s1;
    //sort(s1.begin(),s1.end());
    if(s1[0]==s1[1]&&s1[2]==s1[3]&&s1[0]!=s1[2]||s1[0]==s1[2]&&s1[1]==s1[3]&&s1[0]!=s1[1]||s1[0]==s1[3]&&s1[1]==s1[2]&&s1[0]!=s1[1])
    {
        cout<<"Yes"<<endl;
    }
    else{cout<<"No"<<endl;}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18+1;

int main(){
    long long int n, k;
    cin >> n >> k;

    vector<long long int> a(n), f(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> f[i];
    }
    sort(a.begin(),a.end());
    sort(f.begin(),f.end());
    reverse(f.begin(),f.end());

    long long int upper = INF,// upper_bound
                  lower = -1,// lower_bound
                  mid;

    while(upper - lower > 1){
        mid = (upper + lower) / 2;
        //cout << mid << " : ";
        long long int count = 0;
        for(int i=0; i<n; i++){
            count += max(0LL, a[i] - mid / f[i]);
        }
        //cout << count << endl;
        if(count <= k) upper = mid;
        if(count >  k) lower = mid;
    }
    cout << upper << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int len=0;
  int ans=0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)=='A' or S.at(i)=='C' or S.at(i)=='G' or S.at(i)=='T'){
      len++;
      ans=max(ans, len);
    }
    else{
      len=0;
      ans=max(ans, len);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
  ll a,b;
  cin >> a >> b;
  cout  << a * b << endl;
}

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

int main()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<string> S(N);
	vector<vector<int>> sum(N + 1, vector<int>(M + 1)), w(N + 1, vector<int>(M + 1)), h(N + 1, vector<int>(M + 1));
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		for (int j = 0; j < M; j++) {
			sum[i + 1][j + 1] = S[i][j] == '1';
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j < M; j++) {
			w[i][j + 1] = S[i - 1][j - 1] == '1' && S[i - 1][j] == '1';
		}
	}
	for (int j = 1; j < N; j++) {
		for (int i = 1; i <= M; i++) {
			h[j + 1][i] = S[j - 1][i - 1] == '1' && S[j][i - 1] == '1';
		}
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			sum[i][j] += sum[i][j - 1];
		}
	}
	for (int j = 0; j <= M; j++) {
		for (int i = 1; i <= N; i++) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			h[i][j] += h[i][j - 1];
		}
	}
	for (int j = 0; j <= M; j++) {
		for (int i = 1; i <= N; i++) {
			h[i][j] += h[i - 1][j];
		}
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			w[i][j] += w[i][j - 1];
		}
	}
	for (int j = 0; j <= M; j++) {
		for (int i = 1; i <= N; i++) {
			w[i][j] += w[i - 1][j];
		}
	}
	int x1, x2, y1, y2;
	while (Q--) {
		cin >> x1 >> y1 >> x2 >> y2;
		cout << (sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1])
			- (w[x2][y2] - w[x2][y1] - w[x1 - 1][y2] + w[x1 - 1][y1])
			- (h[x2][y2] - h[x2][y1 - 1] - h[x1][y2] + h[x1][y1 - 1]) << endl;
	}
	return 0;
}


Measured memory_bytes: 54144
h, w = map(int, input().split())
s = [0] * h
for _ in range(h):
    s[_] = input()

# print(s)
# print(s[1][1])

ok = True
for hi in range(h):
    for wi in range(w):
        if s[hi][wi] == '#':
            drawable = False
            # check
            if hi >= 1:
                drawable = (s[hi-1][wi] == '#') | drawable
            
            if hi <= h-2:
                drawable = (s[hi+1][wi] == '#') | drawable
            
            if wi >= 1:
                drawable = (s[hi][wi-1] == '#') | drawable
            
            if wi <= w-2:
                drawable = (s[hi][wi+1] == '#') | drawable

            # if hi >= 1:
            #     if s[hi-1][wi] == 

            if not drawable:
                ok = False

print("Yes" if ok else "No")


Measured memory_bytes: 3188
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	if (s[0] != 'A') {
		cout << "WA\n";
		return 0;
	}
	int p = 0;
	map<char, int>m;
	int cnt = 0;
	for (auto i : s) {
		if (i == 'C')p = cnt;
		m[i]++;
		cnt++;
	}
	N = s.size();
	if (p <= 1 || p == N - 1) {
		cout << "WA\n";
		return 0;
	}
	if (m['A'] != 1 || m['C'] != 1) {
		cout << "WA\n";
		return 0;
	}
	for (auto i : m) {
		if (i.first >= 'A'&&i.first <= 'Z'&&i.first != 'A'&&i.first != 'C') {
			cout << "WA\n";
			return 0;
		}
	}
	cout << "AC\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private void rect(){
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNextInt()){
			int h =scanner.nextInt();
			int w =scanner.nextInt();
			if(h==0 && w==0)break;
			
			if(3<=h && h<=300 && 3<=w && w<=300){
				for(int j=0; j<w; j++){ //top
					System.out.printf("#");
				}System.out.println("");
				
				for(int i=1; i<h-1; i++){
					System.out.printf("#"); //right
					for(int j=1; j<w-1; j++){
						System.out.printf(".");
					}System.out.println("#"); //left
				}
				
				for(int j=0; j<w; j++){ //bottom
					System.out.printf("#");
				}System.out.println("");
				System.out.println("");
			}
		}
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.rect();

	}
}

Measured memory_bytes: 40524
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
int n, A[3*MAXN];
ll L[3*MAXN], R[3*MAXN];
int main() {
	scanf("%d", &n);
	priority_queue <int> pq;
	for (int i = 1; i <= 3 * n; i++) scanf("%d", &A[i]);
	for (int i = 1; i <= n; i++) L[n] += A[i], pq.push(-A[i]);
	for (int i = n + 1; i <= 2 * n; i++) {
		int x = -pq.top();
		if (A[i] - x > 0) {
			L[i] = L[i - 1] + A[i] - x;
			pq.pop();
			pq.push(-A[i]);
		}
		else L[i] = L[i - 1];
	}
	priority_queue <int> pq2;
	for (int i = 3 * n; i >= 2 * n + 1; i--) R[2 * n + 1] += A[i], pq2.push(A[i]);
	for (int i = 2 * n; i >= n + 1; i--) {
		int x = pq2.top();
		if (A[i] - x < 0) {
			R[i] = R[i + 1] + A[i] - x;
			pq2.pop();
			pq2.push(A[i]);
		}
		else R[i] = R[i + 1];
	}
	ll ans = -1e18;
	for (int i = n; i <= 2 * n; i++) {
		ans = max(ans, L[i] - R[i + 1]);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 5112
import java.util.Scanner;

public class Main {
	int[] min = new int[2];
	
	void run() {
		// 入力
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[200000];
		for(int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
		}
		int max = -1000000000;	
		searchMinimun(array, n-1);
		for(int i = n-1; i > 0; i--) {
			if(min[1] == i) searchMinimun(array, i-1);
			int tmp = array[i] - min[0];
			if(tmp > max) max = tmp;
		}
		System.out.println(max);
	}
	
	void searchMinimun(int[] array, int n) {
		min[0] = array[0];
		min[1] = 0;
		for(int i = 1; i <= n; i++) {
			if(min[0] > array[i]) {
				min[0] = array[i];
				min[1] = i;
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 101284
n=int(input())
s=input()
w=0
r=0
for i in s:
    if i=='W':
        w+=1
    else:
        r+=1
if r==0 or w==0:
    print(0)
else:
    t='R'*r
    t=t+'W'*w
    #print(t)
    ans=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans+=1
    ans=ans//2
    print(ans)

Measured memory_bytes: 9596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;

int main()
{
	int v[100];
	int c[100];
	int N;
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> v[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> c[i];
	}
	for (int i = 0; i < N; i++)
	{
		if (v[i] - c[i] > 0)
		{
			ans += v[i] - c[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
///
// File:  alds1_7_b.cpp
// Author: ymiyamoto
//
// Created on Sat Oct 14 16:06:54 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define NIL -1
#define SIZE 100

struct tree_t {
  int32_t right;
  int32_t left;
  int32_t parent;

  tree_t()
  {
    parent = NIL;
  }
};

static tree_t tree[SIZE];

int32_t sibling(int32_t index)
{
  if (tree[index].parent == NIL) {
    return NIL;
  }

  int32_t parent = tree[index].parent;
  if (tree[parent].left != index) {
    return tree[parent].left;
  } else {
    return tree[parent].right;
  }
}

int32_t degree(int32_t index)
{
  return (tree[index].left != NIL) + (tree[index].right != NIL);
}

int32_t depth(int32_t index)
{
  int32_t parent = tree[index].parent;
  int32_t count = 0;
  while (parent != NIL) {
    count++;
    parent = tree[parent].parent;
  }

  return count;
}

int32_t height(int32_t index)
{
  if (index == NIL || (tree[index].left == NIL && tree[index].right == NIL)) {
    return 0;
  } else {
    return 1 + max(height(tree[index].left), height(tree[index].right));
  }
}

string name(int32_t index)
{
  if (tree[index].parent == NIL) {
    return "root";
  } else if (tree[index].left != NIL || tree[index].right != NIL) {
    return "internal node";
  } else {
    return "leaf";
  }
}

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

  for (int32_t i = 0; i < n; i++) {
    int32_t id, left, right;
    cin >> id >> left >> right;
    tree[id].left = left;
    tree[id].right = right;
    tree[left].parent = id;
    tree[right].parent = id;
  }

  for (int32_t i = 0; i < n; i++) {
    cout << "node " << i << ": parent = " << tree[i].parent << ", ";
    cout << "sibling = " << sibling(i) << ", degree = " << degree(i) << ", ";
    cout << "depth = " << depth(i) << ", height = " << height(i) << ", ";
    cout << name(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 3192
package main

import (
	"math"
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	sc = bufio.NewScanner(os.Stdin)
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

//ソートする
//sは最初のインデックス fは最後のインデックス
func Sort(ls []int,l int,r int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if ls[j] < ls[r]{
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort(ls,l,i-1)
	Sort(ls,i+1,r)
}

//配列の大小を指定した要素で比較
//a < bならtrue
func sizeCheck(a []int,b []int,ls []int) bool {
	for _,i:= range ls{
		if a[i] < b[i]{
			return true
		} else if a[i] > b[i] {
			return false
		}
	}
	return false
}

//二次元配列のソート
func Sort2D(ls [][]int,l int,r int,index ...int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if sizeCheck(ls[j],ls[r],index){
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort2D(ls,l,i-1,index ...)
	Sort2D(ls,i+1,r,index ...)
}

func main() {
	n := goint()
	edges := 0
	kari := math.Log2(float64(n))
	if kari > float64(int(kari)){
		edges = int(kari) + 1
	} else {
		edges = int(kari)
	}
	ls := make([][]int,n)
	for i:=0;i<n;i++{
		ls[i] = make([]int,edges)
		for j := 0;j<edges;j++{
			ls[i][j] = int(uint(i) & (uint(1) << uint(j)))
		}
	}
	for i:=0;i<n-1;i++{
		e := posi(ls[i],ls[i+1])
		fmt.Print(e + 1)
		for j:=i+2;j<n;j++{
			e = posi(ls[i],ls[j])
			fmt.Print(" ",e + 1)
		}
		fmt.Print("\n")
	}
}

func posi(a,b []int) int {
	for i:=0;i<len(a);i++{
		if a[i] != b[i]{
			return i
		}
	}
	return -1
}

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

Measured memory_bytes: 3968
n, y = map(int, input().split())
answer_a = -1
answer_b = -1
answer_c = -1

# 10000をa枚、5000をb枚、1000をc枚
for a in range(0, n+1):
  for b in range(0, n-a+1):
    c = n-a-b
    if 10000*a+5000*b+1000*c == y and c>=0:
      answer_a = a
      answer_b = b
      answer_c = c
print("{} {} {}".format(answer_a,answer_b,answer_c))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int n;
	cin >> n;
	vector<vector<int>>v(n-1,vector<int>(3,0));
	rep(i, 0, n - 1) {
		cin >> v[i][0] >> v[i][1] >> v[i][2];
	}


	rep(i,0,n){
		int sum=0;
		rep(j, i, n-1) {
			if (sum <= v[j][1]) {
				sum += v[j][1] - sum;
			}else if((sum-v[j][1])%v[j][2] != 0){
				sum += v[j][2] - (sum-v[j][1]) % v[j][2];
			}
			sum += v[j][0];
		}
		cout << sum << endl;
	}
	return 0;

}

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

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		if (i % 2 == 0) continue;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				cnt ++;
			}
		}
		if (cnt == 8) {
			ans ++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    string s = to_string(N);
    int ans = 0;
    rep(i,3){
        if(s.at(i) == '7'){
            ans++;
        }
    }
    if(ans > 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}    


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int main()
{
	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if(u == s) printf("%d %d\n", a-1, b);
	else if(u == t) printf("%d %d\n", a, b-1);	
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for(ll i=n-1;i>=a;i--)
#define nl "\n"
#define LLMAX 1e18
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fastread cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

const ll MOD=1e9+7;

int main(){
  fastread;

  ll n,m,q,k,temp,x,ct=0,res=0;

  cin >> n >> k;

  vector<ll> a;
  rep(i,0,n){
    cin >> temp;
    a.pb(temp);
  }

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

  // rep(i,0,n)
  //   cout << a[i] << " ";
  // cout << nl;

  ll dp[k+1];
  fill(dp,dp+k+1,0);

  dp[0]=0;
  rep(i,1,a[0])
    dp[i]=0;
  dp[a[0]]=1;
  rep(i,a[0]+1,k+1){
    rep(j,0,n){
      if(a[j]<=i && dp[i-a[j]]==0){
        dp[i]=1;
        break;
      }
    }
  }

  // rep(i,0,k+1)
  //   cout << dp[i] << " ";
  // cout << nl;
  (dp[k]==1)?cout << "First":cout << "Second";
  cout << nl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  memset(a,1000000,sizeof(a));
  for(int i=0;i<n-1;i++){
     int y;
     cin>>y;
     a[i]=min(a[i],y);
     a[i+1]=min(a[i+1],y);
  }
  int ans=0;
  for(int i=0;i<n;i++) ans+=a[i];
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256
x = input()
point1 = 0
for i in range(len(x)):
    if i % 2 == 0 and x[i] == '0':
        point1 += 1
    elif i % 2 == 1 and x[i] == '1':
        point1 += 1

point2 = 0
for i in range(len(x)):
    if i % 2 == 0 and x[i] == '1':
        point2 += 1
    elif i % 2 == 1 and x[i] == '0':
        point2 += 1

print(min(point1,point2))


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>

using namespace std;
int main() {
	int a, b;
	cin >> a;
	cin >> b;
	if (a == b)cout << "Draw" << endl;
	if (a > b) {
		if (b == 1) {
			cout << "Bob" << endl;
		}
		else {
			cout << "Alice" << endl;
		}
	}
	if (a < b) {
		if (a == 1) {
			cout << "Alice" << endl;
		}
		else {
			cout << "Bob" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

[n,p] = [int(i) for i in input().split()]
ls = factorization(p)
ans = 1
for kumi in ls:
    if kumi[1] >= n:
        ans *= (kumi[0] ** (kumi[1] // n))
print(ans)


Measured memory_bytes: 62980
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    cout << x*y/__gcd(x,y) << endl;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    const double PI = 3.14159265358979323846;
    cin.tie(0);
    ios::sync_with_stdio(false);

    long double n,ans;
    cin >> n;

    ans = n * 2 * PI;
    cout << std::setprecision(10) << ans << "\n";

    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
 
#define int long long
#define MOD 1000000007
 
using namespace std;
 
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
  
void solve() {
    int l, r, d;
    cin >> l >> r >> d;
    int count = 0;
    for(int i = l; i <= r; i++) {
        if(i % d == 0) {
            count++;
        }
    }
    cout << count << endl;
}
 
int32_t main() {
    int t;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    // cin >> t;
    // while(t--) {
    //     solve();
    // }
    return 0;
}

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

int main(void) {
	int N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.length(); i++) {
		char c = ((int)S[i] + N) % (int)'A' % 26 + (int)'A';
		cout << c;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
	int n,k,ans=0;
	scanf("%d %d",&n,&k);
	for(int i=1; i<=n; i++) {
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=n; i>=n-k+1; i--) {
		ans+=a[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


class B {
	int N;

public:
	void solve()
	{
		cin >> N;

		int ans{ 1 };

		for (; ans <= N; ans <<= 1);

		cout << ans / 2 << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

int N, x;
const int MAX_N = 1.0e5 + 100;
int a[MAX_N];

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

    ll ans = 0;
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }

    for (int i = 0; i < N-1; i++) {
        if (a[i] + a[i+1] > x) {
            ans += a[i+1] - x + a[i];
            a[i+1] = x - a[i];
        }
    }

    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 640
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))

def hantei(c):
    tmp = 0
    for i in range(n):
        if af[i] > c:
            a1 = c // f[i]
            tmp += a[i]- a1
    if tmp <= k:
        return True
    else:
        return False

hq = []

a.sort()
f.sort(reverse = True)

af = []
for i in range(n):
    af.append(a[i] * f[i])

l = 0
r = 10**12+10

while r - l > 1:
    c = (l + r) // 2
    if hantei(c):
        r = c
    else:
        l = c

if hantei(l):
    print(l)
else:
    print(r)


Measured memory_bytes: 121728
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    int x, n, y;
    string s;
    cin >> n >> x >> y;
    map<int, int> cnt;
    for (int i = 1; i < n; i++) {
        int dis = 0;
        for (int j = i + 1; j <= n; j++) {
            dis = min(j - i, abs(x - i) + 1 + abs(y - j));
            cnt[dis]++;
            //cout << i << " " << dis << " " << j << endl;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long ll;
     
    ll MOD = 1000000007;
     
    bool check(int n, bitset<16> people, vector<vector<int>> s) {
    	for (int i=0; i<n; i++) {
    		int now = people[i];
            if (now==0) continue;
    		for (int j=0; j<n; j++) {
    			int op = people[j];
    			if (s[i][j]==-1) continue;
    			else if (s[i][j] == op) continue;
    			else return false;
    		}
    	}
    	return true;
    }
     
    int main(int, char**) {
    	int n; cin >> n;
    	vector<vector<int>> s(n, vector<int>(n, -1));
    	for (int i=0; i<n; i++) {
    		int a; cin >> a;
    		for (int j=0; j<a; j++) {
    			int x, y;
    			cin >> x >> y;
    			x--;
    			s[i][x] = y;
    		}
    	}
     
    	int ret = 0;
    	for (int bit=0; bit < (1<<n); ++bit){
    		bitset<16> people = bitset<16>(bit);
    		int cnt = people.count();
    		if (ret > cnt) continue;
    		if (check(n, people, s)) ret = max(cnt, ret);
    	}
    	cout << ret << endl;
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
typedef long double ld;
int k,n,a,b,c,ans,MAX,x,y,tmp;
string s;
vector<vector<int>>d(n,vector<int>(n));
signed main(){
cin >>a>>b>>c;
 tmp=a;
 a=b;
 b=tmp;
tmp=a;
  a=c;
  c=tmp;
cout << a << " " << b << " " << c;
 }

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

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

   int N; cin>>N;
   map<string,int> mp;
   for(int i=0;i<N;i++){
      string s; cin>>s;
      mp[s]++;
   }

   int mx=0;
   for(auto I:mp) mx=max(mx,I.second);
   for(auto I:mp) if(I.second==mx) cout<<I.first<<endl;
   return 0;
}


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

const int maxn = 2e5+5;
int h[maxn],n;
long long ans=0;
map<int,int> s;

int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> h[i];	
		s[i-h[i]]++;	
	}
	for (int i=1;i<=n;i++){
		if (s.find(i+h[i])==s.end()) continue;
		ans += s[i+h[i]]; 
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 13004
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    int N,K,R,S,P;cin>>N>>K>>R>>S>>P;
    string T;cin>>T;
    string t = T.substr(0,K);
    ll ans = 0;
    for(int i=0;i<K;i++){
        if(T[i]=='r'){
            ans += P;
            t[i] = 'p';
        }
        else if(T[i]=='s'){
            ans += R;
            t[i] = 'r';
        }
        else{
            ans += S;
            t[i] = 's';
        }
    }
    int cnt = 0;
    for(int i=K;i<N;i++){
        if(cnt == K){
            cnt = 0;
        }
        if(T[i]=='r'){
            if(t[cnt]!='p'){
                ans += P;
                t[cnt] = 'p';
            }else{
                t[cnt] = '?';
            }
        }
        else if(T[i]=='s'){
            if(t[cnt]!='r'){
                ans += R;
                t[cnt] = 'r';
            }else{
                t[cnt] = '?';
            }
        }
        else{
            if(t[cnt]!='s'){
                ans += S;
                t[cnt] = 's';
            }else{
                t[cnt] = '?';
            }
        }        
        cnt++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int c(char l){
        return l - '0';
}

int main(){
        string s;
        cin >> s;

        int m;

        m = c(s[5])*10 + c(s[6]);


        if (m >= 5)
                cout << "TBD" << endl;
        else
                cout << "Heisei" << endl;

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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(){
    ll n,m;cin >> n >>m;
    vpl v(m);
    rep(i,m){
        cin >> v[i].se >> v[i].fi;
        v[i].se--;v[i].fi--;
    }
    sort(all(v));
    ll ans=0;ll right=-inf;
    rep(i,m){
        if(right<=v[i].se){
            ans++;
            right=v[i].fi;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 1792
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long res = LongStream.rangeClosed(1, N).filter(
                p->{
                    return !((p % 3 == 0) || (p%5 == 0));
                }
        ).sum();
        System.out.println(res);
    }

}


Measured memory_bytes: 36100
#include<bits/stdc++.h>
using namespace std;
int TOP=10;
int a[5100][5100];
long long val[5100];
int dis[5100];
int n;
int m;
long long ans;
struct KT
{
    int st[5100];
	int which;
	int top;
    void PJ(int x)
	{	
		which=x;
	}
    void XN(int x)
	{
        while(top&&a[st[top]][which]<=a[x][which])
		{
            val[st[top]]-=a[st[top]][which];
            if(top>1)
            val[st[top-1]]+=a[st[top]][which];
            --top;
        }
        st[++top]=x;
        val[st[top]]+=a[st[top]][which];
        if (top>1)
        val[st[top-1]]-=a[st[top]][which];
    }
}St[5100];
int main()
{
    long long sum;
    cin>>n>>m;
    for(int i=1;i<n;i++) 
	scanf("%d",dis+i);
    memset(val,0,sizeof(val));
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		cin>>a[i][j];
    	}
    }
    for(int i=1;i<=m;i++) 
	St[i].PJ(i);
    for(int l=n;l>=1;--l)
	{
        for(int i=1;i<=m;i++)
        St[i].XN(l);
        sum=0;
        for(int r=l;r<=n;r++)
		{
            sum+=val[r];
            ans=max(ans,sum);
            sum-=dis[r];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 105088
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const ull INF3 = 18446744073709551600LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

bool dpx[8010][32010], dpy[8010][32010];
std::string s;
int x, y;

int main() {
	std::cin >> s >> x >> y;
	int i = 0, j = 0, k = 0;
	x += 16000, y += 16000;
	dpy[0][16000] = true;
	int b = 0;
	for (;i < s.size();i++) {
		if (s[i] == 'T')break;
		b++;
	}
	i++, flag = false;
	dpx[j][16000 + b] = true;
	while (i < s.size()) {
		int sum = 0;
		for (;i < s.size();i++) {
			if (s[i] == 'T') {
				break;
			}
			else sum++;
		}
		if (flag) {
			j++;
			for (int l = 8000;l <= 24000;l++) {
				if (dpx[j - 1][l - sum])dpx[j][l] = true;
				else if (dpx[j - 1][l + sum])dpx[j][l] = true;
				else dpx[j][l] = false;
			}
		flag = false;
	}
		else {
			k++;
			for (int l = 8000;l <= 24000;l++) {
				if (dpy[k - 1][l - sum])dpy[k][l] = true;
				else if (dpy[k - 1][l + sum])dpy[k][l] = true;
				else dpy[k][l] = false;
			}
			flag = true;
		}
		i++;
	}
	if (dpx[j][x] && dpy[k][y])std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll l, r;

int main() {
    cin >> l >> r;
    if (r - l >= 2018) {
        cout << 0 << endl;
        exit(0);
    }
    l %= 2019;
    r %= 2019;
    if (l > r) {
        cout << 0 << endl;
        exit(0);
    }
    int res = 3000;
    for (int i = l; i < r; ++i) {
        for (int j = i + 1; j <= r; ++j) {
            res = min(res, i * j % 2019);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    int s = 0;
    int temp = n;
    while (temp)
    {
        s += temp % 10;
        temp /= 10;
    }

    cout << (n % s == 0 ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7


int main(){
    string s;
    cin >> s;
    bool ans = false;
    for(int i = 0; i < 3; ++i){
        if(s[i] == '7'){
            ans = true;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 3624
/*
  Great problem to learn bitmasking techniques and learn DP with Bitmasks.

  User:- sanyam
*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)
#define base(i,val) memset(i, val, sizeof(val))
#define all(x) (x).begin(), (x).end()

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}


/* ---------------------Code--------------------  */
ll a[20][20];
ll visited_all;
ll dp[1<<16];
ll subset_score[1<<16];

void findSums(ll visited_all) {
  for(int subset = visited_all; subset!=0; subset=((subset-1)&visited_all)){
    bitset<17> b(subset);
    subset_score[subset]=0;
    for(int i=0; i<16; i++) {
      if(b[i]==1)
        for(int j=i+1; j<16; j++) 
          if(b[j]==1)
            subset_score[subset] += a[i][j];
    }
  }
  return;
}

ll solve_by_bitmasking_dp(ll curr_mask) {
  if(curr_mask==0){
    return 0;
  }
  else if(dp[curr_mask]!=-1)
    return dp[curr_mask];
  else{
    ll ans = 0;
    for(ll subset_mask = curr_mask; subset_mask!=0; subset_mask=((subset_mask-1)&curr_mask)) {
      ll remaining_rabbits = (curr_mask - (curr_mask&subset_mask));
      ans = max(ans, subset_score[subset_mask] + solve_by_bitmasking_dp(remaining_rabbits));
    }
    return dp[curr_mask] = ans;
  }
}

void solve() {
  ll n; cin>>n;
  visited_all = ((1<<n)-1);
  
  loop(i, 0, n){
    loop(j, 0, n){
      cin>>a[i][j];
    }
  }
  memset(dp, -1, sizeof dp);

  findSums(visited_all);

  // for(int i=0; i<=((1<<n)-1); i++) {
  //   cout<<subset_score[i]<<endl;
  // }

  cout<<solve_by_bitmasking_dp(visited_all)<<endl;
}

int main(){

  fastIO;
  //take_fileIO();
  solve();
  return 0;
}

Measured memory_bytes: 1280
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1e9+7
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

template<class T> void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
template<class T> void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}

template<class T> void read(T& a) {
    std::cin>>a;
}

template<class T> void read(T& a, T& b) {
    std::cin>>a>>b;
}
template<class T> void read(T& a,T& b, T& c) {
    std::cin>>a>>b>>c;
}

template<class T> void read(T& ara, int sidx,  int eidx) {
    for(int i=sidx; i<eidx; i++)
        std::cin>>ara[i];
}




using namespace std;
using namespace __gnu_pbds;

const int maxn=500;
const int inf = INT_MAX;


void solve()
{
	ll n;
	cin>>n;
    vector<ll>v(n),pr(n);
    
    for(int i=0;i<n;i++) cin>>v[i];
    
    pr[n-1]=v[n-1];
    ll mod=1e9+7;
    for(int i=n-2;i>=0;i--)
    {
		pr[i]=v[i]+pr[i+1];
		pr[i]%=mod;
	}
	
	ll ans=0;
	for(int i=0;i<n-1;i++)
	{
		ans+=(v[i]*pr[i+1])%mod;
		ans%=mod;
	}
	
	cout<<ans<<endl;
	
}



int main()
{
	fast_cin;
	//case
	{
		solve();
		
	}
   
    return 0;
}


Measured memory_bytes: 6304
//Use queue
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int n, D, A;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> D >> A;
    vector<ll> delta(n + 1);
    vector<ii> a(n);
    for (int i = 0; i < n; i++) cin >> a[i].fir >> a[i].sec;
    sort(all(a));
    ll ans = 0;
    int rig = 0;
    D *= 2;
    for (int i = 0; i < n; i++){
        while (rig < n && a[rig].fir <= a[i].fir + D) rig++;
        //cout << i << ' ' << rig << ' ';
        if (i) delta[i] += delta[i - 1];
        ll h = a[i].sec - delta[i];
        //cout << sum << '\n';
        if (h <= 0) continue;
        ll need = (h + A - 1)/A;
        ans += need;
        delta[i] += need*(ll)(A);
        delta[rig] -= need*(ll)(A);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int si = S.size();
    //cout << si << endl;
    int N = atoi(S.c_str());
    //cout << N << endl;
    int nn = N;
    int num[si];
    for(int i = si - 1; i >=0 ; i--)
    {
        int x = nn / pow(10, i);
        num[i] = x;
        //cout << num[i] << endl;
        nn -= x * pow(10,i);
    }
    int sum = 0;
    for(int i = si - 1; i >=0 ; i--)
    {
        sum += num[i];
    }
    int r = N % sum;
    //cout << sum << " " <<r << endl;
    if (r == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  string s;cin>>s;
  int ans=s.size();
  rep(i,2){
    int cnt=0;
    rep(j,s.size()){
      if(j%2==0&&s[j]!=(char)(i+'0'))cnt++;
      if(j%2==1&&s[j]==(char)(i+'0'))cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3744