akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int dp[] = new int[3];
    for (int day = 1; day <= n; day++) {
      int new_dp[] = new int[3];
      int[] c = new int[3];
      for (int i = 0; i < 3; i++)
        c[i] = sc.nextInt();
      Arrays.fill(new_dp, 0);
      for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) {
          if (i != j) {
            new_dp[i] = Math.max(new_dp[i], dp[j] + c[i]);
          }
        }
      for (int i = 0; i < 3; i++)
      dp[i] = new_dp[i];
    }
    System.out.println(Math.max(dp[0],Math.max(dp[1],dp[2])));
  }
}

Measured memory_bytes: 88060
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		vint v(7,0);
		rep(i,n){
			int a;
			cin>>a;
			a/=10;
			if(a>=6){
				v[6]++;
			}
			else{
				v[a]++;
			}
		}
		rep(i,7){
			cout<<v[i]<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1192
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int n = sc.nextInt();
		int[] counts = new int[8];
		int over = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int idx = x / 400;
			if (idx >= 8) {
				over++;
			} else {
				counts[idx]++;
			}
		}
		int types = 0;
		for (int i = 0; i < counts.length; i++) {
			if (counts[i] != 0) {
				types++;
			}
		}
		int max = types + over;
		int min = Math.max(types, 1);
		System.out.println(min + " " + max);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    //freopen("","r",stdin);
    //freopen("","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);/*syn加速*/
	n=read();m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int h,w; cin >> h >> w;
    string s[h];
    rep(i,0,h){
        cin >> s[i];
    }
    int ue[h][w],sita[h][w], migi[h][w], hidari[h][w];
    rep(i,0,w){
        for(int j = h-1; j >= 0; j--){
            ue[j][i] = 0;
            if(s[j][i] == '.') {
                if(j == h-1) ue[j][i] = 1;
                else ue[j][i] = ue[j+1][i] + 1;
            }
        }
    }
    rep(i,0,w){
        rep(j,0,h){
            sita[j][i] = 0;
            if(s[j][i] == '.') {
                if(j == 0) sita[j][i] = 1;
                else sita[j][i] = sita[j-1][i] + 1;
            }
        }
    }
    rep(j,0,h){
        rep(i,0,w){
            migi[j][i] = 0;
            if(s[j][i] == '.'){
                if(i == 0) migi[j][i] = 1;
                else migi[j][i] = migi[j][i-1] + 1;
            }
        }
    }
    rep(j,0,h){
        for(int i = w-1; i >= 0; i--){
            hidari[j][i] = 0;
            if(s[j][i] == '.'){
                if(i == w-1) hidari[j][i] = 1;
                else hidari[j][i] = hidari[j][i+1] + 1;
            }
        }
    }

    int ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j] == '.'){
                ans = max(ans, ue[i][j]+sita[i][j]+migi[i][j]+hidari[i][j] -3);
            }
        }
    }
    cout << ans << "\n";
}

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

 using namespace std;

 int main() {
   string s;
   int i;

   cin >> s;

   if (s.length() % 2 == 0) {
     for (i = 0; i < s.length() / 2; i++) cout << s.at(2 * i);
     cout << endl;
   }

   else {
     for (i = 0; i <= s.length() / 2; i++) cout << s.at(2 * i);
     cout << endl;
   }

 }


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

int main() {
    int n,tem;
    cin>>n;
    int a[n]={0};
    rep(i,n-1) {
        cin>>tem;
        tem--;
        a[tem]++;
    }
    rep(i,n)cout << a[i] <<endl;
}

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




