akhauriyash/Code-Regression huggingface dataset:
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#define println(str) cout << str << endl;

#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int N;
    cin >> N;

    // 入力数がN個の場合
    int ans = 0;
    for (int i = 105; i <= N; i++)
    {
        if (i % 2 == 0)
        {
            // 偶数除外
            continue;
        }

        int count_num = 0;
        for (int j = 1; j <= i; j++)
        {   
            if (i % j == 0)
            {
                // 割り切れた回数(約数の数)
                count_num++;
            }
        }
        if (count_num == 8)
        {
            ans++;
        }
    }

    // 結果出力
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define ll long long int
using namespace std;
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
ll mod = 1e9 + 7;
vector < int > adj[21];
ll dp[21][(1<<21)+1];
ll alldone;
inline ll setbit(ll mask , ll i){
    return mask|(1<<i);
}
inline ll isset(ll mask , ll i){
    return mask&(1<<i);
}
inline ll isunset(ll mask , ll i){
    return !(mask&(1<<i));
}
inline ll unset(ll mask , ll i){
    ll temp=mask&!(1<<i);
    return temp;
}
inline  ll countset(ll mask){
    return __builtin_popcount(mask);
}
int n;
ll solve(int ind, ll mask){
    if(mask==alldone){
        return 1;
    }
    if(ind==n){
        return 0;
    }
    if(dp[ind][mask]!=-1){
        return dp[ind][mask];
    }
    ll ans=0;
    for(auto it:adj[ind]){
        if(isset(mask,it)){
            continue;
        }
        ans+=solve(ind+1,setbit(mask,it))%mod;
        ans%=mod;
    }
    dp[ind][mask]=ans;
    return ans;
}
void getac()
{
   cin>>n;
   alldone=(1<<n)-1;
   for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int x;
            cin>>x;
            if(x==1){
                adj[i].pb(j);
            }
        }
   }
   for(int i=0;i<n;i++){
    for(int j=0;j<=alldone;j++ ){
        dp[i][j]=-1;
    }
   }
   ll ans=solve(0,0);
   cout<<ans<<'\n';
}
int  main()
{


    fastio;
    int t = 1;
    

    while(t--)
    {
        getac();
    }
    return 0;
}

Measured memory_bytes: 344448
s = input()

if len(s) < 26:
    for i in range(26):
        c = chr(ord('a') + i)
        if not c in s:
            print(s + c)
            exit()
elif s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()
else:
    for i in range(24,-1,-1):
        for j in range(25,i,-1):
            if s[i] < s[j]:
                print(s[:i] + s[j])
                exit()



Measured memory_bytes: 38384
n = int(input())
c = list(input())

ans = 0
rightNum = n-1
flag = 0
for i in range(n):
    if c[i] == "W":
        for j in range(n):
            if i >= rightNum-j:
                flag = 1
                break
            if c[rightNum-j] == "R":
                c[rightNum-j] = "W"
                c[i] = "R"
                rightNum -= j+1
                ans += 1
                break
    if flag == 1:
        break
print(ans)


Measured memory_bytes: 10792
import java.util.Scanner;

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

    while( scan.hasNext() ) {
      int x = scan.nextInt();
      int y = scan.nextInt();
      int z = 1;
      int out = 0;
      while( true ) {
        int r = ( x + y ) / z;
        if( r == 0 ) {
          break;
        } else {
          z *= 10;
          out++;
        }
      }
      System.out.println(out);
    }
  }
}

Measured memory_bytes: 26248
import heapq
N, M = map(int, input().split())
L = []


for i in range(N):
    A, B = map(int, input().split())
    L.append([A, B])

L = sorted(L, reverse= True)

dp = [0 for i in range(M+1)]
use = [False for i in range(N)]

dp[0] = 0
h = []

for i in range(M):
    while len(L) != 0:
        m = L[-1]
        if m[0] <= i+1:
            heapq.heappush(h, -L.pop(-1)[1])
        else:
            break
    if len(h) != 0: 
        dp[i+1] = dp[i] + -heapq.heappop(h)
    else:
        dp[i+1] = dp[i]

print(dp[M])

Measured memory_bytes: 21496
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
cost =sum([abs(a[i+1]-a[i]) for i in range(n+1)]) 
for i in range(1,n+1):
  print(cost - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]))


