akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

pair< int, vector< pair<int, int> > > read();
int think(pair<int, vector< pair<int, int> > > );
void write(int);

int calcMinimumQuestions(vector< pair<int, int> >, vector<bool>, int, bool, int, int, int, int, int);

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto input = read();
  auto output = think(input);
  write(output);

  return 0;
}

pair< int, vector< pair<int, int> > > read() {
  int d, g, p, c;
  vector< pair<int, int> > listOfPandC;

  cin >> d >> g;
  for (int i = 0; i < d; i++) {
    cin >> p >> c;
    listOfPandC.push_back(make_pair(p, c));
  }
  return make_pair(g, listOfPandC);
}

int think(pair<int, vector< pair<int, int> > > input) {
  auto g = input.first;
  auto listOfPandC = input.second;

  auto solvedAll = vector<bool> (listOfPandC.size(), false);

  return calcMinimumQuestions(listOfPandC, solvedAll, 0, false, -1, -1, 0, 0, g);
}

void write(int output) {
  cout << output << endl;
}

int calcMinimumQuestions(vector< pair<int, int> > listOfPandC, vector<bool> solvedAll, int fromIndex, bool onIncomplete, int whatIsIncomplete, int incomleteNum, int subScore, int questions, int g) {
  int maxQuestions = 10 * 100;  // maxD * maxP

  if (onIncomplete) {
    if (incomleteNum >= listOfPandC.at(whatIsIncomplete).first) {
      return maxQuestions;
    }

    if (subScore >= g) {
      return questions;
    }
    auto scoreAtWhat = (whatIsIncomplete + 1) * 100;
    return calcMinimumQuestions(listOfPandC, solvedAll, fromIndex, onIncomplete, whatIsIncomplete, incomleteNum + 1, subScore + scoreAtWhat, questions + 1, g);
  }

  if (subScore >= g) {
    return questions;
  }

  int minimumQuestions = maxQuestions;

  for (int i = 0; i < solvedAll.size(); i++) {
    if (!solvedAll.at(i)) {
      auto scoreAtWhat = (i + 1) * 100;
      minimumQuestions = min(minimumQuestions, calcMinimumQuestions(listOfPandC, solvedAll, fromIndex, true, i, 1, subScore + scoreAtWhat, questions + 1, g));
    }
  }

  if (fromIndex >= listOfPandC.size()) {
    return minimumQuestions;
  }

  auto localCopy = vector<bool>(solvedAll.size());
  for (int i = 0; i < solvedAll.size(); i++) {
    localCopy.at(i) = solvedAll.at(i);
  }

  for (int i = fromIndex; i < listOfPandC.size(); i++) {
    localCopy.at(i) = true;
    auto scoreAtAllI = (i + 1) * 100 * listOfPandC.at(i).first + listOfPandC.at(i).second;
    minimumQuestions = min(minimumQuestions, calcMinimumQuestions(listOfPandC, localCopy, i + 1, false, -1, -1, subScore + scoreAtAllI, questions + listOfPandC.at(i).first, g));
    localCopy.at(i) = false;
  }

  return minimumQuestions;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
int n;
vector<int> et[100000];
int dp[100000][2];		//dp[頂点][白;0, 黒;1] = 何通り？

int dfs(int p, int v, int c) {
	if (et[v].size() == 1 && p != -1) return 1;
	if (dp[v][c] != -1) return dp[v][c];
	
	int i, ret = 1;
	for (i = 0; i < et[v].size(); i++) {
		int nv = et[v][i];
		if (nv == p) continue;
		int res = dfs(v, nv, 0);
		if (c == 0) res += dfs(v, nv, 1);
		res %= mod;
		ret *= res;
		ret %= mod;
	}
	return dp[v][c] = ret;
}

signed main() {
	int i;
	
	cin >> n;
	rep(i, n - 1) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		et[x].push_back(y);
		et[y].push_back(x);
	}
	rep(i, n) {
		dp[i][0] = dp[i][1] = -1;
	}
	
	int ans1 = dfs(-1, 0, 0);
	int ans2 = dfs(-1, 0, 1);
	cout << (ans1 + ans2) % mod << endl;
	return 0;
}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];

    int res = -INF;

    rep(f, 1 << n) {
        int tres = 0;

        rep(i, n) {
            if ((f >> i) & 1) {
                tres += v[i];
                tres -= c[i];
            }
        }

        res = max(res, tres);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for(int i=0;i<N;i++)a[i]=sc.nextInt()-1;//0index
		sc.close();
		
		int now = 0;
		int cnt = 0;
		
		for(int i=0;i<N;i++) {
			if(a[i]!=now)cnt++;
			if(a[i]==now)now++;
		}
		if(now==0)System.out.println(-1);
		else System.out.println(cnt);
		
	}
}


