akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    int n,ans=0,r;
    cin >> n;
    int a[n],b[n],maxa;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a,a +n);

    for(int i = a[1]; i > 0; i--){
        int tmp =0;
        for(int j = 0; j < n; j++){
            if(a[j] % i !=0)
                tmp++;
        }
        if(tmp < 2){
            ans = i;
            break;
        }
    }
    cout << ans << endl;    
    
}

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

#define MAX 100000

int N;
int a[MAX];

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

	int odd = 0;
	int even = 0;
	int mul4 = 0;
	for( int i = 0; i < N; i++ ) {
		if( a[i] % 2 ) {
			odd++;
		}
		else if( (a[i] % 4) == 0 ) {
			mul4++;
		}
		else {
			even++;
		}
	}
	int ans = 0;
	if( odd == 0 ) {
		ans = 1;
	}
	else if( mul4 > 0 ) {
		if( odd <= mul4 ) {
			ans = 1;
		}
		else if( odd == mul4 + 1 && even == 0 ) {
			ans = 1;
		}
	}

	if( ans ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    bool j = true;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) j=false;
    }
    if(j) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX_R 1001
#define MAX_N 201
#define inf (1<<29)
using namespace std;
struct P
{
  int to,cost;
  char c;
  P(int to=0,int cost=0,char c='x'):to(to),cost(cost),c(c){}
};
typedef vector<P> VP;
typedef vector<VP> VVP;
int N,M,R;
int LG[MAX_N][MAX_N];
int SG[MAX_N][MAX_N];
int dp[MAX_R][MAX_N];//dp[i][j] := テゥツ崢?ゥツ?催・ツ??

int main()
{
  while(cin >> N >> M,N|M)
    {
      rep(i,MAX_N)rep(j,MAX_N)LG[i][j] = SG[j][i] = (i==j?0:inf);
      rep(i,MAX_R)rep(j,MAX_N)dp[i][j] = inf;
      VVP G(N);
      rep(i,M)
	{
	  int x,y,t;
	  char c;
	  cin >> x >> y >> t >> c;
	  x--,y--;
	  G[x].push_back(P(y,t,c));
	  G[y].push_back(P(x,t,c));
	  if(c == 'L')LG[y][x] = LG[x][y] = min(LG[y][x],t);
	  if(c == 'S')SG[y][x] = SG[x][y] = min(SG[x][y],t);
	}

      cin >> R;
      vector<int> v(R);
      rep(i,R)
	{
	  cin >> v[i];
	  v[i]--;
	}

      for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)LG[i][j] = min(LG[i][j],LG[i][k]+LG[k][j]),SG[i][j] = min(SG[i][j],SG[i][k]+SG[k][j]);
      dp[0][v[0]] = 0;

      /*
      cout << "-----------" << endl;
      rep(i,N)
	{
	  rep(j,N)cout << SG[i][j] << " ";
	  cout << endl;
	}
      */
      rep(i,R-1)
	{
	  rep(j,N)
	    {
	      if(dp[i][j] == inf)continue;

	      //cout << "dp["<<i<<"]["<<j<<"] ------- "<< dp[i][j] << endl;
	      dp[i+1][j] = min(dp[i+1][j],
			       dp[i][j]+LG[v[i]][v[i+1]]);
	      //cout << "dp["<<i+1<<"]["<<j<<"] = " << dp[i+1][j]  << " | " << dp[i][j] << "+" << LG[v[i]][v[i+1]]<< endl; 
	      rep(k,N)
		{
		      dp[i+1][k] = min(dp[i+1][k],
					   dp[i][j] + SG[j][k] + LG[v[i]][j] + LG[k][v[i+1]]);
		      //cout << v[i] << " dp["<<i+1<<"]["<<k<<"] = " << dp[i+1][k] << " | " << dp[i][j] << "+" << SG[v[i]][k] << "+" << LG[k][v[i+1]] << endl;
		      
		}
	    }
	}

      int minCost = (1<<29);
      rep(i,N)minCost = min(minCost,dp[R-1][i]);
      cout << minCost << endl;
    }
  return 0;
}