Measured memory_bytes: 20640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * ????????¢?????????
 *
 * ??????H cm ?????? W cm ???????????¢?????????????????°?????????????????????????????????
 *
 * 1 cm ?? 1cm ???????????¢??? '#'??§??¨????????????
 *
 * Input
 * ??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
 *
 * H W
 *
 * H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????
 *
 * Output
 * ????????????????????????????????????H ?? W ?????? '#' ??§????????????????????¢???????????????????????????
 *
 * ?????????????????????????????????????????????????????\??????????????????
 *
 * Constraints
 * 1 ??? H, W ??? 300
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A
 *
 * @author wsKmatsuda
 *
 */
public class Main {

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

	public void run(){

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String inputData;
        List<Square> squareList = new ArrayList<Square>();
        try {
        	//??\???
	        while(true){
				inputData = reader.readLine();
	            if("0 0".equals(inputData)){
	            	break;
	            }else{
					String[] strNumber = inputData.split(" ");
					int h = Integer.parseInt(strNumber[0]);
					int w = Integer.parseInt(strNumber[1]);
					squareList.add(new Square(h,w));
	            }
	        }

	        //??????
	        for(Square square : squareList){
				outputSquare(square.h , square.w);
				System.out.println();
	        }

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	/**
	 * ????????¢?????????
	 * @param h
	 * @param w
	 */
	private static void outputSquare(int h, int w) {
		StringBuilder sbLine = new StringBuilder();
		for(int i=0;i< w ;i++){
			sbLine.append("#");
		}
		for(int i=0;i<h;i++){
			System.out.println(sbLine.toString());
		}
	}

	/**
	 * ????§???¢?????????
	 * h,w???????????????
	 */
	class Square{

		public int h;
		public int w;

		Square(int _h ,int _w){
			h = _h;
			w = _w;
		}
	}

}

Measured memory_bytes: 25312
using System;

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            for (int i = 0; i < str.Length; i++)
            {
                Console.Write(str[str.Length-i-1]);
            }
            Console.WriteLine();
        }


    }
}