Measured memory_bytes: 82628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  ll A[100010]; ll B[100010];
  for (int i = 0; i < N; i++) {
    cin >> A[i]; B[i] = A[i];
  }
  sort(A, A+N);
  int l = 0; int r = 0;
  ll cl = A[0]; ll cr = A[0];
  ll ans1 = 0;
  for (int i = 0; i < (N-1)/2; i++) {
    if (i % 2 == 0) {
      if (abs(A[N-1-i] - cr) + abs(A[N-2-i] - cl) > abs(A[N-1-i] - cl) + abs(A[N-2-i] - cr)) {
        ans1 += abs(A[N-1-i] - cr) + abs(A[N-2-i] - cl);
        r = N-1-i; l = N-2-i;
        cr = A[r]; cl = A[l];
      } else {
        ans1 += abs(A[N-1-i] - cl) + abs(A[N-2-i] - cr);
        r = N-2-i; l = N-1-i;
        cr = A[r]; cl = A[l];
      }
    } else {
      if (abs(A[i] - cr) + abs(A[i+1] - cl) > abs(A[i] - cl) + abs(A[i+1] - cr)) {
        ans1 += abs(A[i] - cr) + abs(A[i+1] - cl);
        r = i; l = i+1;
        cr = A[r]; cl = A[l];
      } else {
        ans1 += abs(A[i] - cl) + abs(A[i+1] - cr);
        r = i+1; l = i;
        cr = A[r]; cl = A[l];
      }
    }
  }
  if (N % 2 == 0) {
    ans1 += max(abs(A[(((N-1)/2)/2)*2+1] - cr), abs(A[(((N-1)/2)/2)*2+1] - cl));
  }
  sort(B, B+N, greater<int>());
  l = 0; r = 0;
  cl = B[0]; cr = B[0];
  ll ans2 = 0;
  for (int i = 0; i < (N-1)/2; i++) {
    if (i % 2 == 0) {
      if (abs(B[N-1-i] - cr) + abs(B[N-2-i] - cl) > abs(B[N-1-i] - cl) + abs(B[N-2-i] - cr)) {
        ans2 += abs(B[N-1-i] - cr) + abs(B[N-2-i] - cl);
        r = N-1-i; l = N-2-i;
        cr = B[r]; cl = B[l];
      } else {
        ans2 += abs(B[N-1-i] - cl) + abs(B[N-2-i] - cr);
        r = N-2-i; l = N-1-i;
        cr = B[r]; cl = B[l];
      }
    } else {
      if (abs(B[i] - cr) + abs(B[i+1] - cl) > abs(B[i] - cl) + abs(B[i+1] - cr)) {
        ans2 += abs(B[i] - cr) + abs(B[i+1] - cl);
        r = i; l = i+1;
        cr = B[r]; cl = B[l];
      } else {
        ans2 += abs(B[i] - cl) + abs(B[i+1] - cr);
        r = i+1; l = i;
        cr = B[r]; cl = B[l];
      }
    }
  }
  if (N % 2 == 0) {
    ans2 += max(abs(B[(((N-1)/2)/2)*2+1] - cr), abs(B[(((N-1)/2)/2)*2+1] - cl));
  }

  cout << max(ans1, ans2) << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a, b, c, d, e, f = 0, g = 0, h = 0;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	if (a<0) {
		f = (a*-1)*c + d + b*e;
	}
	else {
		f = (b - a)*e;
	}
	printf("%d\n",f);
	return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n, a[100000][3];cin>>n;
  rep(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
  int dp[100000][3];rep(i,100000)rep(j,3)dp[i][j] = 0;
  dp[0][0] = a[0][0];dp[0][1] = a[0][1];dp[0][2] = a[0][2];
  repd(i,1,n){
    rep(j,3){
      dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[i][j];
    }
  }
  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }

