akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll F[107][17];
ll P[107][17];
ll N,U;

ll keisan(int BOOK[]){
  ll T=0;
  ll kasanari[107],sum=0;
  rep(i,107){
    kasanari[i]=0;
  }
  rep(i,10){
    if(BOOK[i]==1){
      T++;
      rep(j,N){
        if(F[j][i]==1){
          kasanari[j]++;
        }
      }
    }
  }
  U++;
  if(T==0){
    return  -MOD;
  }
  rep(i,N){
    sum+=P[i][kasanari[i]];
  }
  return sum;
}

ll DFS(int day,int BOOK[17]){
  ll a,b;
  if(day==10){
    return keisan(BOOK);
  }
  a=DFS(day+1,BOOK);
  for(int i=day;i<10;i++){
    BOOK[i]=0;
  }
  BOOK[day]=1;
  b=DFS(day+1,BOOK);
  return max(a,b);
}

int main(){
  int BOOK[17];cin >> N;
  rep(i,13){
    BOOK[i]=0;
  }
  rep(i,N){
    rep(j,10){
      cin >> F[i][j];
    }
  }
  rep(i,N){
    rep(j,11){
      cin >> P[i][j];
    }
  }
  cout << DFS(0,BOOK) << endl;;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] ab = new int[n][2];
		for (int i = 0; i < ab.length; i++) {
			ab[i][0] = sc.nextInt();
			ab[i][1] = sc.nextInt();
		}

		Arrays.sort(ab, Comparator.comparingInt(a -> a[1]));
		int current = 0;
		for (int i = 0; i < ab.length; i++) {
			current += ab[i][0];
			if (current > ab[i][1]) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
	}
}


Measured memory_bytes: 108560
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll H, ll A) {
  int cnt{};
  while(H>0) {
    H -= A;
    ++cnt;
  }
  cout << cnt << endl;
}

int main() {
  ll H;
  cin >> H;
  ll A;
  cin >> A;
  solve(H, A);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	float h;
	float min=1000000;
	float max=0;
	while(scanf("%f",&h)!=EOF){
		if(h<min) min=h;
		if(h>max) max=h;
	}
	printf("%f\n",max-min);
	return 0;
}

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

