akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;

void solve(long long a, long long b, long long c){

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    set<int> ans;
    REP(i, 3) {
        int tmp;
        cin >> tmp;
        ans.insert(tmp);
    }
    print(ans.size());
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    h_n = [int(s) for s in input().split()]

    cnt = 0
    for i in range(0, n):
        diff = [h_n[i] - h_n[j] for j in range(0, i)]
        cnt = cnt + 1 if len(list(filter(lambda x: x < 0, diff))) == 0 else cnt

    print(cnt)

    
main()

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <string>

std::string count(std::string s) {
    int len = (int)(s.length());
    int diff = int('a') - int('A');
    for (int i = 0; i < len; i++) {
        if ((int)(s[i]) >= int('A') && (int)(s[i]) <= int('Z')) {
            s[i] += diff;
        }
    }
    return s;
}


int main(void) {
    std::string def;
    std::cin >> def;
    def = count(def);
    int num = 0;
    std::string s;
    std::cin >> s;
    while(s != "END_OF_TEXT") {
        s = count(s);
        if (s == def) {
            num++;
        }
        std::cin >> s;
    }
    std::cout << num << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	string s;
	cin>>s;
	if(s.back() != 's')
		s.push_back('s');
	else{
		s.push_back('e');
		s.push_back('s');
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

typedef struct {
	int from_x, from_y;
	int to_x, to_y;
} Operation;

Operation x[500 * 500 + 5];
int x_num;

int main()
{
	int h, w;
	int dat[505][505];

	scanf("%d %d", &h, &w);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			scanf("%d", &dat[i][j]);
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (i == h && j == w) {continue;}

			if (dat[i][j] % 2) {

				if (j == w) {
					x[x_num].from_y = i; x[x_num].from_x = j;
					x[x_num].to_y = i + 1; x[x_num].to_x = j;

					dat[i][j]--;
					dat[i + 1][j]++;

					x_num++;

				} else {
					x[x_num].from_y = i; x[x_num].from_x = j;
					x[x_num].to_y = i; x[x_num].to_x = j + 1;

					dat[i][j]--;
					dat[i][j + 1]++;

					x_num++;
				}

			}
		}
	}

	printf("%d\n", x_num);
	for (int i = 0; i < x_num; i++) {
		printf("%d %d %d %d\n", x[i].from_y, x[i].from_x, x[i].to_y, x[i].to_x);
	}

	return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
  int n; cin >> n;
  int a[n+1];
  vector<pair<int, int> > ans;
  int m=-10000000, mi=10000000, maxid=-1, minid=-1;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    if(a[i] > m){
      m = a[i];
      maxid = i;
    }
    if(a[i] < mi){
      mi = a[i];
      minid = i;
    }
  }
  if(abs(m) > abs(mi)){
    cout << 2*n-2 << endl;
    cout << maxid << " " << 2 << endl;
    cout << maxid << " " << 2 << endl;
    for(int i=2;i<=n-1;i++){
      for(int j=1;j<=2;j++){
        cout << i << " " << i+1 << endl;
      }
    }
  }else{
    cout << 2*n-2 << endl;
    cout << minid << " " << n-1 << endl;
    cout << minid << " " << n-1 << endl;
    for(int i=n-2;i>=1;i--){
      for(int j=1;j<=2;j++){
        cout << i+1 << " " << i << endl;
      }
    }
  }
}

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