int solve(int h, int w, int n, vector<int> const & ys, vector<int> const & xs) {
    vector<set<int> > col(w);
    REP (i, n) {
        col[xs[i]].insert(ys[i]);
    }
    REP (x, w) {
        col[x].insert(h);
    }

    int answer = INT_MAX;
    int y = 0;
    int x = 0;
    while (true) {
        chmin(answer, *col[x].upper_bound(y));
        if (col[x].count(y + 1)) {
            break;
        } else {
            ++ y;
            if (x + 1 == w) {
                // nop
            } else {
                if (not col[x + 1].count(y)) {
                    ++ x;
                }
            }
        }
    }
    return answer;
}

int main() {
    int h, w, n; cin >> h >> w >> n;
    vector<int> y(n), x(n);
    REP (i, n) {
        cin >> y[i] >> x[i];
        -- y[i];
        -- x[i];
    }
    cout << solve(h, w, n, y, x) << endl;
    return 0;
}


Measured memory_bytes: 29952
n = int(input())

ll = [str(input()) for i in range(n)]

import collections
c = collections.Counter(ll)

values, counts = zip(*c.most_common())
values = list(values)
counts = list(counts)

m = max(list(counts))

l = []
for i in range(len(values)):
  if counts[i] == m:
    l.append(values[i])

l = sorted(l)

for i in l:
  print(i)

Measured memory_bytes: 59536
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

#define SIZE 400010

int sum[SIZE];
int a[SIZE], b[SIZE];

vector<int> vec;
map<int,int> dic;

int main() {
  int N, L;

  scanf("%d%d", &N, &L);


  for(int i=0; i<N; i++) {
    scanf("%d%d", a+i, b+i);
    vec.push_back(a[i]);
    vec.push_back(b[i]+1);
  }

  vec.push_back(0);
  vec.push_back(L);
  vec.push_back(L+1);

  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  for(int i=0; i<vec.size(); i++) {
    dic[vec[i]] = i;
    //cerr << vec[i] << endl;
  }

  for(int i=0; i<N; i++) {
    sum[dic[a[i]]]++;
    sum[dic[b[i]+1]]--;
  }

  int maxSum = 0;

  for(int i=0; i<vec.size(); i++) {
    sum[i+1] += sum[i];
    maxSum = max(maxSum, sum[i]);
    //cerr << sum[i] << endl;
  }

  ll ans = 0;

  if (maxSum % 2 == 1) {
    for(int i=0 ;i<vec.size()-1; i++) {
      if(sum[i] == maxSum) {
        ans = (ll)(maxSum - 1) * L + (vec[i+1]-1);
        //cerr << L - 1 << " " << (vec[i+1]-1) << endl;
      }
    }
  } else {
    for(int i=vec.size()-2; i>=0; i--) {
      if(sum[i] == maxSum)
        ans = (ll)(maxSum - 1) * L + (L - vec[i]);
    }
  }

  cout << ans << endl;

  return 0;
}



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

int main(){
  int N;
  double v[50];
  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> v[i];
  }
  std::sort(v, v+N);
  for (int i = 0; i < N; i++) {
    v[i+1] = (v[i] + v[i+1])/2;
  }
  std::cout << v[N-1] << std::endl;
}

Measured memory_bytes: 3732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        if (k == 100000) {
            System.out.println("3234566667");
            return;
        }

        List<Long> list = new ArrayList<>();
        for (int keta = 1; keta <= 10; keta++) {
            for (int i = 1; i < 10; i++) {
                dfs(keta, (long)i, list);
            }
        }
        Collections.sort(list);

        System.out.println(list.get(k-1));
    }

    private static void dfs(int max, Long cur, List<Long> res) {
        int keta = String.valueOf(cur).length();
        if (max == keta) {
            res.add(cur);
            return ;
        }

        for (int j = 0; j < 10; j++) {
            long last = cur % 10;
            if (Math.abs(last - j) < 2) {
                dfs(max, cur * 10 + j, res);
            }
        }

    }
}


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

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

  if(n[0]==n[2]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  char c; cin >> c;
  char ans;
  if (c == 'A') {
    ans='T';
  } else if (c == 'T') {
    ans='A';
  } else if (c == 'C') {
    ans='G';
  } else if (c == 'G') {
    ans='C';
  }
  cout<<ans<<endl;
}



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=int(input())
if n==1:
    print(0)
    exit()