int main(){
    ll N,A,B;cin>>N>>A>>B;
    ll ko=N/(A+B);
    cout<<ko*A+min(N%(A+B),A);
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for (int i = 0;; ++i){
		if (i*i > N){
			cout << (i-1)*(i-1) << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int n; li m; cin >>n >>m;
  if(n==3){
    print(1,2);
    return 0;
  }
  int a=0,b=n/2-1;
  while(m--){
    print(a+1,b+1);
    a++; b--; if(a>=b)break;
  }
  a=n-1,b=n/2+1-n%2;
  if(m==-1)return 0;
  if(df)print(m);
  while(m--){
    print(a+1,b+1);
    a--;b++;
  }
}





Measured memory_bytes: 3668
#include <stdio.h>
int main(void){
    int n,m,l;
    int i,j,k;
    int a[110][110],b[110][110];
    long int c[110][110]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j!=0){
                printf(" ");
            }
            printf("%ld",c[i][j]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    int K;
    cin >> N >> K;
    vector<ll> X(N);
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
        ans += 2 * min(K - X[i], X[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
cnt = 0

for ax in 0..a
    for bx in 0..b
        for cx in 0..c
            cnt += 1 if ax * 500 + bx * 100 + cx * 50 == x
        end
    end
end

puts cnt

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>
#include <set>
#include <utility>
typedef long long ll;

using namespace std;

int main() {
	int a, p;
	cin >> a >> p;
	
	cout << (a * 3 + p) / 2 << endl;
	
    return 0;
}

Measured memory_bytes: 256
// Your code here!
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    input_lines = line.split(" ")
});
reader.on('close', () => {
var  result = input_lines[0]*input_lines[1];
//console.log(result);
  if(result % 2 === 0){
    console.log("Even");
  }
  else{
    console.log("Odd");
  }
});




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

using namespace std;

typedef long long ll;

const int MAX = 1e5+7;

int a[MAX][3],dp[MAX][3];

int main()
{
	int n;scanf("%d", &n);
	for(int i = 0; i<n; ++i)
		scanf("%d%d%d", &a[i][0], &a[i][1], &a[i][2]);
	
	dp[0][0] = a[0][0],dp[0][1] = a[0][1], dp[0][2] = a[0][2];
	
	for(int i = 1; i<n; ++i)
	{
		for(int j = 0; j<3; ++j)
			for(int k = 0; k<3; ++k)
				if(j!=k)dp[i][j] = max(dp[i][j],dp[i-1][k] + a[i][j]);
	}	
	printf("%d\n", max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
	
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int N,K;
vector<ll> A;

bool judge(int mid){
    int mit=mid-1;
    if(A[mit]>=K) return true;

    bool dp[N+1][K+1]={};
    dp[0][0]=true;
    int n=0;
    for(int i=0;i<N;i++){
        if(A[i]>=K) break;

        n++;
        if(i==mit){
            for(int j=0;j<K;j++){
                dp[i+1][j]=dp[i][j];
            }
            continue;
        }

        for(int j=0;j<K;j++){
            if(dp[i][j]){
                if(j+A[i]<K) dp[i+1][j+A[i]]=true;
                dp[i+1][j]=true;
            }
        }
    }

    for(int j=0;j<K;j++){
        if(dp[n][j]){
            if(j+A[mit]>=K) return true;
        }
    }
    return false;
}

int main(){
  cin>>N>>K;
  A.resize(N);
  for(int i=0;i<N;i++) cin>>A[i];

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

  int ok=N+1,ng=0;
  while(ok-ng>1){
      int mid=(ok+ng)/2;
      if(judge(mid)) ok=mid;
      else ng=mid;
  }

  cout<<ng<<endl;

  return 0;
}


Measured memory_bytes: 24704
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main(){
    int A,B; cin >> A >> B;
    int An = 1;
    if (B == 100) B += 1;
    rep(i,0,A) An *= 100;
    cout << B*An;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define CR cerr<<endl;
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
signed main(){
	int N, K; cin >> N >> K;
	cout << N%K << endl;
}

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

namespace ITP1_9_D
{
	class Program
	{
		static void Main(string[] args)
		{
			string str = Console.ReadLine();
			List<string> output = new List<string>();

			int q = int.Parse(Console.ReadLine());
			for(int i = 0; i < q; i++) {
				string[] cmd = Console.ReadLine().Split(' ');

				switch(cmd[0]) {
				case "print":
					Print(str, cmd, output);
					break;
				case "reverse":
					str = Reverse(str, cmd);
					break;
				case "replace":
					str = Replace(str, cmd);
					break;
				}
			}

			foreach(string s in output) {
				Console.WriteLine(s);
			}
		}

		static void Print(string str, string[] cmd, List<string> output)
		{
			int a = int.Parse(cmd[1]);
			int b = int.Parse(cmd[2]);

			output.Add(str.Substring(a, b - a + 1));
		}

		static string Reverse(string str, string[] cmd)
		{
			int a = int.Parse(cmd[1]);
			int b = int.Parse(cmd[2]);

			string rev = string.Join(string.Empty, str.Substring(a, b - a + 1).Reverse());
			char[] str_c = str.ToCharArray();
			char[] rev_c = rev.ToCharArray();
			for(int i = a, j = 0; i <= b; i++, j++) {
				str_c[i] = rev_c[j];
			}

			return new string(str_c);
		}

		static string Replace(string str, string[] cmd)
		{
			int a = int.Parse(cmd[1]);
			int b = int.Parse(cmd[2]);

			char[] str_c = str.ToCharArray();
			char[] rep_c = cmd[3].ToCharArray();

			for(int i = a, j = 0; i <= b; i++, j++) {
				str_c[i] = rep_c[j];
			}

			return new string(str_c);
		}
	}
}



Measured memory_bytes: 20320
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int num[5];
	int k;
	bool flag=true;
	for(int i=0;i<5;i++){
		cin >> num[i];
	}
	cin >> k;
	((num[4]-num[0])<=k) ? cout << "Yay!" << endl: cout << ":(" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N ((1<<17)+1)
int a[9][N];
int b[8] = {0, 1, 3, 2, 2, 3, 1, 0};
int c[4] = {2, 0, 1, 3};
int d[N] = {};

int x[N];
int y[20];

int main(){
	a[0][0]=0;
	a[0][1]=1;
	FOR(i, 1, 9){
		int n = 1<<(i*2+1);
		REP(j, n){
			a[i][j]=a[i-1][j/4]*4;
			if(j < n-4){
				a[i][j] += b[j%8];
			}else{
				a[i][j] += c[j%4];
			}
		}
	}
	REP(i, 17){
		int k = 1<<i;
		REP(j, N) {
			int t = (j>>i)&3;
			if(t==1 || t==2){
				d[j]|=k;
			}
		}
	}

	int n, p, q; scanf("%d%d%d", &n, &p, &q);
	q^=p;
	int s=0, t=n;
	REP(i, n){
		if(q&(1<<i)){
			y[s++]=i;
		} else {
			y[--t]=i;
		}
	}
	t = n-s;
	if(s%2==0){
		printf("NO\n");
		return 0;
	}
	int m = (1<<t)-1;
	REP(i, 1<<n){
		x[i] = a[s/2][i>>t];
		int j = i&m;
		if((i>>t)&1){
			j = m^j;
		}
		x[i]|= (d[j]&m)<<s;
	}
	printf("YES\n");
	REP(i, 1<<n){
		int ans = 0;
		REP(j, n){
			if(x[i]&(1<<j)){
				ans |= 1<<y[j];
			}
		}
		ans ^= p;
		if(i) printf(" ");
		printf("%d", ans);
	}
	printf("\n");
}






Measured memory_bytes: 4736
#include <stdio.h>
int main() {
              int a,b,c,d,s;
              scanf("%d",&a);
        
              b = a/3600;
			  s = a%3600;
			  c = s/60;
              d = s%60; 
              printf("%d:%d:%d\n",b,c,d);
              return 0;
			  }

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

redPoints = []
bluePoints = []

for i in range(n):
    redPoints.append([int(x) for x in input().split(" ")])
for i in range(n):
    bluePoints.append([int(x) for x in input().split(" ")])
# deletation
for bluePoint in bluePoints:
    if bluePoint[0] == 0 or bluePoint[1] == 0:
        bluePoints.remove(bluePoint)

result = 0
bluePoints = sorted(bluePoints)
redPoints = sorted(redPoints, key=lambda x: -x[1])
for bluePoint in bluePoints:
    for redPoint in redPoints:
        # print("See:", redPoint, bluePoint)
        if redPoint[0] < bluePoint[0] and redPoint[1] < bluePoint[1]:
            result += 1
            redPoints.remove(redPoint)
            # print(redPoint, " is inner of ", bluePoint)
            break

print(result)


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

def main():
	H, N = MAP()
	A, B = [0]*N, [0]*N
	for i in range(N):
		A[i], B[i] = MAP()

	dp = [[INF]*(H+1) for _ in range(N+1)]
	dp[0][0] = 0


	for i in range(N):
		for j in range(H+1):
			if j < A[i]:
				dp[i+1][j] = min(dp[i][j], B[i])
			if j>= A[i]:
				dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]]+B[i])
			

	#for i in range(N+1):
	#	print(dp[i])

	print(dp[N][H])

if __name__ == '__main__':
	main()





Measured memory_bytes: 286940
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int a = X / 500;
    int b = (X % 500) / 5;
    System.out.println(a * 1000 + b * 5);
  }
}


Measured memory_bytes: 22996
#include<iostream>
#include<map>
using namespace std;
int main(){
	int x;
	cin>>x;
	int n;
	cin>>n; 
	map<int,int>rec;
  	for(int i=0;i<n;++i){
  		int t;
		cin>>t;
  		++rec[t];
	}
	int d=0;
	while(1){
		if(!rec[x-d]){
			cout<<x-d<<endl;
			break;
		}
		if(!rec[x+d]){
			cout<<x+d<<endl;
			break;
		}
		++d;
	}
	return 0;
}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;
using vivi = vector<vi>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
    //setIO("input.txt", "output.txt");

    string s;
    cin >> s;
    int n = sz(s);
    if (s[n - 1] == 's') s += "es";
    else s += "s";
    cout << s;
}

