akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define FALSE 0
#define TRUE 1
int solve(int , int);

int n, A[2000];

int main(){
  int q, M[2000], i=0;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);

for(i=0; i<q; i++){
  scanf("%d", &M[i]);
}

for(i=0; i<q; i++){
//scanf("%d", &M);
    if(solve(0, M[i])==TRUE) printf("yes\n");
    else printf("no\n");
  }
  return 0;

}

int solve(int i, int m){
  int res = 0;

  if(m==0) return TRUE;
  if(i>=n) return FALSE;

res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;

}

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

int main() {
	string s1,s2;
	cin >> s1 >> s2;
	if((s1[0]==s2[2])&&(s1[1]==s2[1])&&(s1[2]==s2[0]))
		cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main() {
	long long int a = 0;
	long long int b = 100;
	int c = 0;
	scanf("%lld", &a);
	for (int i = 1; i <= 3760; i++) {
		b = b * 1.01 / 1;
		if (b >= a) {
			c = i;
			break;


		}
	}
		printf("%d", c);
		return 0;
}

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

int main() {
	int n;
  cin >> n;
  set<string> ss;
  for (int i = 0; i < n; ++i) {
  	string s;
    cin >> s;
    ss.insert(s);
  }
  cout << ss.size() << endl;
}

Measured memory_bytes: 19040
#include <stdio.h>

void selectionSort(int[],int);

int main()
{
  int i,N,A[100];

  scanf("%d",&N);
  for(i = 0;i < N;i++)
    {
      scanf("%d",&A[i]);
    }
  selectionSort(A,N);
  return 0;
}
void selectionSort(int A[],int N)
{
  int a,i,j,minj,count = 0;
  for(i = 0;i <= N-1;i++)
    {
      minj = i;
      for(j = i;j <= N-1;j++)
	{
	  if(A[j] < A[minj])
	    {
	      minj = j;
	    }
	}
      a = A[i];
	      A[i] = A[minj];
	      A[minj] = a;
	      if(i != minj) count++;
    }
  for(i = 0;i < N;i++)
    {
      if(i > 0) printf(" ");
      printf("%d",A[i]);
    }
  printf("\n%d\n",count);
  
}



Measured memory_bytes: 2108
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int cnt = sc.nextInt();
        while(cnt > 0 && a >= b){
            b *= 2;
            cnt--;
        }
        while(cnt > 0 && b >= c){
            c *= 2;
            cnt--;
        }
        pw.println(a < b && b < c ? "Yes" : "No");
        pw.flush();
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll a;
  cin >> a;
  cout <<( 1000-(a%1000))%1000 << "\n";
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,a[100000]={},ans=0;
  int u=0,d=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n-1; i++) {
    if(a[i]==a[i+1]) {
      continue;
    }
    else if(a[i]<a[i+1]) {
      u=1;
    }
    else {
      d=1;
    }
    if(u&&d) {
      ans++;
      u=0,d=0;
    }
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <atcoder/dsu>
 
using namespace std;
using namespace atcoder;
 
int main(){
  int n, m, a, b;
  cin >> n >> m;
  
  dsu d(n);
  
  for(int i = 0; i < m; ++i){
    cin >> a >> b;
    d.merge(a - 1, b - 1);
  }
  
  unsigned count = d.groups().size();
  
  cout << count - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 8992
n,t=[int(x) for x in input().split()]
w=[]
for i in range(n):
    w.append(int(input()))

totalw=sum(w)  
pmax=totalw
pmin=int(totalw/t)-1

def check(ptest):
    tk=1
    p=0
    global t
    global w
    global n
    i=0
    
    while i<n:
        p+=w[i]
        if p<=ptest:
            i+=1
        else:
            tk+=1
            p=0
            
        if tk>t:
            return 0
            #break   
    
    return 1
    
        
while (pmax-pmin)>1:
    pmid=(pmax+pmin)//2
    if check(pmid)==1:
        pmax=pmid
    else:
        pmin=pmid
        
print(pmax)


Measured memory_bytes: 9564
#include <stdio.h>

int main(void)
{
    char b, A, C, T, G;
    scanf("%c",&b);

    if(b=='A'){
        printf("%c",'T');
    }else if(b=='T'){
        printf("%c",'A');
    }else if(b=='C'){
        printf("%c",'G');
    }else if(b=='G'){
        printf("%c",'C');
    }
    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<vector<int64_t>> vec(N,vector<int64_t>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec[i][j];
    }
  }
  
  //位置midにK本以上の花があるか？
  int64_t ok = pow(2,62)-1;
  int64_t ng = 0;
  while(ok - ng > 1){
    int64_t cnt = 0;
    int64_t mid = (ok+ng)/2;
    for(int i=0; i<N; i++){
      int64_t pos = vec[i][0];
      pos = mid - pos;
      if(pos < 0){
        continue;
      }
      else{
        cnt += (pos / vec[i][1]) + 1;
        if(cnt >= K){
          break;
        }
      }
    }
    if(cnt >= K){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 8812
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;
const long long maxMod = 1000000007;

int H, W;
int world[1001 * 1001];
long long table[1001 * 1001];

void setWorld(int x, int y, char a) {
  if(a == '.') world[y * 1000 + x] = 1;
  else world[y * 1000 + x] = 0;
};

int getNum(int x,int y) {
  if(x < 0 || y < 0 || x >= 1000 || y >= 1000 || world[y*1000+x] == 0) return 0;
  return table[y * 1000 + x];
};

void setNum(int x,int y) {
  table[y * 1000 + x] = (getNum(x, y-1) + getNum(x-1, y)) % maxMod; 
};

int main() {
  for (int i=0;i<1001*1001;i++) {
    world[i] = 0;
    table[i] = 0;
  }
  cin >> H >> W;
  for (int y=0;y<H;y++) {
    for (int x=0;x<W;x++) {
      char a;
      cin >> a;
      setWorld(x, y, a);
    }
  }
  table[0] = 1;

  for (int a=0;a<H;a++) {
    for(int b=0;b<W;b++) {
      if(a+b == 0) continue;
      setNum(b, a);
    }
  }
  cout << getNum(W-1, H-1) << endl;
};


Measured memory_bytes: 15340
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() > k) s = s.substr(0, k) + "...";

    cout << s << endl;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int& l : L)
        cin >> l;

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int a = L[i];
        for (int j = i + 1; j < N; ++j) {
            int b = L[j];

            auto ub = lower_bound(L.begin() + j + 1, L.end(), a + b);
            auto lb = upper_bound(L.begin() + j + 1, L.end(),
                                  max(a - b, b - a));

            ans += ub - lb;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
# coding=utf-8


def insertionSort(A, N):
    print ' '.join(map(str, A))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print ' '.join(map(str, A))
    return A


n = int(raw_input().rstrip())
a = map(int, raw_input().rstrip().split())
insertionSort(a, n)

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main()
{
	int n,total=0;
	cin>>n;
	long long a[n],b[n];
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  cin>>b[i];
	long long c[n];
	for (int i=1;i<=n;i++)  c[i]=a[i]-b[i];
	for (int i=1;i<=n;i++)
	{
		if (c[i]>0)  total+=c[i];
	}
	cout<<total<<endl;
	return 0;
}

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

string S;
int A,B;

int main(){
	cin>>A>>B;
	if(1<=A && A<=9){
		if(1<=B && B<=9){
			cout<<A*B<<endl;
		}
		else
			cout<<-1<<endl;
	}
	else
		cout<<-1<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
km=[list(map(int, input().split())) for _ in range(m)]
p=list(map(int, input().split()))
e=0
for i in range(2 ** n):
    b=0
    d=0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            b+= 10**j # フラグが立っていたら bag に果物を詰める
    if 1==1:
        b="0"*(n-len(str(b)))+str(b)
    for j in range(m):
        c=0
        for k in range(1,km[j][0]+1):
            b=str(b)


            f=int(b[(km[j][k]-1)])

            c+=f
        if c%2!=p[j]:
            break
        else:
            d+=1
    if d==m:
        e+=1
print(e)


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
using namespace std;

int main() {
  int n;
  cin >> n;
  set<string> S;
  REP(i, n) {
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
  return 0;
}


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

ll roop(ll e,vector<ll> x,ll k){
  if(e==1){
    if(x.at(0)<=0){
      return x.at(0);
    }else{
      return x.at(0)*k;
    }
  }
  ll s=0,i,j;
  for(i=0;i<e;i++){
    s += x.at(i);
  }
  if(e>k){
    ll m,mm,mmm=-1000000000000000;
    for(i=0;i<e;i++){
      m=x.at(i);
      mm=m;
      for(j=(i+1)%e;j!=(i+k)%e;j=(j+1)%e){
        m += x.at(j);
        mm=max(m,mm);
      }
      mmm=max(mmm,mm);
    }
    return mmm;
  }else{
    ll m,mm,mmm=-1000000000000000;
    for(i=0;i<e;i++){
      m=x.at(i);
      mm=m;
      for(j=(i+1)%e;j!=(i+e-1)%e;j=(j+1)%e){
        m += x.at(j);
        mm=max(m,mm);
      }
      mmm=max(mmm,mm);
    }
    ll m2,mm2,mmm2=-1000000000000000;
    for(i=0;i<e;i++){
      m2=x.at(i);
      mm2=m2;
      for(j=(i+1)%e;j!=(i+k)%e;j=(j+1)%e){
        m2 += x.at(j);
        mm2=max(m2,mm2);
      }
      mmm2=max(mmm2,mm2);
    }
    if(s<=0){
      return mmm;
    }else if(k%e==0){
      return max(s*(k/e),s*(k/e-1)+mmm);
    }else{
      return max(s*(k/e)+mmm2,s*(k/e-1)+mmm);
    }
  }
}

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n),c(n),checked(n,0),a(0),dflt(0);
  for(ll i=0;i<n;i++){
    cin >> p.at(i);
    p.at(i)--;
  }
  for(ll i=0;i<n;i++){
    cin >> c.at(i);
  }
  
  ll t,mv=-1000000000000000;
  for(ll i=0;i<n;i++){
    if(checked.at(i)==0){
      checked.at(i)=1;
      t=p.at(i);
      a=dflt;
      a.push_back(c.at(i));
      while(t!=i){
        a.push_back(c.at(t));
        checked.at(t)=1;
        t=p.at(t);
      }
      mv=max(mv,roop(a.size(),a,k));
    }
  }
  cout << mv << endl;
}

Measured memory_bytes: 3824
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let h: usize = iterator.next().unwrap().parse().unwrap();
    let w: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let mut bomb: HashSet<(usize, usize)> = HashSet::new();
    let mut row: Vec<usize> = vec![0; h];
    let mut col: Vec<usize> = vec![0; w];
    for _ in 0..m {
        let hi = iterator.next().unwrap().parse::<usize>().unwrap() - 1;
        let wi = iterator.next().unwrap().parse::<usize>().unwrap() - 1;
        row[hi] += 1;
        col[wi] += 1;
        bomb.insert((hi, wi));
    }

    let mut max_row = 0;
    // let mut max_row_index = 0;
    let mut max_row_indexes = Vec::new();
    for i in 0..h {
        if row[i] > max_row {
            max_row = row[i];
            // max_row_index = i;
            max_row_indexes = vec![i];
        } else if row[i] == max_row {
            max_row_indexes.push(i);
        }
    }

    let mut max_col = 0;
    // let mut max_col_index = 0;
    let mut max_col_indexes = Vec::new();
    for i in 0..w {
        if col[i] > max_col {
            max_col = col[i];
            // max_col_index = i;
            max_col_indexes = vec![i];
        } else if col[i] == max_col {
            max_col_indexes.push(i);
        }
        // } else if col[i] == max_col
        //     && bomb.contains(&(max_row_index, max_col_index))
        //     && !bomb.contains(&(max_row_index, i)) {
        //     max_col = col[i];
        //     max_col_index = i;
        // }
    }

    let mut is_happy = false;
    let mut count: usize = 0;
    for &ri in &max_row_indexes {
        for &ci in &max_col_indexes {
            if !bomb.contains(&(ri, ci)) {
                is_happy = true;
                break;
            }
            count += 1;
            if count > 100000000 {
                break;
            }
        }
    }

    let mut ans = max_row + max_col;
    if !is_happy {
        ans -= 1;
    }
    ans.to_string()
}


Measured memory_bytes: 24032
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;

#define L 1000003


string A[L];

int num(char s){
  if(s=='A') return 1;
  else if(s=='C') return 2;
  else if(s=='G') return 3;
  else if(s=='T') return 4;
}

long long key(string s){
  long long sum=0;
  int k=1;
  for(int i=0;i<strlen(&s[0]);i++){
    sum+=num(s[i])*k;
    k*=5;
  }
  return sum;
}

int hash1(int x){
  return x%L;
}

int hash2(int x){
  return 1+x%(L-1);
}

void insert(string s){
  long long k=key(s);
  int h1,h2;
  h1=hash1(k); h2=hash2(k);
  for(int i=0;;i++){
    int h=(h1+i*h2)%L;
    if(A[h][0]=='\0'){ 
      A[h]=s; break;
    }
    else if(A[h]==s) break;
  }
}

void find(string s){
  long long k=key(s);
  int h1,h2;
  h1=hash1(k); h2=hash2(k);
  for(int i=0;;i++){
    int h=(h1+i*h2)%L;
    if(A[h][0]=='\0'){
      cout<<"no"<<endl; return;
    }
    if(A[h]==s){
      cout<<"yes"<<endl;
      return;
    }
  }
}


int main(){
  for(int i=0;i<L;i++){
    A[i]='\0';
  }
  string com,s;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>com>>s;
    if(com[0]=='i'){
      insert(s);
    }else{
      find(s);
    }
  }
  return 0;
}



Measured memory_bytes: 67000
n = int(input())
s = input()

from collections import defaultdict

dic = defaultdict(int)

for i in range(len(s)):
    if s[i] == ')':
        if dic['('] > 0:
            dic['('] -= 1
        else:
            dic[')'] += 1
    else:
        dic['('] += 1

top = bottom = ''
for _ in range(dic[')']):
    top += '('

for _ in range(dic['(']):
    bottom += ')'

print(top + s + bottom)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader("input.txt"));
            var task = new Task();
            using (var sw = Console.Out)
            //using (var sw = new StreamWriter("output.txt"))
            {
                task.Solve(sr, sw);
                //Console.ReadKey();
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var input = sr.ReadArray(Int64.Parse);
            var n = input[0];
            var m = input[1];
            var result = Math.Min(n, m / 2);
            n -= result;
            m -= result * 2;
            while (true) {
                if (m < 4) {
                    break;
                }
                var r = m / 4;
                result += r;
                m -= r * 4;
            }

            sw.WriteLine(result);
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n,k,d;
    cin >> n >> k;
    vector<int> a(n + 1,0);
    rep(i,k){
        cin >> d;
        rep(j,d){
            int in;
            cin >> in;
            a[in] = 1;
        }
    }
    int cnt = 0;
    rep(i,n + 1){
        if(a[i] == 0){
            cnt++;
        }
    }
    cout << cnt - 1 << endl;
    return 0;
}

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

