akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int cnt = 0;
	for (string s; cin >> s&&s != "$";) {
		cnt++;
		for (int i = 0; i < s.size() / 2; i++) {
			if (s[i] != s[s.size() - 1 - i]) {
				cnt--;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, x;
    cin >> a >> b >> c >> x;
    ll ans = 0;
    for(int i = 0; i <= a && 500 * i <= x; ++i){
        for(int j = 0; j <= b && 500 * i + 100 * j <= x; ++j){
            if((x - 500 * i - 100 * j) % 50 == 0 &&
               (x - 500 * i - 100 * j) / 50 <= c){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Linq;


namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);

            int[] ans = new int[n];
            for(int i = 0; i < n; i++)
            {
                ans[i] = -1;
            }

            for(int i = 0; i < m; i++)
            {
                str = Console.ReadLine().Split(' ');
                int s = int.Parse(str[0]);
                int c = int.Parse(str[1]);

                if (ans[s - 1] == -1 || ans[s - 1] == c)
                {
                    ans[s - 1] = c;
                }
                else
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            if (ans[0] == 0 && n!=1)
            {
                Console.WriteLine(-1);
                return;
            }

            if(ans[0]==-1 && n == 1)
            {
                Console.WriteLine(0);
                return;
            }

            if (ans[0] == -1) { ans[0] = 1; }
            for(int i = 0; i < n; i++)
            {
                if (ans[i] == -1) { ans[i] = 0; }
                Console.Write(ans[i]);
            }
            Console.WriteLine();


            //ここまで
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h) == 0)break;
			char [][] data =new char[h][w];
			for(int i = 0 ; i < h; i++){
				String s = sc.next();
				for(int j = 0 ; j < w; j++){
					data[i][j] = s.charAt(j);
				}
			}
			
			String [][] dp = new String[h][w];
			for(int i = 0 ; i < h; i++){
				for(int j = 0 ; j < w; j++){
					if(Character.isDigit(data[i][j]) && (data[i][j] != '0')){
						dp[i][j] = data[i][j] + "";
					}
					else{
						dp[i][j] = "";
					}
				}
			}
			
			for(int i = 0; i < h; i++){
				for(int j = 0 ; j < w; j++){
					if(! Character.isDigit(data[i][j])) continue;
					if(data[i][j] == '0' && dp[i][j].equals("")) continue;
					if(i + 1 != h){
						if(dp[i+1][j].length() < dp[i][j].length()  + 1){
							dp[i+1][j] = dp[i][j] + data[i+1][j];
						}
						else if(dp[i+1][j].length() == dp[i][j].length()  + 1 && dp[i+1][j].compareTo(dp[i][j] + data[i+1][j]) < 0){
							dp[i+1][j] = dp[i][j] + data[i+1][j];
						}
					}
					if(j + 1 != w){
						if(dp[i][j+1].length() < dp[i][j].length()  + 1){
							dp[i][j+1] = dp[i][j] + data[i][j+1];
						}
						else if(dp[i][j+1].length() == dp[i][j].length()  + 1  && dp[i][j+1].compareTo(dp[i][j] + data[i][j+1]) < 0){
							dp[i][j+1] = dp[i][j] + data[i][j+1];
						}
					}
				}
			}
			
			//debug
//			for(int i = 0 ; i < h; i++){
//				for(int j  = 0 ;  j < w; j++){
//					if(dp[i][j].equals("")){
//						System.out.print(". ");
//					}
//					else{
//						System.out.print(dp[i][j] + " ");
//						
//					}
//				}
//				System.out.println();
//			}
			
			String ans = "";
			for(int i = 0 ; i < h; i++){
				for(int j = 0 ; j < w; j++){
					if(! Character.isDigit(data[i][j])) continue;
					if(ans.length() < dp[i][j].length()){
						ans = dp[i][j];
					}
					else if(ans.length() == dp[i][j].length()&& ans.compareTo(dp[i][j]) < 0){
						ans = dp[i][j] ;
					}
				}
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

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


int main(){long N;
cin >> N;
long k = 0;
while(pow(2, k) <= N) k++;
long ans = pow(2, k - 1);

cout << ans << endl;
return 0;
}

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

int main() {
    map<string, int> mp;
    int n;cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    
    return 0;
}

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

int main(){
  int L,R;
  cin>>L>>R;
  if((L-1)/2019!=R/2019)
    cout<<0<<endl;
  else{
    L%=2019;
    R%=2019;
    int k=2019;
    for(int i=L;i<R;i++)
      for(int j=i+1;j<=R;j++)
        k=min(k,i*j%2019);
    cout<<k<<endl;
  }
}

Measured memory_bytes: 256
import sys

N = int(input())
a = list(map(int, sys.stdin.readline().split()))

count = 0

for i in range(N):
    if a[i] == i + 1 - count:
        pass
    else:
        count += 1
        
if count == N:
    print(-1)
else:
    print(count)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(v1, v2));
    graph[v2].push_back(Edge(v2, v1));
  }
  return graph;
}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
    s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  vector<int> colors(n);
  for (int i = 0; i < n; i++) {
    cin >> colors[i];
    colors[i]--;
  }
  auto graph = ReadUndirectedGraph(n, n - 1, true);

  vector<int> sizes(n, -1);
  function<void(int, int)> dfs_fn = [&](int v, int p) {
    sizes[v] = 1;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      dfs_fn(e.to, v);
      sizes[v] += sizes[e.to];
    }
  };
  dfs_fn(0, -1);

  // cout << "sizes: " << sizes << endl;

  vector<int> roots(n, 0);
  vector<map<int, int>> maps(n);
  function<void(int, int)> dfs_2_fn = [&](int v, int p) {
    if (p == -1) {
      roots[colors[v]] = -1;
      for (int c = 0; c < n; c++) {
        if (c == colors[v]) continue;
        maps[v].insert({c, n});
      }

      // cout << "v: " << v << endl;
      // cout << "roots: " << roots << endl;
      for (const auto& e : graph[v]) {
        if (e.to == p) continue;
        dfs_2_fn(e.to, v);
      }
    } else {
      if (roots[colors[v]] >= 0) {
        maps[roots[colors[v]]][colors[v]] -= sizes[v];
      }

      int r1 = roots[colors[v]];
      roots[colors[v]] = -1;

      int r2 = roots[colors[p]];
      if (colors[p] != colors[v]) {
        roots[colors[p]] = v;
        maps[v].insert({colors[p], sizes[v]});
      }

      // cout << "v: " << v << endl;
      // cout << "roots: " << roots << endl;
      for (const auto& e : graph[v]) {
        if (e.to == p) continue;
        dfs_2_fn(e.to, v);
      }

      roots[colors[v]] = r1;
      if (colors[p] != colors[v]) roots[colors[p]] = r2;
    }
  };
  dfs_2_fn(0, -1);

  vector<vector<int>> components(n);
  for (const auto& map : maps) {
    for (auto [color, size] : map) {
      components[color].push_back(size);
    }
  }

  for (int c = 0; c < n; c++) {
    // cout << components[c] << endl;

    int64 sum = static_cast<int64>(n) * static_cast<int64>(n + 1) / 2;
    for (int64 size : components[c]) {
      sum -= static_cast<int64>(size) * static_cast<int64>(size + 1) / 2;
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 83932
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
       int n,m;
       cin>>n>>m;
       int a[n][m];pair<int,int>ichi[n*m+1];
       for(int i=0;i<n;i++)for(int j=0;j<m;j++){
         cin>>a[i][j];
        ichi[a[i][j]]=make_pair(i,j);
       }
       int ten[n][m];
       for(int i=1;i<=n*m;i++){
         ten[(i-1)/m][(i-1)%m]=ichi[i].first;
         int i0=a[ichi[i].first][(i-1)%m],j=ichi[i].second,i1=ichi[i].first;
         if(j==(i-1)%m)continue;
         swap(a[ichi[i].first][(i-1)%m],a[ichi[i].first][ichi[i].second]);
         while((i0-1)/m<(i-1)/m){
           swap(a[ten[(i0-1)/m][j]][j],a[ten[(i0-1)/m][j]][(i-1)%m]);
           i1=ten[(i0-1)/m][j];
           swap(ten[(i0-1)/m][j],ten[(i0-1)/m][(i-1)%m]);
           
          i0=a[ten[(i0-1)/m][(i-1)%m]][j];
         }
        // cerr<<i0<<' '<<i1<<endl;
         ichi[i0]=make_pair(i1,j);
        
       
       }
       for(int i=0;i<n;i++){
         for(int j=0;j<m;j++)cout<<a[i][j]<<' ';
         cout<<endl;
       }
       int b[m][n];for(int i=0;i<n;i++)for(int j=0;j<m;j++)b[j][i]=a[i][j];
       for(int i=0;i<m;i++)sort(b[i],b[i]+n);
       for(int i=0;i<n;i++){
         for(int j=0;j<m;j++)cout<<b[j][i]<<' ';
         cout<<endl;
       }

                  
}


        


Measured memory_bytes: 768
# after listening explanation
n = gets.to_i
arms = []
n.times{
  xi, li = gets.split.map(&:to_i)
  arms << [xi-li, xi+li]
}
# interval scheduling
arms.sort!{|a,b|a[1]<=>b[1]}
ans = 0
lastposition = -1000000007
n.times{|i|
  if arms[i][0]>=lastposition
    ans += 1
    lastposition = arms[i][1]
  end
}
p ans


Measured memory_bytes: 10600
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define sort(v)     sort((v).begin(),(v).end())
#define rsort(v)    sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
//finds the next permutation to given sequence of nos
int nextpermutation(vi v)
{
    vi t=v;
    sort(t);
    int x=0;
    while(true)
    {
        x++;
        if(t==v)
        {
            return x;
        }
        next_permutation(all(t));
    }
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int a,b,k;
    cin>>a>>b>>k;
    cout<<max(a-k,0ll)<<" "<<min(max(0ll,b-(k-a)),b)<<endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_long long.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Blong long = mp::cpp_long long;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

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

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

    cout<<ans/2<<endl;
}


Measured memory_bytes: 3544
// D - Wall

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int c[10][10];
int grid[200][200];

void Warshall_Floyd(int d[10][10], int n) {
	for (int k=0; k<n; k++) {
		for (int i=0; i<n; i++) {
			if (d[i][k] == INF) continue;
			for (int j=0; j<n; j++) {
				if (d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
	int H, W;
	cin >> H >> W;

	for (int i=0; i<=9; i++) {
		for (int j=0; j<=9; j++) {
			cin >> c[i][j];
		}
	}

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cin >> grid[i][j];
		}
	}

	Warshall_Floyd(c, 10);

	int ans = 0;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			if (grid[i][j] != -1) {
				ans += c[grid[i][j]][1];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{
    int n,ans=1;
    cin>>n;
    vector<int> h(n);
    rep(i,n)    cin>>h[i];
    rep(i,n){
        repb(j,i-1){
            if(h[i]<h[j])   break;
            if(j==0)    ans++;
        }
    }
    cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
books = []
min_cost = float("inf")

for _ in range(N):
    books.append(list(map(int, input().split())))

for i in range(1, 2**N):
    i = format(i, '0{}b'.format(N))
    books_bought = [books[j] for j in range(N) if int(i[j])]
    cost = sum(book[0] for book in books_bought)
    experience = [sum(book[k] for book in books_bought) for k in range(1, len(books_bought[0]))]
    if sum(exp >= X for exp in experience) == M:
        min_cost = min(min_cost, cost)


if min_cost < float("inf"):
    print(min_cost)
else:
    print(-1)

Measured memory_bytes: 9252
#include <bits/stdc++.h> 
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
*/

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int c1=0,c2=0,c3=0,c4=0;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC")
        c1++;
        if(s=="WA")
        c2++;
        if(s=="TLE")
        c3++;
        if(s=="RE")
        c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;
}

    


Measured memory_bytes: 3624
#include <stdio.h>


int calc(int n){
  int tmp = n;
  int res = 0;

   while(tmp != 0){
     res += tmp % 10;
     tmp = tmp / 10;

   }  
return res;

}
int main(void){

  int N,A,B;
  scanf("%d %d %d",&N,&A,&B);
int i;
int hoge = 0;
  for(i = 1; i <= N;i++){
  int tmp = calc(i);
    if(tmp >= A && tmp <= B) hoge+=i;
   }  

  printf("%d\n",hoge);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    ll a = n % k;
    ll ans = min(a, k - a);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      char[][] C = new char[2][3];
      for(int i=0;i<2;i++){
        String s = sc.next();
        for(int j=0;j<3;j++){
          C[i][j] = s.charAt(j);
        }
      }
      for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
          if(C[i][j]!=C[1-i][2-j]){
            System.out.println("NO");
            return;
          }
        }
      }
        System.out.println("YES");
    }
}

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

int main(){
    long long int n;
    cin>>n;
    vector<long long int>a(n);
    long long int count=0;
    long long int mind=10000000;
    for(long long int i=0;i<n;i++){
        cin>>a.at(i);
        if(i>0 && a.at(i)>mind)continue;
        else {
            mind=min(mind,a.at(i));
            count+=1;
        }


    }
    cout<<count<<endl;
}

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int N;
	string S;
	cin >> N>>S;
	if (N%2==0 & S.compare(0, N / 2, S, N / 2, N/2) == 0) {
		print("Yes");
	}
	else {
		print("No");
	}
}

Measured memory_bytes: 256
int main(void){
    
    int word_num, i;
    char imput[100];
 
    scanf("%s", imput);  
    word_num = strlen(imput); 
 
    printf("%c%d%c\n", imput[0], word_num - 2, imput[word_num - 1]); 
 
    return 0;
}

Measured memory_bytes: 1688
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll a, b, n;
vector<ll> h;
bool check(ll mid){
    ll rest = mid;
    auto vh = h;
    ll diff = a - b;
    for(int i = 0; i < n; i++){
        vh[i] -= mid * b;
    }
    for(int i = 0; i < n; i++){
        if(vh[i] <= 0) continue;
        if(vh[i] % diff == 0){
            rest -= vh[i] / diff;
        } else {
            rest -= (vh[i] / diff) + 1;
        }
    }

    if(rest < 0) return false;
    return true;
}
int main(void){
    cin >> n >> a >> b;
    h.resize(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    sort(h.begin(), h.end(), greater<ll>());
    
    ll ok = 1e10;
    ll ng = 0;

    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
}   

Measured memory_bytes: 1792
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tempmin = 10**5

for i,h in enumerate(h,1):
    temp = abs(a-(t-h*0.006))
    if tempmin > temp:
        ans = i
        tempmin = temp

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> P(N,0);
	vector< vector<int> > G(N);
	for(int i =1; i < N; i++) {
		cin >> P[i];
		G[--P[i]].push_back(i);}
	vector< pair<int,int> > X(N);
	for(int i =0; i < N; i++) cin >> X[i].ff;
	for(int i =N-1; i >= 0; i--) {
		vector<int> cov(X[i].ff+1,0);
		cov[0] =1;
		ALL_THE(G[i],it) {
			vector<int> cov_nw(X[i].ff+1,0);
			for(int j =X[i].ff; j >= 0; j--) if(cov[j]) {
				if(j+X[*it].ff <= X[i].ff) cov_nw[j+X[*it].ff] =1;
				if(j+X[*it].ss <= X[i].ff) cov_nw[j+X[*it].ss] =1;}
			cov =cov_nw;}
		bool ok =false;
		for(int j =X[i].ff; j >= 0; j--) if(cov[j]) {
			X[i].ss =-j;
			ALL_THE(G[i],it) X[i].ss +=X[*it].ff+X[*it].ss;
			ok =true;
			break;}
		if(!ok) {
			cout << "IMPOSSIBLE\n";
			return 0;}
		}
	cout << "POSSIBLE\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int main()
{
    int sum, bks;
    while(cin >> sum && sum) {
        bks = 0;
        for(int i = 0; i < 9; i++) {
            int tmp;
            cin >> tmp;
            bks += tmp;
        }
            
        cout << (sum - bks) << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define INF 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define print(v); for(auto x:v) cout<<x<<" "; cout<<endl;
typedef long long int ll;
int main()
{
    string str;
    cin >> str;
    ll q;
    cin >> q;
    deque<char> deq;
    for(ll i = 0; i < str.length(); i++){
        deq.pb(str[i]);
    }
    ll flag = 0;
    while(q--){
        ll t; cin >> t;
        // cout << "flag: " << flag << endl;
        if(t == 1){
            // cout << "before flag: " << flag << endl;
            flag = flag ^ 1;
            // cout << "after flag: " << flag << endl;
            continue;
        }
        ll f; char c;
        cin >> f >> c;
        if(flag == 0){
            if(f == 1){
                deq.push_front(c);
            }
            else{
                deq.pb(c);
            }
        }
        else if(flag == 1){
            if(f == 1){
                deq.pb(c);
            }
            else{
                deq.push_front(c);
            }
        }
    }
    if(flag == 0){
        while(!deq.empty()){
            char x = deq.front();
            deq.pop_front();
            cout << x;
        }
    }
    if(flag == 1){
        while(!deq.empty()){
            char x = deq.back();
            deq.pop_back();
            cout << x;
        }
    }

    return 0;
}

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

int main(){

  int N=0;
  
  cin>>N;
  
  std::set<string> S;
  std::map<std::string, int> mp;
  
  string ts;
  
  rep(i,N){

    cin>>ts;

    if(i==0){
      S.insert(ts);
      mp[ts]=1;
      continue;
    }
    
    if(S.count(ts)==1){

      mp[ts]++;
      
    }
    else if(S.count(ts)==0){
    	
      S.insert(ts);
      mp[ts]=1;
      
    }
    
    
  }//end of N
  
  //check the maximum count in map
  int max=-1;
  std::set<string> maxS;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
  
    int count=itr->second;
    if(count>max){
      max=count;
    }
  
  }
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {

    //cout<<"key = "<<itr->first<<", value = "<<itr->second<<endl;
    
    int count=itr->second;
    if(count==max){
      string k=itr->first;
      maxS.insert(k);
    }
    
//    std::cout << "key = " << itr->first           // キーを表示
  //                      << ", val = " << itr->second << "\n";    // 値を表示
  }
  
  
  for(auto itr = maxS.begin(); itr != maxS.end(); ++itr) {
  
    string k=*itr;
    cout<<k<<endl;
  
  }
  
  
  
}

Measured memory_bytes: 43904
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,l;
	cin >> k;
	string s;
	cin >> s;
	l=s.length();
	if(l<=k)
	cout << s;
	else
	{
		for(int i=0;i<k;i++)
		cout << s[i];
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3628
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N, M, K, ans,mi,A,B,C,D;
string s;

bool my_compare(pair<LL,LL> a, pair<LL, LL> b) {
	if (a.first != b.first) {
		return a.first < b.first; 
	}

	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return false;
	}
}
int main() {
	cin >> N;
	LL a, b;
	vector<pair<LL, LL>>ab(N);
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		ab[i] = make_pair(b, a);
	}
	sort(ab.begin(), ab.end(), my_compare);
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (ans + ab[i].second <= ab[i].first) {
			ans += ab[i].second;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;

}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 100010

int n, m;
vector<pair<int, int>> adj[MAX];
vector<int> dist(MAX, -INF);
vector<bool> visited(MAX, false);

bool bfs(int i, int d) {
    if(visited[i] && d != dist[i]) return false;
    if(visited[i] && d == dist[i]) return true;

    visited[i] = true;
    dist[i] = d;

    for(int j = 0; j < adj[i].size(); j++) {
        if(!bfs(adj[i][j].first, d + adj[i][j].second)) return false;
    }

    return true;
}

signed main() {
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int l, r, d; cin >> l >> r >> d;
        l--; r--;
        adj[l].push_back(pair<int, int> (r, d));
        adj[r].push_back(pair<int, int> (l, -d));
    }

    for(int i = 0; i < n; i++) {
        if(!visited[i]) {
            if(!bfs(i, 0)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 16512
while True:
    n = int(input())
    if n == 0:
        break
    num = 2
    cnt = 0
    while True:
        ini = num * (num + 1) // 2
        if n < ini:
            break
        while ini <= n:
            if ini == n:
                cnt += 1
                break
            ini += num

        num += 1

    print(cnt)

Measured memory_bytes: 7532
def main():
	n=int(input())
	a=list(map(int, input().split()))
	count=0
	for i in range(n):
		if a[i]%2==0:
			if a[i]%3==0 or a[i]%5==0:
				count = count
				
			else:
				count +=1
			
	if count>0:
		print('DENIED')
	else:
		print('APPROVED')
main()

Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int X = sc.nextInt();
      	if(400<= X && X < 600){
        System.out.println(8);
        }else if(600 <= X && X < 800){
        	System.out.println(7);
        }else if(800<=X && X < 1000){
        	System.out.println(6);
        }else if(1000<=X && X<1200){
        	System.out.println(5);
        }else if(1200<=X && X<1400){
        	System.out.println(4);
        }else if(1400<=X && X<1600){
        	System.out.println(3);
        }else if(1600<=X && X<1800){
        	System.out.println(2);
        }else if(1800<=X && X<2000){
        	System.out.println(1);
        }
    }
}

Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while (true){
    C -= B;
    if (C <= 0){
      cout << "Yes";
      break;
    }
    A -= D;
    if (A <= 0){
      cout << "No";
      break;
    }
  }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int x, y;
int main() {
	cin >> x >> y;
	if(x == 1 && y == 1) {
		puts("1000000");
		return 0;
	}
	int sum = 0;
	if(x == 1) sum += 300000;
	 if(x == 2) sum += 200000;
	 if(x == 3) sum += 100000;
	 if(y == 1) sum += 300000;
	 if(y == 2) sum += 200000;
	 if(y == 3) sum += 100000;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    int odd = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a % 2 == 1){
            ++odd;
        }
    }
    if(odd % 2 == 1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
 
min = len(T)
for t in range(len(S) - len(T)+1):
    tmp = 0
    for i in range(len(T)):
        if S[i+t] != T[i]:
            tmp+=1
    
    if tmp < min:
        min = tmp
 
print(min)

Measured memory_bytes: 9084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

int a,b,c,k;

cin >> a >> b >> c >> k;

if (a >= b && a > c)
{
   int sum = a;
   rep(i,k){
      sum *= 2;
   }
   cout << sum+b+c << endl;

}else if (b > a && b >= c)
{
   int sum = b;
   rep(i,k){
      sum *= 2;
   }
   cout << sum+a+c << endl;
}else
{
   int sum = c;
   rep(i,k){
      sum *= 2;
   }
   cout << sum+a+b << endl;
}








//////////////////////////////////////////////////////
return 0;}

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

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

  int w;
  if (a > b) {
    w = a;
    a = b;
    b = w;
  }
  if (a > c) {
    w = a;
    a = c;
    c = w;
  }
  if (b > c) {
    w = b;
    b = c;
    c = w;
  }

  cout << a << " " << b << " " << c << endl;
  
  return 0;
}


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

int main() {
 int n,m;
 cin >> n >> m;
 vector<int> a(m);
 rep(i,m) cin >> a[i];
 int count = 0;
 rep(i,m){
   count += a[i];
 }
int ans = n - count;
if(ans < -1){
  cout << "-1" << endl;
}
else{
  cout << ans << endl;
}
}

Measured memory_bytes: 3648
# coding: utf-8
# Your code here!
num1 = []
num1 = input().split(" ")
ans=int(num1[0])
count=int(num1[1])
#print(count)

if count != 0 and count != 1:
    num2 = []
    num2 = input().split(" ")
#print(num2)

    num3 = []
    for i in range(count):
        num3.append(int(num2[i]))
    num3.sort()
#print(num3)
#print(ans)
    up=1
    down=1
    for i in range(count//2+3):
        if up == 1 and down == 1:
            num_up=ans+i
            num_down=ans-i
            up=0
            down=0
        elif up ==1:
            print(num_down)
            break
        elif down == 1:
            print(num_up)
            break
        else:
            print(num_down)
            break
        
        for k in range(count):
            if num_up == num3[k]:
                up=1
            #print("up")
            if num_down == num3[k]:
                down=1
                #print("down")
elif count ==0:
    print(ans)
elif count ==1:
    num2=int(input())
    #print(num2)
    if ans == num2:
        print(num2-1)
    else:
        print(ans)


Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(void)
{
    int n;
    cin >> n;
    cout << (double)((n + (2 - 1)) / 2)/n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashSet;
import java.util.Set;

import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		String order, moji;
		HashSet<String> set = new HashSet<String>();
		for (int i = 0; i < n; i++)
		{
			order = sc.next();
			moji = sc.next();
			if(order.equals("insert"))
			{
				set.add(moji);
			}
			else
			{
				if(set.contains(moji))
				{
					System.out.println("yes");
				}
				else
				{
					System.out.println("no");
				}
			}
		}
		sc.close();
	}
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	ll N, M;
	cin >> N >> M;
	if (N * 2 > M)cout << M / 2 << endl;
	else {
		M -= N * 2;
		if (M >= 4) {
			N += M / 4;
		}
		cout << N << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	ll n;
	cin>>n;
	ll x,y;
	ll arr[n];
	for(int a=0;a<n;a++)
	{
		cin>>arr[a];
	}
	sort(arr,arr+n);
	if(arr[0]==0)
	{
		cout<<0;
		return 0;
	}
	x=1;
	y=1;
	for(int a=0;a<n;a++)
	{
		x*=arr[a];
		if(x>1000000000000000000)
		{
			cout<<-1;
			return 0;
		}
		if(x<y)
		{
			cout<<-1;
			return 0;
		}
		y=x;
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 4408
#ifndef _WIN32
#include<iostream>
#endif

using namespace std;
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>

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

typedef vector<int> V;
typedef vector<V> VV;

VV wrap(VV vs,int c) {
	int R = vs.size();
	int C = vs[0].size();
	VV ret(R + 2, V(C + 2, c));
	REP(i, R)REP(j, C)ret[i + 1][j + 1] = vs[i][j];
	return ret;
}
const int dr[] = { 0,0,-1,1 ,1,1,-1,-1};
const int dc[] = { -1,1,0,0, -1,1,-1,1};
VV g;
void dfs(int r,int c) {
	if (g[r][c] == 0)return;
	//cout << "(" << r << "," << c << ")";
	g[r][c] = 0;
	REP(i, 8) {
		int nr = r + dr[i];
		int nc = c + dc[i];
		dfs(nr, nc);
	}
}
int main() {
	int R, C;
	while (cin >> C >> R, C + R) {
		VV in(R,V(C));
		REP(i, R)REP(j,C)cin >> in[i][j];
		g = wrap(in,0);
		int res = 0;
		REP(i, R)REP(j, C) {
			if (g[i + 1][j + 1]) {
				res++;
				dfs(i + 1, j + 1);// cout << endl;
			}
		}

		cout << res << endl;
	}


}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int INF=1e9;

int main(){
	int N;
	cin >> N;
	vector<int> m;
	m.emplace_back(1);
	int num=1;
	while(num<=N){
		num*=6;
		m.emplace_back(num);
	}
	num=1;
	while(num<=N){
		num*=9;
		m.emplace_back(num);
	}
	vector<int> dp(N+1,INF);
	dp[0]=0;
	for(int i=1; i<=N; i++){
		rep(j,m.size()){
			int p=m[j];
			if(i<p) continue;
			dp[i]=min(dp[i],dp[i-p]+1);
		}
	}
	cout << dp[N] << endl;

	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll h,w, m;
	cin >>h >>w >>m;
	vector<pii> yx(m);
	rep(i, m) cin >>yx[i].first >>yx[i].second;
	set<ll> st;
	VL smh(h+3), smw(w+3);
	for(auto& z:yx){
		st.insert(z.first *w + z.second);
		smw[z.second]++;
		smh[z.first]++;
	}
	
	auto ck=[&](ll a, ll b){
		return st.count(a*w +b) > 0;
	};

	vector<pii> srh, srw;
	rep(i, h+1) srh.emplace_back(smh[i], i);
	rep(i, w+1) srw.emplace_back(smw[i], i);
	
	sort(srh.rbegin(), srh.rend());
	sort(srw.rbegin(), srw.rend());
	
	ll mx = srh[0].first + srw[0].first;
	int ct = 0;
	rep(i, sz(srh)){
		rep(j, sz(srw)){
			ll kei = srh[i].first + srw[j].first;
			if(kei < mx) break;
			if(!ck(srh[i].second, srw[j].second)){
				cout << mx <<"\n"; return 0;
			}
			if(++ct > m+1){
				cout << mx <<"\n"; return 0;
			}
			
		}
	}
	
	cout << mx-1 <<"\n";
	
	return 0;
}



Measured memory_bytes: 32688
s = input()
n = {'a': 0, 'b': 0, 'c': 0}
for c in s:
    n[c] += 1

import sys
if len(s) == 1:
    print('YES')
    sys.exit(0)

min = int(len(s)/3)
val = list(n.values())
val.sort()
if len(s)%3 == 0:
    if val == [min, min, min]:
        print('YES')
    else:
        print('NO')
elif len(s)%3 == 1:
    if val == [min, min, min+1]:
        print('YES')
    else:
        print('NO')
elif len(s)%3 == 2:
    if val == [min, min+1, min+1]:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int height[n];
	for(int i=0; i<n; i++)
	{
		cin>>height[i];
	}
	int flag  = 1;
	for(int i=1; i<n; i++)
	{
		 if(height[i-1]<height[i])
		 {
			height[i]-=1;
		 }
		 if(height[i-1]>height[i]){
				flag = 0;
				break;
		}
	}
	if(flag==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#define eps 1e-14
using namespace std;
double f_pow(double x,int n){
	double res=1;
	while(n--)res*=x;
	return res;
}

struct Man{
	double p,t,v;
	void get(){
		scanf("%lf%lf%lf",&p,&t,&v);
		p/=100;
	}
};
Man man[200];
int N,M;
double L;
double tim[200][61],tsum[200][61];
double rate[200][61];
double C[61][61];
void get_C(){
	int i,j;
	C[0][0]=1;
	C[1][0]=C[1][1]=1;
	for(i=2;i<61;i++){
		C[i][0]=C[i][i]=1;
		for(j=1;j<i;j++){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	}
}
void get_data(){
	scanf("%d%d%lf",&N,&M,&L);
	int i;
	for(i=0;i<N;i++)man[i].get();
}
void get_tim(){
	int i,j;
	for(i=0;i<N;i++){
		rate[i][0]=f_pow(1-man[i].p,M);
		if(man[i].v<eps)tim[i][0]=2000000000;
		else tim[i][0]=L/man[i].v;
		for(j=1;j<=M;j++){
			if(M-j>=j)rate[i][j]=C[M][j]*f_pow(man[i].p*(1-man[i].p),j)*f_pow(1-man[i].p,M-j-j);
			else rate[i][j]=C[M][j]*f_pow(man[i].p*(1-man[i].p),M-j)*f_pow(man[i].p,j+j-M);
			tim[i][j]=tim[i][j-1]+man[i].t;
		}
		tsum[i][M]=rate[i][M];
		for(j=M-1;j>=0;j--)tsum[i][j]=tsum[i][j+1]+rate[i][j];
	}
}
double bina(int ren,double t){
	int h=M,l=0,mid;
	while(h>l){
		mid=(h+l)>>1;
		if(tim[ren][mid]<t+eps)l=mid+1;
		else h=mid;
	}
	return tsum[ren][h];
}
double get_win(int winner,double t){
	int i;
	double res=1;
	for(i=0;i<N;i++){
		if(i==winner)continue;
		if(tim[i][M]<t+eps)return 0;
		res*=bina(i,t);
	}
	return res;
}
void run(){
	int i,j;
	double sum;
	for(i=0;i<N;i++){
		if(man[i].v<eps){
			printf("0.0000000000\n");
			continue;
		}
		sum=0;
		for(j=0;j<=M;j++){
			sum+=rate[i][j]*get_win(i,tim[i][j]);
		}
		printf("%.9lf\n",sum);
	}
}
int main(){
	get_C();
	get_data();
	get_tim();

	run();
	return 0;
}

Measured memory_bytes: 0
x,y = map(int,input().split())
if abs(x-y) <= 1:
    print("Brown")
else:
    print("Alice")
# a:x+y >1 , abs(x-y)>1
# b:x+y >1 , abs(x-y) <=1
# c:x+y <=1, (abs(x-y) <=1  )　--> lose
#
#       c <--- a <---> b
#       a <---> a


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll n, a, b, c, x;

int main()
{
    while (cin >> n >> a >> b >> c >> x)
    {
        if (n == 0)
            return 0;
        vector<ll> y(n);

        for (int i = 0; i < n; i++)
            cin >> y[i];

        ll ans = 0;

        for (int i = 0; i < n && ans <= 10001; i++, x = (a * x + b) % c, ans++)
        {
            while (x != y[i])
            {
                if (ans > 10001)
                    break;
                ans++;
                x = (a * x + b) % c;
            }
        }

        if (ans > 10001)
            cout << -1 << endl;
        else
            cout << ans - 1 << endl;
    }
}


Measured memory_bytes: 3024
class Counter(dict):
    def __missing__(self, i):
        return 0


n = int(input())

counter = Counter()
for x in map(str, range(1, n+1)):
    head = x[0]
    tail = x[-1]
    counter[(head, tail)] += 1

ans = 0
for (head, tail), cnt in counter.items():
    ans += cnt * counter[(tail, head)]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int cond[MAX], n;
stack<int> S;

void set(int m)
{
	int u, v;
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
}

void dfs(int x, int id)
{
	S.push(x);
	cond[x] = id;

	int i, v;
	while (!S.empty()) {
		int u = S.top();
		S.pop();
		for (i = 0; i < (int)G[u].size(); i++) {
			v = G[u][i];			
			if (cond[v] == 0) {				
				cond[v] = id;
				S.push(v);
			}
		}
	}
}

void searchFriends()
{
	int id = 1;
	for (int i = 0; i < n; i++)
		if (cond[i] == 0) dfs(i, id++);
}

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

	int m, q, u, v;
	cin >> n >> m;

	set(m);
	searchFriends();

	cin >> q;
	
	for (int i = 0; i < q; i++) {
		cin >> u >> v;
		if (cond[u] != 0 && cond[v] != 0 && cond[u] == cond[v])
			cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 7076