Measured memory_bytes: 3660
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]
dst[sh][sw] = 0

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] == -1 or d < dst[nh][nw]:
            dq.appendleft((nh, nw, d))
            dst[nh][nw] = d

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        if dst[nh][nw] == -1 or d + 1 < dst[nh][nw]:
            dq.append((nh, nw, d + 1))
            dst[nh][nw] = d + 1

print(dst[eh][ew])


Measured memory_bytes: 95476
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
CB=[]
for i in range(M):
  B,C=map(int,input().split())
  CB.append([C,B])
CB.sort(reverse=True)

idx=0
for C,B in CB:
  for i in range(B):
    if not idx>=len(A) and A[idx]<C:
      A[idx]=C
      idx+=1
    else:
      break
print(sum(A))


Measured memory_bytes: 94456
(* O(n log n) *)
let kNMax = 200000 in
Scanf.scanf " %d %d" @@ fun n k ->
  let balls = Array.make (kNMax + 1) 0 in
  for i = 1 to n do
    let a = Scanf.scanf " %d" @@ (+) 0 in
    balls.(a) <- balls.(a) + 1
  done;
  let c = ref 0 in
  Array.iteri (fun i b -> if b > 0 then incr c) balls;
  Printf.printf "%d\n" @@
  (Array.sort (fun x y -> y - x) balls;
  Array.sub balls k (kNMax + 1 - k) |> Array.fold_left (+) 0)

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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (int &pi: p) cin >> pi;
    vector<int> q(p);
    sort(q.begin(), q.end());
    int cnt = 0;
    for (int i = 0; i < n; i++) cnt += p[i] != q[i];
    cout << (cnt <= 2 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(){
  int a[5], x=10, t, id=0, ans=0;
  for(int i=0;i<5;i++){
    cin >> a[i];
    t=a[i]%10;
    if(t!=0&&x>t){
      id=i;
      x=t;
    }
  }
  for(int i=0;i<5;i++){
    if(i==id)ans+=a[i];
    else{
      if(a[i]%10==0)ans+=a[i];
      else ans+=a[i]/10*10+10;
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define ll long long
#define ull unsigned long long

int a, b, c, k;

void solve() {
    cin >> a >> b >> c >> k;
    bool ok=0;
    for(int i=0; i<k; ++i) {
        if(c<=b)
            c*=2;
        else if(b<=a)
            b*=2;
    }
    if(a<b&&b<c)
        puts("Yes");
    else
        puts("No");
}

int main() {
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 3652
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int a,b;
	cin >> a >> b;
	cout << abs(6-a-b);
	return 0;
}

Measured memory_bytes: 892
import time
import copy

def BubbleSort(A, N):
    flag = 1
    while flag:
        flag = 0
        for j in reversed(range(1, N)):
            if A[j]['value']<A[j-1]['value']:
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1
    return A

def SelectionSort(A, N):
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j]['value']<A[minj]['value']:
                minj = j
        if i!=minj:
            A[i], A[minj] = A[minj], A[i]
    return A

def IsStable(answer, target):
    N = len(answer)
    for i in range(N):
        if answer[i]['body'] != target[i]['body']:
            return False
    return True

# Stable Sort
def main():
    N = int(input())
    A = list(
        map(lambda x: {'body': x, 'value': int(x[1])}, input().split())
    )
    A_sortby_bubble = copy.deepcopy(A)
    A_sortby_select = copy.deepcopy(A)
    A_sortby_bubble = BubbleSort(A_sortby_bubble, N)
    A_sortby_select = SelectionSort(A_sortby_select, N)
    print(' '.join(map(lambda x: x['body'],A_sortby_bubble)))
    print('Stable')
    print(' '.join(map(lambda x: x['body'], A_sortby_select)))
    if IsStable(A_sortby_bubble, A_sortby_select):
        print('Stable')
    else:
        print('Not stable') 
    
main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(ll i = a; i < (ll)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, T;  cin >> N >> T;
    ll ans = 0;
    vector<ll> t(N);
    rep (i, N) {
      cin >> t[i];
    }
    FOR (i, 1, N) {
      if (t[i] - t[i - 1] >= T) {
        ans += T;
      } else {
        ans += t[i] - t[i - 1];
      }
    }
    ans += T;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


def main():
    N, A, B = map(int, input().split())
    a = A*(N-1)+B
    b = B*(N-1)+A
    if b-a+1 >= 0:
        print(b-a+1)
    else:
        print(0)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n, k;
    cin >> n >> k;
    vll h(n);
    rep(i, n) cin >> h[i];

    ll count = 0;
    rep(i, n){
        if(h[i]>=k) ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
 
class MainClass {
  public static void Main (string[] args) {
    //入力3
    var list = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var A = list[0];
    var B = list[1];
    var C = list[2];


    var m = A % B;
    if(m == C){
      Console.WriteLine("YES");
      return;
    }
    for(var i = 2; ; ++i){
      if(A * i % B == C){
        Console.WriteLine("YES");
        return;
      }else if(A * i % B == m){
        Console.WriteLine("NO");
        return;
      }
    }
    
  }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("in.txt","r",stdin);
   freopen("out.txt","w",stdout); 
   #endif
} 

int main(){
   //Fast_IO();
   ll x,n;
   cin>>x>>n;
   vector<ll>v;
   map<ll,ll>m;
   f(i,0,n){
      ll k;
      cin>>k;
      v.pb(k);
      m[k]++;
   }
   ll ans=0,diff=mod;
   f(i,0,200){
      if(m[i]==0){
         if(abs(x-i)<diff){
            diff = abs(x-i);
            ans=i;
         }
      }
   }
   cout<<ans;


   
}




Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int a[500][500];

void solve(int r, int l, int x) {
    if (r + 1 == l)
        return;
    int m = (r + l) / 2;
    for (int i = r; i < m; ++i) {
        for (int j = m; j < l; ++j) {
            a[i][j] = x;
        }
    }
    solve(r, m, x + 1);
    solve(m, l, x + 1);
}

int main() {
    int n;
    cin >> n;
    solve(0, n, 1);
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int i, c = 0;
		for(i = 1; i < k; i++) {
			int xi = sc.nextInt();
			int yi = sc.nextInt();
			if((x1 > xi && y1 < yi) || (x1 < xi && y1 > yi)) {
				c = c + Math.abs(x1 - xi) + Math.abs(y1 - yi);
				}
			else {
				c = c + Math.max(Math.abs(x1 - xi), Math.abs(y1 - yi));
				}
			x1 = xi;
			y1 = yi;
			}
		System.out.println(c);
		sc.close();
		}
	}

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


char p[11]   = { 0 };
int		n;

void calc(int idx, char *s) {
	char str[11] = {0};
	char  mm = 0;

	for (int i=0; i<n; i++) str[i] = s[i];
	
		for (int i=0; i<=idx; i++) mm = max(mm,str[i]);
	
	if (idx == n-1) {
		for (int i=0; i<n; i++) str[i] += 'a';
		cout << str << endl;
		return;
	}
	for (int i=0; i<=mm+1; i++) {
		str[idx+1] = i;
		calc(idx+1,str);
	}
}
	

int main() {
	int		a,b,c,i,j,k,m,x,y,ans = 0;
	char str[11] = { 0 };
	
	cin >> n;

	calc(0 , str);


}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  sort(all(x));
  vector<int> v;
  rep(i, m - 1) v.eb(x[i + 1] - x[i]);
  sort(all(v));
  int ans = 0;
  if (m > n) rep(i, m - n) ans += v[i];
  cout << ans << endl;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n,a;
    cin >> n >>a;
    cout << n*n - a << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String[][] encode = new String[][] { { "11", "a" }, { "12", "b" },
				{ "13", "c" }, { "14", "d" }, { "15", "e" }, { "21", "f" },
				{ "22", "g" }, { "23", "h" }, { "24", "i" }, { "25", "j" },
				{ "31", "k" }, { "32", "l" }, { "33", "m" }, { "34", "n" },
				{ "35", "o" }, { "41", "p" }, { "42", "q" }, { "43", "r" },
				{ "44", "s" }, { "45", "t" }, { "51", "u" }, { "52", "v" },
				{ "53", "w" }, { "54", "x" }, { "55", "y" }, { "61", "z" },
				{ "62", "." }, { "63", "?" }, { "64", "!" }, { "65", " " } };
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String in = sc.nextLine();
			boolean na;
			if (in.length() % 2 == 1) {
				System.out.println("NA");
			} else {
				na = true;
				int index = 0, i = 0;
				StringBuilder sb = new StringBuilder();
				while (index < in.length()) {
					String enc = in.substring(index, index + 2).replace(
							encode[i][0], encode[i][1]);
					if (enc.length() == 1) {
						i = 0;
						sb.append(enc);
						index += 2;
					} else {
						if (i + 1 < encode.length) {
							i++;
						} else {
							System.out.println("NA");
							na = false;
							break;
						}
					}
				}
				if (na) {
					System.out.println(sb.toString());
				} else {
					na = true;
				}
			}
		}
	}
}

Measured memory_bytes: 24788
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n), b(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> b[i];
    }
    LL ans = 0;
    for(LL i = 0; i < 30; ++i){
        LL bit = (1LL<<i);
        LL cnt = 0;
        for(LL j = 0; j < n; ++j){
            if(a[j] & bit) cnt += n;
            if(b[j] & bit) cnt += n;
        }
        vector<LL> b_masked(n);
        for(LL j = 0; j < n; ++j){
            b_masked[j] = (b[j] & (bit-1));
        }
        sort(b_masked.begin(), b_masked.end());
        for(LL v: a){
            LL req = bit - (v & (bit-1));
            auto it = lower_bound(b_masked.begin(), b_masked.end(), req);
            cnt += b_masked.end() - it;
        }
        ans |= ((cnt&1) << i);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MAX 310
#define INF 10000000000000000

long long dis[MAX][MAX];
int dis1[MAX][MAX];


int main(){
	
	for (int i=0; i<MAX; i++){
		for (int j=0; j<MAX; j++){
			if(i!=j){
				dis[i][j]=INF;
				dis1[i][j]=310;
			}
		}
	}
	
	int n,m;
	long long l;
	scanf("%d %d %lld", &n, &m, &l);
	for (int i=0; i<m; i++){
		int x,y;
		long long c;
		scanf("%d%d%lld", &x, &y, &c);
		x--;
		y--;
		dis[x][y]=min(dis[x][y],c);
		dis[y][x]=min(dis[x][y],c);
		
	}
	
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); 
			}
		}
	}
	
	for (int i=0; i<n; i++){
		for (int j=0; j<n; j++){
			//cout<<dis[i][j]<<endl;
			if (dis[i][j]<=l){
				dis1[j][j]=1;
				dis1[i][j]=1;
			}
		}
	}
	
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				dis1[i][j] = min(dis1[i][j], dis1[i][k] + dis1[k][j]); 
			}
		}
	}
	
	int q;
	scanf("%d", &q);
	while(q--){
		int from,to;
		scanf("%d%d", &from, &to);
		from--;
		to--;
		if (dis1[from][to]>305) printf("-1\n");
		else printf("%d\n", dis1[from][to]-1);
	}
}


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