Measured memory_bytes: 13748
#include<bits/stdc++.h>
                using namespace std;
                #define lli long long int
                #define fr(i,a,b) for(int i=a;i<b;i++)
                #define bfr(i,a,b) for(int i=a;i>=b;i--)
                #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
                #define tc int t;cin>>t;while(t--)
                #define mod 1000000007 
                #define all(vec) vec.begin(),vec.end()  
                #define ld long double


               
        int main()
                {
                       
                        
                    
                     fio
                     
                     lli n;
                     cin>>n;
                     cout<<(lli)(ceil(n/2.000));



                     







                     


                     

                     

                     


return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, cnt;
    cin >> N;
    vector<int> data(N);
    vector<int> balls(N, 0);
    rep(i, N){
        cin >> data[i];
    }
    cnt = 0;
    for(int i = N; i >= 1; i--){
        int curTotal;
        curTotal = 0;
        int ref = 1;
        while(ref*i <= N){
            curTotal += balls[i * ref - 1];
            ref++;
        }
        if(curTotal % 2 != data[i - 1]){
            balls[i - 1] = 1;
            cnt++;
        }
    }
    cout << cnt << endl;
    rep(i, N){
        if(balls[i] == 1){
            cout << i+1 << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);

        ll n,d,s=0;
        cin>>n>>d;
        while(n--)
        {   dd x,y,z;
            cin>>x>>y;
            x*=x;
            y*=y;
            z=x+y;
            z=sqrt(z);
   
            if(z<=d)s+=1;
        }

            cout<<s;
}








Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s;
    ll n,m;
    cin>>n;
    ll k;
    cin>>m>>k;
    ll lock=0;
    for(int i=m;i<=k;i++)
    {
        if(i%n==0)
        {
            lock=1;
            cout<<"OK"<<endl;
            break;
        }
    }
    if(lock==0)
        cout<<"NG"<<endl;

}



Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n;
    std::cin >> n;

    int max = 0;
    int i;
    for (i = 1;; i++) {
        max += i;
        if (max > n) {
            break;
        }
    }

    int j = 0;
    while (max != n) {
        j++;
        max--;
    }

    for (int k = 1; k <= i; k++) {
        if (k != j) {
            std::cout << k << std::endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
using namespace std;

class Map {
private:
    int h,w;
    char **map;
    char **count;
    bool getBomb(int i,int j) {
        if(i < 0||h <= i||j < 0||w <= j)return false;
        return map[i][j] == '#';
    }
    void setCount(int i,int j) {
        if(getBomb(i,j)) {
            count[i][j] = '#';
            return;
        }
        count[i][j] += getBomb(i+1,j+1) ? 1 : 0;
        count[i][j] += getBomb(i+1,j-1) ? 1 : 0;
        count[i][j] += getBomb(i+1,j) ? 1 : 0;
        count[i][j] += getBomb(i-1,j+1) ? 1 : 0;
        count[i][j] += getBomb(i-1,j-1) ? 1 : 0;
        count[i][j] += getBomb(i-1,j) ? 1 : 0;
        count[i][j] += getBomb(i,j+1) ? 1 : 0;
        count[i][j] += getBomb(i,j-1) ? 1 : 0;
    }

public:
    Map(int h,int w) {
        this->h = h;
        this->w = w;
        map = (char **)malloc(sizeof(char *)*h);
        count = (char **)malloc(sizeof(char *)*h);
        for(int i = 0;i < h;i++) {
            map[i] = (char *)malloc(sizeof(char)*w);
            count[i] = (char *)malloc(sizeof(char)*w);
            for(int j = 0;j < w;j++) {
                map[i][j] = 0;
            }
        }
    }
    void setBomb(int i,int j,char c) {
        map[i][j] = c;
    }
    void setCount() {
        for(int i = 0;i < h;i++)
            for(int j = 0;j < w;j++)
                setCount(i,j);
    }
    void show() {
        for(int i = 0;i < h;i++) {
            for(int j = 0;j < w;j++) {
                if(getBomb(i,j))printf("%c",count[i][j]);
                else printf("%d",count[i][j]);
            }
            printf("\n");
        }
    }
    void Free() {
        for(int i = h -1;0 <= i;i--) {
            free(map[i]);
        }
        free(map);
    }
};

int main() {
    int h,w;
    char dummy = 0;
    scanf("%d%d",&h,&w);
    scanf("%*c",&dummy);
    Map map(h,w);
    for(int i = 0;i < h;i++) {
        for(int j = 0;j < w;j++) {
            char c;
            scanf("%c",&c);
            map.setBomb(i,j,c);
        }
        scanf("%*c",&dummy);
    }
    map.setCount();
    map.show();
    map.Free();
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int a,b;
    cin>>a>>b;
    int cnt=0;
    FOR(i,a,b+1){
        string s=to_string(i);
        bool flag=true;
        rep(i,s.size()){
            if(s[i]!=s[s.size()-i-1]) flag=false;
        }
        cnt+=flag;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
static const int INF = 1e8;

int main(void){
	while(1){
		int n, k;
		scanf("%d %d", &n, &k);
		if(n == 0 && k == 0) return 0;
		int dist[101][101];
		rep(i, 101) rep(j, 101){
			if(i == j) dist[i][j] = 0;
			else dist[i][j] = INF;
		}

		int flag, a, b, c, d, e;
		//????????????????????£???????????????????????¶??????????§??????????
		int kousinnflag = false;//?????????????????¢????????????????????´??°??????????????¨?????????????????°
		rep(i, k){
			scanf("%d", &flag);
			if(flag == 0){
				scanf("%d %d", &a, &b);
				a--; b--;
				//???????????£?????????????????§?????????????????´??°?????????????????????????????£???????????????????¨??????????????????????????????¢?????´??°????????????????????°?¨????????????????????????????
				if(kousinnflag == true){
					rep(m, n) rep(l, n) rep(j, n)
						dist[l][j] = min(dist[l][j], dist[l][m] + dist[m][j]);
					kousinnflag = false;
				}

				if(dist[a][b] >= 1e8) printf("-1\n");//?????????????????¨???
				else printf("%d\n", dist[a][b]);
			}else{
				scanf("%d %d %d", &c, &d, &e);
				c--; d--;
				if(dist[c][d] > e){
					dist[c][d] = dist[d][c] = e;//????????????????????????????????°??´??°
					kousinnflag = true;
				}
			}
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, Y;
  IN(X,Y);

  ll ans = 0;
  while(X<=Y){
    ans++;
    X*=2;
  }

  OUT(ans);



  return 0;
}

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

map<char,int> cnt;

int main(){
  string s;
  cin >> s;
  
  for(int i = 0;i<4;i++){
    cnt[s[i]]++;
  }
  
  if(cnt.size()!=2)cout << "No" << endl;
  else{
    bool flag = true;
    for(auto i:cnt)if(i.second!=2)flag = false;
    if(flag)cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [0] + [int(a) for a in input().split()]
    B = [0] + [int(b) for b in input().split()] + [0] + [0]
    
    ans = 0
    
    for i in range(1,N+2):
        for j in range(-1,1):
            kill = min(A[i],B[i+j])
            ans += kill
            A[i] -= kill
            B[i+j] -= kill
    print(ans)
            
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 18624
#include <stdio.h>

int main(void)
{
	int n, a, i;
	double revans = 0;

	scanf("%d", &n);

	//入力された数値の逆数を合計する
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		revans += 1 / (double)a;
	}

	//「逆数の合計」の逆数を出力する
	printf("%f", 1 / revans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string n;

    cin>>n;

    int sum = 0;

    for(int i=0;i<n.size();i++)
        sum+=(n[i]-48);

    if(sum%9==0) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 3720
import Control.Monad.State
import Control.Monad
import Data.List

main = do
    s <- getLine
    q <- getLine >>= return . (read :: String -> Int)
    x <- replicateM q (getLine >>= return . words)
    let ((b,b'),c) = (runState $ foldl' (>>=) (return (s,"")) (map f x)) True
    if c then putStrLn (b ++ (reverse b')) else putStrLn (b' ++ (reverse b))

f :: [String] -> (String,String) -> State Bool (String,String)
f ["1"] (s,s') = do
    b <- get
    put $ not b
    return (s,s')

f x (s,s') = do
    b <- get
    return (if (x !! 1 == "1") == b then ((x !! 2 !!0:s),s') else (s,(x !! 2 !!0:s')))

{-
f :: [String] -> String -> State Bool String
f ["1"] s = do
    b <- get
    put $ not b
    return s

f x s = do
    b <- get
    return (if (x !! 1 == "1") == b then (x !! 2 !!0:s) else s ++ x !! 2)
-}

Measured memory_bytes: 169596
S = gets.chomp
T = gets.chomp

#puts S,T

count=T.length
for i in 0..S.length-T.length
  count_tmp=0
  for j in 0..T.length-1
    if(S[i+j]!=T[j])
      count_tmp+=1
    end
  end
  if(count_tmp<count)
    count=count_tmp
  end
end

puts count

Measured memory_bytes: 14260
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N, K; 
	cin >> N >> K;
	int H[114514] = {}; 
	for(int i = 0; i < N; i++){
		cin >> H[i]; 
	}
	sort(H, H + N); 
	int saishou = 1145141919;
	for(int i = 0; i <= N - K; i++){
		saishou = min(saishou, H[i + K - 1] - H[i]); 
	}
	cout << saishou << endl; 
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

void yes() {
	cout << "Yes" << endl;
}

void no() {
	cout << "No" << endl;
}

int main() {
	int h, n;
	cin >> h >> n;
	int sum = 0, temp;
	rept(i, n) {
		cin >> temp;
		sum += temp;
	}
	if (sum >= h)yes();
	else no();


	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#define ROP(i,n) for(int i=0;i<n;i++)
#define ROOP(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
  int P;int A,B,C,D;
  scanf("%d",&P);
  A=P/1000;B=P%1000/100;C=P%100/10;D=P%10;
  if(A+B+C+D==7) printf("%d+%d+%d+%d=7\n",A,B,C,D);
  else if(A+B+C-D==7) printf("%d+%d+%d-%d=7\n",A,B,C,D);
  else if(A+B-C+D==7) printf("%d+%d-%d+%d=7\n",A,B,C,D);
  else if(A-B+C+D==7) printf("%d-%d+%d+%d=7\n",A,B,C,D);
  else if(A+B-C-D==7) printf("%d+%d-%d-%d=7\n",A,B,C,D);
  else if(A-B-C+D==7) printf("%d-%d-%d+%d=7\n",A,B,C,D);
  else if(A-B+C-D==7) printf("%d-%d+%d-%d=7\n",A,B,C,D);
  else if(A-B-C-D==7) printf("%d-%d-%d-%d=7\n",A,B,C,D);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long lli;

int GCD(int a, int b)
{
    while(a%b) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return b;
}

int main()
{
	int n, gcd;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    gcd = a[0];
    for(int i=1; i<n; i++) {
        gcd = GCD(gcd, a[i]);
    }
    cout << gcd << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;

namespace arc098_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
			long ret = 0; long now = 0; int j = 0;
			for (int i = 0; i < n; i++)
			{
				while (j < n && (now & x[j]) == 0)
				{
					now ^= x[j];
					j++;
				}
				ret += j - i;
				now ^= x[i];
			}
			Console.WriteLine(ret);
		}
	}
}

Measured memory_bytes: 36436
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

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

  int grid[100][100];
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      grid[i][j] = -1;
    }
  }

  int x = 0, y = 0;
  while(a > 1){
    if(x >= 100){
      x = 0;
      y += 2;
    }
    grid[x][y] = 0;
    grid[x+1][y] = 0;
    grid[x][y+1] = 0;
    grid[x+1][y+1] = 1;
    a--;
    x += 2;
  }

  while(x < 100){
    grid[x][y] = 0;
    grid[x][y+1] = 0;
    grid[x+1][y] = 0;
    grid[x+1][y+1] = 0;
    x += 2;
  }

  y += 2;
  for(int i = 0; i < 100; i++){
    grid[i][y] = 0;
  }

  x = 0;
  y += 1;

  while(b > 1){
    if(x >= 100){
      x = 0;
      y += 2;
    }
    grid[x][y] = 1;
    grid[x+1][y] = 1;
    grid[x][y+1] = 1;
    grid[x+1][y+1] = 0;
    b--;
    x += 2;
  }

  while(x < 100){
    grid[x][y] = 1;
    grid[x][y+1] = 1;
    grid[x+1][y] = 1;
    grid[x+1][y+1] = 1;
    x += 2;
  }

  x = 0;
  y += 2;
  for(int i = 0; i < 100; i++){
    grid[i][y] = 1;
  }


  cout << y+1 << " " << 100 << endl;
  for(int i = 0; i <= y; i++){
    for(int j = 0; j < 100; j++){
      if(grid[j][i] == 1) cout << '.';
      else cout << '#';
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int j;
	int k;
	static int prime[1000000];
	
	for (i = 1; i <= 999999; i++){
		if (i == 2){
			prime[i] = 1;
		}
		else if (i != 1){
			k = 0;
			for (j = 2; j * j <= i; j++){
				if (i % j == 0){
					k = 1;
					break;
				}
			}
			if (k == 0){
				prime[i] = 1;
			}
		}
	}
	
	for (i = 1; i < 999999; i++){
		prime[i + 1] += prime[i];
	}
	while (scanf("%d", &n) != EOF){
		printf("%d\n", prime[n]);
	}
	
	return 0;
}

Measured memory_bytes: 4500
#include <stdio.h>

int main(){
	int a,b;
	double _a,_b;
	scanf("%d%d",&a,&b);
	printf("%d ",a/b);
	printf("%d ",a%b);
	_a=a;
	_b=b;
	printf("%lf\n",_a/_b);
	return 0;
}

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

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

        int X = scanner.nextInt();
        int N = scanner.nextInt();
        Set<Integer> p = new HashSet<>();

        for (int i = 0 ; i < N ; i++) {
            p.add(scanner.nextInt());
        }

        int diff = 0;
        while(true) {
            if (!p.contains(X - diff)) {
                System.out.println(X - diff);
                return;
            }
            if (!p.contains(X + diff)) {
                System.out.println(X + diff);
                return;
            }
            diff++;
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  int a[n],i,count=0;
  for(i=0;i<n;i++)
  {
    cin >> a[i];
  }
  for(i=0;i<n;i++)
  {
    if(i % 2 ==0)
    {
      if(a[i] % 2 !=0)
      {
        count++;
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m;
    cin >> n >> m;
    // Sがn個、cがm個
    ll ans = 0;
    if (2*n <= m) {
        ans += n;
        m -= 2*n;
        ans += m/4;
    } else {
        ans = m/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a == 0){
    cout << "Zero";
  } else if (b == 0){
    cout << "Zero";
  } else if (a < 0 && b > 0){
    cout << "Zero";
  } else if (a > 0){
    cout << "Positive";
  } else {
    if ((b - a) % 2 == 1){
      cout << "Positive";
    } else {
      cout << "Negative";
    }
  }
}

Measured memory_bytes: 256
#include<iostream>//头文件~~~ 
using namespace std;//emm……
int main(){
	string a;	bool v[2]={0};//这个初始化害人不浅啊 
	cin>>a;//读入 
	for(int i=0;i<a.length();i++){//a[0]==>a[n-1]全部看一遍 
		if(a[i]=='C') v[0]=1;//出现了C 
		if(a[i]=='F'&&v[0])  v[1]=1;//出现了F 
	}
	if(v[1]) cout<<"Yes";//可以 
	else cout<<"No";//不行 
	return 0;
}

Measured memory_bytes: 3596
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	
	ans := "No"
	for i:=0; i<x+1; i++{
		l := x - i
		if 2 * i + 4 * l == y{
			ans = "Yes"
		}

	}

	fmt.Println(ans)
}

Measured memory_bytes: 1752
#include <iostream>

using namespace std;

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

    bool cards[4][13];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            cards[i][j] = false;
        }
    }

    char suit;
    int rank;
    for (int i = 0; i < n; i++) {
        cin >> suit >> rank;

        if (suit == 'S') cards[0][rank - 1] = true;
        else if (suit == 'H') cards[1][rank - 1] = true;
        else if (suit == 'C') cards[2][rank - 1] = true;
        else if (suit == 'D') cards[3][rank - 1] = true;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (!cards[i][j]) {
                if (i == 0) suit = 'S';
                else if (i == 1) suit = 'H';
                else if (i == 2) suit = 'C';
                else if (i == 3) suit = 'D';
                cout << suit << ' ' << j + 1 << endl;
            }
        }
    }
}


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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

ll n,k; 
ll a[200005];

bool check(ll x){
    ll cnt = 0;
    rep(i,n){
        cnt += (a[i]+x-1)/x-1;
    }
    if(cnt <= k){
        return true;
    }else{
        return false;
    }
}

int main()
{
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    ll ng = 0,ok = 10000000000;
    
    while(ok - ng > 1){
        ll mid = (ok+ng)/2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 5076
Imports System.Collections.Generic
Imports System
Module C
    Sub Main(ByVal args() As String)
        Dim s As String
        Dim n, i, maxcnt As Integer
        Dim list As List(Of String)
        Dim item As String
        Dim dict As New Dictionary(Of String, Integer)
        Dim kvp As KeyValuePair(Of String, Integer)
        n = Integer.Parse(Console.ReadLine())
        maxcnt = 0
        For i = 1 To n
            s = Console.ReadLine()
            If dict.ContainsKey(s) Then
                dict(s) += 1
            Else
                dict.Add(s, 1)
            End If
            maxcnt = Math.Max(maxcnt, dict(s))
        Next
        If maxcnt > 1 Then
            List = New List(Of String)
            For Each kvp In dict
                If kvp.Value = maxcnt Then list.Add(kvp.Key)
            Next
        Else
            List = New List(Of String)(dict.Keys)
        End If
        list.Sort(StringComparer.OrdinalIgnoreCase)
        For Each item In List
            Console.WriteLine(item)
        Next
    End Sub
End Module

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

int main(){
    int N;
    cin >> N;
    int bucket[100000] = {0};
    for(int i =0; i < N; i++){
        int d;
        cin >>d;
        bucket[d] ++;
    }
    int sum = 0;
    int index = 0;
    int res = 0;
    while(sum <= N/2){
        sum += bucket[index];
        if(sum == N/2) res ++;
        index ++;
    }
    cout << res << endl;
}

Measured memory_bytes: 640
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int  n = Integer.parseInt(sn.next());
        int  x = Integer.parseInt(sn.next());
        int  t = Integer.parseInt(sn.next());
        int c = n % x;
      if (c > 0){
        System.out.println((n / x + 1)* t);
      } else {
         System.out.println((n / x )* t);
      }
   }
}


Measured memory_bytes: 35772
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


S = s_in()
N = len(S)

if S == S[::-1] and S[:(N-1)//2] == S[:(N-1)//2][::-1] and S[(N+3)//2-1:] == S[(N+3)//2-1:][::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	ll x;
  	cin >> x;
  	ll time500 = x / 500;
  	ll ans = time500 * 1000;
  	x %= 500;
  	ans += (x / 5) * 5;
  	cout << ans << endl;
    return 0;
}



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

using namespace std;



int main () {
	string N;
	cin >> N;
	string res = "";
	vector<int>nums(4);
	vector<char> ops(2);
	ops[0] = '+';
	ops[1] = '-';
	for(int i=0; i < 4; i++){
		nums[i] = N[i]-'0';
	}
	for(int i = 0; i < 2; i++){
		for(int j = 0; j <2; j++){
			for(int k = 0; k < 2; k ++){
				int temp = 0;
				if(i == 0) {
					temp += nums[0] + nums[1];
				}
				else{
					temp += nums[0] - nums[1];
				}
				if(j == 0){
					temp += nums[2];				
				}
				else temp -=nums[2];
				if(k==0)temp+=nums[3];
				else temp-=nums[3];
				
				if (temp == 7) {
					cout << N[0] << ops[i]<< N[1] << ops[j]<<N[2] << ops[k]<< N[3]<< "=7";
					
					return 0;
				}
			}
		}
	
	}

	return 0;
}

Measured memory_bytes: 256
z[1999999];
main(N,a,b,i){for(;scanf("%d%d%d",&N,&a,&b),N;printf("%d\n",a)){
	for(memset(z,0,sizeof(z)),*z=1,i=0;i<=N;i++)if(z[i])z[a+i]=a+i<=N,z[b+i]=b+i<=N;
	for(a=i=0;i<=N;i++)a+=!z[i];
}exit(0);}

Measured memory_bytes: 8420
import math

def main():

    n,m,c = list(map(int, input().split()))
    b = list(map(int, input().split()))
    aii = [input().split() for l in range(n)]
    cnt = 0
    
    for i in range(n):
        aa = aii[i]
        a_sum = 0
        for ii in range(m):
            a_sum += int(aa[ii])*b[ii]
        a_sum += c
        if a_sum > 0:
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()
    

Measured memory_bytes: 9132
#include <cstdio>
#include <algorithm>
using namespace std;

int dp[100005];
int inp[100005];
int main() {
	int N; scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", inp + i);
		if (i == 2) 
			dp[i] = dp[i - 1] + abs(inp[i] - inp[i - 1]);
		if (i > 2) 
			dp[i] = min(dp[i - 1] + abs(inp[i] - inp[i - 1]), dp[i - 2] + abs(inp[i] - inp[i - 2]));
	}
	printf("%d", dp[N]);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n,d;
	cin>>n>>d;
	int g=2*d+1;
	cout<<n/g+(n%g!=0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll INF = 1e6;

void solve()
{
    /*ll x,y,a,b,c;
    ll p[a], q[b], r[c];
    for(ll i=0i<a;i++)
        cin>>p[i];
    for(ll i=0i<b;i++)
        cin>>q[i];
    for(ll i=0i<c;i++)
        cin>>r[i];
    sort(p,p+a,greater<ll>);
    sort(q,q+b,greater<ll>);
    sort(r,r+c,greater<ll>);
    for(ll i=0;i<x;i++)
    {
        if(i<c)
        {
            if(r[i]>p[i])
        }
    }*/
    ll k,n;
    cin>>k>>n;
    ll a[n], sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll pivot=a[0], pos=0;
    sort(a, a+n);
    ll diff=k-a[n-1]+a[0];
    for(ll i=1;i<n;i++)
    {
        if(a[i]-a[i-1]>diff)
        {
            diff=a[i]-a[i-1];
            pivot=a[i];
            pos=i;
        }
    }
    ll ansc=0;
    for(ll i=pos+1;i<n;i++)
        ansc+=a[i]-a[i-1];
    if(pos!=0)
    {
        ansc+=k-a[n-1]+a[0];
        for(ll i=1;i<pos;i++)
            ansc+=a[i]-a[i-1];
    }
    cout<<ansc;
}

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


Measured memory_bytes: 1792
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        x=round(x,3)
        y=round(y,3)
        print("{0:.3f}".format(x),"{0:.3f}".format(y))
except EOFError:
    pass

Measured memory_bytes: 7400
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//?????????Memory Limit Exceeded????????£??????????????? ????§£?±?
//
//?????±???queue?????\????????????????????°??§visited=1??????????????¨???????????????????????????queue?????\????????????????????¨??§?????°????????????queue?????????????????????????????????

//?????????
//queue??§?????????????????????visited=1
//??¨??????field=min(?????????field,??????field+1)
//??¨??????visited=0??????queue?????\?????????

//field[y][x]=(x,y)?????§??????????????¢???


int main(void){
	int w,h,field[30][30],visited[30][30],wall[61][30],ans[100],cnt=0,x,y;
	while(1){
		queue<pair<int,int> > Q;
		cin>>w>>h;
		if(w==0 && h==0)break;
		rep(i,h){
			rep(j,w){
				field[i][j]=10000;//?????¢????????????
				visited[i][j]=0;//?¨????????????????
			}
		}
		rep(i,h*2-1){
			if(i%2==0){
				rep(j,w-1)cin>>wall[i][j];
			}else if(i%2==1){
				rep(j,w)cin>>wall[i][j];
			}
		}

		Q.push(make_pair(0,0));//??????????????°???????????¢1
		field[0][0]=1;
		visited[0][0]=1;

		while(!Q.empty()){
			pair<int,int> p = Q.front();
			Q.pop();
			x = p.first;
			y = p.second;
			//???????????????????????????????????????
			if(x>0 && wall[2*y][x-1]==0){//???
				if(visited[y][x-1]==0){
					visited[y][x-1]=1;
					Q.push(make_pair(x-1,y));
				}
				if(field[y][x-1]>field[y][x]+1)field[y][x-1]=field[y][x]+1;
			}
			if(x<w-1 && wall[2*y][x]==0){//???
				if(visited[y][x+1]==0){
					visited[y][x+1]=1;
					Q.push(make_pair(x+1,y));
				}
				if(field[y][x+1]>field[y][x]+1)field[y][x+1]=field[y][x]+1;
			}
			if(y>0 && wall[2*y-1][x]==0){//???
				if(visited[y-1][x]==0){
					visited[y-1][x]=1;
					Q.push(make_pair(x,y-1));
				}
				if(field[y-1][x]>field[y][x]+1)field[y-1][x]=field[y][x]+1;
			}
			if(y<h-1 && wall[2*y+1][x]==0){//???
				if(visited[y+1][x]==0){
					visited[y+1][x]=1;
					Q.push(make_pair(x,y+1));
				}
				if(field[y+1][x]>field[y][x]+1)field[y+1][x]=field[y][x]+1;
			}
		}
		if(visited[h-1][w-1]==1){
			ans[cnt]=field[h-1][w-1];
		}else{
			ans[cnt]=0;
		}
		cnt++;
	}
	rep(i,cnt)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = pair<ll, int>;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<ll> A(N);
    for (ll& x : A) cin >> x;
    vector<int> B(M);
    vector<ll> C(M);
    for (int i = 0; i < M; i++) cin >> B[i] >> C[i];
    vector<P> ps(M);
    for (int i = 0; i < M; i++) ps[i] = make_pair(C[i], B[i]);
    sort(ps.rbegin(), ps.rend());
    sort(A.begin(), A.end());
    int i = 0;
    for (auto& p : ps) {
      ll c = p.fst;
      int rem = p.snd;
      for (; rem > 0 && i < N; i++, rem--) {
        if (A[i] >= c) break;
        A[i] = c;
      }
    }
    ll res = accumulate(A.begin(), A.end(), 0ll);
    cout << res << endl;
  }
  return 0;
}


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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n, m; cin >> n >> m;

    int sx, sy; cin >> sx >> sy;
    int dx, dy; cin >> dx >> dy;
    --sx; --sy; --dx; --dy;
    
    vector<vector<char>> v(n, vector<char>(m));
    vector<vector<bool>> visited(n, vector<bool>(m, false));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> v[i][j];
        }
    }

    deque<pair<pair<int, int>, int>> q;
    q.push_back({{sx, sy}, 0});

    vector<pair<int, int>> coords = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

    while (!q.empty()) {
        int cx = q.front().first.first, cy = q.front().first.second, cw = q.front().second;

        if (cx == dx && cy == dy) {
            cout << cw << NL;
            return;
        }

        q.pop_front();

        visited[cx][cy] = true;

        for (int i = 0; i < 4; ++i) {
            int nx = cx + coords[i].first;
            int ny = cy + coords[i].second;

            if (nx < 0 || ny < 0 || nx >= n || ny >= m || visited[nx][ny] || v[nx][ny] == '#') continue;

            q.push_front({{nx, ny}, cw});
        }

        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                int nx = cx + i;
                int ny = cy + j;

                if (nx < 0 || ny < 0 || nx >= n || ny >= m || visited[nx][ny] || v[nx][ny] == '#') continue;

                q.push_back({{nx, ny}, cw + 1});
            }
        }
    }

    cout << -1 << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 11920
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079&lang=jp

#include <stdio.h>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

xy_t P[110];

int main() {
  // 入力例 読み込んだ点の個数を N とする
 int N;
 scanf("%d",&N);
 double x, y;
 int count = 0;
 while (count != N) {
   scanf("%lf %lf", &x, &y);
   P[count] = xy_t(x,y);
   count++;
 }
 // 面積計算
  double sum = 0.0;
  for (int i=0; i+2<N; ++i) {
    xy_t a=P[0], b=P[i+1], c=P[i+2];
    sum += cross_product(b-a,c-a)/2; // 三角形 abc の面積を加算
  }
  printf("%.1f\n", abs(sum));
}



Measured memory_bytes: 2740
#include <cstdlib>
#include <iostream>
#include <vector>
typedef long long LL;

#define DEBUG 0

int main() {
  int N, W; std::cin >> N >> W;
  std::vector<LL> score(W+1, 0);
  for (int i = 0; i < N; ++i) {
    int w; LL v; std::cin >> w >> v;
    auto prev_score = score;
    for (int j = 0; j <= W - w; ++j) {
      score[j+w] = std::max(
          prev_score[j + w], prev_score[j] + v);
    }

#if DEBUG
    for (LL s : score) std::cout << s << " ";
    std::cout << std::endl;
#endif
  }

#if DEBUG
  for (LL s : score) std::cout << s << " ";
  std::cout << std::endl;
#endif

  std::cout << score[W] << std::endl;
}


Measured memory_bytes: 1804