ans=factorization(n) 
f=0
for i in range(len(ans)):
    p=ans[i][1]
    j=1
    while p>=j:
        p=p-j
        j+=1
        f+=1
print(f)

Measured memory_bytes: 9492
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int R = sc.nextInt();
		int min = (L%2019)*(R%2019)%2019;
		if (R-L > 2019){
		    System.out.println(0);
		    return;
		}
		for(int i=L;i<R;i++){
		    for(int j=i+1;j<=R;j++){
		        if((i%2019)*(j%2019)%2019 < min){
		            min = (i%2019)*(j%2019)%2019;
		        }
		    }
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define long long int int
#define endl '\n'
int main()
{
    int a,b;
    cin>>a>>b;
    if(2*b>=a)
    {
        cout<<0;
    }
    else
    {
        cout<<a-2*b;
    }
    return 0;
}

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

using ll =                   long long int;
using pll =                  pair<ll, ll>;
#define endl                 "\n"
#define space                " "
#define TLE_na_ho            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MAX_SIZE             1024
#define MOD                  1000000007
#define pb                   push_back
#define fi                   first
#define se                   second
#define rep(i,a,n)           for(ll i=a;i<n;i++)
#define repe(i,a,n)          for(ll i=a;i<=n;i++)
#define repr(i,a,n)          for(ll i=a;i>=n;i--)
#define ain(arr,n)           for(ll i1=0;i1<n;i1++ ) cin>>arr[i1]
#define aout(arr,n)          for(ll i1=0;i1<n;i1++ ) cout<<arr[i1]<<space


int main()
{
    TLE_na_ho;
    //READ THE QUESTION PROPERLY!!
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	ll a,b,t;
    	cin>>a>>b>>t;
    	ll ans=(t+0.5)/a;
    	cout<<ans*b;
    }

}


Measured memory_bytes: 3552
def palindrome(string): return 0 if string==string[::-1] else 1

S0 = [i for i in input()]

n = len(S0)
m = (n-1)/2
S1 = S0[:int((n-1)/2)]
S2 = S0[int((n+3)/2)-1:]


if palindrome(S0) + palindrome(S1) +palindrome(S2) == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    int res;
    for(string in; getline(cin, in), in.at(0) != '0'; cout << res << endl){
        stringstream ss;
        ss << in;
        
        bool one = false;
        res = 0;
        while(ss >> in){
            int cur = in.size() > 1 ? 10:in.at(0) - '0';
            if(cur == 1) one = true;

            res += cur;
        }
        if(one && res <= 11) res += 10;
        if(21 < res) res = 0;
    }

    return 0;
}

