akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	map <pair <int, int> ,int > mp;
	for(int i=1;i<=n;i++)
	{
		string x=tostring(i);
		mp[mkp(x[0],x[x.size()-1])]++;
	}
	int sum=0;
	for(char i='1';i<='9';i++)
	{
		for(char j='1';j<='9';j++)
		{
			sum+=mp[mkp(i,j)]*mp[mkp(j,i)];
		}
	}
	cout<<sum<<endl;
}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(iinclude<snt i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int c[1000];
int a[1000];
void solve() {
	int n; cin >> n;
	rep(i, n)cin >> c[i];
	int q; cin >> q;
	rep(i, q) {
		int t; cin >> t; int x, d; cin >> x >> d;
		if (t == 1) {
			x--; a[x] += d;
			if (a[x] > c[x]) {
				cout << x + 1 << endl; return;
			}
		}
		else {
			x--; a[x] -= d;
			if (a[x] < 0) {
				cout << x + 1 << endl; return;
			}
		}
	}
	cout << 0 << endl;
}

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


Measured memory_bytes: 3224
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] str1 = sc.nextLine().split(" ");
    String[] str2 = sc.nextLine().split(" ");
    int x = Integer.parseInt(str1[0]);
    int n = Integer.parseInt(str1[1]);
    int index = x;
    int[] num = new int[102];
    for(int i = 0 ; i < 102;i++) {
      num[i] = i;
    }
//    if(n != 0) {
//      num[index] = -1;
//    }
    for(int i = 0;i < n;i++) {
      num[Integer.parseInt(str2[i])] = -1;
    }
    int minIndex = -1;
    int maxIndex = -1;
    for(int i = 0 ; i < 102;i++) {
      if(i < index) {
        if(num[i] != -1) {
          minIndex = i;
        }
      }else {
        if(num[i] != -1) {
          maxIndex = i;
          break;
        }
      }
    }
    int ans = 0;
    if(minIndex != -1 && maxIndex != -1) {
      if(x - num[minIndex] <= num[maxIndex] - x) {
        ans = num[minIndex];
      }else {
        ans = num[maxIndex];
      }
    }else if(minIndex != -1 && maxIndex == -1) {
      ans = num[minIndex];
    }else {
      ans = num[maxIndex];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35620
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;
	
	return 0;
}


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