int main() {
    string in_str;
    string out_str;

    cin >> in_str;

    for (int i = 0; i < in_str.size(); i++) {
        if (in_str[i] == '0') {
            out_str.push_back('0');
        } else if (in_str[i] == '1') {
            out_str.push_back('1');
        } else if (in_str[i] == 'B') {
            if (out_str.size() != 0) {
                out_str.pop_back();
            }
        }
    }
    cout << out_str << endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int h,w,hc,wc,c,d;
        while(1){
	 scanf("%d %d",&h,&w);
         if(h==0 && w==0){
          break;
         }
         c=0;d=0;
	 for(hc=1;hc<=h;hc++){
 	        for(wc=1;wc<=w;wc++){
	 	        if(c==0){
                                printf("#");
                                c=1;
                        }else{
                                printf(".");
                                c=0;
                        }
                 }
                 if(d==0){
                                c=1;
                                d=1;
                        }else{
                                c=0;
                                d=0;
                        }
                 printf("\n");
	 }
        printf("\n");
        }
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

// 1 way is to find compute all the sorted permutations and find the 
// positions of the current permutation.

ll _find(ll A,ll B,ll C,ll X){
    ll cnt=0;
    
    for(ll c=0;c<=C;c++){
        if(c*50>X){
            break;
        }
        for(ll b=0;b<=B;b++){
            if(b*100>X){
                break;
            }
            for(ll a=0;a<=A;a++){
                if(a*500>X){
                    break;
                }
                if( (a*500 + b*100 + c*50) == X){
                    cnt++;
                }
            }
        }
    }
    return cnt;
}


void solve(){
    ll sum;
    ll a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>sum;
    
    cout<<_find(a,b,c,sum);
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

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

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long

const int upper = 3e5 + 20;
const int M = (int) 1e9 + 7;
const int inf = (int) 1e17;
const double eps =  1e-8;

signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif

	cout << "Christmas ";
	int d; cin >> d;

	for (int i = 0; i < 25 - d; i += 1) {
		cout << "Eve ";
	}
 	end_routine();	
}

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

using namespace std;

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

int main() {
	int w, h, n, x, y, a;
	cin >> w >> h >> n;
	VV m(h, V(w, 1));
	int sum = 0;
	for (;n--;) {
		cin >> x >> y >> a;
		if (a == 1) {
			for (int _y = 0; _y < h; _y++) {
				for (int _x = 0; _x < x; _x++) {
					m[_y][_x] = 0;
				}
			}
		} else if (a == 2) {
			for (int _y = 0; _y < h; _y++) {
				for (int _x = x; _x < w; _x++) {
					m[_y][_x] = 0;
				}
			}
		} else if (a == 3) {
			for (int _y = 0; _y < y; _y++) {
				for (int _x = 0; _x < w; _x++) {
					m[_y][_x] = 0;
				}
			}
		} else {
			for (int _y = y; _y < h; _y++) {
				for (int _x = 0; _x < w; _x++) {
					m[_y][_x] = 0;
				}
			}
		}
	}
	for (y = 0; y < h; y++) {
		for (x = 0; x < w; x++) {
			sum += m[y][x];
		}
	}
	cout << sum << endl;
}

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

int main(){
  int N; scanf("%d", &N);
  
   vector<vector<char>> S(N,vector<char>(N));
  
  int cnt = 0;
  
  for(int i = 0 ; i < N; i++){
    for(int j = 0; j < N; j++){ cin >> S[i][j];}}
  
  vector<vector<char>> T(N,vector<char>(N));
 
    for(int B = 0; B < N; B++){
      
      for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
          
          T[i][j] = S[i][(j+B)%N];
          
          
           
        }
      }
      
      bool flag = true;
     

      for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
          
          if( T[i][j] != T[j][i]){ flag = false; break;}
        }
      }
      
      if(flag){cnt++; }
     
    }
  
  
  printf("%d\n", cnt*N); return 0;
}
     
        

Measured memory_bytes: 436
from collections import *

N = int(input())
v_list = input().split()

if len(set(v_list)) == 1:
    print(len(v_list) // 2)
    exit()

v1_count_list = Counter(v_list[::2]).most_common()
v2_count_list = Counter(v_list[1::2]).most_common()

if v1_count_list[0][0] != v2_count_list[0][0]:
    leave_value = v1_count_list[0][1] + v2_count_list[0][1]
else:
    leave_value = max(v1_count_list[1][1] + v2_count_list[0][1], v1_count_list[0][1] + v2_count_list[1][1])
print(len(v_list) - leave_value)

Measured memory_bytes: 23020
def countSharp(s, h):
    tmp = s
    for i in range(len(s)):
        if ((h >> i) & 1) == 0:
            tmp = tmp[:i] + '.' + tmp[min(i+1, len(s)):]
    return len(tmp.replace('.', ''))


def countRes(AR, w, h):
    res = 0
    for i, s in enumerate(AR):
        if ((w >> i) & 1) == 0:
            continue
        res += countSharp(s, h)
    return res

H, W, K = list(map(int, input().split()))
C = []
res = 0
for i in range(H):
    C.append(input())

for i in range(2**H):
    for j in range(2**W):
        if(countRes(C, i, j) == K):
            res += 1
print(res)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int x = n % 100;
	int num = n / 100;
	if(x <= num * 5){
		printf("%d", 1);
	}else{
		printf("%d", 0);
	}
	return 0;
}

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

using namespace std;

int n, m, p[int(2e5)], a, b, c, ans;

void pre () {
	for (int i = 0 ; i <= n ; ++ i) {
		p[i] = i;
	}
	ans = n;
}

int get (int x) {
	if (x == p[x]) return x;
	return p[x] = get(p[x]);
}