int main(){
    int N;
    cin >> N;
    vector<tuple<string, int, int>> p(N);
    string s;
    int score;
    for(int i = 0; i < N; i++){
        cin >> s >> score;
        p[i] = make_tuple(s, score, i+1);
    }
    sort(p.begin(), p.end(), [](tuple<string, int, int> a, tuple<string, int, int> b){
        if(get<0>(a) == get<0>(b)) return a > b;
        else return a < b;
    });
    for(int i = 0; i < N; i++){
        cout << get<2>(p[i]) << endl;
    }
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int x,y;
  int flag=0;
  cin >> x >> y;
  for(int i =0;i<=x;i++){
    if( 2*i + 4*(x-i) == y ) flag=1;
  }
  if(flag==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,x;
    int d[214514]={};
    cin >> N >> x;
    if(x==1||x==2*N-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << Endl;
    if(N==2){
        cout << 1 << Endl << 2 << endl << 3 << endl;
        return 0;
    }
    int e=1;
    if(x==2){
        e*=-1;
    }
    int M=2*N-1;
    d[N-1]=(x)%M;
    REP(i,N){
        d[(N-1+i)]=(x+e*i+M)%M;
        d[(N-1-i)]=(x-e*i+M)%M;
    }
    
    REP(i,M){
        if(d[i]==0)d[i]=M;
        cout << d[i] << Endl;
    }
    return 0;
}   


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

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

const int N = 1e5 + 5;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	int x = min(k, a);
	ans += x;
	k -= x;
	x = min(k, b);
	k -= x;
	x = min(k, c);
	ans -= x;
	cout << ans << "\n";
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int a[5];
int main(){
	int i,j,k,p,n,m;
	for(i=1;i<=3;i++) cin>>a[i];
	for(i=1;i<=2;i++){
		for(j=i+1;j<=3;j++){
			if(a[i]>a[j]) swap(a[i],a[j]);
		}
	}
	if((a[1]+a[3])==a[2]*2) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0;i < N;i++) {
		cin >> L[i];
	}
	sort(all(L));

	ll ans = 0, a;
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N;j++) {
			auto it1 = L.begin() + j + 1;
			auto it2 = upper_bound(it1, L.end(), abs(L[i] - L[j]));
			auto it3 = lower_bound(it1, L.end(), L[i] + L[j]);
			a = it3 - it2;
			ans += max(0LL, a);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define SPEED ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define ll long long int
#define inf 999999999
#define maxn 200003
#define F first
#define S second
#define PB push_back
#define MP make_pair
const ll mod = 1e9+7;
using namespace std;
void code()
{
	int n;
	cin >> n;
	int l[n];
	for(int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	int cnt = 0;
	for(int i = 0; i < n-2; i++)
	{
		for(int j = i+1; j < n-1; j++)
		{	
			for(int k = j+1; k < n; k++)
			{
				if(!((l[i]==l[j]) || (l[j]==l[k]) || (l[k]==l[i])))
				{
					if((l[i]+l[j] > l[k]) && (l[j]+l[k] > l[i])&&(l[i]+l[k] > l[j]))
					{

//					cout << l[i] << " " << l[j] << " " << l[k] << "\n";
						cnt++;
					}
				}
			}
		}
	}
	cout << cnt;
}
int main()
{
	SPEED
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	int t = 1;
	while(t--)
	{
		code();//DEBUG
	}
}

Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Text;

namespace ITP1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                if (input.All(s => s == "0"))
                    break;
                var H = int.Parse(input[0]);
                var W = int.Parse(input[1]);
                for(int i = 0; i < H; i++)
                {
                    sb.AppendLine(new string('#', W));
                }
                sb.AppendLine();
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9516
#include<stdio.h>
#include<string.h>

#define MAX 1000000
#define MODNUM 1000000007

long long f[MAX*2+5];
long long finv[MAX+5];

long long modpow(long long a, long long n, long long mod){
	long long result = 1;
	while(n > 0){
		if(n & 1){
			result = result * a % mod;
		}
		a = a * a % mod;
		n /= 2;
	}

	return result;
}

long long modinv(long long a, long long mod){
	return modpow(a, mod - 2, mod);
}

/*
 * g(r2, c2) = f(0, 0)+...+f(0, c2)
 * 			   +f(1, 0)+...
 * 			   +f(r2, 0)+...+f(r2, c2)
 * 			 = f(1, c2)+f(2, c2)+...+f(r2,c2)+f(r2+1, c2)
 * 			 = f(0, c2)-f(0, c2)+f(1, c2)+f(2, c2)+...+f(r2,c2)+f(r2+1, c2)
 * 			 = f(r2+1, c2+1)-f(0,c2)
 * 			 = f(r2+1, c2+1)-1
 *
 * g(r2, c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1, c1-1)
 * = {f(r2+1, c2+1)-1}-{f(r2+1,c1)-1}-{f(r1, c2+1)-1}+{f(r1, c1)-1}
 * = f(r2+1, c2+1)-f(r2+1,c1)-f(r1, c2+1)+f(r1, c1)
 */

int main(){
	int r1, r2, c1, c2;
	int i;
	long long t1, t2, t3, t4, ans;

	scanf("%d %d %d %d", &r1, &c1, &r2, &c2);

	f[0] = 1;
	finv[0] = 1;
	for(i=1; i<=MAX+1; i++){
		f[i] = f[i-1] * i % MODNUM;
		finv[i] = modinv(f[i], MODNUM);
	}
	for(; i<=MAX*2+2; i++){
		f[i] = f[i-1] * i % MODNUM;
	}

	t1 = f[r2+c2+2] * (finv[r2+1] * finv[c2+1] % MODNUM) % MODNUM;
	t2 = f[r2+c1+1] * (finv[r2+1] * finv[c1] % MODNUM) % MODNUM;
	t3 = f[r1+c2+1] * (finv[r1] * finv[c2+1] % MODNUM) % MODNUM;
	t4 = f[r1+c1] * (finv[r1] * finv[c1] % MODNUM) % MODNUM;
	ans = (t1 - t2 - t3 + t4) % MODNUM;
  	if(ans < 0){
      ans += MODNUM;
    }
	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 23552