int main() {
    long n;cin>>n;
    long a=0,b=n;

    while(n>0){
        long c = n%10;
        a+=c;
        n/=10;
    }
    if(b%a==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

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

string s;
int ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	for(auto &i:s)
		if(i == 'C' || i == 'G' || i == 'T')
			i = 'A';
	for(size_t i=0; i<s.size(); ++i){
		if(s[i] == 'A'){
			int j = 0;
			while(i+j < s.size() && s[i+j] == 'A') ++j;
			i += j - 1;
			ans = max(ans, j);
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
/*input
13 5 6
1 3 35902
4 6 19698
4 6 73389
3 6 3031
3 1 4771
1 4 4784
2 1 36357
2 1 24830
5 6 50219
4 6 22645
1 2 30739
1 4 68417
1 5 78537
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
#define version 20190814
//}}}
const ll maxn=100005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int dsu[maxn];
int sz[maxn];
int rcnt[maxn],ccnt[maxn];

int find(int u){
	if(dsu[u]==u) return u;
	return find(dsu[u]);
}

void mrg(int u,int v){
	if(u==v) return;
	if(sz[u]<sz[v]){
		sz[v]+=sz[u];
		rcnt[v]+=rcnt[u];
		ccnt[v]+=ccnt[u];
		dsu[u]=v;
	}
	else{
		sz[u]+=sz[v];
		rcnt[u]+=rcnt[v];
		ccnt[u]+=ccnt[v];
		dsu[v]=u;
	}
}

void unmrg(int u,int v){
	if(u==v) return;
	if(sz[u]<sz[v]){
		sz[v]-=sz[u];
		rcnt[v]-=rcnt[u];
		ccnt[v]-=ccnt[u];
		dsu[u]=u;
	}
	else{
		sz[u]-=sz[v];
		rcnt[u]-=rcnt[v];
		ccnt[u]-=ccnt[v];
		dsu[v]=v;
	}
}

bool check(int i){
	i=find(i);
	if(rcnt[i]+ccnt[i]<sz[i]) return 0;
	return 1;
}

ll n,h,w;

vector<pair<ll,pll>> v;
int rr[maxn],cc[maxn];

int main(){
	IOS;
	cin>>n>>h>>w;
	REP(i,n){
		ll a,b,c;
		cin>>a>>b>>c;
		v.eb(c,MP(a,b));
	}
	sort(ALL(v));
	reverse(ALL(v));
	ll ans=0;

	REP(i,n) dsu[i]=i,sz[i]=rcnt[i]=ccnt[i]=1;
	REP(i,maxn) rr[i]=cc[i]=-1;
	REP(i,SZ(v)){
		ll val=v[i].F;
		ll x=v[i].S.F,y=v[i].S.S;
		bool fR=0,fC=0;
		if(rr[x]==-1){
			rr[x]=i;
			fR=1;
		}
		if(cc[y]==-1){
			cc[y]=i;
			fC=1;
		}
		int tmp1,tmp2,tmp3,tmp4;
		if(rr[x]!=i){
			tmp1=find(i);
			tmp2=find(rr[x]);
			mrg(tmp1,tmp2);
		}
		if(cc[y]!=i){
			tmp3=find(i);
			tmp4=find(cc[y]);
			mrg(tmp3,tmp4);
		}
		if(!fR) rcnt[find(i)]--;
		if(!fC) ccnt[find(i)]--;

		if(check(i)){
			ans+=val;
		}
		else{
			if(!fC) ccnt[find(i)]++;
			if(!fR) rcnt[find(i)]++;
			if(cc[y]!=i) unmrg(tmp3,tmp4);
			if(rr[x]!=i) unmrg(tmp1,tmp2);
			if(fC){
				cc[y]=-1;
			}
			if(fR){
				cc[x]=-1;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 5488
int main(void){
  int i,n,s,total,max,min;

  while(1){
    scanf("%d",&n);
    if(!n) break;

    min=1000;
    total=max=0;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      total+=s;
      if(max<s){max=s;}
      if(min>s){min=s;}
    }
    printf("%d\n",(total-max-min)/(n-2));
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int ans=0;
	
	for(int i=1;i<s.size();i++){
		if(s[i] == s[i-1]){
			if(s[i] == '1')s[i] = '0';
			else s[i] = '1';
			ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a


using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;


const ll MOD = 1e9+7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}



ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}





int main(){

	ll n,w;
    cin>>n>>w;
    ll wt[n+1],val[n+1];
    ll v = 0;
    reps(i,n){
        cin>>wt[i]>>val[i];
        v+=val[i];
    }

    ll dp[n+1][v+1];
    for (ll i = 0; i <= n; i++)
    {
        
        dp[i][0] = 0;
        for (int j = 1; j <= v; j++)
            dp[i][j] = MOD;
    }
  
   
   
   

   for(ll i = 1 ; i<=n ; i++){
    for(ll j = 1 ; j<=v ; j++){
    	
    dp[i][j] = dp[i-1][j];
        if(j-val[i] >=0){
        dp[i][j] = min(dp[i][j] , dp[i-1][j-val[i]] + wt[i]);
        }
    }


   }


   ll ans=0;
   for(ll i = v; i>=0 ; i--){
    if(dp[n][i]<=w ){
        ans  = i;
        break;
    }
   }


   cout<<ans;






	



























}

Measured memory_bytes: 82304
#include "bits/stdc++.h"
using namespace std;
int factional(int N) {
	int sum = 1;
	for (int i = 2; i <= N; i++) {
		sum *= i;
	}
	return sum;
}
int main() {
	int N;
	cin >> N;
	vector<int>P(N), Q(N);
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> Q.at(i);
	}
	vector<int>S(N);
	for (int i = 0; i < N; i++) {
		S.at(i) = i + 1;
	}
	int Kinds = factional(N);
	vector<vector<int>>A(N, vector<int>(Kinds));
	int j = 0;
	do {
		for (int i = 0; i < N; i++) {
			A.at(i).at(j) = S.at(i);
		}
		j++;
	} while (next_permutation(S.begin(), S.end()));
	int p_pos = 0, q_pos = 0;
	for (int i = 0; i < Kinds; i++) {
		bool check = true;
		for (int j = 0; j < N; j++) {
			if (A.at(j).at(i) != P.at(j)) check = false;
		}
		if (check) p_pos = i;
		check = true;
		for (int j = 0; j < N; j++) {
			if (A.at(j).at(i) != Q.at(j)) check = false;
		}
		if (check) q_pos = i;
	}
	cout << abs(p_pos - q_pos) << endl;	
}

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

int main() {
	long long x,y;cin>>x>>y;
	long long sub=x-y;
	if(x<y){
		sub*=-1;
	}
	if(sub>=2){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Brown"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 100005
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll n; string s;
    cin>>n>>s;
    ll r[n],b[n],g[n];
    fill(r,r+n,0);
    fill(g,g+n,0);
    fill(b,b+n,0);
    for(ll i=0;i<n;i++){
        if(i==0){
            if(s[i]=='R')
                r[i]=1;
            else if(s[i]=='G')
                g[i]=1;
            else b[i]=1;
            
        }
        else{
        if(s[i]=='R')
            r[i]+=r[i-1]+1;
        else r[i]=r[i-1];
        if(s[i]=='G')
            g[i]+=g[i-1]+1;
        else g[i]=g[i-1];
        if(s[i]=='B')
            b[i]+=b[i-1]+1;
        else b[i]=b[i-1];
        }
    }

    ll count=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(s[i]!=s[j]){
                string s1;
                s1+=s[i];
                s1+=s[j];
                sort(s1.begin(),s1.end());
                if(s1=="BG"){
                    count+=r[n-1]-r[j];
                    if(s[2*j-i]=='R' )
                        count--;
                }
                else if(s1=="GR"){
                    count+=b[n-1]-b[j];
                    if(s[2*j-i]=='B' )
                        count--;
                }
                else if(s1=="BR"){
                    count+=g[n-1]-g[j];
                    if(s[2*j-i]=='G' )
                        count--;
                }
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
class unionfind {
    vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う
public:
    unionfind(int n) :par(n), rank(n), size_(n, 1) {
        iota(all(par), 0);
    }
    int find(int x) {
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])swap(x, y);
        par[y] = x;
        size_[x] += size_[y];
        if (rank[x] == rank[y])rank[x]++;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return size_[find(x)];
    }
};
signed main(){
    int n,k,l; cin>>n>>k>>l;
    unionfind u(n+1);
    unionfind v(n+1);
    rep(i,k){
        int a,b;cin>>a>>b;
        u.unite(a, b);
    }
    rep(i,l){
        int a,b;cin>>a>>b;
        v.unite(a, b);
    }
    map<pii,int>parent;
    for(int i=1;i<=n;i++){
        parent[make_pair(u.find(i),v.find(i))]++;
    }
    for(int i=1;i<=n;i++){
        if(i!=1)cout<<" ";
        cout<<parent[make_pair(u.find(i),v.find(i))];
    }
    cout<<endl;
}


Measured memory_bytes: 16640
#include <stdio.h>

int plug_add(int A,int B);
int main(){
  int A,B;

  scanf("%d %d",&A,&B);
  printf("%d\n",plug_add(A,B));

  return 0;
}
int plug_add(int A,int B){
  int ct=0,p=1;
  while(p-ct<B){
    ct++;
    p+=A;
  }

  return ct;
}


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


Measured memory_bytes: 3540
#include<iostream>

using namespace std;

int gcd(int a,int b){
  if(b == 0){
    return a;
  }
  return gcd(b,a%b);
}

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

  
    int ans1 = gcd(a,b);
    cout<<ans1<<" "<<a/ans1*b<<endl;
  }
  return 0;
}

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

#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main(void)
{
    const int N_MAX = 2000;
    const int A_MAX = 2000;
    int N;
    int S_all = 0;
    bitset<N_MAX * A_MAX + 1> b(1);
    cin >> N;
    REP(i, N) {
        int A;
        cin >> A;
        S_all += A;
        b |= b << A;
    }
    string str = b.to_string();
    int result = find(str.rbegin() + (S_all + 1) / 2, str.rend(), '1') - str.rbegin();
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 5632
N = int(input())
A = list(map(int,input().split()))

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

def lcm(m, n):
  return (m*n)//gcd(m, n)

ans = A[0]
for i in range(1, N):
  ans = gcd(ans, A[i])
print(ans)

Measured memory_bytes: 15020
#include<iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <vector> 
#include <unordered_map>
using namespace std; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main()
{   
	//IOS;
	#define int long long int
	string s1,s2;
	cin>>s1>>s2;
	int cnt=0;
	for(int i=0;i<s1.size();i++){
		if(s1[i]!=s2[i]) cnt++;
	}
	cout<<cnt;

    return 0;
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define PI         2*acos(0)
#define pb         push_back
#define mp         make_pair
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define bs         binary_search
#define For(i,j,k) for(i=j;i<k;i++)
#define FOR(i,j,k) for(i=j;i>=k;i--)
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
char s[cs];
int main()
{	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);
  
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0;
    bool flag = false;
    cin >> n;
    a=7;
    k=n;
    cnt=1;
    while(k--){
        if(a%n==0){
            flag = true;
            break;
        }
        a = a*10 + 7;
        a=a%n;
        cnt++;
    }
 
    if(flag){
        cout << cnt << endl;
    }else{
        cout << -1 << endl;
    }
    
    return 0;
}

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

int main(){
  int N,D,A;
  cin >> N >> D >> A;

  vector<pair<int, int>> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i).first >> data.at(i).second;
  }
  sort(data.begin(), data.end());

  queue<pair<int,int>> bombs; // 各爆弾の右端,威力を管理するキュー
  int64_t ans= 0;
  int64_t blast= 0; // モンスターiがモンスターiが[0,i)から受ける爆風
  for(auto e:data){
    auto x_edge= e.first;
    auto hp_edge= e.second;
    while(!bombs.empty() && bombs.front().first < x_edge){
      blast-= bombs.front().second;
      bombs.pop();
    }
    hp_edge-= blast;
    if(hp_edge > 0){
      int n_diff= (hp_edge+A-1)/ A;
      ans+= n_diff;
      blast+= A*n_diff;
      bombs.push(make_pair(x_edge+2*D, A*n_diff) );
    }
    else continue;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2688
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    flag = True
    cnt = 0
    while flag:
        flag = False
        for i in range(N-1, 0, -1):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                cnt += 1
                flag = True
    print(" ".join(map(str, A)))
    print(cnt)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define lepb(i,s,t) for(int i=(s);i>=(t);--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll inff = 4557430888798830399ll;
const db eps = 1e-10;
const db pi = acos(-1.0);
const ll mod = 1e9+7;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,x[2000],y[2000];vector<int> v;string c;
	cin>>n;
	rep(i,0,n)cin>>x[i]>>y[i];
	rep(i,1,n)if((abs(x[i])+abs(y[i]))%2!=(abs(x[0])+abs(y[0]))%2)
	{
		cout<<-1<<endl;return 0;
	}
	if((abs(x[0])+abs(y[0]))%2==0)v.pb(1);
	repb(i,0,30)v.pb(1<<i);reverse(all(v));
	cout<<sz(v)<<endl;rep(i,0,sz(v))cout<<v[i]<<" ";cout<<endl;
	rep(i,0,n)
	{
		c.clear();
		rep(j,0,sz(v))
		{
			if(abs(x[i])>abs(y[i]))
			{
				if(x[i]>0){x[i]-=v[j];c+="R";}
				else {x[i]+=v[j];c+="L";}
			}
			else
			{
				if(y[i]>0){y[i]-=v[j];c+="U";;}
				else {y[i]+=v[j];c+="D";;}
			}
		}
		cout<<c<<endl;
	/*	int tx=0,ty=0;
		rep(j,0,sz(v))
		{
			if(c[j]=='R')tx+=v[j];
			if(c[j]=='L')tx-=v[j];
			if(c[j]=='U')ty+=v[j];
			if(c[j]=='D')ty-=v[j];
		}
		dd(tx);de(ty);*/
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 入力ミスは考慮しない

	    // 引数で標準入力System.inを指定する
	    Scanner scanner = new Scanner(System.in);
		try {

		    // 1行目を取得(a)
//		    int input_text１ = scanner.nextInt();
			String line = scanner.nextLine();
			int input_text１ = Integer.parseInt(line);

		    // AC, WA, TLE, RE
		    int[] countArray = {0, 0, 0, 0};

		    for (int i = 0; i < input_text１; i++) {

		    	String input_text = scanner.nextLine();

		    	if ("AC".equals(input_text)) {
		    		countArray[0]++;
		    	} else if ("WA".equals(input_text)) {
		    		countArray[1]++;
		    	} else if ("TLE".equals(input_text)) {
		    		countArray[2]++;
		    	} else if ("RE".equals(input_text)) {
		    		countArray[3]++;
		    	}
		    }

		    System.out.println("AC x " + countArray[0]);
		    System.out.println("WA x " + countArray[1]);
		    System.out.println("TLE x " + countArray[2]);
		    System.out.println("RE x " + countArray[3]);

		} finally {
		    // Scannerクラスのインスタンスをクローズ
		    scanner.close();
		}
	}

}


Measured memory_bytes: 50992
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    map<string,int> s;
    for(int i=0;i<n;i++){
        string sstr;
        cin>>sstr;
        s[sstr]+=1;
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 19124
s=input()
a=-1
at=-1
b=-1
bt=-1
for i in range(len(s)):
    if a==s[i]:
        print(at+1,i+1)
        quit()
    if b==s[i]:
        print(bt+1,i+1)
        quit()
    a=b
    at=bt
    b=s[i]
    bt=i
print(-1,-1)


Measured memory_bytes: 3188
N = int(input())
print(0, flush=True)
l = input()
if l == 'Vacant':
    exit()
print(N - 1, flush=True)
t = input()
if t == 'Vacant':
    exit()

top = N - 1
lo = 0
while top - lo > 1:
    mid = (top + lo) // 2
    print(mid, flush=True)
    tmp = input()
    if tmp == 'Vacant':
        exit()
    elif ((mid - lo) % 2 != 0 and l == tmp) or ((mid - lo) % 2 == 0 and l != tmp):
        top = mid
    else:
        lo = mid
        l = tmp


Measured memory_bytes: 9156
from operator import itemgetter
N,M =[int(x) for x in input().split()]
ans = []
for i in range(M):
  p,y = [int(x) for x in input().split()]
  ans1 = [p,y,i]
  ans += [ans1]
ans = sorted(ans,key=itemgetter(1))
ans = sorted(ans,key=itemgetter(0))
cnt = 0
pcnt = 1
a = ans[0][0]
for i in range(M):
  if a == ans[i][0]:
    cnt += 1
    a = ans[i][0]
    ans[i][0] = "{:06d}".format(ans[i][0])+ "{:06d}".format(cnt)
  else:
    a = ans[i][0]
    cnt = 1
    ans[i][0] = "{:06d}".format(ans[i][0])+ "{:06d}".format(cnt)
ans = sorted(ans,key=itemgetter(2))
for i in range(M):
	print(ans[i][0])


Measured memory_bytes: 32028
def main()
  n = gets.chomp.to_i
  inputL = gets.chomp.strip
  l = []
  sum = 0
  can_be_drawn = 'Yes'
  for i in 1..n do
    l[i] = inputL.split(' ').map(&:to_i)[i-1]
    sum += l[i]
  end

  for i in 1..n do
    can_be_drawn = 'No' if 2*l[i] >= sum
  end
  
  puts "#{can_be_drawn}"
end
main

Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << x << endl
const int INF = 1e+8+7;
ll n,m;
int a,b,c = 0;
string s,t;
int d[100],dp1[500][500],dp2[500][500];
vi vec;

int main(){
  cin >> s;
  rep(i,0,3){
    if(s[i] == '1')c++;
  }
  print(c);
  return 0;
}

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

long double func(long long n,long long x){
  if(n == 1){return x;}
  else{return func(n-1,x*n);}
}
            
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> a(n+1,vector<int>(0,0));
  for(int i=0;i < m;i++){
    int x, y;
    cin >> x >> y;
    a.at(x).push_back(y);
    a.at(y).push_back(x);
  }
  vector<int> b(n-1);
  for(int i=0;i <n-1;i++){
    b.at(i) = i+2;
  }
  long double x = func(n-1,1);
  long double sum = 0;
  for(int i=0;i < x;i++){
  	next_permutation(b.begin(),b.end());
    int check = 0;
    for(int l=0;l < (int)a.at(1).size();l++){
      if(a.at(1).at(l) == b.at(0)){check = 1;}
    }
    if(check == 1){
      int buf = 1;
      for(int j=1;j < n-1;j++){
     	 int check_2 = 0;
        //cout << a.at(b.at(j-1)).size() << endl;
      	for(int l=0;l < (int)a.at(b.at(j-1)).size();l++){
          //cout << a.at(b.at(j-1)).at(l) << b.at(j) << endl;
      		if(a.at(b.at(j-1)).at(l) == b.at(j)){check_2 = 1;}
      	}
      	if(check_2 == 1){buf++;}
      }
      if(buf == n-1){sum++;}
 	 }
  }
  cout << sum << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b||a==c||b==c){
        if(a==b&&b==c){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n;
  cin >> n;
  vector<ll>a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  int pre=-999;
  for(int i=0;i<n;i++){
    if(pre<=a[i]-1){
      pre=a[i]-1;
    }else if(pre<=a[i]){
      pre=a[i];
    }else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 3964
def d_SimpleKnapsack(N, W, T):
    from collections import defaultdict
    # dp[i]は、ナップサックに重さの和がiになるように物を入れたときの
    # 価値の最大値が格納される
    dp = defaultdict(int)
    dp[0] = 0  # 重さ0で達成できる価値は0とする
    for w, v in T:
        for nw, nv in list(dp.items()):
            # 今のdpの要素それぞれに対して、
            # 注目している物を入れて重さがWを超えなければ、
            # 物を入れて価値の最大値を更新する
            if nw + w <= W:
                dp[nw + w] = max(dp[nw + w], nv + v)
    return max(dp.values())

N,W = [int(i) for i in input().split()]
T = [[int(i) for i in input().split()] for j in range(N)]
print(d_SimpleKnapsack(N, W, T))

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB pop_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 25
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
#define vi vector<long long>

using namespace std;
typedef long long ll;
const ll mod=1e9;
const ll inf = 1e18+7;
const int maxn = 3e6+7;
int n,num_edge,a[maxn],f[maxn],ans[maxn],head[maxn];
struct Edge
{
	int to;
	int Next;
}edge[maxn];
void add_edge(int from,int to){
	edge[++num_edge].to=to;
	edge[num_edge].Next=head[from];
	head[from]=num_edge;
}
void dfs(int x,int fa){
	int last;
	int l=1,r=ans[fa];
	if(fa==0)
	{
		f[1]=a[x];
		ans[1]=1;
	}
	else
	{
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(a[x]<=f[mid])
				r=mid-1;
			else
				l=mid+1;
		}
		last=f[l];
		f[l]=a[x];
		ans[x]=ans[fa];
		if(l>ans[fa])
			ans[x]++;
	}
	for(int i=head[x];i;i=edge[i].Next)
	{
		int y=edge[i].to;
		if(y!=fa)
			dfs(y,x);
	}
	f[l] = last;
}
int main(){
    FIO
    int x,y;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n-1;i++){
		cin>>x>>y;
		add_edge(x,y);
		add_edge(y,x);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
	return 0;
}
/**
5
6
7
1 2 2 4
2 4 3 3
3 4 2 4
1 3 4 1
4 6 2 1
3 5 2 0
5 4 3 2
**/


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) cin >> s.at(i);
  vector<vector<int>> step(h + 1, vector<int>(w + 1, 1000));
  step.at(1).at(1) = 0;
  if (s.at(0).at(0) == '#') step.at(1).at(1) = 1;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (i == 1 && j == 1) continue;
      int d = 0, r = 0;
      if (i > 1 && s.at(i - 2).at(j - 1) == '.' && s.at(i - 1).at(j - 1) == '#') {
        d = 1;
      }
      if (j > 1 && s.at(i - 1).at(j - 2) == '.' && s.at(i - 1).at(j - 1) == '#') {
        r = 1;
      }
      step.at(i).at(j) = min(step.at(i - 1).at(j) + d, step.at(i).at(j - 1) + r);
    }
  }
  cout << step.at(h).at(w) << endl;
}


Measured memory_bytes: 256