int main () {
  int N , M ;
  cin >> N >> M ;
  char A[N][N] , B[M][M] ;
  for(int i = 0 ; i < N ; i++ )
    for(int j= 0 ; j < N ; j++ ) 
      cin >> A[i][j] ;
  for(int i = 0 ; i < M ; i++ )
    for(int j= 0 ; j < M ; j++ ) 
      cin >> B[i][j] ;
  bool ans = false ;
  for(int i = 0 ; i < N - M  + 1 ; i++ ){
    for(int j = 0 ; j < N - M + 1 ; j++ ){
      bool can = true ;
      for(int k = 0 ; k < M ; k++ ){
        for(int l = 0 ; l < M ; l++ ){
          if(A[i+k][j+l]!=B[k][l])
            can = false ;
        }
      }
      if(can) ans = true ;
    }
  }
  if(ans) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
#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

int UF[114514];
int UFnum[114514];
void UFinit(int n){
    for(int i=0;i<=n;i++){
        UF[i]=i;
    }
}
int UFroot(int k){
    if(UF[k]==k){
        return k;
    }else{
        UF[k]=UFroot(UF[k]);
        return UF[k];
    }
}
int UFsame(int P,int Q){
    if(UFroot(P)==UFroot(Q)){
        return true;
    }else{
        return false;
    }
}
void UFunite(int P,int Q){
    int p=UFroot(P);
    int q=UFroot(Q);
    if(p==q)return;
    if(p>q)swap(p,q);
    UF[q]=p;
}


signed main(){
    int N,M;
    int A[114514],B[114514];
    int Ans[114514]={};
    cin >> N >> M;
    REP(i,M){cin >> A[i] >> B[i]; A[i]--;B[i]--;}
    
    int now=N*(N-1)/2;
    REP(i,N+1){UFnum[i]=1;}
    UFinit(N);
    Ans[M]=now;
    for(int i=M-1;i>=0;--i){
        
        if(!UFsame(A[i],B[i])){
            now-=UFnum[UFroot(A[i])]*UFnum[UFroot(B[i])];
            
            UFnum[UFroot(A[i])]+=UFnum[UFroot(B[i])];
            UFnum[UFroot(B[i])]=UFnum[UFroot(A[i])];
            UFunite(A[i],B[i]);
        }
        Ans[i]=now;
        
        //REP(j,N){cout << UFnum[j] << " ";}cout << "   ";
        //REP(j,N){cout << UFroot(j) << " ";}cout << endl;
    }
    
    REP(i,M-1){
        cout << Ans[i+1] << endl;
    }
    cout << N*(N-1)/2;
    
    return 0;
}


Measured memory_bytes: 5504
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define MAX_N 100001
ll dp[101][MAX_N];

void init(){
	rep(i,101){
		rep(j,100001){
			dp[i][j] = 0;
		}
	}
}

int main()
{
	int N,W;
	cin>>N>>W;
	init();
	int *v = new int[N];
	int *w = new int[N];
	rep(i,N){
		cin>>w[i]>>v[i];
	}
	for(int i = 0;i < N; i++){
		for(int j = 0; j <= W; j++){
			if( j - w[i] >= 0){
				dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]] + v[i]);
			}else{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= W; i++){
		ans = max(ans,dp[N][i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 79104
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t H, W;
  cin >> H >> W;
  int64_t answer = 0;
  if (H == 1 || W == 1) {
    answer = 1;
  } else {
    if (H % 2 == 0) {
      answer = H * W / 2;
    } else {
      answer = (H - 1) * W / 2;
      answer += (W + 1) / 2;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>

using namespace std;

const int N = 105;
int main() {
	int n, t;
	cin >> n >> t;
	list<int> L;
	list<int>::iterator it, min;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		L.push_back(x);		
	}	
	vector<int>v;
	while (v.size() != t)
	{
		min = L.begin();
		for (it = L.begin(); it != L.end(); it++) {
			if (*it <= *min)
				min = it;
		}
		v.push_back(*min);
		L.erase(min);
	}
	int sum = 0;
	for (int i = 0; i < v.size(); i++)
	{
		sum += v[i];
	}
	cout << sum << endl;
	return 0;
}

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

class FastScanner {
    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());
    }
}

public class Main {
    static int MOD = 1000000007;

    public static class Mas {
        int x;
        int y;
        int step;

        Mas(int x, int y, int step) {
            this.x = x;
            this.y = y;
            this.step = step;
        }
    }

    private static final int[] vX = { 1, 0, 0, -1 };
    private static final int[] vY = { 0, 1, -1, 0 };

    public static void main(String[] args) {

        FastScanner fs = new FastScanner();
        int x=fs.nextInt();
        int a=fs.nextInt();
        int b=fs.nextInt();
        System.out.println(Math.abs(x - a) > Math.abs(x - b) ? 'B' : 'A');

    }

}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define INF 100000000000LL

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef long double ld;

int main(void) {
  int a,b,c;
  cin >> a >> b >> c;
  cout << min(b / a, c) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
 ll A,B;
 cin>>A>>B;

 ll gc = __gcd(A,B);
 cout<<(A*B)/gc<<endl;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define mod 1000000007
using namespace std;
int mincosttogo(int a[],int memo[],int st,int end,int k)
{
  if(st>end)
    return 0;
  if(st==end)
  	return a[0];
  if(memo[end]!=-1)
  	return memo[end];
  // if(st==end)
  // 	return a[0];
  // if(memo[end]!=-1)
  //   return memo[end];
  int temp1=INT_MAX,temp2=INT_MAX;
 // if(end>=1)
    for(int i=1;i<=k;i++)
    {
      if(end -i>=0)
      temp2=mincosttogo(a,memo,st,end-i,k)+a[end];
      temp1=min(temp1,temp2);
    }
 
  return memo[end]=temp1;
}
int main()
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	// int t;
	// scanf("%d",&t);
	// while(t--)
	// {
		
     
    
 //     }
	string s;
	cin>>s;
	long long sum=0;
	for(long long i=0;i<s.length();i++)
		{
      sum+=s[i]-'0';
      
    }
      if((sum%9)==0)
      	cout <<"Yes" << endl;
      else
      	cout <<"No" << endl;
  //cout << sum << endl;
}

Measured memory_bytes: 3720
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0 for _ in range(n-1)]
for i in range(0, n-1):
    for j in range(i+1, n):
        cur = min(j-i, abs(x-i)+1+abs(y-j))
        ans[cur-1] += 1
        
print(*ans, sep='\n')

Measured memory_bytes: 3444
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    int r, g, b;
    cin>>r>>g>>b;
    if((g*10+b)%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int main(){
	int n;
	cin >> n;
	for(int d = 2; d <= n << 1; d += 2)
	{
		int res = 0;
		for(int i = 1; i * i < d; ++i)
		{
			int limj = d - i * i;
			for(int j = 1; j * j < limj; ++j)
			{
				int lo = abs(i-j), hi = i + j, k = sqrt(d - i * i - j * j);
				if(lo < k && k < hi && k*k == limj - j*j) ++res;
			}
		}
		cout << res << '\n';
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 1000000009
#define infll 1e15


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int maxtime=inf;

int main(){
    int n;
    cin>>n;
    reps(i,n,1000){
        if(to_string(i)[0]==to_string(i)[1] && to_string(i)[1]==to_string(i)[2]){
            cout<<i<<endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
using namespace std;
int main(){
  ll X,t;
  cin>>X>>t;
  ll ans=0;
  if(X-t<0)ans = 0;
  else ans = X-t;
  // ans = max(0,X-t);
  cout<<ans<<endl;
  return 0;
}


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

void solve() {
  int n;
  int64_t k;
  cin >> n >> k;

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

  auto pos = lower_bound(a.begin(), a.end(), 0);
  auto rpos_left = make_reverse_iterator(pos);
  auto non_zero_pos = upper_bound(a.begin(), a.end(), 0);
  auto rpos_right = make_reverse_iterator(non_zero_pos);

  auto pos_cnt = a.end() - pos;
  auto neg_cnt = n - pos_cnt;
  auto non_zero_pos_cnt = a.end() - non_zero_pos;
  auto zero_cnt = pos_cnt - non_zero_pos_cnt;

  constexpr int64_t limit = 1'000'000'000LL;
  int64_t left = -limit * limit;
  int64_t right = limit * limit + 1;
  while (left <= right) {
    int64_t lcnt = 0;
    int64_t ucnt = 0;
    auto mid = left + (right - left) / 2;

    if (mid == 0) {
      lcnt = neg_cnt * non_zero_pos_cnt;
      ucnt = lcnt;
      for (int i = 0; i < zero_cnt; ++i) {
        ucnt += n - 1 - i;
      }
      assert(lcnt <= ucnt);
    } else if (mid < 0) {
      for (auto it = a.begin(); it != pos; ++it) {
        auto lit =
            lower_bound(a.rbegin(), rpos_right, mid / *it, greater<int64_t>{});
        auto uit =
            lower_bound(lit, rpos_right, (mid + 1) / *it, greater<int64_t>{});
        auto dl = lit - a.rbegin();
        auto du = uit - a.rbegin();
        assert(dl <= du);
        lcnt += dl;
        ucnt += du;
      }
    } else {
      for (auto it = a.begin(); it != pos; ++it) {
        auto end = make_reverse_iterator(it + 1);
        auto lit =
            upper_bound(rpos_left, end, (mid - 1) / *it, greater<int64_t>{});
        auto uit = upper_bound(lit, end, mid / *it, greater<int64_t>{});
        auto dl = non_zero_pos_cnt + lit - rpos_left;
        auto du = non_zero_pos_cnt + uit - rpos_left;
        assert(dl <= du);
        lcnt += dl;
        ucnt += du;
      }
      for (int i = 0; i < zero_cnt; ++i) {
        lcnt += n - 1 - i;
        ucnt += n - 1 - i;
      }
      for (auto it = non_zero_pos; it != a.end(); ++it) {
        auto lit = upper_bound(it + 1, a.end(), (mid - 1) / *it);
        auto uit = upper_bound(lit, a.end(), mid / *it);
        auto dl = lit - it - 1;
        auto du = uit - it - 1;
        assert(dl <= du);
        lcnt += dl;
        ucnt += du;
      }
    }
    assert(lcnt <= ucnt);
    if (k <= lcnt) {
      right = mid;
    } else if (ucnt < k) {
      left = mid + 1;
    } else {
      cout << mid << endl;
      return;
    }
  }
  assert(false);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
bool judge(int n){
  int res=0;
  rep1(i,n){
    if(n%i==0)res++;
  }
  return res==8;
}
signed main(){
  int n;cin>>n;
  int res=0;
  rep1(i,n){
    if(judge(i)&&i%2==1)res++;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int x,y;
  scanf("%d %d", &x, &y);
  int get = 0;
  if (x == 3) {
    get += 100000;
  }
  if (x == 2) {
    get += 200000;
  }
  if (x == 1) {
    get += 300000;
  }
  if (y == 3) {
    get += 100000;
  }
  if (y == 2) {
    get += 200000;
  }
  if (y == 1) {
    get += 300000;
  }
  if (x == 1 && y == 1) {
    get += 400000;
  }
  printf("%d\n", get);

  return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

  vector<ll> x(N, 0), v(N, 0);

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

  // 累積和
  vector<ll> rwv(N + 1, 0);
  for (int i = 0; i < N; i++) {
    rwv[i + 1] = rwv[i] + v[i];
  }

  vector<ll> r(N + 1, 0);
  r[1] = rwv[1] - x[0];
  for (int i = 1; i < N; i++) {
    r[i + 1] = max(r[i], rwv[i + 1] - x[i]);
  }

  vector<ll> l(N + 1, 0);
  l[1] = rwv[N] - rwv[N - 1] - (C - x[N - 1]);
  for (int i = 1; i < N; i++) {
    l[i + 1] = max(l[i], rwv[N] - rwv[N - (i + 1)] - (C - x[N - (i + 1)]));
  }

  // for (int i = 0; i <= N; i++) {
  //   cout << l[i] << " ";
  // }
  // cout << endl;
  // for (int i = 0; i <= N; i++) {
  //   cout << r[i] << " ";
  // }
  // cout << endl;


  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, rwv[i] - x[i - 1]);
    if (i < N) {
      ans = max(ans, rwv[i] - 2 * x[i - 1] + l[N - i]);
    }
  }

  for (int i = 1; i <= N; i++) {
    ans = max(ans, rwv[N] - rwv[N - i] - (C - x[N - i]));
    if (i < N) {
      ans = max(ans, rwv[N] - rwv[N - i] - 2 * (C - x[N - i]) + r[N - i]);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define ll long long 
#define MAX (int)(pow(10,7) + 10)
#define dim 3
#define pb(a) push_back(a)
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9) + 7;
double eps = 1e-6;
ifstream in;
ofstream out;


void deal(){
	ll n , m;
	cin>>n>>m;
	string a;
	fori(n){
		a+="?";
	}
	fori(m){
		ll idx;
		char vl;
		cin>>idx>>vl;
		if(idx == 1 && vl == '0' && n>1){
			cout<<-1;
			return;
		}
		--idx;
		if(a[idx] == '?'){
			a[idx] = vl;
			
		}
		if(a[idx]!=vl){
			cout<<-1;
			return;
		}	
		
	}
	fori(n){
		if(a[i] == '?'){
			a[i] = '0';
		}
	}
	if(a[0] == '0' && n>1){
		a[0] = '1';
	}
	cout<<a;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

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

int main(void){
  int N, i, n, f=0, c=0;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&n);
    if(f==1) f=0;
    else if(n==i){c++; f=1;} 
  }
  printf("%d\n",c);
  return 0;
}


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

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int n, minA = INF, minusCount = 0;
    ll ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (a < 0) {
            minusCount++;
        }

        int absA = abs(a);
        minA = min(minA, absA);

        ans += absA;
    }

    if (minusCount % 2 == 1) {
        ans -= 2 * minA;
    }

    cout << ans << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main() {
    long long A, B, C, K; cin >> A >> B >> C >> K;

    int ans = 0;
    if (A > K) {
        ans += K;
        cout << ans << endl;
        return 0;
    } else {
        K -= A;
        ans += A;
    }

    if (B > K) {
        cout << ans << endl;
        return 0;
    } else {
        K -= B;
    }

    ans -= K;
    cout << ans << endl;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[100010];
int B[100010];
pii event[200020];
const int mod = 1000000000 + 7;

int main(){

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        event[i] = pii(A[i], 0);
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
        event[i + N] = pii(B[i], 1);
    }
    ll ans = 1;
    sort(event, event + 2 * N);
    int tot_a = 0;
    for(int i = 0; i < 2 * N; i++){
        if(event[i].second == 0){
            if(tot_a >= 0) tot_a++;
            else{
                (ans *= abs(tot_a)) %= mod;
                tot_a++;
            }
        }
        else{
            if(tot_a <= 0) tot_a--;
            else{
                (ans *= abs(tot_a)) %= mod;
                tot_a--;
           } 
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    int ans;
    if (n%x == 0){
      ans = (n/x) * t;
    }else{
      int m =  n / x;
      ans = (m+1) *t;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35708
def get_check(num, place):
    dist = abs(place[0][0]) + abs(place[0][1])
    check_flg = dist

    for i in range(num - 1):
        dist_now = abs(place[i + 1][0]) + abs(place[i + 1][1])
        if dist % 2 != dist_now % 2:
            check_flg = 0
            break
        if check_flg < dist_now:
            check_flg = dist_now
    return check_flg

def start_process(num, place):

    check_flg = get_check(num, place)
    if check_flg:

        seeds = [2 ** (31 - i) for i in range(32)]
        if check_flg % 2 == 0:
            seeds.append(1)
        print(len(seeds))
        print(' '.join(map(str, seeds)))

        for x, y in place:
            for k in seeds:
                if abs(x) > abs(y):
                    if x > 0:
                        res = 'R'
                        x -= k
                    else:
                        res = 'L'
                        x += k
                else:
                    if y > 0:
                        res = 'U'
                        y -= k
                    else:
                        res = 'D'
                        y += k
                print(res, end='')
            print('')


    else:
        print(-1)


def main():
    num = int(input())
    place = [list(map(int, input().split())) for i in range(num)]
    start_process(num, place)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4624
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, X, Y, x[105], y[105];
int main() {
	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; ++i) cin >> x[i];
	for (int i = 0; i < M; ++i) cin >> y[i];
	int bx = max(X, *max_element(x, x + N));
	int by = min(Y, *min_element(y, y + M));
	cout << (bx < by ? "No War" : "War") << endl;
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
L = gets.split.map(&:to_i).sort

ans = 0
N.times do |i|
  k = i
  (i + 1).upto(N - 2) do |j|
    k += 1 while k < N && L[k] < L[i] + L[j]
    ans += k - (j + 1)
  end
end

puts ans


Measured memory_bytes: 1912
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int[] top = new int[n];
		for(int i=0;i<n;i++) top[i] = sc.nextInt();
		sort(top);
		for(int i=n-1;i>=0;i--) {
			if( c * (a+b) < a * (c + top[i]) ) {
				c += top[i];
				a += b;
			}
		}
		System.out.println(c/a);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
l, r = map(int, input().split())

mod = 2019
if r - l >= mod:
    print(0)
else:
    l_mod = l % mod
    r_mod = r % mod
    if l_mod > r_mod:
        print(0)
    else:
        print(min([
            i * j % mod 
            for j in range(l_mod, r_mod + 1)
            for i in range(l_mod, r_mod + 1)
            if j > i
        ]))



Measured memory_bytes: 75416
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc = initScanner(os.Stdin)
	s := scanString(sc)
	fmt.Println(solve(s))
}

func solve(s string) int {
	var a, z int
	ss := strings.Split(s, "")

	for i := 0; i < len(ss); i++ {
		if ss[i] == "A" {
			a = i
			break
		}
	}
	for j := len(ss) - 1; j > 0; j-- {
		if ss[j] == "Z" {
			z = j
			break
		}
	}

	return z - a + 1
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanFloat64(sc *bufio.Scanner) float64 {
	sc.Scan()
	f, _ := strconv.ParseFloat(sc.Text(), 64)
	return f
}

func scanFloat64Slice(sc *bufio.Scanner, n int) []float64 {
	fs := make([]float64, n)
	for i := 0; i < n; i++ {
		fs[i] = scanFloat64(sc)
	}

	return fs
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 5780
fun main(args: Array<String>) {
    agc036a()
}

fun agc036a() {
    val s = readLine()!!.toLong()
    val sqrt = Math.pow(s.toDouble(), 1 / 2.0).toLong()

    val p2y = Math.pow(10.0, 9.0).toLong()

    val p3x = Math.ceil(s / p2y.toDouble()).toLong()
    val p3y = p2y * p3x - s

    return println("0 0 1 $p2y $p3x $p3y")
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

ll K;

ll S(ll v) {
  ll sum = 0;
  while( v ) {
    sum += ( v % 10LL );
    v /= 10LL;
  }
  return sum;
}

void compute() {

}

bool check(ll i) {
  ll coef = 1;
  double v1 = i / (double)S(i);
  rep(_,16) {
    double v2 = ( i + coef ) / (double)S(i+coef);
    if( !LTE(v1,v2) ) {
      return false;
    }
    coef *= 10LL;
  }
  return true;
}

int main() {
  cin >> K;
  int cnt = 0;
  ll maxi = 0;
  while( K ) {
    string tail = "";
    rep(_,cnt) tail += "9";
    REP(i,1,1000) {
      string s = to_string(i) + tail;
      ll v = atoll(s.c_str());
      if( v <= maxi ) continue;
      if( check(v) ) {
	cout << s << endl;
	maxi = max(maxi,v);
	--K;
	if( K <= 0 ) goto Fin;
      }
    }
    ++cnt;
  }
 Fin:;
  return 0;
}
/*
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
2 3 4 5 6 7 8 9
10 11 12 13 14  16 17 18 19
20 21 22 23 24 25 26 27 28 29
3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 
20 21 22 23 24  26 27 28
29
30
31
32
33
34
35
36
37
38
39
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>; using ppii = pair<pii, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

int h, w;
char c[55][55];
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

int visited[55][55];
int d[55][55];

bool movable(int x, int y) {
    return !(x < 0 || y < 0 || x >= w || y >= h) && !visited[y][x] && d[y][x] == INF && c[y][x] == '.';
}


int main() {
    scanf("%d%d", &h, &w);
    int white = 0;
    rep(y, h) rep(x, w) {
        cin >> c[y][x];
        white += c[y][x] == '.';
    }

    fill_n(*d, 55 * 55, INF);
    queue<ppii> q;
    q.push(ppii(pii(0, 0), 0));
    int cnt = 0;
    visited[0][0] = 1;
    while (q.size()) {
        ++cnt;
        auto p = q.front(); q.pop();
        int px = p.first.first, py = p.first.second;
        d[py][px] = p.second;
        rep(i, 4) {
            int nx = px + dx[i], ny = py + dy[i];
            if (visited[ny][nx]) continue;
            if (movable(nx, ny)) {
                visited[ny][nx] = 1;
                q.push(ppii(pii(nx, ny), p.second + 1));
            }
        }
    }

    //cout << cnt << "\n";
    if (d[h - 1][w - 1] == INF) {
        puts("-1"); return 0;
    }
    printf("%d\n", white - (d[h - 1][w - 1] + 1));

    return 0;
}


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

void
solver(int x)
{
    int c;
    int r;

    c = x/100;
    r = x%100;
    if (r>5*c) {
        printf("0\n");
    }
    else {
        printf("1\n");
    }
    return;
}

int
main(int argc, char *argv[])
{
    int x;
    scanf("%d", &x);
    solver(x);
    return 0;
}

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

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

int main() {
    int a, b;
    while (scanf("%d%d", &a, & b) != EOF) {
        int p = gcd(a, b);
        printf("%d %d\n", p, a / p * b);
    }
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A));

  int ans = 0;
  REP(i, K){
    ans += A[i];
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3612
L = []
while True:
    a, b, c = map(str, input().split(" "))
    k = [a, b, c]
    if b == "?":
        break


    L.append(k)

for i in range(len(L)):
    if L[i][1] == "+":
        result = int(L[i][0]) + int(L[i][2])
        print(result)
    elif L[i][1] == "-":
        result = int(L[i][0]) - int(L[i][2])
        print(result)
    elif L[i][1] == "*":
        result = int(L[i][0])*int(L[i][2])
        print(result)
    else:
        result = int(L[i][0]) // int(L[i][2])
        print(result)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

int main(){ 
	int N,ans=0,s;
	cin >> N;
	bitset<10001> p(1);
	FOR(i,0,N){
		cin >> s;
		p = p|(p<<s);
	}
	FOR(i,1,10001){
		if(p[i] && i%10){
			ans = i;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 05/05/2018 14:22:10
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int a, b;
	cin>>a>>b;
	if(b >= a) cout<<a<<endl;
	else cout<<a-1<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    Scanner sc = new Scanner(System.in);

    void run() {
        int n = ni();
        ArrayList<LinkedList<Integer>> list = new ArrayList<>();
        for (int i = 0; i <= 100001; ++i) {
            list.add(new LinkedList<>());
        }
        for (int i = 0; i < n; ++i) {
            int a = ni();
            int b = ni();
            list.get(a).add(b);
        }
        int max = 0;
        PriorityQueue<Integer> kouho = new PriorityQueue<>(Comparator.reverseOrder());
        PriorityQueue<Integer> friends = new PriorityQueue<>();
        for (int i = 2; i <= 100001; ++i) {
            kouho.addAll(list.get(i));
            while (friends.size() < i - 1 && kouho.size() > 0) {
                int v = kouho.poll();
                if (v < i) {
                    break;
                }
//                if (i <= 10)
//                    debug(i, "add", v);
                friends.add(v);
            }
            if (friends.size() == i - 1) {
                max = Math.max(max, i - 1);
            }
            while (friends.size() > 0 && friends.peek() == i) {
                int v = friends.poll();
//                if (i <= 10) debug(i, "remove", v);
            }
//            if (i <= 10) debug(i, friends);
        }
        System.out.println(max);
    }

    int ni() {
        return Integer.parseInt(sc.next());
    }

    public static void main(String[] args) {
        new Main().run();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }
}

Measured memory_bytes: 84228
import numpy as np
yama = int(input())
T, A = map(int, input().split())
takasas = list(map(int, input().split()))
takasass = np.array(takasas)
mokuhyou=(T-A)/0.006
sabun=takasass-mokuhyou
sabun2=sabun*sabun
saisyou=np.argmin(sabun2)
kotae=saisyou+1
print(kotae)


Measured memory_bytes: 12504
n = int(input())
ans = 0
if n < 3 * 5 * 7:
    ans = 0
elif n < 3 * 3 * 3 * 5: 
    ans = 1
elif n < 3 * 5 * 11:
    ans = 2
elif n < 3 * 3 * 3 * 7:
    ans = 3    
elif n < 3 * 5 * 13:
    ans = 4
else:
    ans = 5
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    long long H,W,ans;
    cin>>H>>W;
    if(H == 1 || W == 1) 
        ans = 1;
    else 
        ans = (H*W%2 == 1)? (H*W+1)/2:(H*W)/2;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
"use strict";

const main = (arg) => {
  const array = arg.trim().split("\n");
  let K = parseInt(array[0]);
  let S = array[1];

  if (S.length <= K) {
    console.log(S);
  } else {
    let result = S.substr(0, K);
    console.log(result + "...");
  }
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("1\nz");
// https://atcoder.jp/contests/abc168/tasks/abc168_b


Measured memory_bytes: 29656
#include<bits/stdc++.h>
using namespace std;
int a=-1,b=-1;
string s;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C') 
        {
            a=i;
            break;
        }
    }
    for(int i=a+1;i<s.size();i++)
    {
        if(s[i]=='F') 
        {
            b=i;
            break;
        }
    }
    if(a!=-1 && b!=-1) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

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

const int INF = pow(2,30);
const int MAX_N = pow(10,5);

int dp[MAX_N][3] = {};

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

  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]);
    }
  }
  int result; for (int i=0; i<3; i++) result = max(result, dp[N][i]);
   cout << result << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll  N[300005],ans[300005],sumN[300005];
int n,m;
 
int search(int b){
  int L=0,M,R=n+1;
  while(L<R){
    M=(R+L)/2;
    if(N[M]>b) R=M;
    else L=M+1;
  }
  return L-1;
}
 
int main(){
 
  cin>>n;
  for(int i=1;i<=n;i++) scanf("%d",&N[i]);
  sort(N,N+n+1);
  for(int i=1;i<=n;i++) sumN[i]+=sumN[i-1]+N[i];
  cin>>m;
  for(int i=0;i<m;i++){
    int b;
    scanf("%d",&b);
    ans[i]=sumN[search(b)];
  }
 
  for(int i=0;i<m;i++){
    ll c;
    cin>>c;
    if(c<=ans[i]) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 8288
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}

Measured memory_bytes: 256
main = do
  s <- getLine 
  print $ (length $ dist s "") - 1

dist :: String ->  String -> [String]
dist [] ys = [ys]
dist (x:xs) [] = dist xs [x]
dist (x:xs) (y:ys)
  | x == y = dist xs (x:y:ys)
  | otherwise = (y:ys) : dist xs [x]

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

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, 0, h) cin >> s[i];
    if(h == 1 && w == 1){
        cout << "No" << endl;
        return 0;
    }
    rep(i, 0, h){
        rep(j, 0, w){
            if(s[i][j] == '.') continue;
            bool flag = true;
            rep(dir, 0, 4){
                int ni = i + di[dir], nj = j + dj[dir];
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') flag = false;
            }
            if(flag){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll h;
	cin>>h;
	ll a;
	cin>>a;
	ll t=0;
	while(h>0)
	{
		h=h-a;
		t=t+1;
	}
	cout<<t<<"\n";
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int matrix[n][n];
		rep(i,n)rep(j,n)matrix[i][j]=0;
		matrix[n/2+1][n/2]=1;
		int nx=n/2,ny=n/2+1;
		int counta=2;
		while(1){
			nx++;
			ny++;
			if(nx==n)nx=0;
			if(ny==n)ny=0;
			if(matrix[ny][nx]!=0){
				nx--;
				ny++;
				if(nx==-1)nx=n-1;
				if(ny==n)ny=0;
			}
			matrix[ny][nx]=counta;
			counta++;
			if(counta>n*n)break;
		}
		rep(i,n){
			rep(j,n){
				if(matrix[i][j]/100>0){
					cout<<" "<<matrix[i][j];
				}else if(matrix[i][j]/10>0){
					cout<<"  "<<matrix[i][j];
				}else{
					cout<<"   "<<matrix[i][j];
				}
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main() {
  char a, b;
  while (cin >> a >> b) {
    cout << "HD"[a == b ? 0 : 1] << endl;
  }
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; int q;
    cin >> s; 
    cin >> q;
    int rev = 0;
    vector<int> t(q); 
    vector<int>f(q); vector<char> c(q);
    rep(i,0,q){
        int tmp;
        cin >> tmp;
        t[i] = tmp;
        if(tmp == 1){rev++;}
        else{ 
            cin >> f[i] >> c[i];
        }
    }
    if(rev%2==1) reverse(all(s));
    int retu = 1; //
    string tmp;
    rep(i,0,q){
        if(t[i]==1){ retu *= -1; continue; }
        if((f[i] == 1 && rev%2 == 0 && retu==1) || 
           (f[i] == 2 && rev%2 == 0 && retu==-1) ||
           (f[i] == 1 && rev%2 == 1 && retu==-1) || 
           (f[i] == 2 && rev%2 == 1 && retu==1)) tmp += c[i];
        else s += c[i];  
    }
    reverse(all(tmp));
    cout << tmp << s << endl;
}

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

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

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

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

  if (((int)a == (int)b && (int)b == (int)c) ||
      ((int)b == (int)c && (int)c == (int)d)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
// using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int binarySearch(int key, vector<int> a, int n) {
  vector<int>::iterator it = lower_bound(ALL(a), key);
  if (*it == key) return 1;
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  ll n, ans = 0;
  cin >> n;
  n--;
  for (int i = 1; i <= n; ++i) {
    ans += n / i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
def determine(array)
  x = array.sort
  return 'not triangle' if x[0] + x[1] <= x[2]

  x.map! { |y| y**2 }

  if x[0] + x[1] == x[2]
    'chokkaku'
  elsif x[0] + x[1] > x[2]
    'eikaku'
  elsif x[0] + x[1] < x[2]
    'donkaku'
  end
end

a = gets.split.map(&:to_i)
count = Hash.new(0)
total = 0
now = determine(a)

until now == 'not triangle'
  count[now] += 1
  total += 1
  a = gets.split.map(&:to_i)
  now = determine(a)
end

puts "#{total} #{count['chokkaku']} #{count['eikaku']} #{count['donkaku']}"



Measured memory_bytes: 6868
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var alice = Convert.ToInt32(input[0]);
        var bob = Convert.ToInt32(input[1]);

        var result = "";
        if (alice == bob) result = "Draw";
        else if (alice == 1 || (alice > bob&&bob!=1)) result = "Alice";
        else result = "Bob";

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13268