bool unite (int a, int b) {
	a = get (a), b = get (b);
	if (a == b) return false;
	p[a] = b;
	return true;
}

int main () { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	pre();
	while (m--) {
		cin >> a >> b >> c;
		ans -= unite (a, b);
	}
	cout << ans;
}

Measured memory_bytes: 640
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s=readln.chomp.to!(char[]);

  if(s.length>"AKIHABARA".length){
    writeln("NO"); return;
  }

  auto cs=['K', 'I', 'H', 'B', 'R'];
  bool[char] exist; exist['A']=true;
  foreach(c; cs) exist[c]=true;
  foreach(c; s){
    if((c in exist)==null){writeln("NO"); return;}
  }
  auto cnt1=new int[](cs.length);
  foreach(c; s)foreach(i, c1; cs){
    if(c==c1) cnt1[i]++;
  }
  foreach(e; cnt1){
    if(e!=1){writeln("NO"); return;}
  }
  long idx=-1;
  foreach(c; cs){
    auto jdx=indexOf(s, c);
    if(jdx==-1){writeln("NO"); return;}
    if(idx>=jdx){writeln("NO"); return;}
    idx=jdx;
  }

  auto cnt=new long[](cs.length+1);
  cnt[0]=indexOf(s, cs[0]);
  foreach(i; 1..cs.length){
    cnt[i]=indexOf(s, cs[i])-indexOf(s, cs[i-1])-1;
  }
  cnt[$-1]=s.length-indexOf(s, cs[$-1])-1;
  auto ok=[1, 0, 0, 1, 1, 1]; assert(ok.length==cnt.length);
  foreach(i; 0..cnt.length){
    if(cnt[i]>ok[i]){writeln("NO"); return;}
  }
  writeln("YES");
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000