int main() {
    int W, H, N;
    cin >> W >> H >> N;

    int x, y, a;

    int x_min = 0;
    int x_max = W;
    int y_min = 0;
    int y_max = H;
    for (int i = 0; i < N; i++) {
        cin >> x >> y >> a;
        if (a == 1) {
            x_min = max(x_min, x);
            continue;
        }
        if (a == 2) {
            x_max = min(x_max, x);
            continue;
        }
        if (a == 3) {
            y_min = max(y_min, y);
            continue;
        }
        if (a == 4) {
            y_max = min(y_max, y);
            continue;
        }
    }
    cout << max(0, (x_max - x_min)) * max(0, (y_max - y_min)) << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n;
  string s;
  cin>>s;
  if(s.size()>3&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;



}


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

namespace AOJ.Codes
{
    //問題の名称... 	1192:   Tax Rate Changed
    //問題文のURL... http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1192&lang=jp
    //所要時間... 今週は不要
    //学んだこと... 今週は不要
    //教室内の大まかな着席位置... {中央} x {奥}

    class _1192_TaxRateChanged
    {
        static void Main(string[] args)
        {

            var output = new List<int>();

            while (true)
            {
                //読み込み
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (line[0] == 0 && line[1] == 0 && line[2] == 0)
                    break;

                var x = line[0];
                var y = line[1];
                var s = line[2];
                var max = 0;

                //計算
                for (int i1 = 1; i1 < s; i1++)
                {
                    var can = new int[3];
                    var i1x = calctax(i1, x);
                    var i2x = s - i1x;
                    if (i2x <= 0) continue;

                    can[0] = i2x * 100 / (100 + x);
                    can[1] = can[0] - 1;
                    can[2] = can[0] + 1;
                    var i1y = calctax(i1, y);
                    for (int k = 0; k < 3; k++)
                    {
                        var i2x_new = calctax(can[k], x);
                        if (i1x + i2x_new == s)
                        {
                            var i2y = calctax(can[k], y);
                            var sum = i1y + i2y;
                            max = Math.Max(max, sum);
                        }
                    }
                }

                output.Add(max);
            }

            //出力
            foreach (var item in output)
                Console.WriteLine(item);

            //Enterを押して終了
            Console.ReadLine();
        }

        internal static int calctax(int Price, int TaxRate)
        {
            return Price * (100 + TaxRate) / 100;
        }
    }
}


Measured memory_bytes: 22484
#include <stdio.h>

char S[100005];
int ans[100005];

int main() {

	int N, A, B;

	scanf("%d %d %d",&N,&A,&B);

	scanf("%s",S);

	int i;

	int tuuka = 0;
	int foreign = 0;

	for (i = 0; i < N; i++) {
		if (S[i] == 'a'&&tuuka < A + B) { ans[i] = 1; tuuka++; }
		else if (S[i] == 'b'&&tuuka < A + B&&foreign < B) { ans[i] = 1; tuuka++; foreign++; }
	}

	for (i = 0; i < N; i++) {
		if (ans[i] == 1) { printf("Yes\n"); }
		else { printf("No\n"); }
	}

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    ll N, A, B;
    cin>>N>>A>>B;

    ll loop = N / (A + B);
    ll res = N % (A + B);
    if (res > A) res = A;
    cout<<A * loop + res<<endl;
}

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

int main(){
  int M, K;
  cin >> M >> K;
  if((1<<M) <= K or (M == 1 and K == 1)){
    cout << -1 << endl;
    return 0;
  }
  if(M == 1 and K == 0){
    cout << "0 0 1 1" << endl;
    return 0;
  }
  vector<int> A;
  for(int i = 0; i < (1<<M); ++i){
    if(i == K) continue;
    A.push_back(i);
  }
  A.push_back(K);
  for(int i = (1<<M)-1; i >= 0; --i){
    if(i == K) continue;
    A.push_back(i);
  }
  A.push_back(K);
  cout << A[0];
  for(size_t i = 1; i < A.size(); ++i) cout << " " << A[i];
  cout << endl;
}


Measured memory_bytes: 2932
#include <iostream>                                                             
using namespace std;
 
int main()
{
    int S, h=0, m=0, s=0;
    cin >> S;
    h = S/3600;
    S -= h*3600;
    m = S/60;
    S -= m*60;
    s = S;
    cout << h << ":" << m << ":" << s <<endl;
    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define  INF 1100000000
#define	 MOD 1000000007
using namespace std;

int main(){
	int N;
	cin >> N;
	int members[110000];
	for(int i=0;i<110000;i++){
		members[i] = 0;
	}
	members[0]++;//私
	for(int i=0;i<N;i++){
		int a, b;
		cin >> a >> b;
		members[a]++;
		members[b+1]--;
	}
	int max = members[0];
	for(int i=1;i<=N+1;i++){
		members[i] += members[i-1];
		if(members[i] >= i){
			max = i;
		}
	}
	
	max--;
	
	cout << max << endl;
	return 0;
	
	
}


Measured memory_bytes: 3536
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include "bits/stdc++.h"

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define deb(x) cerr << (#x) << " is " << (x) << '\n'

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int deg[10000045];
int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	
	for(int i = 0; i < n - 1; i++){
		int a;
		cin >> a;
		deg[a]++;
	}
	for1(i, n)cout << deg[i] << '\n';
	return 0;               
}
// Write Here
	


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

using namespace std;

int main(void){
    
    int n, k;
    cin >> n >> k;
    const int c = 200200;
    vector<int> cnt(c);
    
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a-1]++;
    }
    
    sort(cnt.begin(),cnt.begin()+n);
    int ans = 0;
    for (int i = 0; i < n - k; i++) ans +=cnt[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4028
#include<iostream>
#include<string>

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int v = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			v++;
		}
		else {
			b++;
		}
	}
	if (v > b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,m;
    cin>>n>>m;
    string a,b;
    cin>>a>>b;
    int lcm=n*m/__gcd(n,m);
    map<int,char>M;
    for(int i=0;i<n;i++){
        M[(lcm/n)*i]=a[i];
    }
    for(int i=0;i<m;i++){
        if(M.count((lcm/m)*i)&&M[(lcm/m)*i]!=b[i]){
    cout<<-1<<endl;
    return 0;
}
    }
    cout<<lcm<<endl;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
	int res = a % MOD;
	if(res < 0) {
		return res + MOD;
	}
	return res;
}
int mul_mod(int a, int b)
{
	ll res = ((ll)a * (ll)b) % MOD;
	return mod((int)res);
}
int pow_mod(int a, int b)
{
	ll res = 1;
	while (b > 0) {
		if(b & 1) {
			res = res * (ll)a % (ll)MOD;
		}
		a = mul_mod(a, a);
		b >>= 1;
	}
	return (int)res;
}
int inv_mod(int a)
{
	return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
	return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 100000;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < FAC_MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll com_mod(int a, int b){
	if (a < b) return 0;
	if (a < 0 || b < 0) return 0;
	return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	com_init();

	int n;
	cin >> n;
	int digit[64] = {};
	rep (i, n) {
		ll a, c = 0;
		cin >> a;
		while (a != 0) {
			if (a % 2 != 0) digit[c]++;
			a /= 2;
			c++;
		}
	}
	ll ans = 0;
	rep (i, 64) {
		// cout << n << " " << digit[i] << " ";
		// cout << pow_mod(2, i) << " " << com_mod(n, digit[i]) << endl;
		ans = mod(ans + mul_mod(pow_mod(2, i), mul_mod(digit[i], n - digit[i])));
	}
	cout << ans << endl;
	// ans = div_mod(ans, 2);
	// cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
n,m=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
q=[list(map(int,input().split())) for _ in range(m)]
for a,b in p:
    l=[]
    for c,d in q:
        l.append(abs(a-c)+abs(b-d))
    print(l.index(min(l))+1)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define SIZE(x) ((int)((x).size()))
#define PB push_back
#define ST first
#define ND second
#define mp(x,y) make_pair(x,y)
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FOREACH(it, (x)) cerr <<*it <<", "; cout <<endl; }}
typedef short int sint;