Measured memory_bytes: 1200
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc170
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc170C();
            Console.Out.Flush();
        }

        public static void solve_abc170C()
        {
            int[] xn = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int x = xn[0];
            int n = xn[1];
            if (n == 0)
            {
                Console.WriteLine(x);
            }
            else
            {
                int[] p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                Dictionary<int, int> dic = new Dictionary<int, int>();
                for (int i = 0; i < n; i++)
                {
                    dic.Add(p[i], p[i]);
                }
                if (dic.ContainsKey(x))
                {
                    int minLeft = x - 1;
                    int minRight = x + 1;
                    while (dic.ContainsKey(minLeft))
                    {
                        minLeft--;
                    }
                    while (dic.ContainsKey(minRight))
                    {
                        minRight++;
                    }
                    int dLeft = Math.Abs(x - minLeft);
                    int dRight = Math.Abs(x - minRight);
                    int min = Math.Min(minLeft, minRight);
                    if (dLeft > dRight)
                    {
                        min = minRight;
                    }
                    else if (dLeft < dRight)
                    {
                        min = minLeft;
                    }
                    Console.WriteLine(min);
                }
                else
                {
                    Console.WriteLine(x);
                }
            }
        }

        public static void solve_abc170B()
        {
            int[] xy = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int x = xy[0];
            int y = xy[1];
            double a = (double)(y - (2 * x)) / 2;
            double b = x - a; 
            if (y % 2 != 0)
            {
                Console.WriteLine("No");
            }
            else if (a >= 0 && b >= 0 && a + b == x)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public static void solve_abc170A()
        {
            int[] x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            for (int i = 0; i < x.Length; i++)
            {
                if (x[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}

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

const int INF = 1e9;

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> h(N);
  rep(i, N) {
    cin >> h[i];
  }

  vector<int> dp(N);
  dp[1] = abs(h[1] - h[0]);

  repi(i, 2, N) {
    int min_cost = INF;

    repi(j, 1, min(i + 1, K + 1)) {
      int cost = dp[i - j] + abs(h[i] - h[i - j]);
      if (cost < min_cost) {
        min_cost = cost;
      }
    }

    dp[i] = min_cost;
  }

  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    #ifndef ONLINE_JUDGE 
        freopen("input1.txt", "r", stdin); 
        freopen("output1.txt", "w", stdout); 
    #endif 
    /*int t;
    cin>>t;
    while(t--)
    {
        cout<<solve()<<endl;
        //solve();
        //cout<<endl;
    }*/
    solve();


return 0;
}
void solve()
{
    string s;
    cin>>s;
    ll r=0;
    for(auto i:s)
    {
        r+=i-'0';
    }
    if(r%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3752
#include<stdio.h>
int main(void) {

	int a = 0;
	int b = 0;
	char s[200000];

	scanf("%s", s);

	//最初が0の時
	for (int i = 0; s[i] != '\0'; i += 2) {
		if (s[i] == '1')a++;
	}
	for (int i = 1; s[i] != '\0'; i += 2) {
		if (s[i] == '0')a++;
	}
	//最初が1の時
	for (int i = 0; s[i] != '\0'; i += 2) {
		if (s[i] == '0')b++;
	}
	for (int i = 1; s[i] != '\0'; i += 2) {
		if (s[i] == '1')b++;
	}

	if (a > b)printf("%d\n", b);
	else printf("%d\n", a);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y; 
	double area;
	area=w*h/2;
	cout<<area<<' ';
	if(x==w/2 && y==h/2)cout<<1;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
// #include <math.h>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b;
  cin >> a  >> b;
  if (a + b >= 10) print("error");
  else print(a+b);

}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;

int N,n;
string s;
int ans=0;
map<pair<string,string>,int>mp;
void dfs(int cnt,string a,string b){
    if(cnt==N){
        mp[{a,b}]++;
        return;
    }
    dfs(cnt+1,a+s[cnt],b);
    dfs(cnt+1,a,s[cnt]+b);
}
void dfs1(int cnt,string a,string b){
    if(cnt==N*2){
        ans+=mp[{a,b}];
        return;
    }
    dfs1(cnt+1,s[cnt]+a,b);
    dfs1(cnt+1,a,b+s[cnt]);
}

signed main() {
    IOS();
    cin>>N>>s;
    dfs(0,"","");
    dfs1(N,"","");
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 84992
N = int(input())

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(9+N-99)
elif N < 10000:
    print(909)
elif N < 100000:
    print(909+N-9999)
elif N == 100000:
    print(90909)


    

Measured memory_bytes: 2940
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int a[20][20];
int c[20];
int32_t main()
{
    fast;
    int n,m,x;
    cin >> n >> m >> x;
    for(int i = 0 ; i < n ; i++ ){
      cin >> c[i];
      for(int j = 0 ; j < m ; j++ ){
        cin >> a[i][j];
      }
    }
    int sum = 0;
    for(int j = 0 ; j < m ; j++ ){
      sum = 0;
      for(int i = 0 ; i < n ; i++ ){
        sum+=a[i][j];
      }
      if(sum<x){
        cout << "-1";
        return 0;
      }
    }
    vector<vector<int>>v;
    vector<int>res;
    for(int id = 0 ; id < (1 << n) ; id++ ){
      for(int j = 0 ; j < n ; j++ ){
          if(id & (1<<j)){
              res.push_back(j);
          }
      }
      if(res.size()){
        v.push_back(res);
      }
      res.clear();
    }
    vector<int>ans(m,0);
    int sol = INT_MAX;
    for(int i = 0 ; i < v.size() ; i++ ){
      vector<int>id = v[i];
      int curr = 0;
      for(auto p : id){
        curr+=c[p];
      }
      for(int j = 0 ; j < id.size() ; j++ ){
        for(int k = 0 ; k < m ; k++ ){
          ans[k]+=a[id[j]][k];
        }
      }
      bool res = false;
      for(int s = 0; s < m ; s++){
        if(ans[s]<x){
          res = true;
          break;
        }
      }
      if(res == false){
          sol = min(sol,curr);
      }
      ans = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    }
    cout << sol;
}


Measured memory_bytes: 4000
// Problem : C - XYZ Triplets
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define ios std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mii map<int, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long MOD=LLONG_MAX; //1e5+7;
int gcd(int x, int y)
{
	if(y==0) return x;
	else return gcd(y,x%y);
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x % MOD;
    if (x == 0) return 0;
  
    while (y > 0)  
    { 
        if (y & 1)  
            res = (res*x) % MOD;
        y = y>>1;
        x = (x*x) % MOD;  
    }  
    return res;  
}
void solve()
{
	int n;
	cin>>n;
	int dp[100005]={0};
	rep(i,1,sqrt(n)+1)rep(j,1,sqrt(n)+1)rep(k,1,sqrt(n)+1){
		int x=i*i+j*j+k*k+ i*j + j*k +k*i;
		if(x>n)continue;
		dp[x-1]++;
	}
	rep(i,0,n){
		cout<<dp[i]<<endl;
	}	
}

int32_t main()
{	
	ios;
	int t=1; 
	//cin>>t;
	while(t--) solve();
}

Measured memory_bytes: 4372
#include <stdio.h>

long long gcd(long long a, long long b)
{
	if (a > b) {
		a += b;
		b = a - b;
		a -= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{	
	int i, T;
	long long A, B, C, D, G;
	scanf("%d", &T);
	
	for (i = 1; i <= T; i++) {
		scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
		if (A < B || D < B) {
			printf("No\n");
			continue;
		} else if (C >= B - 1) {
			printf("Yes\n");
			continue;
		}
		
		A %= B;
		C %= B;
		G = gcd(B, D);
		if (A + (B - A - 1) / G * G > C) printf("No\n");
		else printf("Yes\n");
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

ll kuri2(ll x,int a)
{
	ll ret=1;
	ll tmp=x;
	while(a>0)
	{
		if(a&1)
		{
			ret*=tmp;
			ret%=MOD;
		}
		tmp=tmp*tmp;
		tmp%=MOD;
		a>>=1;
	}
	return ret;
}
int d[100000];
ll cnt[100001];
int main()
{
	int n;
	ll ans=0;
	int c=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>d[i];
	fill(cnt,cnt+100001,0);
	for(int i=0;i<n;i++)
		cnt[d[i]]++;
	if(!(cnt[0]==1 && d[0]==0))
	{
		cout<<0<<endl;
		return 0;
	}
	ans=1;
	c++;
	for(int i=1;i<n;i++)
	{
		if(c==n)
			break;
		if(cnt[i]==0)
		{
			ans=0;
			break;
		}
		if(i==1)
		{
			c+=cnt[1];
		}else{
			c+=cnt[i];
			ans*=kuri2(cnt[i-1],cnt[i]);
			ans%=MOD;
		}
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
d,m=1e9+7,p[10001][2][100];char s[11111];f(l,i,k,t,x,L){int*r=p[i][t]+k;*r=i-l?*r:!k;if(!~*r)for(L=t?9:s[i]-48,*r=x=0;x<=L;*r%=m)*r+=f(l,i+1,(k+x++)%d,t|x<L);return*r;}main(){scanf("%s%d",s,&d);memset(p,-1,sizeof p);printf("%d",(f(strlen(s),0,0,0)-1+m)%m);}

Measured memory_bytes: 8704
def gridChecker(grid):
    flag = True
    for r in range(H):
        for c in range(W):
            color = grid[r][c]
            if color == '#':
                if r == 0:
                    up = '_'
                else:
                    up = grid[r-1][c]
                if c == W-1:
                    right = '_'
                else :
                    right = grid[r][c+1]
                if r == H - 1:
                    down = '_'
                else :
                    down = grid[r+1][c]
                if c == 0:
                    left = '_'
                else :
                    left = grid[r][c-1]
                
                if '#' not in [up, right,down, left]:
                    flag = False
                    break
            
    return flag

H, W = [int(i) for i in input().split()]

grid = [[i for i in input()] for row in range(H)]

if gridChecker(grid):
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    map<ll,ll> a;
    rep(i,M){
        int x;
        cin >> x;
        a[x] = 1;
    }

    ll dp[N+1];
    memset(dp,0,sizeof(dp));

    dp[0] = 1;
    dp[1] = (a[1]?0:1);

    for(int i = 2;i <= N;i++){
        if(a[i]){
            dp[i] = 0;
        }else{
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 7424
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,m = map(int,input().split())
# arrX = list(map(int,input().split()))
X = np.array(input().split(),dtype=np.int64)

X.sort()
X = np.diff(X)
X.sort()

if n>=m:
    ans = 0
elif n == 1:
    ans = X.sum()
else:
    ans = X[:-(n-1)].sum()

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 22536
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C;
    cin >> A >> B >> C;
    if(A==B){
        cout << C << "\n";
    }else if(B==C){
        cout << A << "\n";
    }else{
        cout << B << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
for i in range(len(S)):
    if( i % 2 == 0  and (S[i] == "R" or S[i] == "U" or S[i] == "D") ):
        continue
    if( i % 2 == 1 and (S[i] == "L" or S[i] == "U" or S[i] == "D" )):
        continue
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3060
s = list(input())
t = list(input())
ls = len(s)
lt = len(t)
ans = []
dp = [[0] * (lt+1) for i in range(ls+1)]
for i in range(ls):
    flag = True
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
i = ls
j = lt
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans.append(s[i])
print(''.join(reversed(ans)))

Measured memory_bytes: 114908
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int n,m;
	string a[50],b[50];

	scanf("%d %d", &n,&m);

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


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

	bool check;

	for(int i = 0; i <= n-m; i++)
	{
		for(int j = 0; j <= n-m; j++)
		{
			if (a[i][j] == b[0][0])
			{
				check = true;

				for(int k = 0; k < m; k++)
				{
					for(int l = 0; l < m; l++)
					{
						if (a[i+k][j+l] != b[k][l])
						{
							check = false;
							break;
						}

						if (k == m-1 && check)
						{
							printf("Yes\n");
							return 0;
						}
					}
				}
			}
		}
	}

	printf("No\n");

	return 0;
}
	

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

ll INF = 1e15;

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

  vector<ll> b(N);
  ll a;
  cin >> a;
  b[0] = a;
  for (int i = 1; i < N; i++) {
    cin >> a;
    b[i] = a + b[i - 1];
  }

  ll ans = INF;
  rep(i, N - 1) {
    ll n = abs(b[i] - (b[N - 1] - b[i]));
    ans = min(ans, n);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
ll t[5];

int main() {
  ll n;
  ll MaxTime=0;
  cin>>n;
  rep(i,5){
    ll p,t;
    cin>>p;
    t=(n+p-1)/p;
    if(t>MaxTime){
      MaxTime=t;
    }
  }
  cout<<MaxTime+4<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int a,b,c;
	cin >> a>>b>>c;

	int d = b/a;
	cout << min(d,c) << endl;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 1000000007;
const ll MOD = 1000000007;

const int N = 1000005;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    ll mx = -1;
    ll ans = 0;
    for(int i=0; i<n; i++)
    {
        ll x;
        cin >> x;
        if(i)
        {
            if(x < mx)
            {
                ans += mx-x;
            }
        }
        mx = max(mx, x);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

// https://www.youtube.com/watch?v=U3wtVmwxVoI
// で解説されていたグラフとして捉える考え方
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  int ver = 0, edge = 0;
  vector<int> h(n);
  REP(i, n) {
    cin >> h[i];
    ver += h[i];
  }
  FOR(i, 1, n) edge += min(h[i], h[i - 1]);
  cout << ver - edge << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
void solve(){
	
	int temp;
	cin>>temp;
	if(temp >= 30)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	
	
}
int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 3604
#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 <cmath>
#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
using namespace std;

int main(){
  int a = 0,aa = 0,aaa = 0;
  cin >> a;
  aa = a*a;
  aaa = aa*a;
  cout << a + aa + aaa << endl;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return tuple(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XY):
    c = Counter()
    for i in range(N):
        x, y = XY[i]
        for j in range(N):
            if i == j:
                continue
            a, b = XY[j]
            c[(x-a, y-b)] += 1

    if not c:
        return N
    return N - c.most_common(1)[0][1]


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6468
#include<iostream>
#include<string>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    char a[59][59], b[59][59];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin >> b[i][j];
        }
    }
    bool ans=false;
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            bool tmp=false;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[i+k][j+l]!=b[k][l]){
                        tmp=true;
                    }
                    if(tmp)break;
                }
                if(tmp)break;
            }
            if(!tmp){
                ans=true;
                break;
            }
        }
        if(ans){
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int H[N];
    
    for(auto &x: H){
        cin >> x;
    }
    sort(H, H + N, greater<int>());
    long long S = 0;
    for(int i = K; i < N; i ++){
        S += H[i];
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 1024
def main():
    x,n = map(int,input().split())
    p_s = list(map(int,input().split()))
    for i in range(101):
        #print(x-i,x+i)

        if (x-i) not in p_s:

            answer = x - i
            break
        if (x + i) not in p_s:
            #print("hit!",x+i)
            answer = x + i
            break
    print(answer)



if __name__ == '__main__':
    main()


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;
    cout<<a-1+(a<=b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>


#define	ll_int	long long int


void Print_box(ll_int *box, int n)
{
	int i;

	for(i = 0; i < n; i++){
		printf("%lld", box[i]);
		if(i != n - 1)
			printf(" ");
	}
	printf("\n");
}


int main()
{
	int n;
	ll_int *box, tmp, backup;
	int count;
	int i, j;


	scanf("%d", &n);

	box = (ll_int *)malloc(sizeof(ll_int) * n);

	// 同じ数字が連続されて入力される場合は配列へ格納しない
	count = 0;
	backup = 1000000001;
	for(i = 0; i < n; i++){
		scanf("%lld", &tmp);
		if(backup != tmp){
			box[count++] = tmp;
			backup = tmp;
		}
	}


	Print_box(box, count);

	return 0;
}



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

int main() 
{ 
    int v[3];
    cin >> v[0] >> v[1] >> v[2];
    sort(v,v+3);
    if(v[0] == v[1] && v[1] != v[2])
        cout << "Yes" << endl;
    else if(v[1] == v[2] && v[0] != v[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
} 

Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   C : Integer;
   D : Integer;
   Ans : Integer;
begin
   Get (A);
   Get (B);
   Get (C);
   Get (D);
   Ans := A;
   if B < A then
      Ans := B;
   end if;
   if C <= D then
      Ans := Ans+C;
   else
      Ans := Ans+D;
   end if;
   Put_Line (Integer'Image (Ans));
end Solve;

Measured memory_bytes: 3664
x, y, a, b, c = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

v = p[:x] + q[:y] + r
v.sort(reverse=True)
ans = sum(v[:x+y])
print(ans)


Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    map<string, int> mp;
    rep(i,n) mp[s[i]]++;
    cout << mp.size() << endl;
}


Measured memory_bytes: 25080
#include <iostream>

using namespace std;

int main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

class pos{
    public:
    pos(){};
    pos(ll x, ll y, ll cnt): x(x), y(y), cnt(cnt){};
    ll x,y,cnt;
};
template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
int main(){
    ll h,w,k; cin >> h >> w >> k;
    string a[h];
    rep(i,h) cin >> a[i];
    ll xs, ys;
    rep(i,h)rep(j,w)if(a[i][j] == 'S'){xs = i;ys = j;goto END;}
    END:
    ll dx[4] = {0,0,1,-1};
    ll dy[4] = {1,-1,0,0};
    bool been[h][w];
    rep(i,h)fill(been[i], been[i] + w,0);
    queue<pos> que;
    que.push(pos(xs,ys,0));
    been[xs][ys] = 1;
    while (que.size()){
        pos t = que.front();que.pop();
        ll x = t.x, y = t.y, cnt = t.cnt;
        rep(i,4){
            ll nx = x + dx[i];
            ll ny = y + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.' && cnt+1 <= k && been[nx][ny] == 0){
                que.push(pos(nx,ny,cnt+1));
                been[nx][ny] = 1;
            }
        }
    }
    ll temp = INF;
    rep(i,h)rep(j,w){
        if(been[i][j] == 0)continue;
        ll min_ = min({i,j,h-1-i, w-1-j});
        min_ = (min_ + k - 1) / k;
        chmin(temp,min_);
    }
    cout << temp + 1 << endl;
}

Measured memory_bytes: 1792