int main()
{
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));
    
    if (a[0] == a[1]) {
        if (a[1] != a[2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    if (a[2] == a[1]) {
        if (a[1] != a[0]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << /*#X <<":" <<*/X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000

ll N,K,ans=0;
ll X[100010],Y[100010];
ll W[3001][3001],B[3001][3001];
char C[100010];
//yxyx
ll imos(int a,int b,int c,int d,int mode){
    int res=0;
    if(a>c||b>d)return 0;
        if(mode==0){
             if((0<=c&&c<2*K)&&(0<=d&&d<2*K))res+=W[c][d];
             if((0<=c&&c<2*K)&&(0<=b-1&&b-1<2*K))res-=W[c][b-1];
             if((0<=a-1&&a-1<2*K)&&(0<=d&&d<2*K))res-=W[a-1][d];
             if((0<=a-1&&a-1<2*K)&&(0<=b-1&&b-1<2*K))res+=W[a-1][b-1];
        }else{
            if((0<=c&&c<2*K)||(0<=d&&d<2*K))res+=B[c][d];
            if((0<=c&&c<2*K)||(0<=b-1&&b-1<2*K))res-=B[c][b-1];
            if((0<=a-1&&a-1<2*K)||(0<=d&&d<2*K))res-=B[a-1][d];
            if((0<=a-1&&a-1<2*K)||(0<=b-1&&b-1<2*K))res+=B[a-1][b-1];
        }
        return res;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>K;
    REP(i,N){
        cin>>X[i]>>Y[i]>>C[i];
        X[i]%=2*K,Y[i]%=2*K;
        if(C[i]=='W')W[Y[i]][X[i]]+=1;
        else B[Y[i]][X[i]]+=1;
    }
    REP(i,2*K)REP(j,2*K){
        W[i][j+1]+=W[i][j];
        B[i][j+1]+=B[i][j];
    }
    REP(i,2*K)REP(j,2*K){
        W[i+1][j]+=W[i][j];
        B[i+1][j]+=B[i][j];
    }
    REP(i,2*K){REP(j,2*K){
        DEB(B[K-1-i][j])
    }END}
    REP(i,K)REP(j,K)REP(k,2){
      ll tans=0;
        tans+=imos(0,0,i-1,j-1,(k==0?0:1));
        tans+=imos(0,j,i-1,j+K-1,(k!=0?0:1));
        tans+=imos(0,j+K,i-1,2*K-1,(k==0?0:1));
        tans+=imos(i,0,i+K-1,j-1,(k!=0?0:1));
        tans+=imos(i,j,i+K-1,j+K-1,(k==0?0:1));
        tans+=imos(i,j+K,i+K-1,2*K-1,(k!=0?0:1));
        tans+=imos(K+i,0,2*K-1,j-1,(k==0?0:1));
        tans+=imos(K+i,j,2*K-1,j+K-1,(k!=0?0:1));
        tans+=imos(K+i,j+K,2*K-1,2*K-1,(k==0?0:1));
        ans=max(tans,ans);
    }

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


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

using namespace std;

int main(void) {
    int n, m;
    while (cin >> n >> m, n) {
        int t[110], h[110], sumt = 0, sumh = 0;
        for (int i = 0; i < n; i++) {
            cin >> t[i];
            sumt += t[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> h[i];
            sumh += h[i];
        }
        
        int flag = 0, cpyt, cpyh;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cpyt = sumt - t[i] + h[j];
                cpyh = sumh - h[j] + t[i];
                if (cpyt != cpyh) continue;
                cout << t[i] << " " << h[j] << endl;
                flag = 1;
                break;
            }
            if (flag) break;
        }

        if (!flag) cout << "-1\n";
    }

    return 0;
}


Measured memory_bytes: 3044
// AtCoder Regular Contest 065

#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define se second
#define fi first
using namespace std;
string str;
int n;
string aft(int x){
    string ret="";
    for(int i=x, c=0;i<n && c<5;i++,c++){
        ret+=str[i];
    }
    return ret;
}
int main(){
    //string str;
    cin>>str;
    set<char>s;
    s.insert('d'); s.insert('r');  s.insert('e'); s.insert('a'); s.insert('m'); s.insert('e');
    s.insert('s');// s.insert('r');  s.insert('e'); s.insert('a'); s.insert('m'); s.insert('e');

    n=str.length();
    string tmp="";
    for(int i=0;i<n;){
        if(!s.count(str[i])){
            cout<<"NO"<<endl; return 0;
        }
        tmp+=str[i];
        if(tmp.length()==5){
            if(tmp=="dream"){
                if(i+2<n && str[i+1]=='e' && str[i+2]=='r' && aft(i+1)!="erase"){
                    i+=3; tmp=""; continue;
                }
                tmp="";
                i++;
                continue;
            }
            if(tmp=="erase"){
                if(i+1<n && str[i+1]=='r'){
                    i+=2; tmp=""; continue;
                }
                tmp="";
                i++;
                continue;
            }
            cout<<"NO"<<endl; return 0;
        }
        i++;
        //cout<<tmp<<endl;
        if(tmp.size()>5){
            cout<<"NO"<<endl; return 0;
        }
    }
    //cout<<tmp<<endl;
    if(tmp.size()!=0)cout<<"NO"<<endl;
    else cout<<"YES"<<Endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(ll i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N;
    string S;
    cin>>N;
    cin>>S;

    ll c_max=0;
    ll realmax=0;
    ll ans=0;

    rep(i,1,N){
        realmax=0;
        c_max=0;
        rep(j,i,N){
            if(S[j-i]==S[j]){
                c_max++;
                realmax=max(c_max,realmax);
            }
            else c_max=0;
        }
        realmax=min(realmax,i);
        ans=max(ans,realmax);
    }

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) throws IOException {
		int a[]=setArray(3);
		Arrays.sort(a);
		int sum=0;
		for(int i=1;i<3;i++) {
			sum+=Math.abs(a[i]-a[i-1]);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	if (n == m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


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

ll dp[401][401];

ll sum(ll i,ll j,vector<ll> &v)
{
    ll ans=0;
    for(ll k=i;k<=j;k++)
    {
        ans+=v.at(k);
    }
    return ans;
}

ll cost(ll i,ll j,vector<ll> &v)
{
    if(i>=j)
    {
        return dp[i][j]=0;
    }
    else
    {
        if(dp[i][j]!=-1)
        {
            return dp[i][j];
        }
        
        ll min=LLONG_MAX;
        for(ll k=i;k<=j-1;k++)
        {
            //cout<<ans<<" ";
            if(min>(cost(i,k,v)+cost(k+1,j,v)))
            {
                min=(cost(i,k,v)+cost(k+1,j,v));
            }
        }
        return dp[i][j]=sum(i,j,v)+min;
    }
}

ll solve(ll n,vector<ll> &v)
{
    memset(dp,-1,sizeof(dp));
    return cost(1,n,v);
}

int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin>>v.at(i);
    }
    cout<<solve(n,v);
    return 0;
}

Measured memory_bytes: 4876
import java.util.Scanner;

public class Main {

	public static void main(String... args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());

		System.out.println((n - h + 1) * (n - w + 1));


	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int a[10];
int main()
{
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif  */
     __

    int n;
    cin>>n;
    ll a[n],dp[n];
    mem(dp);
    f0(n) cin>>a[i];
    for(int i=1;i<n;i++)
    {
        if(i>1) dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
        else dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
    }
    cout<<dp[n-1];
    return 0;
}



Measured memory_bytes: 1792
S = str(input())
T = str(input())

s = set([s for s in S])
t = set([t for t in T])

if s == t:
    if S == T:
        print("Yes")
    else:
        counter = 0
        for i in range(len(S)):
            S = S[-1] + S[0:-1]
            if S == T:
                print("Yes")
                break
            else:
                counter += 1
        if counter == len(S):
            print("No")
else:
    print("No")

Measured memory_bytes: 38484
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main(void){
	
	int n;cin >> n;
	priority_queue<double,vector<double>,greater<double>> q;
	rep(i,n){
		double x;cin >> x;
		q.push(x);
	}
	rep(i,n-1){
		double x = q.top();q.pop();
		double y = q.top();q.pop();
		q.push((x+y)/2);
	}
	cout << q.top() << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
		//new AOJ0578().run();
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		
		while(sc.hasNext()){
			int n=sc.nextInt();
			int count=0;
			char name[]=sc.next().toCharArray();
			char old[][]=new char[n][];
			//テ」ツ??」ツ??・ツ青催・ツ可催」ツ?古ヲツ?敕」ツ??ヲツオツョテ」ツ?凝」ツ?ーテ」ツ?ェテ」ツ?凝」ツ?」テ」ツ?淌」ツ??
			//temp[i]テ」ツ?ッテ」ツ?、テ」ツ?湘」ツつ甘」ツ?淌」ツ??ァツ慊凝ヲツ敖ソテ」ツ?ョiテヲツ鳴?・ツュツ療ァツ崢ョテ」ツ?経ldテ」ツ?ョテ、ツスツ陛ヲツ鳴?・ツュツ療ァツ崢ョテ」ツ?ォテ」ツ?づ」ツ?」テ」ツ?淌」ツ?凝」ツつ津・ツ?・テ」ツつ古」ツ?ヲテ」ツ?甘」ツ??
			int temp[]=new int[name.length];
			for(int i=0; i<n; i++){
				old[i]=sc.next().toCharArray();
			}
			
			for(int i=0; i<n; i++){
				for(int j=0; j<old[i].length; j++){
					if(name[0]==old[i][j]){
						//テ」ツ?ェテ」ツつ禿」ツ?凝ゥツ鳴「テヲツ閉ーテ」ツつ津・ツ堕シテ」ツ?カ
						if(signBord(name, old[i], j, 0, temp)){
							//System.out.println(i+" "+String.valueOf(old[i]));
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
	
	boolean signBord(char name[],char old[],int k,int d, int temp[]){
		temp[d]=k;
		if(name.length-1 <= d){
			for(int i=0; i+2<name.length; i++){
				if(temp[i+1]-temp[i] != temp[i+2]-temp[i+1]){
						return false;
				}
			}
			return true;
		}
		for(int j=k+1; j<old.length; j++){
			if(name[d+1]==old[j]){
				if(signBord(name, old, j, d+1, temp)){
					return true;
				}
			}
		}
		return false;
	}

}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    rep(i,w+2) cout << '#';
    cout << endl;
    rep(i,h) cout << '#' << a[i] << '#'<< endl;
    rep(i,w+2) cout << '#';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;

int N,M,Res;
bitset<8> memo;
vector< vector<int> > el;

void dfs(int now) {
	if (memo.count() == N) {
		++Res;
		return;
	}
	for (int i = 0; i < el[now].size(); ++i) {
		if (!memo[el[now][i]]) {
			memo.set(el[now][i]);
			dfs(el[now][i]);
			memo.reset(el[now][i]);
		}
	}
	return;
}

int main(void) {
	cin >> N >> M;
	el = vector< vector<int> >(N);
	for (int i = 0; i < M; ++i) {
		int u,v;
		cin >> u >> v;
		el[u-1].push_back(v-1);
		el[v-1].push_back(u-1);
	}
	Res = 0;
	memo = bitset<8>(1);
	dfs(0);
	cout << Res << endl;
	return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  if (s[0] == t[0]) cnt++;
  if (s[1] == t[1]) cnt++;
  if (s[2] == t[2]) cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3492
package main

import (
	"fmt"
	"math"
)

func repeatedSquaring(n, p, m int) int {
	if p == 0 {
		return 1
	}
	if p%2 == 0 {
		t := repeatedSquaring(n, p/2, m)
		return t * t % m
	}
	return n * repeatedSquaring(n, p-1, m) % m
}

func combination(n, a, m int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i) % m
		y = y * (i + 1) % m
	}

	return x * repeatedSquaring(y, m-2, m) % m
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	divisor := int(math.Pow10(9) + 7)
	all := repeatedSquaring(2, n, divisor) - 1
	all -= combination(n, a, divisor)
	all += divisor
	all %= divisor
	all -= combination(n, b, divisor)
	all += divisor
	all %= divisor
	fmt.Println(all)
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
using namespace std;
int main() {
	int x,y ;
	char str[101][101];
	cin >> y >> x;
	for (int j = 0; j < y; j++) {
		for (int i = 0; i < x; i++) {
			cin >> str[i][j];
		}
	}
	for (int j = 0; j < x+2; j++) {
		cout << "#";
	}
	cout << endl;
	for (int j = 0; j < y; j++) {
		cout << "#";
		for (int i = 0; i < x; i++) {
			cout << str[i][j];
		}
		cout << "#" << endl;
	}
	for (int j = 0; j < x + 2; j++) {
		cout << "#";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
from math import ceil

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

x = min((a - 1) % 10, (b - 1) % 10, (c - 1) % 10, (d - 1) % 10, (e - 1) % 10) + 1
ans = ceil(a / 10) * 10 + ceil(b / 10) * 10 + ceil(c / 10) * 10 + ceil(d / 10) * 10 + ceil(e / 10) * 10
ans -= (10 - x)
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
	long long N; std::cin >> N;
	std::string str = "";
	while (N) {
		--N;
		str += (char)('a' + (N % 26));
		N /= 26;
	}
	std::reverse(str.begin(), str.end());
	std::cout << str << std::endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    
    // 4文字同じの時
    if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)&&(s.at(3)==s.at(1))){
       cout<<"No" <<endl; 
    }
    else{
    // ２：２になっているとき
    if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)){
      cout<<"Yes" <<endl;
    }else if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)){
       cout<<"Yes" <<endl;
    }else if(s.at(0)==s.at(3)&&s.at(1)==s.at(2)){
       cout<<"Yes" <<endl;
    }else{
       cout<<"No" <<endl;
    }
    }
}

Measured memory_bytes: 3584
import java.util.*;

class Main {

    void solve() {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++){
			int r = in.nextInt();
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
	}

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

Measured memory_bytes: 99216
N, K = map(int, input().split())
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
M = 0
for i in range(N):
  if A[i]*F[i]>M:
    M = A[i]*F[i]

l = -1
r = M+1
while l+1<r:
  s = (l+r)//2
  cnt = 0
  for i in range(N):
    b = s//F[i]
    cnt += max(0, A[i]-b)
  if cnt>K:
    l = s
  else:
    r = s

print(r)


Measured memory_bytes: 119500
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for(int i = 0; i < n / 2; ++i){
    if(s[i] != s[n - i - 1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#それぞれの竹はA,B,Cのどれかのために使うか使わないかしかない
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C) -30 if min(a,b,c)>0 else inf
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 45148
#!/bin/ruby
loop = true

while loop
  line=STDIN.gets.chomp
  if line == '-'
    loop = false
    next
  end
  count=STDIN.gets.to_i
  count.times do
    pivot = STDIN.gets.to_i
    line = line[pivot..line.size-1] + line[0..pivot-1]
  end
  puts line
end

Measured memory_bytes: 8684
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
//#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    a[2]*=10;
    cout<<a[0]+a[1]+a[2]<<endl;
    return 0;
}



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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if(s[0] == '1') ++counter;
  if(s[1] == '1') ++counter;
  if(s[2] == '1') ++counter;
  cout << counter << endl;
}



Measured memory_bytes: 256
k, n = gets.split(' ').map(&:to_i)
ary = gets.split(' ').map(&:to_i)

distance = []
(n).times do |i|
  dis = ary[(i + 1) % n] - ary[i]
  if dis < 0
    dis += k
  end
  distance[i] = dis
end

p (k - distance.max)


Measured memory_bytes: 16972
#include <bits/stdc++.h>
using namespace std;
#define soort(v) sort(v.begin(),v.end())
#define foor(i,n) for(int i=0; i<n; i++)
//#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i] << " ";}
int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
int string_prod(string s){int b = 1;auto k =s.size();for(int j=0; j<k; j++){b *=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
#define ll long long
#define pb push_back

 
//int cnt =0;
//map<int,int>mp;
//
//void SieveOfEratosthenes(int n=2000000)
//{
//
//    vector <bool>prime(n+1,true);
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          mp[p]++;
//}
//
 
//set <int>s;
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        s.insert(2);
//        n /= 2;
//    }
//
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            s.insert(i);
//            n /= i;
//        }
//
//    }
//
//    if(n>2){
//       s.insert(n);
//    }
//
//}
 
 
//int isprime(long long int N){
//    if(N<2 || (!(N&1) && N!=2))
//        return 0;
//    for(long long int i=3; i*i<=N; i+=2){
//        if(!(N%i))
//            return 0;
//    }
//    return 1;
//}
 
//int binary_ser(vector<int>&v,int target,int r,int l=0){
//
//    int mid;
//    mid = l+((r-l)/2);
//
//    if(l>r)return -1;
//
//    if(v[mid]==target)return mid;
//    else if(v[mid]>target){
//        r = mid-1;
//        return binary(v, target,r,l);
//    }
//    else{
//        l = mid+1;
//        return binary(v, target,r,l);
//    }
//
//    return -1;
//
//}
 
//int lcs(string s,string p){
//
//    vector<vector<int>>v(s.size()+1,vector<int>(p.size()+1));
//
//    for(int i=1; i<=s.size(); i++){
//        for(int j=1; j<=p.size(); j++){
//
//    if(s[i-1]==p[j-1]) v[i][j] = v[i-1][j-1]+1;
//
//    else v[i][j] = max(v[i-1][j], v[i][j-1]);
//
//  }
// }
//
//    return v[s.size()][p.size()];
//}



int main(){
    vector<int>v;
    map<int,int> mp;
    map<int,int> m;
    int a,b,c=0,n,cnt=100000000,cn=0;
    
    cin >> a;
    
    cout << a*a << endl;
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main () {
	cin >> a >> b >> c;
	if (a==b){
		cout << c << endl;	
	} else if (a==c){
		cout << b << endl;
	} else {
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull long long
using namespace std;
ull knapsack01(ull *weight, ull *value, int i, int n, int w, ull **dp){
    if (i==n) return 0;
    if (dp[i][w]!=-1) return dp[i][w];
    ull inc=INT_MIN, exc=INT_MIN;
    if (w>=weight[i])
        inc = value[i] + knapsack01(weight, value, i+1, n, w-weight[i], dp);
    exc = knapsack01(weight, value, i+1, n, w, dp);
    return dp[i][w] = max(inc, exc);
}
int main(){
  cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int n, w;
    cin>>n>>w;
    ull weight[n], value[n];
    ull ** dp = new ull* [n];
    for (int i=0; i<n;i++){
        dp[i] = new ull[w+1];
        for (int j=0;j<=w;j++){
            dp[i][j]=-1;
        }
    }
    for (int i=0; i<n; i++)
        cin>>weight[i]>>value[i];

    cout<<knapsack01(weight, value, 0, n, w, dp);
    return 0;
   }
  


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

int N, M;
string A[55], B[55];

int main() {
  cin >> N >> M;
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<M; i++) cin >> B[i];

  bool finish = false;
  for (int i=0; i<=N-M; i++) {
    for (int j=0; j<=N-M; j++) {
      if (A[i][j] == B[0][0] && !finish) {
        bool flag = true;
        for (int k=0; k<M; k++) {
          for (int l=0; l<M; l++) {
            if (A[i+k][j+l] != B[k][l]) flag = false;
          }
        }
        if (flag) finish = true;
      }
    }
  }

  if (finish) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
list = []
for bc in BC:
    for _ in range(bc[0]):
        list.append(bc[1])
        if len(list) == N:
            break
    else:
        continue
    break
#print(list)
#for i in range(1, N):
#    A[i] += A[i-1]
#for i in range(1, len(list)):
#    list[i] += list[i-1]
for i in range(min(N, len(list))):
    if A[i] >= list[i]:
        break
    A[i] = list[i]
print(sum(A))



Measured memory_bytes: 100116
package main

import "fmt"

func main() {
	// Your code here!
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	dec := false
	for i := 1; i < n; i++ {
		d := h[i-1] - h[i]
		if d > 1 || (d == 1 && dec == true) {
			fmt.Println("No")
			return
		}
		if d == 1 && dec == false {
			dec = true
		}
		if d < 0 {
			dec = false
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <iostream>
using namespace std;
int main()
{
	int n,a,b,l;
	scanf("%d%d%d",&n,&a,&b);
	long long ans=0;
	for (int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		if (i)
		ans+=min(1LL*b,1LL*(x-l)*a);
		l=x;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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 COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}



int H, W, N;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> H >> W >> N) {
        int ma = max(H, W);
        cout << (N + ma - 1) / ma << endl;
    }
}


















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

int main() {
	ll n,m;
	cin >> n >> m;
	ll k = 1900*m + 100*(n-m);
	cout << (k<<m) << endl;
	return 0;
}


Measured memory_bytes: 256
void main(){
	string s = readln().chomp();
	if(s=="ABC")writeln("ARC");
	else writeln("ABC");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[10];
char cS[] = "AWTR";
ll Ct[10];

ll i, j, k;

int main(){
    scanf("%lld", &N);
    rep(i,0,N){
        scanf("%s", S);
        rep(j,0,4){
            if(S[0]==cS[j]){
                ++Ct[j];
            }
        }
    }
    printf("AC x %lld\n", Ct[0]);
    printf("WA x %lld\n", Ct[1]);
    printf("TLE x %lld\n", Ct[2]);
    printf("RE x %lld\n", Ct[3]);
    return 0;
}

Measured memory_bytes: 3812
#pragma GCC optimize("O2")
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <map>
#include <string>
#include <cmath>
#include <queue>
#include <ctime>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10;

vector<ll> vec;
ll q;

int main() {
    fastInp;

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll g = 0, ans = 0;
    g = min(a, k);
    k -= g;
    ans += g;

    g = min(b, k);

    k -= g;

    g = min(c, k);

    ans -= g;

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 3640
n,k=gets.split.map &:to_i
s=gets.chomp
a=[]
pre=nil
s.each_char.with_index{|c,i|
	if c!=pre
		a<<[c.to_i,i]
	end
	pre=c
}
p a.map.with_index{|(c,j),i|
	t=i+2*k+c
	(t>=a.size ? n : a[t][1]) - j
}.max

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	ll n, k;
	cin >> n >> k;
	ll cnt = 0;
	while (n > 0) {
		n /= k;
		cnt++;
	}
	pv(cnt)
	return(0);
}

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sat May 16 10:36:41 2020

*/
#include<bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9+7;

int main(){
	int a,b;
	cin >> a >> b;
	int g = 10*b;
	for(int i = 0; i < 10; ++i){
		if(((g+i)*8)/100 == a){
			cout << g+i <<"\n";
			return 0;
		}
	}
	cout << -1 <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define inf 0x3fffffff
#define M 10000
using namespace std;

char str[40];
map<string,int>ss;
int main()
{
	char ans[40],ans2[40];
	char a;
	int maxi,l_maxi;
	while(scanf("%s",str)!=EOF)
	{
		a = getchar();
		maxi = l_maxi = 0;
		ss.clear();
		while(scanf("%s",str))
		{
			a = getchar();
			ss[str]++;
			if(ss[str] > maxi)
			{
				maxi = ss[str];
				strcpy(ans,str);
		//		cout<<ans<<endl;
			}
			if(strlen(str) > l_maxi)
			{
				l_maxi = strlen(str);
				strcpy(ans2,str);
			}
			if(a == '\n')
			{
				cout<<ans<<" "<<ans2<<endl;
			  	break;	
				
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1216
n,x,y = map(int,input().split())
x -= 1
y -= 1

array = [[-1 for i in range(n)] for j in range(n)]

for i in range(n):
  for j in range(n):
    array[i][j] = abs(j-i)
    
for i in range(n):
  if array[i][x] == array[i][y]:
    pass
  
  elif array[i][x] > array[i][y]:
    array[i][x] = array[i][y] + 1
    
    index = x - 1
    while True:
      if index < 0 or array[i][index] <= array[i][index+1]:
        break
        
      array[i][index] = array[i][index+1] + 1
      index -= 1
      
    index = x + 1
    while True:
      if index >= n or array[i][index] <= array[i][index-1]:
        break
        
      array[i][index] = array[i][index-1] + 1
      index += 1
      
  else:
    array[i][y] = array[i][x] + 1
    
    index = y - 1
    while True:
      if index < 0 or array[i][index] <= array[i][index+1]:
        break
        
      array[i][index] = array[i][index+1] + 1
      index -= 1
      
    index = y + 1
    while True:
      if index >= n or array[i][index] <= array[i][index-1]:
        break
        
      array[i][index] = array[i][index-1] + 1
      index += 1
      
ans = [0] * (n+1)
for i in range(n):
  for j in range(i, n):
    tmp = array[i][j]
    ans[tmp] += 1
    
for i in range(1,n):
  print(ans[i])
  

Measured memory_bytes: 80348