int main() {
	ios_base::sync_with_stdio(false);
	int s, w;
	cin >> s >> w;
	if (w >=s) {
		cout << "unsafe" << endl;
	} else {
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
using namespace std;


int main(){
  const long long max=100000;
  long long x;
  std::cin >> x;

  std::vector<bool> v(max);


  for (long long i = 2; i < sqrt(max); i++) {
      if(v[i]==false)
      for (long long k = i+i; k < max ; k+=i) {
        // std::cout << i<<":"<<k << '\n';
        v[k]=true;
      }
  }

  bool flag=false;
  for (long long  i = x; i < max ; i++) {
    if(v[i]==false){std::cout << i << '\n';flag=true;break;}
  }
  if(flag==false)std::cout  <<100003<< '\n';
  
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w, fh[100], fw[100];
string s[100];

int main() {
	cin >> h >> w;
	inc(i, h) { cin >> s[i]; }
	
	inc(i, h) {
		int c = 0;
		inc(j, w) { if(s[i][j] == '#') { c++; } }
		if(c == 0) { fh[i] = 1; }
	}
	
	inc(j, w) {
		int c = 0;
		inc(i, h) { if(s[i][j] == '#') { c++; } }
		if(c == 0) { fw[j] = 1; }
	}
	
	inc(i, h) { if(fh[i]) { continue; }
	inc(j, w) { if(fw[j]) { continue; }
		cout << s[i][j];
	} cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	
	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	PrintWriter out;
	final int MOD = (int)1e9+7;
	final int INF = Integer.MAX_VALUE / 2;
	
	void solve() throws Exception{
		int N = sc.nextInt();
		int max = 0, cnt = 0;
		for(int i = 0; i < N; i++){
			int h = sc.nextInt();
			if(h >= max) cnt++;
			max = Math.max(max, h);
		}
		System.out.println(cnt);
	}
	
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws Exception {
		new Main().m();
	}
	
	void m() throws Exception {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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

int ctoi(const char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return -1;
    }
}

int main(void)
{
    string input = "";
    cin >> input;
    int back = ctoi(input[0]); //1つ前のやつ
    int change_color = 10;     //かぶってる色
    int times = 0;
    for (int i = 1; i < input.length(); i++)
    {
        int now = ctoi(input[i]);
        if (back == now)
        {
            change_color = now;
        }
        back = now;
        if (change_color != 10)
        {
            if (now != change_color)
            {
                if (change_color > 0)
                {
                    input[i - 1] = '0';
                    input[i] = '1';
                    times += 2;
                }
                else
                {
                    input[i - 1] = '1';
                    input[i] = '0';
                    times += 2;
                }
            }
            else
            {
                if (change_color > 0)
                {
                    input[i] = '0';
                    times++;
                }
                else
                {
                    input[i] = '1';
                    times++;
                }
            }
            change_color = 10;
            now = ctoi(input[i]);
            back = now;
        }
    }
    cout << times << endl;
    return 0;
}

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

int main(){
	int d, i;
	char p[3];
	for (i=0; i<3; i++)
		cin >> p[i];
	d = 0;
	if (p[0] == 'o') d+=1;
	if (p[1] == 'o') d+=1;
	if (p[2] == 'o') d+=1;
	
	printf("%d", 700 + 100*d);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	for( char &c : s ){
		c += n;
		if( c > 'Z' ) c = 'A'+(c-'Z'-1);
	}
	cout << s << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
PY = []
for i in range(M):
    PY.append(list(map(int, input().split())) + [i])

PY.sort()

l = []
t = 0
for i in range(M):
    if t != PY[i][0]:
        t = PY[i][0]
        cnt = 1
    l.append([str(t).zfill(6) + str(cnt).zfill(6), PY[i][2]])
    cnt += 1

l.sort(key=lambda x: x[1])

for i in range(M):
    print(l[i][0])

Measured memory_bytes: 41668
#include <stdio.h>

int main(void){
	int pp=0;

	while(1){
		int a, b, flag=0;
		scanf("%d %d", &a, &b);
		if(a==0 && b==0) break;
		
		if(pp==1)printf("\n");
	
		int i=a;
		while(i<=b){
			if(i%4==0){
				if(i%100==0){
					if(i%400==0){
						printf("%d\n", i);
						flag=1;
					}
					else{}
				}
				else{
					printf("%d\n", i);
					flag=1;
				}
			}
			
			i++;
		}
		
		if(flag==0) printf("NA\n");
		pp=1;
	
	}
		
	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int n;
long long a[500000];

long long g(vector<long long> c, int all, int useodd)
{
    vector<long long> suff(c.size() + 1);
    for (int i = c.size() - 1; i >= 0; i--)
    {
        suff[i] = suff[i + 1] + c[i];
    }
    long long even = 0, opt = 0, ans = suff[0];
    for (int i = 0; i < c.size(); i++)
    {
        if (c[i] % 2 == 0) even++;
        opt += (c[i] % 2 == 1) * 1 + (c[i] == 0) * 2;
        if (useodd) if (even < opt) opt = even;
        ans = min(ans, opt + suff[i + 1]);
    }
    if (all == 0)
        return ans;
    else
        return opt;
}

map<pair<int, int>, int> calc[4];

long long solve(int l, int r, int LR)
{
    if (l + 1 >= r)
    {
        return 0;
    }
    if (calc[LR].find({l, r}) != calc[LR].end()) return calc[LR][{l, r}];
    int m = (l + r) / 2;
    long long dl = 0, dr = 0;
    for (int i = m; i < r; i++) dr += a[i];
    for (int i = l; i < m; i++) dl += a[i];
    long long ans = 1e18;
    vector<long long> b1(m - l), b2(r - m);
    for (int i = l; i < m; i++) b1[i - l] = a[i];
    for (int i = m; i < r; i++) b2[i - m] = a[i];
    reverse(b1.begin(), b1.end());
    if (LR == 0)
    {
        ans = min(ans, solve(l, m, 0) + dr);
        ans = min(ans, solve(m, r, 0) + dl);
        ans = min(ans, g(b1, 0, 1) + g(b2, 0, 1));
        ans = min(ans, solve(l, m, 1) + g(b2, 0, 0));
        ans = min(ans, solve(m, r, 2) + g(b1, 0, 0));
    }
    if (LR == 1)
    {
        ans = min(ans, solve(m, r, 1) + dl);
        ans = min(ans, solve(m, r, 3) + g(b1, 0, 0));
        ans = min(ans, g(b1, 0, 1) + g(b2, 1, 1));
        ans = min(ans, solve(l, m, 1) + g(b2, 1, 0));
    }
    if (LR == 2)
    {
        ans = min(ans, solve(l, m, 2) + dr);
        ans = min(ans, solve(l, m, 3) + g(b2, 0, 0));
        ans = min(ans, g(b2, 0, 1) + g(b1, 1, 1));
        ans = min(ans, solve(m, r, 1) + g(b1, 1, 0));
    }
    if (LR == 3)
    {
        ans = min(ans, g(b1, 1, 1) + g(b2, 1, 1));
        ans = min(ans, solve(m, r, 3) + g(b1, 1, 0));
        ans = min(ans, solve(l, m, 3) + g(b2, 1, 0));
    }
    calc[LR][{l, r}] = ans;
    return ans;
}

signed main()
{
    n = 200000;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        a[i] = i;
        cin >> a[i];
    }
    cout << solve(0, n, 0);
}


Measured memory_bytes: 56784
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
#define d read()
ll n,m,q,ans;
ll a[55],b[55],c[55],dd[55];
ll sq[15];
void dfs(ll u,ll st){
	if(u==n+1){
		ll k=0;
		f(i,1,q)if(sq[b[i]]-sq[a[i]]==c[i])k+=dd[i];
		ans=max(ans,k);
		return;
	}
	f(i,st,m)sq[u]=i,dfs(u+1,i);
}
int main(){
	n=d,m=d,q=d;
	f(i,1,q)a[i]=d,b[i]=d,c[i]=d,dd[i]=d;
	dfs(1,1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3592
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s1,s2;
    vector<int> v;
    cin>>s1;
    if(s1[1]=='R')
    cout<<"ABC"<<endl;
    else
    cout<<"ARC"<<endl;
    
    
}


Measured memory_bytes: 3588
import java.util.Scanner;

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

		int[][] list1 = new int[a][b];
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				list1[i][j] = scanner.nextInt();
			}
		}
		int[][] list2 = new int[b][c];
		for (int i = 0; i < b; i++)
			for (int j = 0; j < c; j++)
				list2[i][j] = scanner.nextInt();

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < c; j++) {
				long sum = 0;
				for (int k = 0; k < b; k++) {
					sum += list1[i][k] * list2[k][j];
				}
				if (j == 0)
					System.out.print(sum);
				else
					System.out.print(" " + sum);
			}
			System.out.println();
		}

	}
}

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

int main() {
#ifdef LOCAL
  freopen("b.txt", "r", stdin);
  // freopen("main.txt","w",stdout);
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#endif
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  for (int i = 0; i < b; i++) cout << a;
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rrep(i,1,n+1){
        if(i%2==1)cnt++;
    }
    double anss;
    anss=(double)cnt/(double)n;
    doublecout(anss);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

void solve() {
	string s;
	cin >> s;
	int x = s.back() - '0';
	int a[] = {2, 4, 5, 7, 9};
	for (int i = 0; i < 5; i++) {
		if (x == a[i]) {
			cout << "hon";
			return;
		}
	}
	if (x == 3) {
		cout << "bon";
	}
	else cout << "pon";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1; 
    //cin >> T;
    while(T--) solve();
}

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

int C[102][102];

void meiro(int W,int H,int c){
  if(C[W][H]!=c){
    return;
  }

  C[W][H] = -1;

  meiro(W-1,H  ,c);
  meiro(W  ,H+1,c);
  meiro(W+1,H  ,c);
  meiro(W  ,H-1,c);
}

int main(){
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0 && h==0){
      break;
    }

    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        C[i][j] = 0;
      }
    }

    int xs,ys,xg,yg;
    cin >> xs >> ys >> xg >> yg;

    int n;
    cin >> n;

    int c,d,x,y;
    for(int i=0;i<n;i++){
      cin >> c >> d >> x >> y;

      if(d==0){
        for(int j=x;j<x+4;j++){
          for(int k=y;k<y+2;k++){
            C[j][k]=c;
          }
        }
      }else{
        for(int j=x;j<x+2;j++){
          for(int k=y;k<y+4;k++){
            C[j][k]=c;
          }
        }
      }
    }
    if(C[xs][ys]==0){
      cout << "NG" << endl;
      continue;
    }

    meiro(xs,ys,C[xs][ys]);

    if(C[xg][yg] == -1){
      cout << "OK" << endl;
    }else{
      cout << "NG" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;

int main(void){
    int a,b;
    double c;
    cin >> a >> b;
    c = 1.00000 * a/b;
    cout << a/b << " " << a%b << " " << fixed << setprecision(8) << c << endl;
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
long long ten[200002], ten2[200002];
char s[200002];
long long dp[10002], dp2[10002];
long long pow2(long long a, long long b, int p){
    long long ans = 1;
    while(b){
        if(b%2 == 1) ans = ans*a%p;
        a = a*a%p;
        b/=2;
    }
    return ans;
}
int main(){
    int n, p;
    scanf("%d%d", &n, &p);   
    ten[0] = 1;
    for(int i=1;i<=200000;i++) ten[i] = ten[i-1]*10%p;
    for(int i=1;i<=200000;i++) ten2[i] = pow2(ten[i], p-2, p);

    scanf("%s", s+1);
    long long sum = 0, ans = 0;

    if(p <= 10){
        for(int i=1;i<=n;i++){
            for(int j=0;j<p;j++) dp2[j] = 0;
            for(int j=0;j<p;j++) dp2[j*10%p] += dp[j];
            sum = (sum*10 + s[i]-'0')%p;

            if(sum == 0) ans++;
            ans += dp2[sum];

            dp2[sum]++;

            for(int j=0;j<p;j++) dp[j] = dp2[j];
        }
    }
    else{
        for(int i=1;i<=n;i++){
            int c = s[i]-'0';
            sum = (sum + c*ten2[i]%p)%p;
            if(sum*1ll*ten[i]%p == 0) ans++;
            ans = (ans + dp[sum]);
            dp[sum]++;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3584
N, W = map(int, input().split())
v = []
w = []
for _ in range(N):
    x, y = map(int, input().split())
    v.append(x)
    w.append(y)
dp = [[-1 for _ in range(W+1)] for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])



Measured memory_bytes: 42268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
    // 配列の最大値を取得
    int max = *max_element(vec.begin(), vec.end());
    // 配列の最大値のイテレータを取得
    vector<int>::iterator maxIt = max_element(vec.begin(), vec.end());
    // 配列の最大値までの距離を取得
    int maxIndex = distance(vec.begin(), maxIt);
    // 隣り合う重複要素を削除し、末尾のゴミを削除
    // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す)
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
*/

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


    int cnt8 = 0;
    for (int i=105; i<N+1; ++i) {
        int cnt = 0;
        for (int j=1; j<N+1; ++j) {
            if (i % (2*j - 1) == 0) cnt++;
        }
        if (cnt == 8) cnt8++;
    }

    cout << cnt8 << endl;
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;


int main(){
    int n,m;cin >> n >> m;
    vector<P> v;
    for (int i = 0; i < n; i++) {
        int a,b;cin >> a >> b;
        v.pb(P(a,b));
    }
    sort(ALL(v));
    LL ans=0;
    for (int i = 0; i < n; i++) {
        P p=v[i];
        LL s=min(p.sc,m);
        ans+=p.fs*s;
        m-=s;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
string s;
cin >> s;
int ans;
if(s == "SUN")ans = 7;
else if(s == "MON")ans = 6;
else if(s == "TUE")ans = 5;
else if(s == "WED")ans = 4;
else if(s == "THU")ans = 3;
else if(s == "FRI")ans = 2;
else if(s == "SAT")ans = 1;
cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int N =fsc.nextInt();
        int K =fsc.nextInt();
        fsc.close();
        double tmp = Math.pow(K-1, N-1)*K;
        int ans = (int)tmp;
        System.out.print(ans);

    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 32428
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long K, A, B; cin >> K >> A >> B;
	if (B-A<=2)cout << K + 1 << endl;
	else cout << B * ((K - A + 1) / 2) - (A*((K - A + 1) / 2 - 1)) + (K - A + 1) % 2 << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,d;
	cin>>n>>d;
	ll count = 0;
	while(n--){
		
		ll x,y;
		cin>>x>>y;
		ll ans = (x*x + y*y);
		if(ans<=d*d){
			count++;
		}
	
	}
		cout<<count<<endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
#define abs(x) ((x) > 0 ? (x) : -(x))

struct grid {
  int x, y;
};

int d(struct grid r1, struct grid r2){
  return abs(r1.x - r2.x) + abs(r1.y - r2.y);
}

int
main(int argc, char *argv[])
{
  int n, m;
  struct grid a[50], b[50];
  scanf("%d %d", &n, &m);
  for(int i = 0; i < n; i++) scanf("%d %d", &a[i].x, &a[i].y);
  for(int i = 0; i < m; i++) scanf("%d %d", &b[i].x, &b[i].y);

  int ans, min, temp;
  for(int i = 0; i < n; i++){
    min = 1000000000;
    for(int j = 0; j < m; j++){
      temp = d(a[i], b[j]);
      if(min > temp){
	min = temp;
	ans = j + 1;
      }
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    string s;cin>>s;
    int cnt=0;
    for(int i=0;i<n;i++){
        while(i+1<n && s[i]==s[i+1]){
            i++;
        }
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/dp/tasks/dp_x
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};
int N;
int w[2123];
int s[2123];
LL v[2123];
LL dp[21234];
pair<int,int> a[2123];
int main(){
    cin>>N;
    for(int i:range(N)){
        cin>>w[i]>>s[i]>>v[i];
        a[i]={w[i]+s[i],i};
    }
    sort(a,a+N);
    for(int _i:range(N)){
        int i=a[_i].second;
        for(int j=w[i]+s[i];j>=w[i];j--){
            chmax(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout<<*max_element(dp,dp+21234)<<endl;
    return 0;
}

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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch)
{
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key)
{
    return key % M;
}

int h2(int key)
{
    return 1 + (key % (M - 1));
}

int find(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            return 0;
        }
    }
    return 0;
}

int insert(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) {
        H[i][0] = '\0';
    }
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
using Int= int64_t;
Int solve() {
    Int N, K;
    cin >> N >> K;
    if (N <= K) return 0;
    vector<Int> H(N);
    for (auto& i : H) cin >> i;
    partial_sort(H.begin(), H.begin() + N - K, H.end());
    return accumulate(H.begin(), H.begin() + N - K, (Int)0);
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 1792
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

inline int max(int a,int b) {
	if (a > b) return a;
	return b;
}

inline int min(int a, int b) {
	if (a < b) return a;
	return b;
}

string w[] = { "Sunny","Cloudy","Rainy" };
int main() {
	string s;
	cin >> s;
	if (s == w[0]) {
		cout << w[1] << endl;
		return 0;
	}
	if (s == w[1]) {
		cout << w[2] << endl;
		return 0;
	}
	if (s == w[2]) {
		cout << w[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256