Measured memory_bytes: 2632
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int f(ll x){
  return log10(x) + 1;
}

int F(ll a, ll b){
  return max(f(a), f(b));
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  int ans = F(1, N);
  if(N % 2 == 0){
    ans = min(ans, F(2, N/2));
  }
  for(ll i = 3; i * i <= N; i++){
    if(N % i == 0){
      ans = min(ans, F(i, N/i));
    }
  }
  cout << ans <<endl;
}

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

int main() {
	int k, x;
	cin >> k >> x;

	rep(i, x - k + 1, x + k) {
		if (i == x + k - 1) {
			cout << i << endl;
			return 0;
		}
		cout << i << " ";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int cnt[1000010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[10010];
    rep(i, N) cin >> A[i];
    rep(i, N) {
        int num = A[i];
        int j = 2;  
        int tmp = 0;
        while(num > 1 && j * j <= 1000000) {
            tmp = 0;
            while(num % j == 0) {
                tmp++;
                num /= j;
            }
            cnt[j] = max(cnt[j], tmp);
            j++;
        }
        if(num > 1) cnt[num] = 1;
    }
    int G = 1;
    REP(i, 2, 1000000) {
        G = Mul(G, power(i, cnt[i]));
        //if(cnt[i] > 0 ) cerr << i << " " << cnt[i] << " " << power(i, cnt[i]) << endl;
    }
    int ans = 0;
    rep(i, N) {
        ans = (ans + Div(G, A[i])) % mod;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7348
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A {
	class main {
		static void Main(string[] args) {
			var s="";
			while((s=Console.ReadLine())!=null) {
				char[,] c= new char[6,5] {{'a','b','c','d','e'},{'f','g','h','i','j'},{'k','l','m','n','o'},
					{'p','q','r','s','t'},{'u','v','w','x','y'},{'z','.','?','!',' '}};
				bool ck=true;
				if(s.Length%2==1) ck=false;
				for(int i=0; i<s.Length; i++){
					if(!(s[i]>='1' && s[i]<='6')) ck=false;
				}
				if(ck) {
					string t="";
					for(int i=0; i<s.Length; i+=2) {
						int a=(int)s[i]-'0',b=(int)s[i+1]-'0';
						if(a>=1 && a<=6 && b>=1 && b<=5) {
							t+=c[a-1,b-1];
						} else {
							t="NA";
							break;
						} 
					}
					Console.WriteLine(t);
				} else {
					Console.WriteLine("NA");					
				}
			}
		}
	}
}


Measured memory_bytes: 5372
import itertools
N,M = [int(x) for x in input().split()]
d = [[]]*M
for i in range(M):
    s = [int(x) for x in input().split()]
    d[i] = s[1:]
p = [int(x) for x in input().split()]

l = [(0,x) for x in range(1,N+1)]
kumi = itertools.product(*l)
ans = 0

for s in kumi:
    ok = True
    for i in range(M):
        if not ok:
            break
        if len(set(s) & set(d[i]))%2 != p[i]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		if(N>999){
			System.out.println("ABD");
		}else{
			System.out.println("ABC");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <unordered_map>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve(){
    int x;
    cin >> x;
    cout << 24+(24-x) << endl;
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

struct BIT {
    ll n;
    VL dat;
    void init(ll in) {
        n = in + 1;
        dat.clear();
        dat.resize(n + 1, 0);
    }
    ll sum(ll i) {
        ll s = 0;
        while (i >= 0) {
            s += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }
    void add(ll i, ll x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    ll n;
    cin >> n;
    VL a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT bit;

    ll border = ((n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <atcoder/math>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using namespace atcoder;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 1e9;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> c;
    ll m = n;
    rep(i,2,sqrt(n)+1){
        ll acc = 1;
        bool f = 0;
        while(m%i == 0){
            f = 1;
            m /= i;
            acc *= i;
        }
        if (f){
            if (i != 2) c.push_back(acc);
            else c.push_back(acc*2);
        }
    }
    if (m > 1){
        c.push_back(m);
    }
    //array_output(all(c));
    ll siz = c.size(),ans = INF;
    rep(bit,(1<<siz)){
        vector<ll> r,m;
        rep(i,siz){
            if (bit&(1<<i)) r.push_back(c[i]-1);
            else r.push_back(0);
            m.push_back(c[i]);
        }
        ll a,b;
        tie(a,b) = crt(r,m);
        if (b != 0){
            chmin(ans,((a == 0 ? b : a)));
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 3680
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}
#define int ll
int a[200005];
int dp[200005];
int sum[200005];

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i!=1)
			sum[i]=sum[i-2]+a[i];
		else
			sum[1]=a[1];
	}
	for(int i=2;i<=n;i++)
	{
		if(i%2)
			dp[i]=max(dp[i-2]+a[i],dp[i-1]);
		else
			dp[i]=max(dp[i-2]+a[i],sum[i-1]);
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 8344
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a = input()
    n = len(a)
    total = (n - 1) * n // 2 + 1

    D = Counter(a)
    for v in D.values():
        total -= (v - 1) * v // 2
    print(total)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9492
//a[n-1]<-a[0]へ移動
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  reverse(all(a));
  reverse(all(b));
  long long plus=0;
  rep(i,n){
    a[i]+=plus;
    if(a[i]%b[i]!=0){
     // plus++;
     // a[i]++;
      int c=b[i]-(a[i]%b[i]);
      plus+=c;
      
    }
    
  }
  cout<<plus<<endl;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
const int MAX = 1e5+10;

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main () {
    ll n,a,b;
    cin >> n >> a >>b;
    ll cnt=n/(a+b)*a;
    ll t=n%(a+b);
    if(t>a) {
        cnt+=a;
    }else {
        cnt+=t;
    }
    cout << cnt;
}

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

int main(){
 	int N,K;
	cin >> N >> K;
	long long int count =0;
	for (int i = 1; i <= N; i++) {
		int j = (K-i)% K;
		while(j <= 0)
			j+=K;
        	if((i % K) == (j % K)) {
			count += (long long int)( (N+(j%K)) /K) * (long long int)((N+(i%K)) /K);
		}
	}
	cout << count << endl;
}


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

int N;
vector<long long> A;
long long K;

long long cases(long long threshold){
    long long res = 0LL;
    for(int i=0; i<N; i++){
        if(A[i] > 0){
            res += distance(A.begin()+i+1, lower_bound(A.begin()+i+1, A.end(), (long double)(threshold)/A[i]));
        }else if(A[i] < 0){
            res += distance(upper_bound(A.begin()+i+1, A.end(), (long double)(threshold)/A[i]), A.end());
        }else{
            if(threshold > 0)res += N-i-1;
        }
    }
    return res;
}

int main(void){
    long long Abuf;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
    }
    sort(A.begin(), A.end());
    long long minproduct = min(min(A[0]*A[1], A[0]*A[N-1]), A[N-1]*A[N-2]);
    long long maxproduct = max(max(A[0]*A[1], A[0]*A[N-1]), A[N-1]*A[N-2])+1LL;
    long long res = (minproduct+maxproduct)/2;
    while(maxproduct-minproduct>1){
        if(cases(res)>=K){
            maxproduct = res;
        }else{
            minproduct = res;
        }
        res = (minproduct+maxproduct)/2;
    }
    cout << minproduct << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,N,a[200005],b[200005];
bool check(int mid){
	for(int i=0;i<N;i++)b[i]=(a[i]>mid);
	for(int i=n-1;i;i--){
		if(b[N-i-1]==b[N-i])return b[N-i];
		if(b[i]==b[i-1])return b[i];
	}
	return b[0];
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	N=2*n-1;
	for(int i=0;i<N;i++)cin>>a[i];
	int lb=0,ub=N;
	while(ub-lb>1){
		int mid=(lb+ub)>>1;
		if(check(mid))lb=mid;
		else ub=mid;
	}
	cout<<ub<<endl;
	return 0;
}

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

const int INF = 1001001001;
int co = 0;

void merge(vector<int> &a, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> l(n1+1), r(n2+1);
	rep(i, n1) l.at(i) = a.at(left+i);
	rep(i, n2) r.at(i) = a.at(mid+i);
	l.at(n1) = r.at(n2) = INF;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		co++;
		if(l.at(i) <= r.at(j)){
			a.at(k) = l.at(i);
			i++;
		}else{
			a.at(k) = r.at(j);
			j++;
		}
	}
}

void mergeSort(vector<int> &a, int left, int right){
	if(left + 1 < right){
		int mid = (left+right)/2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}

int main(){
	int n;
	cin >> n;
	vector<int> s(n);
	rep(i, n) cin >> s.at(i);
	mergeSort(s, 0, n);
	rep(i, n){
		if(i != 0) cout << " ";
		cout << s.at(i);
		
	}
	cout << endl;
	cout << co << endl;
	
	return 0;
}


Measured memory_bytes: 6820
#include<bits/stdc++.h>
using namespace std;
static const long long MOD=1000000007;

int main(){
  int N;
  cin>>N;
  string s1,s2,s3;
  cin>>s1>>s2;
  s3="";
  for(int i=0;i<N;i++){
    if(s1.at(i)==s2.at(i)){
      s3+="A";
    }
    else{
      s3+="B";
      i++;
    }
  }
  long long ans=1;
  int flag=0;
  for(int i=0;i<s3.size();i++){
    if(i==0 && s3.at(i)=='A'){
      ans=ans*3;
      flag=0;
      continue;
    }
    if(i==0 && s3.at(i)=='B'){
      ans=(ans*6);
      flag=1;
      continue;
    } 
    if(s3.at(i)=='A' && flag==0){
      ans=(ans*2)%MOD;
      continue;
    }
    if(s3.at(i)=='A' && flag==1){
      flag=0;
      continue;
    }   
    if(s3.at(i)=='B' && flag==0){
      ans=(ans*2)%MOD;
      flag=1;
      continue;
    }    
    if(s3.at(i)=='B' && flag==1){
      ans=(ans*3)%MOD;
      flag=1;
      continue;
    } 
  }
  cout<<ans<<endl;
  return 0;
}
 
    

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}
int main(void){
    int i,h[10];
    for(i=0;i<10;i++){
        scanf("%d",&h[i]);
    }
    qsort(h,10,sizeof(int),compare);
    for(i=0;i<3;i++){
        printf("%d\n",h[i]);
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main() {
  
  double w, h;cin>>w>>h;
  {cout << fixed << setprecision(6);
    
  double sq = w*h /2;
 cout<<sq;
 cout <<" ";
  }
  int y, x;cin>>x>>y;
  if (x==w/2 && y==h/2){
    cout << 1 << endl;
  }else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def is_balanced?(line)
  brackets = []

  line.each do |char|
    case char
      when '('
        brackets.push(char)
      when ')'
        return false if brackets.pop != '('
      when '['
        brackets.push(char)
      when ']'
        return false if brackets.pop != '['
      else
        # pass
    end
  end

  return brackets.empty?
end

loop do
  line = gets.chomp.to_s.chars
  break if line.size == 1 && line[0] == '.'

  puts is_balanced?(line) ? 'yes' : 'no'
end

Measured memory_bytes: 8888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int h,w,k;cin >> h >> w >> k;
  vector<vector<int>> a(w,vector<int>(h));
  int black=0;
  rep(y,h){
    string s;
    cin >> s;
    rep(x,w){
      if(s[x]=='#'){a[x][y]=1;black++;}//black
      else a[x][y]=0;
    }
  }
  ll ans=0;
  for(int bity=0;bity<(1<<h);bity++){
    for(int bitx=0;bitx<(1<<w);bitx++){
      vector<vector<ll>>check(w,vector<ll>(h));
      int b=black;
      rep(k,h){
	if(bity&(1<<k)){
	  rep(i,w){
	    if(a[i][k]==1){
	      b--;
	      check[i][k]=mod;
	    }
	  }
	}
      }
      rep(k,w){
	if(bitx&(1<<k)){
	  rep(i,h){
	    if(a[k][i]==1&&check[k][i]!=mod)b--;
	  }
	}
      }
      if(b==k)ans++;
    }
  }

  cout << ans;
}











Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
int main() {
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int top    = sc.nextInt();
		int front  = sc.nextInt();
		int left   = sc.nextInt();
		int right  = sc.nextInt();
		int back   = sc.nextInt();
		int bottom = sc.nextInt();
		
		HashMap<Integer, HashMap<Integer, Integer>> dice = new HashMap<Integer, HashMap<Integer, Integer>>();
		dice.put(top, new HashMap<Integer, Integer>());
		dice.put(front, new HashMap<Integer, Integer>());
		dice.put(left, new HashMap<Integer, Integer>());
		dice.put(right, new HashMap<Integer, Integer>());
		dice.put(back, new HashMap<Integer, Integer>());
		dice.put(bottom, new HashMap<Integer, Integer>());
		dice.get(top).put(front, left);
		dice.get(top).put(left, back);
		dice.get(top).put(back, right);
		dice.get(top).put(right, front);
		dice.get(front).put(bottom, left);
		dice.get(front).put(left, top);
		dice.get(front).put(top, right);
		dice.get(front).put(right, bottom);
		dice.get(bottom).put(back, left);
		dice.get(bottom).put(left, front);
		dice.get(bottom).put(front, right);
		dice.get(bottom).put(right, back);
		dice.get(back).put(top, left);
		dice.get(back).put(left, bottom);
		dice.get(back).put(bottom, right);
		dice.get(back).put(right, top);
		dice.get(left).put(top, front);
		dice.get(left).put(front, bottom);
		dice.get(left).put(bottom, back);
		dice.get(left).put(back, top);
		dice.get(right).put(front, top);
		dice.get(right).put(top, back);
		dice.get(right).put(back, bottom);
		dice.get(right).put(bottom, front);
		
		final int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			
			System.out.println(dice.get(a).get(b));
			
		}
		
	}
}

Measured memory_bytes: 17216
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <__msvc_all_public_headers.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
 
typedef long long  ll;

#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}

const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int N = 200010;
const int INF = 1e8;
const ll LL_INF=1e10;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int questions=1;
// cin>>questions;
 
 while(questions--)
 {
       ll n;
       long double d;
       cin>>n>>d;
       int ans=0;
       while(n--)
       {
                 ll a,b;
                 cin>>a>>b;
                 long double dis= sqrt(a*a+b*b);
                 if(dis<=d) ans++;
       }
       cout<<ans;
 }
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3800
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

const int M = 26;

int main() {
  ios::sync_with_stdio(false);
  string a;
  cin >> a;
  int n = a.size();
  VI sep;
  vector<bool> app(M, false);
  int appcount = 0;
  vector<VI> pos(M);
  for(int i = n-1; i >= 0; i--) {
    if(!app[a[i]-'a']) {
      app[a[i]-'a'] = true;
      appcount++;
      if(appcount == M) {
        sep.push_back(i);
        app.assign(M, false);
        appcount = 0;
      }
    }
  }
  if(sep.empty()) {
    REP(i,0,M) {
      if(!app[i]) {
        cout << (char)('a'+i) << endl;
        return 0;
      }
    }
  }
  reverse(sep.begin(), sep.end());
  sep.push_back(n);
  REP(i,0,n) {
    pos[a[i]-'a'].push_back(i);
  }
  int len = sep.size();
  int used = -1;
  string ans;
  REP(i,0,len) {
    REP(c,0,M) {
      auto cp = lower_bound(pos[c].begin(), pos[c].end(), used);
      if(cp == pos[c].end() || *cp >= sep[i]) {
        ans.push_back('a' + c);
        used = *cp + 1;
        break;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1428
def main():
    N = int(input())
    playlist = list()

    for _ in range(N):
        title, time = input().split()
        playlist.append([title, int(time)])

    st = input()
    add_flag = 0
    ans = 0

    for p in playlist:

        if add_flag:
            ans += p[1]

        if p[0] == st:
            add_flag = 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    for (Int i = 0; i < n; i++) cin >> b[i];
    vector<Int> c = b;
    priority_queue<pair<Int, Int>> q;
    for (Int i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            dump(-1);
            return 0;
        }
        if (a[i] == b[i]) continue;
        q.push({b[i], i});
    }
    Int res = 0;
    while (!q.empty()) {
        pair<Int, Int> p = q.top();
        q.pop();
        Int pre = c[(p.se - 1 + n) % n];
        Int nex = c[(p.se + 1) % n];
        Int sub = (c[(p.se - 1 + n) % n] + c[(p.se + 1) % n]);
        if ((c[p.se] - a[p.se]) % sub == 0) {
            res += (c[p.se] - a[p.se]) / sub;
            c[p.se] = a[p.se];
            continue;
        }
        else {
            Int add = (c[p.se] - a[p.se]) / sub;
            c[p.se] -= add * sub;
            res += add;
            if (max(pre, nex) <= c[p.se]) {
                dump(-1);
                return 0;
            }
        }
        if (c[p.se] > a[p.se]) {
            q.push({c[p.se], p.se});
        }
        //res++;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 11248
N = int(input())
A = []
BTC = 380000.0
ans = 0
for _ in range(N):
    x,u = input().split()
    tmp = (float(x),u)
    A.append(tmp)
for a in A:
    x = a[0]
    u = a[1]
    if u == "JPY":
        ans += x
    else:
        ans += x*BTC
print(ans)


Measured memory_bytes: 3060
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 1e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int n;
ll a[maxn], b[maxn], c[maxn];
ll dp[5][maxn];

ll dfs (int act, int pos){
    if (pos - 1 == n) return 0;

    ll &ans = dp[act][pos];
    if (ans != -1) return ans;

    if (act == 0){
        ans = max(ans, dfs(1, pos + 1) + a[pos]);
        ans = max(ans, dfs(2, pos + 1) + b[pos]);
        ans = max(ans, dfs(3, pos + 1) + c[pos]);
    }
    else if (act == 1){
        ans = max(ans, dfs(2, pos + 1) + b[pos]);
        ans = max(ans, dfs(3, pos + 1) + c[pos]);
    }
    else if (act == 3){
        ans = max(ans, dfs(1, pos + 1) + a[pos]);
        ans = max(ans, dfs(2, pos + 1) + b[pos]);
    }
    else{
        ans = max(ans, dfs(1, pos + 1) + a[pos]);
        ans = max(ans, dfs(3, pos + 1) + c[pos]);
    }

    return ans;
}

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

    cin >> n;

    memset(dp, -1, sizeof dp);

    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 3; j++){
            if (j == 1) cin >> a[i];
            if (j == 2) cin >> b[i];
            if (j == 3) cin >> c[i];
        }
    }

    cout << dfs(0, 1) << "\n";

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
vector<ll>NUM(1e6+20,1);
void Div(ll n){
    for(ll i=2;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            NUM[j]++;
        }
    }
}
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    Div(1e6);
    for(ll i=1;i<n;i++){
        ans+=NUM[i];
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N,M;
    cin>>N>>M;
    cout<<(N-1)*(M-1)<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int sum = 0;
	while (sum <= n) {
		int rest = n - sum;
		if (rest % 4 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
		sum += 7;
	}
	cout << "No" << endl;
	return 0;
}


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

int main(){
  int N,Q;
  cin >> N >> Q;
  vector<pair<int,int>> A(N-1,pair<int,int>(0,0));
  for(int i=0;i<N-1;i++){
    cin >> A.at(i).first >> A.at(i).second;
  }
  sort(A.begin(),A.end());
  vector<long long> P(N+1,0);
  int r,s;
  for(int i=0;i<Q;i++){
    cin >> r >> s;
    P.at(r) += s;
  }
  r=0;
  s=0;
  for(int i=0;i<N-1;i++){
    r=A.at(i).first;
    s=A.at(i).second;
    P.at(s) += P.at(r);
  }
  for(int i=1;i<=N;i++){
    cout << P.at(i) << " " ;
  }
}

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


auto solve(long long A, long long B){
    int p[] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    return (p[A] < p[B]) ? "Bob":
        (p[A] > p[B]) ? "Alice":
        "Draw";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    auto result = solve(A, B);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  int n;
  int a[100000];
  int c = 0;
  
  scanf("%d", &n);
  
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if(a[i] % 2 != 0) {
      c++;
    }
  }
  
  if(c > 0) {
    printf("first");
  } else {
    printf("second");
  }
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a, b, c, d;
bool check(ll l, ll r)
{
	bool flag = 0;
	for(int k = -(n - 2); k <= n - 2; k += 2)
	{
		ll nl = l - c * k, nr = r - c * k;
		if(d - c == 0) flag |= (nl <= 0 && 0 <= nr);
		else
		{
			nr = nr >= 0 ? nr / (d - c) : (nr - (d - c - 1)) / (d - c);
			nl = nl >= 0 ? (nl + d - c - 1) / (d - c) : nl / (d - c);
			if(nl > nr) continue;
			flag |= (abs(nl) + abs(k - nl) <= n - 2);
			flag |= (abs(nr) + abs(k - nr) <= n - 2);
			flag |= (nl <= 0 && 0 <= nr);
			flag |= (nl <= k && k <= nr);
			//if(flag) { cout << l << ' ' << r << ' ' << nl << ' ' << nr << ' ' << k << ' ' << n << endl; system("pause");}
		}
	}
	return flag;
}
int main()
{
	cin >> n >> a >> b >> c >> d;
	b -= a;
	if(check(b - d, b - c) || check(b + c, b + d)) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	int a,b,c,n;
	scanf("%d %d %d",&a,&b,&c);
	n=a*100+b*10+c;
	if(n%4==0) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_W = 30, MAX_H = 30;

int w, h, vwall[MAX_H][MAX_W-1], hwall[MAX_H-1][MAX_W];

int d[MAX_H][MAX_W];

int main() {
    while (true) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        REP(i, 2 * h - 1) {
            if (i % 2 == 0) {
                REP(j, w - 1) cin >> vwall[i / 2][j];
            }
            else {
                REP(j, w) cin >> hwall[i / 2][j];
            }
        }

        REP(i, h) {
            REP(j, w) d[i][j] = 0;
        }

        queue<pair<int, int>> Q;
        Q.push(MP(0, 0));
        d[0][0] = 1;

        while (Q.size()) {
            int x = Q.front().first;
            int y = Q.front().second;
            Q.pop();
            int nx, ny;

            if (x > 0) {
                nx = x - 1, ny = y;
                if (hwall[nx][ny] == 0 && d[nx][ny] == 0) {
                    Q.push(MP(nx, ny));
                    d[nx][ny] = d[x][y] + 1;
                }
            }

            if (x < h - 1) {
                nx = x + 1, ny = y;
                if (hwall[x][y] == 0 && d[nx][ny] == 0) {
                    Q.push(MP(nx, ny));
                    d[nx][ny] = d[x][y] + 1;
                }
            }

            if (y > 0) {
                nx = x, ny = y - 1;
                if (vwall[nx][ny] == 0 && d[nx][ny] == 0) {
                    Q.push(MP(nx, ny));
                    d[nx][ny] = d[x][y] + 1;
                }
            }

            if (y < w - 1) {
                nx = x, ny = y + 1;
                if (vwall[x][y] == 0 && d[nx][ny] == 0) {
                    Q.push(MP(nx, ny));
                    d[nx][ny] = d[x][y] + 1;
                }
            }
        }

        int ans = d[h-1][w-1];
        PRINT(ans);
    }
    return 0;
}


Measured memory_bytes: 3056
N, K, Q=map(int, input().split())
A=[None]*Q
for i in range(Q):
    A[i]=int(input())
#print(A)

import collections
dict=collections.Counter(A)
for person in range(1,N+1):
    if K-Q+dict[person]>0:
        print('Yes')
    else:
        print('No')

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

int num[200050]={0};
int main()
{
		int n;
		int maxv=-2000000000,minv;
		scanf("%d",&n);
		for(int i = 1 ; i <= n ; i++)
				scanf("%d",&num[i]);
		minv=num[1];
    for(int i = 2 ; i <= n ; i++)
		{
				maxv=max(maxv,num[i]-minv);
				minv=min(minv,num[i]);
		}
		printf("%d\n",maxv);
		return 0 ;
}



Measured memory_bytes: 3968
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int res = 0;
    for (int r = 0; r <= N / R; r++) {
        for (int g = 0; g <= (N - r * R) / G; g++) {
            if ((N - r * R - g * G) % B == 0) res++;
        }
    }

    cout << res << endl;

    return 0;
}


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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

int main(){
	fast;
    int d,t,s;
    cin>>d>>t>>s;
    int val;
    if(d%s==0)
        val=d/s;
    else
        val=d/s+1;
    if(val <=t)
        cout<<"Yes";
    else
        cout<<"No";
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n);
  map<ll, int> cnt;
  rep(i, n) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  ll ans = 0;
  for(auto ele: cnt) {
    if(ele.second >= ele.first) {
      ans += ele.second - ele.first;
    } else {
      ans += ele.second;
    }
  }
  cout << ans << "\n";
  return 0;
}


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

typedef struct point{
	int x,y;
} t_point;

bool cmp(const t_point& a, const t_point& b)
{
	if( a.x < b.x )return true;
	else if( a.x > b.x )return false;
	return a.y < b.y;
}

int main()
{
	int n;
	t_point points[3000];
	
	while(cin>>n,n){
		for(int i=0; i<n; i++)
			cin >> points[i].x >> points[i].y ;
		sort( points, points+n, cmp );
		
		int ans = 0;
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				t_point p3 = {points[i].y-points[j].y+points[j].x,
											points[j].x-points[i].x+points[j].y};
				t_point p4 = {points[i].y-points[j].y+points[i].x,
											points[j].x-points[i].x+points[i].y};
				int left3,left4;
				int right3,right4;
				int flag3,flag4;
				left3 = left4 = 0;
				right3 = right4 = n-1;
				flag3 = flag4 = 1;
				int diff3,diff4;
				while( left3<=right3 && left4<=right4 && (flag3||flag4) ){
					diff3 = (left3+right3)/2;
					diff4 = (left4+right4)/2;
					if( points[diff3].x==p3.x && points[diff3].y==p3.y )
						flag3 = 0;
					else if( cmp(points[diff3],p3) )
						left3 = diff3+1;
					else
						right3 = diff3-1;
					
					if( points[diff4].x==p4.x && points[diff4].y==p4.y )
						flag4 = 0;
					else if( cmp(points[diff4],p4) )
						left4 = diff4+1;
					else
						right4 = diff4-1;
				}
				if( left3>right3 || left4>right4 )continue;

				ans = max(ans,(p3.x-p4.x)*(p3.x-p4.x)+(p3.y-p4.y)*(p3.y-p4.y));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

ll powmod(ll x, ll y) {
    ll res = 1;
    for (ll i = 0; i < y; i++) {
        res = res * x % MOD;
    }
    return res;
}

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

    ll ans = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;

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


Measured memory_bytes: 3492
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    int N, X;
    cin >> N >> X;

    int D = 0;
    int L;
    int ans = 1;
    REPinit(i, 1, N + 1) {
        cin >> L;
        D = D + L;
        if (D <= X) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
N,M = map(int, input().split())
data = [list(map(int, input().split())) for i in range(N)]

data.sort()
num = 0
# for x in data:
#     print(x)
    
for x in data:
    for xx in range(int(x[1])):
        M -= 1
        num += int(x[0])
        if(M == 0):
            break
    if(M == 0):
        break
print(num)        

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    n=1000-n%1000;
    
    if (n==1000){
        cout<<0;
    }
    else cout<<n;
    
    
    
    
    return 0;
}

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

using namespace std;

int main() {
  int N, M;
  vector<pair<long long, int>> AB;
  
  cin >> N >> M;
  
  for (int i = 0; i < N; i++) {
    long in1;
    int in2;
    
    cin >> in1 >> in2;
    
    AB.push_back(make_pair(in1, in2));
  }
  
  sort(AB.begin(), AB.end());
  
  int buy = 0;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    buy = min(M, AB[i].second);
    sum += AB[i].first * buy;
    M -= buy;
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 2420